Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_ | |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_ | |
| 7 | |
| 8 #include "media/base/android/media_codec_decoder.h" | |
| 9 | |
| 10 namespace media { | |
| 11 | |
| 12 class AudioTimestampHelper; | |
| 13 | |
| 14 // Audio decoder for MediaCodecPlayer | |
| 15 class MediaCodecAudioDecoder : public MediaCodecDecoder { | |
| 16 public: | |
| 17 MediaCodecAudioDecoder( | |
| 18 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner, | |
| 19 const scoped_refptr<base::SingleThreadTaskRunner>& ui_runner, | |
| 20 const base::Closure& request_data_cb, | |
| 21 const base::Closure& starvation_cb, | |
| 22 const base::Closure& stop_done_cb, | |
| 23 const base::Closure& error_cb, | |
| 24 const SetTimeCallback& update_current_time_cb); | |
| 25 ~MediaCodecAudioDecoder() override; | |
| 26 | |
| 27 const char * class_name() const override { return "AudioDecoder"; } | |
|
qinmin
2015/05/26 00:49:19
s/char */char*/
Tima Vaisburd
2015/05/28 02:00:34
Done.
| |
| 28 | |
| 29 bool HasStream() const override; | |
| 30 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; | |
| 31 void Flush() override; | |
| 32 | |
| 33 // Sets the volume of the audio output. | |
| 34 void SetVolume(double volume); | |
| 35 | |
| 36 // Sets the base timestamp for |audio_timestamp_helper_|. | |
| 37 void SetBaseTimestamp(base::TimeDelta base_timestamp); | |
| 38 | |
| 39 protected: | |
| 40 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, | |
| 41 const DemuxerConfigs& next) const override; | |
| 42 ConfigStatus ConfigureInternal() override; | |
| 43 void OnOutputFormatChanged() override; | |
| 44 void Render(int buffer_index, size_t size, bool render_output, | |
| 45 base::TimeDelta pts, bool eos_encountered) override; | |
| 46 | |
| 47 private: | |
| 48 void SetVolumeInternal(); | |
| 49 void ResetTimestampHelper(); | |
| 50 | |
| 51 // Data. | |
| 52 | |
| 53 // Configuration received from demuxer | |
| 54 DemuxerConfigs configs_; | |
| 55 | |
| 56 // Requested volume | |
| 57 double volume_; | |
| 58 | |
| 59 // Number of bytes per audio frame. Depends on the output format | |
| 60 // and the number of channels. | |
| 61 int bytes_per_frame_; | |
| 62 | |
| 63 // The sampling rate received from decoder. | |
| 64 int output_sampling_rate_; | |
| 65 | |
| 66 // Frame count to sync with audio codec output. | |
| 67 int64 frame_count_; | |
| 68 | |
| 69 // Base timestamp for the |audio_timestamp_helper_|. | |
| 70 base::TimeDelta base_timestamp_; | |
| 71 | |
| 72 // Object to calculate the current audio timestamp for A/V sync. | |
| 73 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | |
| 74 | |
| 75 // Callback to report current playback time to player. | |
| 76 SetTimeCallback update_current_time_cb_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder); | |
| 79 }; | |
| 80 | |
| 81 } // namespace media | |
| 82 | |
| 83 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ | |
| OLD | NEW |