Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1398)

Unified Diff: media/mojo/common/mojo_decoder_buffer_converter.h

Issue 2096063003: media: Add MojoDecoderBuffer{Reader|Writer} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/mojo/common/mojo_decoder_buffer_converter.h
diff --git a/media/mojo/common/mojo_decoder_buffer_converter.h b/media/mojo/common/mojo_decoder_buffer_converter.h
new file mode 100644
index 0000000000000000000000000000000000000000..47fc4ef5781bb4db23082182dd97bda7f1013ce3
--- /dev/null
+++ b/media/mojo/common/mojo_decoder_buffer_converter.h
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
+#define MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "media/base/demuxer_stream.h"
+#include "media/mojo/interfaces/media_types.mojom.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+
+namespace media {
+
+class DecoderBuffer;
+
+// A helper class that converts mojom::DecoderBuffer to media::DecoderBuffer.
+// The data part of the DecoderBuffer is read from a DataPipe.
+class MojoDecoderBufferReader {
+ public:
+ // Creates a MojoDecoderBufferWriter of |type| and set the |producer_handle|.
alokp 2016/06/24 19:35:10 is this a typo?
xhwang 2016/06/24 23:44:12 Done.
+ static std::unique_ptr<MojoDecoderBufferReader> Create(
+ DemuxerStream::Type type,
+ mojo::ScopedDataPipeProducerHandle* producer_handle);
+
+ // Hold the consumer handle to read DecoderBuffer data.
+ explicit MojoDecoderBufferReader(
+ mojo::ScopedDataPipeConsumerHandle consumer_handle);
+
+ ~MojoDecoderBufferReader();
+
+ // Converts |buffer| into a DecoderBuffer (read data from DataPipe if needed).
+ // Returns the result DecoderBuffer. Returns null in case of an error.
+ scoped_refptr<DecoderBuffer> ConvertDecoderBuffer(
alokp 2016/06/24 19:35:10 A Convert function on a Reader seems a bit weird.
xhwang 2016/06/24 23:44:12 Done.
+ const mojom::DecoderBufferPtr& buffer);
+
+ private:
+ // For reading the data section of a DecoderBuffer.
+ mojo::ScopedDataPipeConsumerHandle consumer_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferReader);
+};
+
+// A helper class that converts media::DecoderBuffer to mojom::DecoderBuffer.
+// The data part of the DecoderBuffer is written into a DataPipe.
+class MojoDecoderBufferWriter {
+ public:
+ // Creates a MojoDecoderBufferWriter of |type| and set the |consumer_handle|.
+ static std::unique_ptr<MojoDecoderBufferWriter> Create(
alokp 2016/06/24 19:35:10 I would replace this with a CreateDataPipe functio
xhwang 2016/06/24 23:44:12 See above.
+ DemuxerStream::Type type,
+ mojo::ScopedDataPipeConsumerHandle* consumer_handle);
+
+ // Hold the producer handle to write DecoderBuffer data.
+ explicit MojoDecoderBufferWriter(
+ mojo::ScopedDataPipeProducerHandle producer_handle);
+
+ ~MojoDecoderBufferWriter();
+
+ // Converts a DecoderBuffer into mojo DecoderBuffer, writing data into
+ // DataPipe if needed. Returns null if conversion failed.
+ mojom::DecoderBufferPtr ConvertDecoderBuffer(
alokp 2016/06/24 19:35:10 ditto. A Convert function on writer seems weird.
xhwang 2016/06/24 23:44:11 Done.
+ const scoped_refptr<DecoderBuffer>& media_buffer);
+
+ private:
+ // For writing the data section of DecoderBuffer into DataPipe.
+ mojo::ScopedDataPipeProducerHandle producer_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoDecoderBufferWriter);
+};
+
+} // namespace media
+
+#endif // MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_

Powered by Google App Engine
This is Rietveld 408576698