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

Unified Diff: services/media/framework/stages/active_sink_stage.cc

Issue 1577953002: Motown in-proc streaming framework used to implement media services. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sync Created 4 years, 11 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: services/media/framework/stages/active_sink_stage.cc
diff --git a/services/media/framework/stages/active_sink_stage.cc b/services/media/framework/stages/active_sink_stage.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c49b55e0b3ae6052513dbbf22f75b84e2a11825e
--- /dev/null
+++ b/services/media/framework/stages/active_sink_stage.cc
@@ -0,0 +1,67 @@
+// Copyright 2016 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 "services/media/framework/stages/active_sink_stage.h"
+
+namespace mojo {
+namespace media {
+
+ActiveSinkStage::ActiveSinkStage(ActiveSinkPtr sink) : sink_(sink) {
+ DCHECK(sink_);
+
+ demand_function_ = [this](Demand demand) {
+ DCHECK(update_callback_);
+ if (sink_demand_ != demand) {
+ sink_demand_ = demand;
+ update_callback_(this);
+ }
+ };
+
+ sink_->SetDemandCallback(demand_function_);
+}
+
+ActiveSinkStage::~ActiveSinkStage() {}
+
+uint32_t ActiveSinkStage::input_count() const {
+ return 1;
+};
+
+StageInput& ActiveSinkStage::input(uint32_t index) {
+ DCHECK_EQ(index, 0u);
+ return input_;
+}
+
+uint32_t ActiveSinkStage::output_count() const {
+ return 0;
+}
+
+StageOutput& ActiveSinkStage::output(uint32_t index) {
+ NOTREACHED();
+ static StageOutput result;
+ return result;
+}
+
+bool ActiveSinkStage::Prepare(UpdateCallback update_callback) {
+ input_.Prepare(sink_->allocator(), sink_->must_allocate());
+ update_callback_ = update_callback;
+ return true;
+}
+
+void ActiveSinkStage::Prime() {
+ sink_->Prime();
+}
+
+void ActiveSinkStage::Update(Engine* engine) {
+ DCHECK(engine);
+
+ if (input_.packet_from_upstream()) {
+ sink_demand_ =
+ sink_->SupplyPacket(std::move(input_.packet_from_upstream()));
+ }
+
+ input_.SetDemand(sink_demand_, engine);
+}
+
+} // namespace media
+} // namespace mojo
« no previous file with comments | « services/media/framework/stages/active_sink_stage.h ('k') | services/media/framework/stages/active_source_stage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698