Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: media/base/android/audio_decoder_job.h

Issue 254473010: Refactor MSE implementation on Android to simplify the logic and improve the performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments on unit tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 10
11 #include "base/callback.h"
10 #include "media/base/android/media_decoder_job.h" 12 #include "media/base/android/media_decoder_job.h"
11 13
12 namespace media { 14 namespace media {
13 15
14 class AudioCodecBridge; 16 class AudioCodecBridge;
15 class AudioTimestampHelper; 17 class AudioTimestampHelper;
16 18
17 // Class for managing audio decoding jobs. 19 // Class for managing audio decoding jobs.
18 class AudioDecoderJob : public MediaDecoderJob { 20 class AudioDecoderJob : public MediaDecoderJob {
19 public: 21 public:
22 // Creates a new AudioDecoderJob instance for decoding audio.
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
25 // demuxer config has changed.
26 AudioDecoderJob(const base::Closure& request_data_cb,
27 const base::Closure& on_demuxer_config_changed_cb);
20 virtual ~AudioDecoderJob(); 28 virtual ~AudioDecoderJob();
21 29
22 // Creates a new AudioDecoderJob instance for decoding audio. 30 // MediaDecoderJob implementation.
23 // |audio_codec| - The audio format the object needs to decode. 31 virtual bool HasStream() const OVERRIDE;
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 32
33 // Sets the volume of the audio output.
36 void SetVolume(double volume); 34 void SetVolume(double volume);
37 35
38 // Sets the base timestamp for |audio_timestamp_helper_|. 36 // Sets the base timestamp for |audio_timestamp_helper_|.
39 void SetBaseTimestamp(base::TimeDelta base_timestamp); 37 void SetBaseTimestamp(base::TimeDelta base_timestamp);
40 38
41 private: 39 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. 40 // MediaDecoderJob implementation.
48 virtual void ReleaseOutputBuffer( 41 virtual void ReleaseOutputBuffer(
49 int output_buffer_index, 42 int output_buffer_index,
50 size_t size, 43 size_t size,
51 bool render_output, 44 bool render_output,
52 base::TimeDelta current_presentation_timestamp, 45 base::TimeDelta current_presentation_timestamp,
53 const ReleaseOutputCompletionCallback& callback) OVERRIDE; 46 const ReleaseOutputCompletionCallback& callback) OVERRIDE;
47 virtual bool ComputeTimeToRender() const OVERRIDE;
48 virtual bool AreDemuxerConfigsChanged(
49 const DemuxerConfigs& configs) const OVERRIDE;
50 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE;
51 virtual bool CreateMediaCodecBridgeInternal() OVERRIDE;
54 52
55 virtual bool ComputeTimeToRender() const OVERRIDE; 53 // Helper method to set the audio output volume.
54 void SetVolumeInternal();
56 55
57 // number of bytes per audio frame; 56 // Audio configs from the demuxer.
57 AudioCodec audio_codec_;
58 int num_channels_;
59 int sampling_rate_;
60 std::vector<uint8> audio_extra_data_;
61 double volume_;
58 int bytes_per_frame_; 62 int bytes_per_frame_;
59 63
60 scoped_ptr<AudioCodecBridge> audio_codec_bridge_; 64 // Base timestamp for the |audio_timestamp_helper_|.
65 base::TimeDelta base_timestamp_;
61 66
62 // Object to calculate the current audio timestamp for A/V sync. 67 // Object to calculate the current audio timestamp for A/V sync.
63 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; 68 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
69
70 DISALLOW_COPY_AND_ASSIGN(AudioDecoderJob);
64 }; 71 };
65 72
66 } // namespace media 73 } // namespace media
67 74
68 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_ 75 #endif // MEDIA_BASE_ANDROID_AUDIO_DECODER_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/android/audio_decoder_job.cc » ('j') | media/base/android/media_source_player.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698