// Copyright 2016 The Chromium Authors // 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_H_ #define MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_H_ #include <memory> #include "base/containers/circular_deque.h" #include "base/memory/scoped_refptr.h" #include "media/base/demuxer_stream.h" #include "media/mojo/mojom/media_types.mojom.h" #include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/simple_watcher.h" namespace media { class DecoderBuffer; // Creates mojo::DataPipe and sets `producer_handle` and `consumer_handle`. // Returns true on success. Otherwise returns false and reset the handles. bool CreateDataPipe(uint32_t capacity, mojo::ScopedDataPipeProducerHandle* producer_handle, mojo::ScopedDataPipeConsumerHandle* consumer_handle); // Returns the default capacity to be used with MojoDecoderBufferReader and // MojoDecoderBufferWriter for |type|. uint32_t GetDefaultDecoderBufferConverterCapacity(DemuxerStream::Type type); // Combines mojom::DecoderBuffers with data read from a DataPipe to produce // media::DecoderBuffers (counterpart of MojoDecoderBufferWriter). class MojoDecoderBufferReader { … }; // Converts media::DecoderBuffers to mojom::DecoderBuffers, writing the data // part to a DataPipe (counterpart of MojoDecoderBufferReader). // // If necessary, writes to the DataPipe will be chunked to fit. // MojoDecoderBufferWriter maintains an internal queue of buffers to enable // this asynchronous process. // // On DataPipe closure, future calls to WriteDecoderBuffer() will return // nullptr. There is no mechanism to determine which past writes were // successful prior to the closure. class MojoDecoderBufferWriter { … }; } // namespace media #endif // MEDIA_MOJO_COMMON_MOJO_DECODER_BUFFER_CONVERTER_H_