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

Unified Diff: media/mojo/services/demuxer_stream_provider_shim.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: More MSVC... Created 6 years, 1 month 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/demuxer_stream_provider_shim.h ('k') | media/mojo/services/media_type_converters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/demuxer_stream_provider_shim.cc
diff --git a/media/mojo/services/demuxer_stream_provider_shim.cc b/media/mojo/services/demuxer_stream_provider_shim.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6620e6ae665429e9b0ddd0c3d8e2166d9bc16a08
--- /dev/null
+++ b/media/mojo/services/demuxer_stream_provider_shim.cc
@@ -0,0 +1,62 @@
+// 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/demuxer_stream_provider_shim.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback_helpers.h"
+
+namespace media {
+
+DemuxerStreamProviderShim::DemuxerStreamProviderShim(
+ mojo::DemuxerStreamPtr audio,
+ mojo::DemuxerStreamPtr video,
+ const base::Closure& demuxer_ready_cb)
+ : demuxer_ready_cb_(demuxer_ready_cb),
+ streams_ready_(0),
+ weak_factory_(this) {
+ DCHECK(audio || video);
+ DCHECK(!demuxer_ready_cb_.is_null());
+
+ if (audio) {
+ streams_.push_back(new MojoDemuxerStreamAdapter(
+ audio.Pass(),
+ base::Bind(&DemuxerStreamProviderShim::OnStreamReady,
+ weak_factory_.GetWeakPtr())));
+ }
+
+ if (video) {
+ streams_.push_back(new MojoDemuxerStreamAdapter(
+ video.Pass(),
+ base::Bind(&DemuxerStreamProviderShim::OnStreamReady,
+ weak_factory_.GetWeakPtr())));
+ }
+}
+
+DemuxerStreamProviderShim::~DemuxerStreamProviderShim() {
+}
+
+DemuxerStream* DemuxerStreamProviderShim::GetStream(DemuxerStream::Type type) {
+ DCHECK(demuxer_ready_cb_.is_null());
+ for (auto* stream : streams_) {
+ if (stream->type() == type)
+ return stream;
+ }
+
+ return nullptr;
+}
+
+DemuxerStreamProvider::Liveness DemuxerStreamProviderShim::GetLiveness() const {
+ // TODO(dalecurtis): This should be removed once liveness lives elsewhere, see
+ // http://crbug.com/420025
+ return DemuxerStreamProvider::LIVENESS_UNKNOWN;
+}
+
+void DemuxerStreamProviderShim::OnStreamReady() {
+ if (++streams_ready_ == streams_.size())
+ base::ResetAndReturn(&demuxer_ready_cb_).Run();
+}
+
+} // namespace media
« no previous file with comments | « media/mojo/services/demuxer_stream_provider_shim.h ('k') | media/mojo/services/media_type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698