Update V8 to version 4.7.56.
[chromium-blink-merge.git] / media / base / android / media_codec_audio_decoder.h
blobdf0193fe5c09d24b56466d1c17ef81057599d51f
1 // Copyright 2015 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_MEDIA_CODEC_AUDIO_DECODER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_
8 #include "media/base/android/media_codec_decoder.h"
10 namespace media {
12 class AudioTimestampHelper;
14 // Audio decoder for MediaCodecPlayer
15 class MediaCodecAudioDecoder : public MediaCodecDecoder {
16 public:
17 // For parameters see media_codec_decoder.h
18 // update_current_time_cb: callback that reports current playback time.
19 // Called for each rendered frame.
20 MediaCodecAudioDecoder(
21 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner,
22 const base::Closure& request_data_cb,
23 const base::Closure& starvation_cb,
24 const base::Closure& decoder_drained_cb,
25 const base::Closure& stop_done_cb,
26 const base::Closure& error_cb,
27 const SetTimeCallback& update_current_time_cb);
28 ~MediaCodecAudioDecoder() override;
30 const char* class_name() const override;
32 bool HasStream() const override;
33 void SetDemuxerConfigs(const DemuxerConfigs& configs) override;
34 void ReleaseDecoderResources() override;
35 void Flush() override;
37 // Sets the volume of the audio output.
38 void SetVolume(double volume);
40 // Sets the base timestamp for |audio_timestamp_helper_|.
41 void SetBaseTimestamp(base::TimeDelta base_timestamp);
43 protected:
44 bool IsCodecReconfigureNeeded(const DemuxerConfigs& next) const override;
45 ConfigStatus ConfigureInternal() override;
46 void OnOutputFormatChanged() override;
47 void Render(int buffer_index,
48 size_t offset,
49 size_t size,
50 RenderMode render_mode,
51 base::TimeDelta pts,
52 bool eos_encountered) override;
54 private:
55 // A helper method to set the volume.
56 void SetVolumeInternal();
58 // Recreates |audio_timestamp_helper_|, called when sampling rate is changed.
59 void ResetTimestampHelper();
61 // Data.
63 // Configuration received from demuxer
64 DemuxerConfigs configs_;
66 // Requested volume
67 double volume_;
69 // Number of bytes per audio frame. Depends on the output format and the
70 // number of channels.
71 int bytes_per_frame_;
73 // The sampling rate received from decoder.
74 int output_sampling_rate_;
76 // Frame count to sync with audio codec output.
77 int64 frame_count_;
79 // Base timestamp for the |audio_timestamp_helper_|.
80 base::TimeDelta base_timestamp_;
82 // Object to calculate the current audio timestamp for A/V sync.
83 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
85 // Reports current playback time to the callee.
86 SetTimeCallback update_current_time_cb_;
88 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder);
91 } // namespace media
93 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_