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 class MediaCodecAudioDecoder : public MediaCodecDecoder { |
| 15 public: |
| 16 MediaCodecAudioDecoder( |
| 17 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner, |
| 18 const scoped_refptr<base::SingleThreadTaskRunner>& ui_runner, |
| 19 const base::Closure& request_data_cb, |
| 20 const base::Closure& starvation_cb, |
| 21 const base::Closure& stop_done_cb, |
| 22 const base::Closure& error_cb, |
| 23 const SetTimeCallback& update_current_time_cb); |
| 24 ~MediaCodecAudioDecoder() override; |
| 25 |
| 26 const char * class_name() const override { return "AudioDecoder"; } |
| 27 |
| 28 bool HasStream() const override; |
| 29 void Flush() override; |
| 30 |
| 31 // Sets the volume of the audio output. |
| 32 void SetVolume(double volume); |
| 33 |
| 34 // Sets the base timestamp for |audio_timestamp_helper_|. |
| 35 void SetBaseTimestamp(base::TimeDelta base_timestamp); |
| 36 |
| 37 protected: |
| 38 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, |
| 39 const DemuxerConfigs& next) const override; |
| 40 ConfigStatus ConfigureInternal() override; |
| 41 void Render(int buffer_index, size_t size, bool render_output, |
| 42 base::TimeDelta pts, bool eos_encountered) override; |
| 43 |
| 44 private: |
| 45 void SetVolumeInternal(); |
| 46 void ResetTimestampHelper(); |
| 47 |
| 48 // Data. |
| 49 |
| 50 // Requested volume |
| 51 double volume_; |
| 52 |
| 53 // Number of bytes per audio frame. Depends on the output format |
| 54 // and the number of channels. |
| 55 int bytes_per_frame_; |
| 56 |
| 57 // Frame count to sync with audio codec output |
| 58 int64 frame_count_; |
| 59 |
| 60 // Base timestamp for the |audio_timestamp_helper_|. |
| 61 base::TimeDelta base_timestamp_; |
| 62 |
| 63 // Object to calculate the current audio timestamp for A/V sync. |
| 64 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
| 65 |
| 66 // Callback to report current playback time to player |
| 67 SetTimeCallback update_current_time_cb_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder); |
| 70 }; |
| 71 |
| 72 } // namespace media |
| 73 |
| 74 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ |
OLD | NEW |