| Index: media/mojo/services/mojo_demuxer_stream_impl.cc
|
| diff --git a/media/mojo/services/mojo_demuxer_stream_impl.cc b/media/mojo/services/mojo_demuxer_stream_impl.cc
|
| index e89143649cb1ff1a3a735ff9675718b4842c955a..1554f1aef362685b200a435387e62dd81be8ad90 100644
|
| --- a/media/mojo/services/mojo_demuxer_stream_impl.cc
|
| +++ b/media/mojo/services/mojo_demuxer_stream_impl.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/bind.h"
|
| #include "base/macros.h"
|
| #include "media/base/audio_decoder_config.h"
|
| +#include "media/base/decoder_buffer.h"
|
| #include "media/base/video_decoder_config.h"
|
| #include "media/mojo/interfaces/demuxer_stream.mojom.h"
|
| #include "media/mojo/services/media_type_converters.h"
|
| @@ -45,8 +46,16 @@ void MojoDemuxerStreamImpl::OnBufferReady(
|
| }
|
| }
|
|
|
| - // TODO(tim): Once using DataPipe, fill via the producer handle and then
|
| - // read more to keep the pipe full.
|
| + // Serialize the data section of the DecoderBuffer into our pipe.
|
| + uint32_t num_bytes = buffer->data_size();
|
| + CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &num_bytes,
|
| + MOJO_READ_DATA_FLAG_ALL_OR_NONE),
|
| + MOJO_RESULT_OK);
|
| + CHECK_EQ(num_bytes, static_cast<uint32_t>(buffer->data_size()));
|
| +
|
| + // TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via
|
| + // the producer handle and then read more to keep the pipe full. Waiting for
|
| + // space can be accomplished using an AsyncWaiter.
|
| callback.Run(static_cast<mojo::DemuxerStream::Status>(status),
|
| mojo::MediaDecoderBuffer::From(buffer));
|
| }
|
| @@ -63,9 +72,25 @@ void MojoDemuxerStreamImpl::DidConnect() {
|
| mojo::VideoDecoderConfig::From(stream_->video_decoder_config()));
|
| }
|
|
|
| - // TODO(tim): Create a DataPipe, hold the producer handle, and pass the
|
| - // consumer handle here.
|
| - client()->OnStreamReady(mojo::ScopedDataPipeConsumerHandle());
|
| + MojoCreateDataPipeOptions options;
|
| + options.struct_size = sizeof(MojoCreateDataPipeOptions);
|
| + options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
|
| + options.element_num_bytes = 1;
|
| +
|
| + // Allocate DataPipe sizes based on content type to reduce overhead. If this
|
| + // is still too burdensome we can adjust for sample rate or resolution.
|
| + if (stream_->type() == media::DemuxerStream::VIDEO) {
|
| + // Video can get quite large; at 4K, VP9 delivers packets which are ~1MB in
|
| + // size; so allow for 50% headroom.
|
| + options.capacity_num_bytes = 1.5 * (1024 * 1024);
|
| + } else {
|
| + // Other types don't require a lot of room, so use a smaller pipe.
|
| + options.capacity_num_bytes = 512 * 1024;
|
| + }
|
| +
|
| + mojo::DataPipe data_pipe(options);
|
| + stream_pipe_ = data_pipe.producer_handle.Pass();
|
| + client()->OnStreamReady(data_pipe.consumer_handle.Pass());
|
| }
|
|
|
| } // namespace media
|
|
|