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

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

Issue 1176993005: Audio and video decoders for MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for video decoder, video decoder now reports current time. Created 5 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
OLDNEW
(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 // Audio decoder for MediaCodecPlayer
15 class MediaCodecAudioDecoder : public MediaCodecDecoder {
16 public:
17 MediaCodecAudioDecoder(
18 const scoped_refptr<base::SingleThreadTaskRunner>& media_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 SetDemuxerConfigs(const DemuxerConfigs& configs) override;
30 void Flush() override;
31
32 // Sets the volume of the audio output.
33 void SetVolume(double volume);
34
35 // Sets the base timestamp for |audio_timestamp_helper_|.
36 void SetBaseTimestamp(base::TimeDelta base_timestamp);
37
38 protected:
39 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr,
40 const DemuxerConfigs& next) const override;
41 ConfigStatus ConfigureInternal() override;
42 void OnOutputFormatChanged() override;
43 void Render(int buffer_index,
44 size_t size,
45 bool render_output,
46 base::TimeDelta pts,
47 bool eos_encountered) override;
48
49 private:
50 // A helper method to set the volume.
51 void SetVolumeInternal();
52
53 // Recreates |audio_timestamp_helper_|, called when sampling rate is changed.
54 void ResetTimestampHelper();
55
56 // Data.
57
58 // Configuration received from demuxer
59 DemuxerConfigs configs_;
60
61 // Requested volume
62 double volume_;
63
64 // Number of bytes per audio frame. Depends on the output format
65 // and the number of channels.
66 int bytes_per_frame_;
67
68 // The sampling rate received from decoder.
69 int output_sampling_rate_;
70
71 // Frame count to sync with audio codec output.
72 int64 frame_count_;
73
74 // Base timestamp for the |audio_timestamp_helper_|.
75 base::TimeDelta base_timestamp_;
76
77 // Object to calculate the current audio timestamp for A/V sync.
78 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
79
80 // Reports current playback time to the callee.
81 SetTimeCallback update_current_time_cb_;
82
83 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder);
84 };
85
86 } // namespace media
87
88 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698