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

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

Issue 1254293003: MediaCodecPlayer implementation (stage 4 - preroll) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-browserseek
Patch Set: Save the first post-preroll audio buffer and replay it when preroll is done Created 5 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_MEDIA_CODEC_AUDIO_DECODER_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_AUDIO_DECODER_H_
7 7
8 #include <vector>
8 #include "media/base/android/media_codec_decoder.h" 9 #include "media/base/android/media_codec_decoder.h"
9 10
10 namespace media { 11 namespace media {
11 12
12 class AudioTimestampHelper; 13 class AudioTimestampHelper;
13 14
14 // Audio decoder for MediaCodecPlayer 15 // Audio decoder for MediaCodecPlayer
15 class MediaCodecAudioDecoder : public MediaCodecDecoder { 16 class MediaCodecAudioDecoder : public MediaCodecDecoder {
16 public: 17 public:
17 // For parameters see media_codec_decoder.h 18 // For parameters see media_codec_decoder.h
18 // update_current_time_cb: callback that reports current playback time. 19 // update_current_time_cb: callback that reports current playback time.
19 // Called for each rendered frame. 20 // Called for each rendered frame.
20 MediaCodecAudioDecoder( 21 MediaCodecAudioDecoder(
21 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner, 22 const scoped_refptr<base::SingleThreadTaskRunner>& media_runner,
22 const base::Closure& request_data_cb, 23 const base::Closure& request_data_cb,
23 const base::Closure& starvation_cb, 24 const base::Closure& starvation_cb,
25 const base::Closure& preroll_done_cb,
24 const base::Closure& stop_done_cb, 26 const base::Closure& stop_done_cb,
25 const base::Closure& error_cb, 27 const base::Closure& error_cb,
26 const SetTimeCallback& update_current_time_cb); 28 const SetTimeCallback& update_current_time_cb);
27 ~MediaCodecAudioDecoder() override; 29 ~MediaCodecAudioDecoder() override;
28 30
29 const char* class_name() const override; 31 const char* class_name() const override;
30 32
31 bool HasStream() const override; 33 bool HasStream() const override;
32 void SetDemuxerConfigs(const DemuxerConfigs& configs) override; 34 void SetDemuxerConfigs(const DemuxerConfigs& configs) override;
33 void Flush() override; 35 void Flush() override;
36 void ReleaseMediaCodec() override;
34 37
35 // Sets the volume of the audio output. 38 // Sets the volume of the audio output.
36 void SetVolume(double volume); 39 void SetVolume(double volume);
37 40
38 // Sets the base timestamp for |audio_timestamp_helper_|. 41 // Sets the base timestamp for |audio_timestamp_helper_|.
39 void SetBaseTimestamp(base::TimeDelta base_timestamp); 42 void SetBaseTimestamp(base::TimeDelta base_timestamp);
40 43
41 protected: 44 protected:
42 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, 45 bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr,
43 const DemuxerConfigs& next) const override; 46 const DemuxerConfigs& next) const override;
44 ConfigStatus ConfigureInternal() override; 47 ConfigStatus ConfigureInternal() override;
45 void OnOutputFormatChanged() override; 48 void OnOutputFormatChanged() override;
46 void Render(int buffer_index, 49 void Render(int buffer_index,
47 size_t size, 50 size_t size,
48 bool render_output, 51 RenderMode render_mode,
49 base::TimeDelta pts, 52 base::TimeDelta pts,
50 bool eos_encountered) override; 53 bool eos_encountered) override;
51 54
52 private: 55 private:
56 struct PendingBuffer {
57 std::vector<uint8> data;
58 base::TimeDelta pts;
59 bool IsValid() const { return !data.empty(); }
60 void Invalidate() { data.clear(); }
61 };
62
63 void CreatePendingBuffer(int buffer_index, size_t size, base::TimeDelta pts);
64
65 void PlayOutputBuffer(int buffer_index, size_t size, base::TimeDelta pts);
66
53 // A helper method to set the volume. 67 // A helper method to set the volume.
54 void SetVolumeInternal(); 68 void SetVolumeInternal();
55 69
56 // Recreates |audio_timestamp_helper_|, called when sampling rate is changed. 70 // Recreates |audio_timestamp_helper_|, called when sampling rate is changed.
57 void ResetTimestampHelper(); 71 void ResetTimestampHelper();
58 72
59 // Data. 73 // Data.
60 74
61 // Configuration received from demuxer 75 // Configuration received from demuxer
62 DemuxerConfigs configs_; 76 DemuxerConfigs configs_;
(...skipping 10 matching lines...) Expand all
73 87
74 // Frame count to sync with audio codec output. 88 // Frame count to sync with audio codec output.
75 int64 frame_count_; 89 int64 frame_count_;
76 90
77 // Base timestamp for the |audio_timestamp_helper_|. 91 // Base timestamp for the |audio_timestamp_helper_|.
78 base::TimeDelta base_timestamp_; 92 base::TimeDelta base_timestamp_;
79 93
80 // Object to calculate the current audio timestamp for A/V sync. 94 // Object to calculate the current audio timestamp for A/V sync.
81 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; 95 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
82 96
97 // Output buffer that we want to play at a later time, normally after video
98 // preroll.
99 PendingBuffer pending_buffer_;
100
83 // Reports current playback time to the callee. 101 // Reports current playback time to the callee.
84 SetTimeCallback update_current_time_cb_; 102 SetTimeCallback update_current_time_cb_;
85 103
86 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder); 104 DISALLOW_COPY_AND_ASSIGN(MediaCodecAudioDecoder);
87 }; 105 };
88 106
89 } // namespace media 107 } // namespace media
90 108
91 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 109 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/android/media_codec_audio_decoder.cc » ('j') | media/base/android/media_codec_audio_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698