Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/mojo/services/mojo_demuxer_stream_impl.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/macros.h" | |
| 9 #include "media/base/audio_decoder_config.h" | |
| 10 #include "media/mojo/interfaces/demuxer_stream.mojom.h" | |
| 11 #include "media/mojo/services/media_type_converters.h" | |
| 12 #include "mojo/public/cpp/bindings/interface_impl.h" | |
| 13 #include "mojo/public/cpp/system/data_pipe.h" | |
| 14 | |
| 15 namespace media { | |
| 16 | |
| 17 MojoDemuxerStreamImpl::MojoDemuxerStreamImpl(media::DemuxerStream* stream) | |
| 18 : stream_(stream), weak_factory_(this) {} | |
| 19 | |
| 20 MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() {} | |
| 21 | |
| 22 void MojoDemuxerStreamImpl::Read( | |
| 23 const mojo::Callback<void(mojo::DemuxerStream::Status, | |
| 24 mojo::MediaDecoderBufferPtr)>& callback) { | |
| 25 stream_->Read(base::Bind(&MojoDemuxerStreamImpl::OnBufferReady, | |
| 26 weak_factory_.GetWeakPtr(), | |
| 27 callback)); | |
|
xhwang
2014/09/10 00:00:52
In media code, we don't allow unsatisfied callback
tim (not reviewing)
2014/09/10 23:08:29
The caller of this Read(...) is the MojoDXStreamAd
| |
| 28 } | |
| 29 | |
| 30 void MojoDemuxerStreamImpl::OnBufferReady( | |
| 31 mojo::Callback<void(mojo::DemuxerStream::Status, | |
| 32 mojo::MediaDecoderBufferPtr)> callback, | |
| 33 media::DemuxerStream::Status status, | |
| 34 const scoped_refptr<media::DecoderBuffer>& buffer) { | |
| 35 if (status == media::DemuxerStream::kConfigChanged) { | |
|
scherkus (not reviewing)
2014/09/09 20:35:32
to keep things simple for this CL (and future ones
tim (not reviewing)
2014/09/10 23:08:29
Maybe I need to understand this better. I added s
| |
| 36 // Send the config change so our client can read it once it parses the | |
| 37 // Status obtained via Run() below. | |
| 38 client()->OnAudioDecoderConfigChanged( | |
| 39 mojo::AudioDecoderConfig::From(stream_->audio_decoder_config())); | |
| 40 } | |
| 41 | |
| 42 // TODO(tim): Once using DataPipe, fill via the producer handle and then | |
| 43 // read more to keep the pipe full. | |
| 44 callback.Run(static_cast<mojo::DemuxerStream::Status>(status), | |
| 45 mojo::MediaDecoderBuffer::From(buffer)); | |
| 46 } | |
| 47 | |
| 48 void MojoDemuxerStreamImpl::OnConnectionEstablished() { | |
| 49 // This is called when our DemuxerStreamClient has connected itself and is | |
| 50 // ready to receive messages. Send an initial config and notify it that | |
| 51 // we are now ready for business. | |
| 52 client()->OnAudioDecoderConfigChanged( | |
| 53 mojo::AudioDecoderConfig::From(stream_->audio_decoder_config())); | |
| 54 | |
| 55 // TODO(tim): Create a DataPipe, hold the producer handle, and pass the | |
| 56 // consumer handle here. | |
| 57 client()->OnStreamReady(mojo::ScopedDataPipeConsumerHandle()); | |
| 58 } | |
| 59 | |
| 60 } // namespace media | |
| OLD | NEW |