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

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: public_deps 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
« no previous file with comments | « media/mojo/services/mojo_demuxer_stream_impl.h ('k') | media/mojo/services/mojo_renderer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0bce8a29fda84e93917fd7b0153d247828bfdaa6
--- /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));
+}
+
+void MojoDemuxerStreamImpl::OnBufferReady(
+ const BufferReadyCB& callback,
+ media::DemuxerStream::Status status,
+ const scoped_refptr<media::DecoderBuffer>& buffer) {
+ if (status == media::DemuxerStream::kConfigChanged) {
+ // 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
« no previous file with comments | « media/mojo/services/mojo_demuxer_stream_impl.h ('k') | media/mojo/services/mojo_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698