Chromium Code Reviews| Index: services/media/framework/stages/stage_input.h |
| diff --git a/services/media/framework/stages/stage_input.h b/services/media/framework/stages/stage_input.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7a957a20558867177ce48cc48e9fc58079366786 |
| --- /dev/null |
| +++ b/services/media/framework/stages/stage_input.h |
| @@ -0,0 +1,84 @@ |
| +// 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. |
| + |
| +#ifndef SERVICES_MEDIA_FRAMEWORK_ENGINE_STAGE_INPUT_H_ |
| +#define SERVICES_MEDIA_FRAMEWORK_ENGINE_STAGE_INPUT_H_ |
| + |
| +#include "services/media/framework/models/demand.h" |
| +#include "services/media/framework/packet.h" |
| + |
| +namespace mojo { |
| +namespace media { |
| + |
| +class Stage; |
| +class Engine; |
| +class StageOutput; |
| +class LpcmStageInput; |
| + |
| +// Represents a stage's connector to an adjacent upstream stage. |
| +class StageInput { |
| + public: |
| + StageInput(); |
| + |
| + ~StageInput(); |
| + |
| + // The stage to which this input is connected. |
| + Stage* upstream_stage() const { return upstream_stage_; } |
| + |
| + // The index of the output to which this input is connected. |
| + uint32_t output_index() const { return output_index_; } |
| + |
| + // Establishes a connection. Called only by the engine. |
| + void connect(Stage* upstream_stage, uint32_t output_index) { |
|
johngro
2016/01/26 23:47:30
It would be good to DCHECK that we are not already
dalesat
2016/01/28 18:49:16
Done.
|
| + upstream_stage_ = upstream_stage; |
| + output_index_ = output_index; |
| + } |
| + |
| + // Determines whether the input is connected to an output. |
| + bool connected() const { return upstream_stage_ != nullptr; } |
| + |
| + // The connected output. |
| + StageOutput& mate() const; |
| + |
| + // Prepare to move packets by providing an allocator for the upstream stage |
| + // if we have one and indicating whether we require its use. |
| + void Prepare(Allocator* allocator, bool must_allocate); |
| + |
| + // Returns the allocator provided by this input. |
| + Allocator* allocator() const { |
| + return allocator_; |
| + } |
| + |
| + // Determines whether the input requires the use of its allocator. |
| + bool must_allocate() const { |
| + return must_allocate_; |
|
johngro
2016/01/26 23:47:30
must_allocate_ is only really defined after Prepar
dalesat
2016/01/28 18:49:16
My thinking regarding allocator() was that it coul
|
| + } |
| + |
| + // A packet supplied from upstream. |
| + PacketPtr& packet_from_upstream() { return packet_from_upstream_; } |
| + |
| + // Updates mate's demand. Called only by Stage::Update implementations. |
| + void set_demand(Demand demand, Engine* engine) const; |
| + |
| + // Updates packet_from_upstream. Return value indicates whether the stage for |
| + // this input should be added to the supply backlog. Called only by |
| + // StageOutput instances. |
| + virtual bool supply_packet_internal(PacketPtr packet); |
| + |
| + // Returns the LPCM specialization if this instance is an LpcmStageInput, |
| + // nullptr otherwise. |
| + virtual LpcmStageInput* get_lpcm(); |
| + |
| + private: |
| + Stage* upstream_stage_; |
|
johngro
2016/01/26 23:47:30
FWIW, you can initialize PoD members at declaratio
dalesat
2016/01/28 18:49:16
Thanks for pointing that out...I wasn't aware. Thi
|
| + uint32_t output_index_; |
| + Allocator* allocator_; |
| + bool must_allocate_; |
| + PacketPtr packet_from_upstream_; |
| +}; |
| + |
| +} // namespace media |
| +} // namespace mojo |
| + |
| +#endif // SERVICES_MEDIA_FRAMEWORK_ENGINE_STAGE_INPUT_H_ |