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..2fe61c64888a2ed28951b19096b91d410a5c08a1 |
| --- /dev/null |
| +++ b/services/media/framework/stages/stage_input.h |
| @@ -0,0 +1,83 @@ |
| +// 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); |
| + |
| + // Breaks a connection. Called only by the engine. |
| + void disconnect() { |
| + upstream_stage_ = nullptr; |
| + output_index_ = 0; |
| + } |
| + |
| + // 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; |
| + |
| + // Determines whether the input requires the use of its allocator. |
| + bool must_allocate() const; |
|
jeffbrown
2016/02/02 05:35:49
Or else what? Some arbitrary allocator can be use
dalesat
2016/02/02 21:46:40
We should discuss. This isn't a stream attribute,
|
| + |
| + // A packet supplied from upstream. |
| + PacketPtr& packet_from_upstream() { return packet_from_upstream_; } |
| + |
| + // Updates mate's demand. Called only by Stage::Update implementations. |
| + void SetDemand(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 SupplyPacketFromOutput(PacketPtr packet); |
|
jeffbrown
2016/02/02 05:35:48
Should this type really be subclassed? I wonder.
dalesat
2016/02/02 21:46:40
This is virtual so that the LPCM version can run m
|
| + |
| + // Returns the LPCM specialization if this instance is an LpcmStageInput, |
| + // nullptr otherwise. |
| + virtual LpcmStageInput* get_lpcm(); |
|
jeffbrown
2016/02/02 05:35:49
nit: GetLpcmStageInput().
But something about thi
dalesat
2016/02/02 21:46:40
This is a downcast. I'd be happy to do it differen
|
| + |
| + private: |
| + Stage* upstream_stage_; |
| + 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_ |