Chromium Code Reviews| Index: services/media/framework/stages/stage.h |
| diff --git a/services/media/framework/stages/stage.h b/services/media/framework/stages/stage.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..607a63c783f7dc9cf95aeb3f6ba6879bb27440e0 |
| --- /dev/null |
| +++ b/services/media/framework/stages/stage.h |
| @@ -0,0 +1,175 @@ |
| +// 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_H_ |
| +#define SERVICES_MEDIA_FRAMEWORK_ENGINE_STAGE_H_ |
| + |
| +#include <vector> |
| + |
| +#include "services/media/framework/packet.h" |
| +#include "services/media/framework/stages/lpcm_stage_input.h" |
| +#include "services/media/framework/stages/lpcm_stage_output.h" |
| +#include "services/media/framework/stages/stage_input.h" |
| +#include "services/media/framework/stages/stage_output.h" |
| + |
| +namespace mojo { |
| +namespace media { |
| + |
| +class Engine; |
| + |
| +// Host for a source, sink or transform. |
| +class Stage { |
| + public: |
| + Stage(); |
| + |
| + virtual ~Stage(); |
| + |
| + // Returns the number of input connections. |
| + virtual uint32_t input_count() const = 0; |
| + |
| + // Returns the indicated input connection. |
| + virtual StageInput& input(uint32_t index) = 0; |
| + |
| + // Returns the number of output connections. |
| + virtual uint32_t output_count() const = 0; |
| + |
| + // Returns the indicated output connection. |
| + virtual StageOutput& output(uint32_t index) = 0; |
| + |
| + // Prepares the stage for operation, providing a callback used to signal the |
| + // need to update this stage. Returns true if the stage will call the |
| + // callback, false if not. The default implementation of this method returns |
| + // false. |
| + using UpdateCallback = std::function<void(Stage* stage)>; |
|
johngro
2016/01/26 23:47:29
public typedefs go at the top of the class. see
ht
dalesat
2016/01/28 18:49:16
OK. Someone should tell the mojo compiler.
johngro
2016/02/01 22:38:16
agreed; I'll mention it to Mitch.
|
| + virtual bool Prepare(UpdateCallback update_callback); |
| + |
| + // Initiates demand. Called on sink stages after the graph is prepared. The |
| + // default implementation does nothing. |
| + virtual void Prime(); |
| + |
| + // Performs processing. |
| + virtual void Update(Engine* engine) = 0; |
| + |
| + // Returns a bool indicating whether the stage is prepared. |
| + bool prepared() { |
| + return prepared_; |
| + } |
| + |
| + private: |
| + bool prepared_; |
| + bool in_supply_backlog_; |
| + bool in_demand_backlog_; |
| + |
| + friend class Engine; |
| +}; |
| + |
| +// Stage with no inputs. |
| +class SourceStage : public virtual Stage { |
|
johngro
2016/01/26 23:47:29
so,this type of MI is pretty much banned by google
dalesat
2016/01/28 18:49:16
The goal here was to make stage authoring a bit ea
johngro
2016/02/01 22:38:16
Acknowledged.
|
| + public: |
| + uint32_t input_count() const override; |
| + |
| + StageInput& input(uint32_t index) override; |
| +}; |
| + |
| +// Stage with no outputs. |
| +class SinkStage : public virtual Stage { |
| + public: |
| + uint32_t output_count() const override; |
| + |
| + StageOutput& output(uint32_t index) override; |
| +}; |
| + |
| +// Stage with one input. |
| +class SingleInputStage : public virtual Stage { |
| + public: |
| + uint32_t input_count() const override; |
| + |
| + StageInput& input(uint32_t index) override; |
| + |
| + protected: |
| + StageInput input_; |
| +}; |
| + |
| +// Stage with one output. |
| +class SingleOutputStage : public virtual Stage { |
| + public: |
| + uint32_t output_count() const override; |
| + |
| + StageOutput& output(uint32_t index) override; |
| + |
| + protected: |
| + StageOutput output_; |
| +}; |
| + |
| +// Stage with multiple inputs. |
| +class MultiInputStage : public virtual Stage { |
| + public: |
| + MultiInputStage(); |
| + |
| + ~MultiInputStage() override; |
| + |
| + uint32_t input_count() const override; |
| + |
| + StageInput& input(uint32_t index) override; |
| + |
| + protected: |
| + std::vector<StageInput> inputs_; |
| +}; |
| + |
| +// Stage with multiple outputs. |
| +class MultiOutputStage : public virtual Stage { |
| + public: |
| + MultiOutputStage(); |
| + |
| + ~MultiOutputStage() override; |
| + |
| + uint32_t output_count() const override; |
| + |
| + StageOutput& output(uint32_t index) override; |
| + |
| + protected: |
| + std::vector<StageOutput> outputs_; |
| +}; |
| + |
| +// LPCM stage with one input. |
| +class LpcmSingleInputStage : public virtual Stage { |
| + public: |
| + uint32_t input_count() const override; |
| + |
| + StageInput& input(uint32_t index) override; |
| + |
| + protected: |
| + LpcmStageInput input_; |
| +}; |
| + |
| +// LPCM stage with multiple inputs. |
| +class LpcmMultiInputStage : public virtual Stage { |
| + public: |
| + LpcmMultiInputStage(); |
| + |
| + ~LpcmMultiInputStage() override; |
| + |
| + uint32_t input_count() const override; |
| + |
| + StageInput& input(uint32_t index) override; |
| + |
| + protected: |
| + std::vector<LpcmStageInput> inputs_; |
| +}; |
| + |
| +// LPCM stage with one output. |
| +class LpcmSingleOutputStage : public virtual Stage { |
| + public: |
| + uint32_t output_count() const override; |
| + |
| + StageOutput& output(uint32_t index) override; |
| + |
| + protected: |
| + LpcmStageOutput output_; |
| +}; |
| + |
| +} // namespace media |
| +} // namespace mojo |
| + |
| +#endif // SERVICES_MEDIA_FRAMEWORK_ENGINE_STAGE_H_ |