OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | |
6 #define MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <stddef.h> | |
10 #include <stdint.h> | |
11 #include <memory> | |
12 #include <vector> | |
13 | |
14 #include "base/callback.h" | |
15 #include "base/macros.h" | |
16 #include "media/base/android/media_decoder_job.h" | |
17 | |
18 namespace media { | |
19 | |
20 class AudioCodecBridge; | |
21 class AudioTimestampHelper; | |
22 | |
23 // Class for managing audio decoding jobs. | |
24 class AudioDecoderJob : public MediaDecoderJob { | |
25 public: | |
26 // Creates a new AudioDecoderJob instance for decoding audio. | |
27 // |request_data_cb| - Callback used to request more data for the decoder. | |
28 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that | |
29 // demuxer config has changed. | |
30 AudioDecoderJob(const base::Closure& request_data_cb, | |
31 const base::Closure& on_demuxer_config_changed_cb); | |
32 ~AudioDecoderJob() override; | |
33 | |
34 // MediaDecoderJob implementation. | |
35 bool HasStream() const override; | |
36 void Flush() override; | |
37 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; | |
38 | |
39 // Sets the volume of the audio output. | |
40 void SetVolume(double volume); | |
41 | |
42 // Sets the base timestamp for |audio_timestamp_helper_|. | |
43 void SetBaseTimestamp(base::TimeDelta base_timestamp); | |
44 | |
45 private: | |
46 // MediaDecoderJob implementation. | |
47 void ReleaseOutputBuffer(int output_buffer_index, | |
48 size_t offset, | |
49 size_t size, | |
50 bool render_output, | |
51 bool is_late_frame, | |
52 base::TimeDelta current_presentation_timestamp, | |
53 MediaCodecStatus status, | |
54 const DecoderCallback& callback) override; | |
55 bool ComputeTimeToRender() const override; | |
56 bool AreDemuxerConfigsChanged(const DemuxerConfigs& configs) const override; | |
57 MediaDecoderJobStatus CreateMediaCodecBridgeInternal() override; | |
58 bool OnOutputFormatChanged() override; | |
59 | |
60 // Helper method to set the audio output volume. | |
61 void SetVolumeInternal(); | |
62 | |
63 void ResetTimestampHelper(); | |
64 | |
65 // Audio configs from the demuxer. | |
66 AudioCodec audio_codec_; | |
67 int config_num_channels_; | |
68 int config_sampling_rate_; | |
69 std::vector<uint8_t> audio_extra_data_; | |
70 int64_t audio_codec_delay_ns_; | |
71 int64_t audio_seek_preroll_ns_; | |
72 double volume_; | |
73 | |
74 // Audio output sample rate. | |
75 int output_sampling_rate_; | |
76 | |
77 // Number of output audio channels. | |
78 int output_num_channels_; | |
79 | |
80 // Frame count to sync with audio codec output. | |
81 int64_t frame_count_; | |
82 | |
83 // Base timestamp for the |audio_timestamp_helper_|. | |
84 base::TimeDelta base_timestamp_; | |
85 | |
86 // Object to calculate the current audio timestamp for A/V sync. | |
87 std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_; | |
88 | |
89 // The time limit for the next frame to avoid underrun. | |
90 base::TimeTicks next_frame_time_limit_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob); | |
93 }; | |
94 | |
95 } // namespace media | |
96 | |
97 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ | |
OLD | NEW |