1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_
6 #define CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "chromecast/media/cma/pipeline/audio_pipeline.h"
14 #include "chromecast/media/cma/pipeline/av_pipeline_client.h"
15 #include "chromecast/public/media/stream_id.h"
18 class AudioDecoderConfig
;
19 class VideoDecoderConfig
;
22 namespace chromecast
{
24 class AudioPipelineDevice
;
28 class CodedFrameProvider
;
30 class AudioPipelineImpl
: public AudioPipeline
{
32 // |buffering_controller| can be NULL.
33 explicit AudioPipelineImpl(AudioPipelineDevice
* audio_device
);
34 ~AudioPipelineImpl() override
;
36 // Input port of the pipeline.
37 void SetCodedFrameProvider(scoped_ptr
<CodedFrameProvider
> frame_provider
);
39 // Provide the CDM to use to decrypt samples.
40 void SetCdm(BrowserCdmCast
* media_keys
);
42 // Functions to control the state of the audio pipeline.
44 const ::media::AudioDecoderConfig
& config
,
45 scoped_ptr
<CodedFrameProvider
> frame_provider
,
46 const ::media::PipelineStatusCB
& status_cb
);
47 bool StartPlayingFrom(base::TimeDelta time
,
48 const scoped_refptr
<BufferingState
>& buffering_state
);
49 void Flush(const ::media::PipelineStatusCB
& status_cb
);
52 // Update the playback statistics for this audio stream.
53 void UpdateStatistics();
55 // AudioPipeline implementation.
56 void SetClient(const AvPipelineClient
& client
) override
;
57 void SetVolume(float volume
) override
;
60 void OnFlushDone(const ::media::PipelineStatusCB
& status_cb
);
61 void OnUpdateConfig(StreamId id
,
62 const ::media::AudioDecoderConfig
& audio_config
,
63 const ::media::VideoDecoderConfig
& video_config
);
65 AudioPipelineDevice
* audio_device_
;
67 scoped_ptr
<AvPipelineImpl
> av_pipeline_impl_
;
68 AvPipelineClient audio_client_
;
70 ::media::PipelineStatistics previous_stats_
;
72 base::WeakPtr
<AudioPipelineImpl
> weak_this_
;
73 base::WeakPtrFactory
<AudioPipelineImpl
> weak_factory_
;
75 DISALLOW_COPY_AND_ASSIGN(AudioPipelineImpl
);
79 } // namespace chromecast
81 #endif // CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_