OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | 5 #ifndef MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ |
6 #define MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | 6 #define MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Creates a new AudioDecoderJob instance for decoding audio. | 22 // Creates a new AudioDecoderJob instance for decoding audio. |
23 // |request_data_cb| - Callback used to request more data for the decoder. | 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 | 24 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that |
25 // demuxer config has changed. | 25 // demuxer config has changed. |
26 AudioDecoderJob(const base::Closure& request_data_cb, | 26 AudioDecoderJob(const base::Closure& request_data_cb, |
27 const base::Closure& on_demuxer_config_changed_cb); | 27 const base::Closure& on_demuxer_config_changed_cb); |
28 virtual ~AudioDecoderJob(); | 28 virtual ~AudioDecoderJob(); |
29 | 29 |
30 // MediaDecoderJob implementation. | 30 // MediaDecoderJob implementation. |
31 virtual bool HasStream() const override; | 31 virtual bool HasStream() const override; |
| 32 virtual void Flush() override; |
32 virtual void SetDemuxerConfigs(const DemuxerConfigs& configs) override; | 33 virtual void SetDemuxerConfigs(const DemuxerConfigs& configs) override; |
33 | 34 |
34 // Sets the volume of the audio output. | 35 // Sets the volume of the audio output. |
35 void SetVolume(double volume); | 36 void SetVolume(double volume); |
36 | 37 |
37 // Sets the base timestamp for |audio_timestamp_helper_|. | 38 // Sets the base timestamp for |audio_timestamp_helper_|. |
38 void SetBaseTimestamp(base::TimeDelta base_timestamp); | 39 void SetBaseTimestamp(base::TimeDelta base_timestamp); |
39 | 40 |
40 private: | 41 private: |
41 // MediaDecoderJob implementation. | 42 // MediaDecoderJob implementation. |
42 virtual void ReleaseOutputBuffer( | 43 virtual void ReleaseOutputBuffer( |
43 int output_buffer_index, | 44 int output_buffer_index, |
44 size_t size, | 45 size_t size, |
45 bool render_output, | 46 bool render_output, |
46 base::TimeDelta current_presentation_timestamp, | 47 base::TimeDelta current_presentation_timestamp, |
47 const ReleaseOutputCompletionCallback& callback) override; | 48 const ReleaseOutputCompletionCallback& callback) override; |
48 virtual bool ComputeTimeToRender() const override; | 49 virtual bool ComputeTimeToRender() const override; |
49 virtual bool AreDemuxerConfigsChanged( | 50 virtual bool AreDemuxerConfigsChanged( |
50 const DemuxerConfigs& configs) const override; | 51 const DemuxerConfigs& configs) const override; |
51 virtual bool CreateMediaCodecBridgeInternal() override; | 52 virtual bool CreateMediaCodecBridgeInternal() override; |
| 53 virtual void OnOutputFormatChanged() override; |
52 | 54 |
53 // Helper method to set the audio output volume. | 55 // Helper method to set the audio output volume. |
54 void SetVolumeInternal(); | 56 void SetVolumeInternal(); |
55 | 57 |
| 58 void ResetTimestampHelper(); |
| 59 |
56 // Audio configs from the demuxer. | 60 // Audio configs from the demuxer. |
57 AudioCodec audio_codec_; | 61 AudioCodec audio_codec_; |
58 int num_channels_; | 62 int num_channels_; |
59 int sampling_rate_; | 63 int config_sampling_rate_; |
60 std::vector<uint8> audio_extra_data_; | 64 std::vector<uint8> audio_extra_data_; |
61 double volume_; | 65 double volume_; |
62 int bytes_per_frame_; | 66 int bytes_per_frame_; |
63 | 67 |
| 68 // Audio output sample rate |
| 69 int output_sampling_rate_; |
| 70 |
| 71 // Frame count to sync with audio codec output |
| 72 int64 frame_count_; |
| 73 |
64 // Base timestamp for the |audio_timestamp_helper_|. | 74 // Base timestamp for the |audio_timestamp_helper_|. |
65 base::TimeDelta base_timestamp_; | 75 base::TimeDelta base_timestamp_; |
66 | 76 |
67 // Object to calculate the current audio timestamp for A/V sync. | 77 // Object to calculate the current audio timestamp for A/V sync. |
68 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | 78 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
69 | 79 |
70 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob); | 80 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob); |
71 }; | 81 }; |
72 | 82 |
73 } // namespace media | 83 } // namespace media |
74 | 84 |
75 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | 85 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ |
OLD | NEW |