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

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

Issue 551963004: media: scaffolding and plumbing for MojoRenderer{Impl, Service} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_impl.cc
diff --git a/media/mojo/services/mojo_demuxer_stream_impl.cc b/media/mojo/services/mojo_demuxer_stream_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d1eece7e2b81f686aa2ed4611ff36cbd96337c3
--- /dev/null
+++ b/media/mojo/services/mojo_demuxer_stream_impl.cc
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/mojo/services/mojo_demuxer_stream_impl.h"
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "media/base/audio_decoder_config.h"
+#include "media/mojo/interfaces/demuxer_stream.mojom.h"
+#include "media/mojo/services/media_type_converters.h"
+#include "mojo/public/cpp/bindings/interface_impl.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+
+namespace media {
+
+MojoDemuxerStreamImpl::MojoDemuxerStreamImpl(media::DemuxerStream* stream)
+ : stream_(stream), weak_factory_(this) {}
+
+MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() {}
+
+void MojoDemuxerStreamImpl::Read(
+ const mojo::Callback<void(mojo::DemuxerStream::Status,
+ mojo::MediaDecoderBufferPtr)>& callback) {
+ stream_->Read(base::Bind(&MojoDemuxerStreamImpl::OnBufferReady,
+ weak_factory_.GetWeakPtr(),
+ 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
+}
+
+void MojoDemuxerStreamImpl::OnBufferReady(
+ mojo::Callback<void(mojo::DemuxerStream::Status,
+ mojo::MediaDecoderBufferPtr)> callback,
+ media::DemuxerStream::Status status,
+ const scoped_refptr<media::DecoderBuffer>& buffer) {
+ 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
+ // Send the config change so our client can read it once it parses the
+ // Status obtained via Run() below.
+ client()->OnAudioDecoderConfigChanged(
+ mojo::AudioDecoderConfig::From(stream_->audio_decoder_config()));
+ }
+
+ // TODO(tim): Once using DataPipe, fill via the producer handle and then
+ // read more to keep the pipe full.
+ callback.Run(static_cast<mojo::DemuxerStream::Status>(status),
+ mojo::MediaDecoderBuffer::From(buffer));
+}
+
+void MojoDemuxerStreamImpl::OnConnectionEstablished() {
+ // This is called when our DemuxerStreamClient has connected itself and is
+ // ready to receive messages. Send an initial config and notify it that
+ // we are now ready for business.
+ client()->OnAudioDecoderConfigChanged(
+ mojo::AudioDecoderConfig::From(stream_->audio_decoder_config()));
+
+ // TODO(tim): Create a DataPipe, hold the producer handle, and pass the
+ // consumer handle here.
+ client()->OnStreamReady(mojo::ScopedDataPipeConsumerHandle());
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698