1 // Copyright 2013 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 MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_
6 #define MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_
11 #include "base/callback.h"
12 #include "media/base/android/media_decoder_job.h"
16 class AudioCodecBridge
;
17 class AudioTimestampHelper
;
19 // Class for managing audio decoding jobs.
20 class AudioDecoderJob
: public MediaDecoderJob
{
22 // Creates a new AudioDecoderJob instance for decoding audio.
23 // |request_data_cb| - Callback used to request more data for the decoder.
24 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that
25 // demuxer config has changed.
26 AudioDecoderJob(const base::Closure
& request_data_cb
,
27 const base::Closure
& on_demuxer_config_changed_cb
);
28 ~AudioDecoderJob() override
;
30 // MediaDecoderJob implementation.
31 bool HasStream() const override
;
32 void Flush() override
;
33 void SetDemuxerConfigs(const DemuxerConfigs
& configs
) override
;
35 // Sets the volume of the audio output.
36 void SetVolume(double volume
);
38 // Sets the base timestamp for |audio_timestamp_helper_|.
39 void SetBaseTimestamp(base::TimeDelta base_timestamp
);
42 // MediaDecoderJob implementation.
43 void ReleaseOutputBuffer(
44 int output_buffer_index
,
48 base::TimeDelta current_presentation_timestamp
,
49 const ReleaseOutputCompletionCallback
& callback
) override
;
50 bool ComputeTimeToRender() const override
;
51 bool AreDemuxerConfigsChanged(const DemuxerConfigs
& configs
) const override
;
52 MediaDecoderJobStatus
CreateMediaCodecBridgeInternal() override
;
53 void OnOutputFormatChanged() override
;
55 // Helper method to set the audio output volume.
56 void SetVolumeInternal();
58 void ResetTimestampHelper();
60 // Audio configs from the demuxer.
61 AudioCodec audio_codec_
;
63 int config_sampling_rate_
;
64 std::vector
<uint8
> audio_extra_data_
;
65 int64 audio_codec_delay_ns_
;
66 int64 audio_seek_preroll_ns_
;
70 // Audio output sample rate
71 int output_sampling_rate_
;
73 // Frame count to sync with audio codec output
76 // Base timestamp for the |audio_timestamp_helper_|.
77 base::TimeDelta base_timestamp_
;
79 // Object to calculate the current audio timestamp for A/V sync.
80 scoped_ptr
<AudioTimestampHelper
> audio_timestamp_helper_
;
82 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob
);
87 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_