Chromium Code Reviews| 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..2461a09d1c4ae74493616e4374d1b15e49b23c49 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::AUDIO) { |
| + // Audio doesn't require a lot of room, so use a smaller pipe than video. |
| + options.capacity_num_bytes = 512 * 1024; |
| + } else { |
| + // 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); |
|
xhwang
2014/12/06 00:03:44
nit: we have the config; we might be able to do be
DaleCurtis
2014/12/06 00:42:59
I can try and figure out some metric based on reso
xhwang
2014/12/06 01:16:54
Low priority for now. But we may need to have some
|
| + } |
| + |
|
xhwang
2014/12/06 00:03:44
nit: How about Demuxer::TEXT?
DaleCurtis
2014/12/06 00:42:59
Flipped so only video gets the large pipe.
|
| + mojo::DataPipe data_pipe(options); |
| + stream_pipe_ = data_pipe.producer_handle.Pass(); |
| + client()->OnStreamReady(data_pipe.consumer_handle.Pass()); |
| } |
| } // namespace media |