| Index: services/media/framework/stages/lpcm_stage_output.h
|
| diff --git a/services/media/framework/stages/lpcm_stage_output.h b/services/media/framework/stages/lpcm_stage_output.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..44b87ada41d269151263ca907531231eb722d309
|
| --- /dev/null
|
| +++ b/services/media/framework/stages/lpcm_stage_output.h
|
| @@ -0,0 +1,79 @@
|
| +// 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_LPCM_STAGE_OUTPUT_H_
|
| +#define SERVICES_MEDIA_FRAMEWORK_ENGINE_LPCM_STAGE_OUTPUT_H_
|
| +
|
| +#include "services/media/framework/allocator.h"
|
| +#include "services/media/framework/lpcm_util.h"
|
| +#include "services/media/framework/stages/lpcm_demand.h"
|
| +#include "services/media/framework/stages/stage_output.h"
|
| +
|
| +namespace mojo {
|
| +namespace media {
|
| +
|
| +class LpcmStageInput;
|
| +
|
| +// Represents a stage's connector to an adjacent downstream stage.
|
| +class LpcmStageOutput : public StageOutput {
|
| + public:
|
| + LpcmStageOutput();
|
| +
|
| + ~LpcmStageOutput();
|
| +
|
| + // Sets the stream type.
|
| + void set_stream_type(LpcmStreamType& stream_type) {
|
| + DCHECK(buffer_ == nullptr);
|
| + lpcm_demand_from_downstream_.frames_.bytes_per_frame_ =
|
| + stream_type.bytes_per_frame();
|
| + lpcm_util_.reset(LpcmUtil::Create(stream_type));
|
| + }
|
| +
|
| + // Sets the presentation time for the next packet. Used for adaptation to
|
| + // non-lpcm input.
|
| + void set_next_presentation_time(int64_t next_presentation_time) {
|
| + next_presentation_time_ = next_presentation_time;
|
| + }
|
| +
|
| + // Gets the demand signalled from downstream. The caller can suggest a frame
|
| + // count in case the downstream input isn't lpcm. In that case, the output
|
| + // needs to allocate a packet. If suggested_frame_count is 0, the output uses
|
| + // a default frame count instead.
|
| + LpcmDemand& lpcm_demand_from_downstream(uint64_t suggested_frame_count = 0);
|
| +
|
| + // Indicates that all demanded frames have been supplied or we've hit end of
|
| + // stream. Called only by Stage::Update implementations.
|
| + void supply_frames(bool end_of_stream, Engine& engine);
|
| +
|
| + // Updates lpcm_demand_from_downstream_. Called only by LpcmStageInput
|
| + // instances.
|
| + bool update_lpcm_demand_internal(void* buffer, uint64_t frames, bool mix) {
|
| + lpcm_demand_from_downstream_.frames_.buffer_ = buffer;
|
| + lpcm_demand_from_downstream_.frames_.frame_count_ = frames;
|
| + lpcm_demand_from_downstream_.mix_ = mix;
|
| + return true;
|
| + }
|
| +
|
| + // StageOutput override.
|
| + Allocator* Prepare(bool can_accept_allocator) override;
|
| +
|
| + LpcmStageOutput* get_lpcm() override;
|
| +
|
| + private:
|
| + static const uint64_t kDefaultFrameCount = 512;
|
| +
|
| + LpcmDemand lpcm_demand_from_downstream_;
|
| +
|
| + std::unique_ptr<LpcmUtil> lpcm_util_;
|
| +
|
| + // Fields below are used when the connected input isn't lpcm.
|
| + int64_t next_presentation_time_;
|
| + void* buffer_;
|
| + uint64_t buffer_frame_count_;
|
| +};
|
| +
|
| +} // namespace media
|
| +} // namespace mojo
|
| +
|
| +#endif // SERVICES_MEDIA_FRAMEWORK_ENGINE_LPCM_STAGE_OUTPUT_H_
|
|
|