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 | 9 |
10 #include "media/base/android/media_decoder_job.h" | 10 #include "media/base/android/media_decoder_job.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 class AudioCodecBridge; | 14 class AudioCodecBridge; |
15 class AudioTimestampHelper; | 15 class AudioTimestampHelper; |
16 | 16 |
17 // Class for managing audio decoding jobs. | 17 // Class for managing audio decoding jobs. |
18 class AudioDecoderJob : public MediaDecoderJob { | 18 class AudioDecoderJob : public MediaDecoderJob { |
19 public: | 19 public: |
20 virtual ~AudioDecoderJob(); | 20 // Creates a new AudioDecoderJob instance for decoding audio. |
21 // |request_data_cb| - Callback used to request more data for the decoder. | |
22 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that | |
23 // demuxer config has changed. | |
24 AudioDecoderJob(const base::Closure& request_data_cb, | |
25 const base::Closure& on_demuxer_config_changed_cb); | |
26 ~AudioDecoderJob(); | |
21 | 27 |
22 // Creates a new AudioDecoderJob instance for decoding audio. | 28 virtual bool HasStream() const OVERRIDE; |
23 // |audio_codec| - The audio format the object needs to decode. | |
24 // |sample_rate| - The sample rate of the decoded output. | |
25 // |channel_count| - The number of channels in the decoded output. | |
26 // |extra_data|, |extra_data_size| - Extra data buffer needed for initializing | |
27 // the decoder. | |
28 // |media_crypto| - Handle to a Java object that handles the encryption for | |
29 // the audio data. | |
30 // |request_data_cb| - Callback used to request more data for the decoder. | |
31 static AudioDecoderJob* Create( | |
32 const AudioCodec audio_codec, int sample_rate, int channel_count, | |
33 const uint8* extra_data, size_t extra_data_size, jobject media_crypto, | |
34 const base::Closure& request_data_cb); | |
35 | 29 |
30 // Set the volume of the audio output. | |
36 void SetVolume(double volume); | 31 void SetVolume(double volume); |
37 | 32 |
38 // Sets the base timestamp for |audio_timestamp_helper_|. | 33 // Sets the base timestamp for |audio_timestamp_helper_|. |
39 void SetBaseTimestamp(base::TimeDelta base_timestamp); | 34 void SetBaseTimestamp(base::TimeDelta base_timestamp); |
40 | 35 |
41 private: | 36 private: |
42 AudioDecoderJob(scoped_ptr<AudioTimestampHelper> audio_timestamp_helper, | |
43 scoped_ptr<AudioCodecBridge> audio_decoder_bridge, | |
44 int bytes_per_frame, | |
45 const base::Closure& request_data_cb); | |
46 | |
47 // MediaDecoderJob implementation. | 37 // MediaDecoderJob implementation. |
48 virtual void ReleaseOutputBuffer( | 38 virtual void ReleaseOutputBuffer( |
49 int output_buffer_index, | 39 int output_buffer_index, |
50 size_t size, | 40 size_t size, |
51 bool render_output, | 41 bool render_output, |
52 base::TimeDelta current_presentation_timestamp, | 42 base::TimeDelta current_presentation_timestamp, |
53 const ReleaseOutputCompletionCallback& callback) OVERRIDE; | 43 const ReleaseOutputCompletionCallback& callback) OVERRIDE; |
44 virtual bool ComputeTimeToRender() const OVERRIDE; | |
45 virtual bool IsDemuxerConfigChanged( | |
46 const DemuxerConfigs& configs) const OVERRIDE; | |
47 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE; | |
48 virtual bool CreateMediaCodecBridgeInternal() OVERRIDE; | |
54 | 49 |
55 virtual bool ComputeTimeToRender() const OVERRIDE; | 50 // Helper method to set the audio output volume. |
51 void SetVolumeInternal(); | |
56 | 52 |
57 // number of bytes per audio frame; | 53 // Audio configs from the demuxer. |
54 AudioCodec audio_codec_; | |
55 int num_channels_; | |
56 int sampling_rate_; | |
57 std::vector<uint8> audio_extra_data_; | |
wolenetz
2014/04/25 23:13:13
lint nit: Add #include for vector<>
qinmin
2014/04/26 01:30:11
Done.
| |
58 double volume_; | |
58 int bytes_per_frame_; | 59 int bytes_per_frame_; |
59 | 60 |
60 scoped_ptr<AudioCodecBridge> audio_codec_bridge_; | 61 // Base timestamp for the |audio_timestamp_helper_|. |
62 base::TimeDelta base_timestamp_; | |
61 | 63 |
62 // Object to calculate the current audio timestamp for A/V sync. | 64 // Object to calculate the current audio timestamp for A/V sync. |
63 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | 65 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob); | |
64 }; | 68 }; |
65 | 69 |
66 } // namespace media | 70 } // namespace media |
67 | 71 |
68 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | 72 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ |
OLD | NEW |