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

Unified Diff: media/mojo/services/mojo_demuxer_stream_adapter.cc

Issue 684963003: Add support for external video renderers in mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_config
Patch Set: Created 6 years, 2 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/services/mojo_demuxer_stream_adapter.cc
diff --git a/media/mojo/services/mojo_demuxer_stream_adapter.cc b/media/mojo/services/mojo_demuxer_stream_adapter.cc
index 5b60177afebe8420990edcfba4ca7d53ac75b7e0..c38ed42f8d849c6d51f3c060fc279bd4093b729f 100644
--- a/media/mojo/services/mojo_demuxer_stream_adapter.cc
+++ b/media/mojo/services/mojo_demuxer_stream_adapter.cc
@@ -13,9 +13,11 @@ namespace media {
MojoDemuxerStreamAdapter::MojoDemuxerStreamAdapter(
mojo::DemuxerStreamPtr demuxer_stream,
- const base::Closure& stream_ready_cb)
+ const base::Closure& stream_ready_cb,
+ DemuxerStream::Type type)
xhwang 2014/10/29 00:22:13 Can we drop this |type| param and populate |type_|
DaleCurtis 2014/10/30 23:16:56 Done.
: demuxer_stream_(demuxer_stream.Pass()),
stream_ready_cb_(stream_ready_cb),
+ type_(type),
weak_factory_(this) {
DVLOG(1) << __FUNCTION__;
demuxer_stream_.set_client(this);
@@ -35,21 +37,23 @@ void MojoDemuxerStreamAdapter::Read(const DemuxerStream::ReadCB& read_cb) {
}
AudioDecoderConfig MojoDemuxerStreamAdapter::audio_decoder_config() {
- DCHECK(!config_queue_.empty());
- return config_queue_.front();
+ DCHECK_EQ(type_, DemuxerStream::AUDIO);
+ DCHECK(!audio_config_queue_.empty());
+ return audio_config_queue_.front();
}
VideoDecoderConfig MojoDemuxerStreamAdapter::video_decoder_config() {
- NOTREACHED();
- return VideoDecoderConfig();
+ DCHECK_EQ(type_, DemuxerStream::VIDEO);
+ DCHECK(!video_config_queue_.empty());
+ return video_config_queue_.front();
}
-media::DemuxerStream::Type MojoDemuxerStreamAdapter::type() {
- return media::DemuxerStream::AUDIO;
+DemuxerStream::Type MojoDemuxerStreamAdapter::type() {
+ return type_;
}
void MojoDemuxerStreamAdapter::EnableBitstreamConverter() {
- NOTREACHED();
+ NOTIMPLEMENTED();
}
bool MojoDemuxerStreamAdapter::SupportsConfigChanges() {
@@ -66,16 +70,29 @@ void MojoDemuxerStreamAdapter::OnStreamReady(
DVLOG(1) << __FUNCTION__;
// TODO(tim): We don't support pipe streaming yet.
DCHECK(!pipe.is_valid());
- DCHECK(!config_queue_.empty());
+ if (type_ == DemuxerStream::AUDIO)
+ DCHECK(!audio_config_queue_.empty());
+ if (type_ == DemuxerStream::VIDEO)
+ DCHECK(!video_config_queue_.empty());
xhwang 2014/10/29 00:22:13 Some clean up idea for the future. We have both au
DaleCurtis 2014/10/30 23:16:56 Maybe, that's the opposite of what you're suggesti
xhwang 2014/10/31 03:25:57 Yeah, I just felt that'd be something nice. But ho
stream_ready_cb_.Run();
}
void MojoDemuxerStreamAdapter::OnAudioDecoderConfigChanged(
mojo::AudioDecoderConfigPtr config) {
- config_queue_.push(config.To<media::AudioDecoderConfig>());
+ audio_config_queue_.push(config.To<AudioDecoderConfig>());
+
+ if (!read_cb_.is_null()) {
+ read_cb_.Run(DemuxerStream::Status::kConfigChanged, NULL);
+ read_cb_.Reset();
+ }
+}
+
+void MojoDemuxerStreamAdapter::OnVideoDecoderConfigChanged(
+ mojo::VideoDecoderConfigPtr config) {
+ video_config_queue_.push(config.To<VideoDecoderConfig>());
if (!read_cb_.is_null()) {
- read_cb_.Run(media::DemuxerStream::Status::kConfigChanged, NULL);
+ read_cb_.Run(DemuxerStream::Status::kConfigChanged, NULL);
read_cb_.Reset();
}
}
@@ -85,21 +102,35 @@ void MojoDemuxerStreamAdapter::OnBufferReady(
mojo::MediaDecoderBufferPtr buffer) {
DVLOG(3) << __FUNCTION__;
DCHECK(!read_cb_.is_null());
- DCHECK(!config_queue_.empty());
+ if (type_ == DemuxerStream::AUDIO)
+ DCHECK(!audio_config_queue_.empty());
+ if (type_ == DemuxerStream::VIDEO)
+ DCHECK(!video_config_queue_.empty());
- media::DemuxerStream::Status media_status(
- static_cast<media::DemuxerStream::Status>(status));
- scoped_refptr<media::DecoderBuffer> media_buffer(
- buffer.To<scoped_refptr<media::DecoderBuffer> >());
+ DemuxerStream::Status media_status(
+ static_cast<DemuxerStream::Status>(status));
+ scoped_refptr<DecoderBuffer> media_buffer(
+ buffer.To<scoped_refptr<DecoderBuffer> >());
if (status == mojo::DemuxerStream::STATUS_CONFIG_CHANGED) {
DCHECK(!media_buffer.get());
- config_queue_.pop();
- // If the |config_queue_| is empty we need to wait for
- // OnAudioDecoderConfigChanged before invoking |read_cb|.
- if (config_queue_.empty())
- return;
+ if (type_ == DemuxerStream::AUDIO) {
+ audio_config_queue_.pop();
+
+ // If the |config_queue_| is empty we need to wait for
+ // OnAudioDecoderConfigChanged before invoking |read_cb|.
+ if (audio_config_queue_.empty())
+ return;
+ }
+ if (type_ == DemuxerStream::VIDEO) {
+ video_config_queue_.pop();
+
+ // If the |config_queue_| is empty we need to wait for
+ // OnAudioDecoderConfigChanged before invoking |read_cb|.
+ if (video_config_queue_.empty())
+ return;
+ }
}
read_cb_.Run(media_status, media_buffer);
read_cb_.Reset();

Powered by Google App Engine
This is Rietveld 408576698