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: services/media/framework/stages/active_source_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_source_stage.cc
diff --git a/services/media/framework/stages/active_source_stage.cc b/services/media/framework/stages/active_source_stage.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6dd2fc99595554d238d90f6942e05e704eca6b34
--- /dev/null
+++ b/services/media/framework/stages/active_source_stage.cc
@@ -0,0 +1,69 @@
+// 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_source_stage.h"
+
+namespace mojo {
+namespace media {
+
+ActiveSourceStage::ActiveSourceStage(ActiveSourcePtr source) : source_(source) {
+ DCHECK(source_);
+
+ supply_function_ = [this](PacketPtr packet) {
+ bool packets_was_empty_ = packets_.empty();
+ packets_.push_back(std::move(packet));
+ if (packets_was_empty_ && update_callback_) {
+ update_callback_(this);
+ }
+ };
+
+ source_->SetSupplyCallback(supply_function_);
+}
+
+ActiveSourceStage::~ActiveSourceStage() {}
+
+uint32_t ActiveSourceStage::input_count() const {
+ return 0;
+};
+
+StageInput& ActiveSourceStage::input(uint32_t index) {
+ NOTREACHED();
+ static StageInput result;
+ return result;
+}
+
+uint32_t ActiveSourceStage::output_count() const {
+ return 1;
+}
+
+StageOutput& ActiveSourceStage::output(uint32_t index) {
+ DCHECK_EQ(index, 0u);
+ return output_;
+}
+
+bool ActiveSourceStage::Prepare(UpdateCallback update_callback) {
+ update_callback_ = update_callback;
+ Allocator* allocator = output_.Prepare(source_->can_accept_allocator());
+ if (allocator) {
+ DCHECK(source_->can_accept_allocator());
+ source_->set_allocator(allocator);
+ }
+ return true;
+}
+
+void ActiveSourceStage::Update(Engine* engine) {
+ DCHECK(engine);
+
+ Demand demand = output_.demand();
+
+ source_->SetDownstreamDemand(demand);
+
+ if (demand != Demand::kNegative && !packets_.empty()) {
+ output_.SupplyPacket(std::move(packets_.front()), engine);
+ packets_.pop_front();
+ }
+}
+
+} // namespace media
+} // namespace mojo
« no previous file with comments | « services/media/framework/stages/active_source_stage.h ('k') | services/media/framework/stages/distributor_stage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698