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

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

Issue 1367403003: Added UMA metrics for MediaSourcePlayer and MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-drm
Patch Set: Attempt to fix clang compilation Created 5 years, 2 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_DECODER_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "media/base/android/access_unit_queue.h" 17 #include "media/base/android/access_unit_queue.h"
18 #include "media/base/android/demuxer_stream_player_params.h" 18 #include "media/base/android/demuxer_stream_player_params.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 struct FrameStatistics;
22 class MediaCodecBridge; 23 class MediaCodecBridge;
23 24
24 // The decoder for MediaCodecPlayer. 25 // The decoder for MediaCodecPlayer.
25 // This class accepts the incoming data into AccessUnitQueue and works with 26 // This class accepts the incoming data into AccessUnitQueue and works with
26 // MediaCodecBridge for decoding and rendering the frames. The MediaCodecPlayer 27 // MediaCodecBridge for decoding and rendering the frames. The MediaCodecPlayer
27 // has two decoder objects: audio and video. 28 // has two decoder objects: audio and video.
28 // 29 //
29 // The decoder works on two threads. The data from demuxer comes on Media 30 // The decoder works on two threads. The data from demuxer comes on Media
30 // thread. The commands from MediaCodecPlayer, such as Prefetch, Start, 31 // thread. The commands from MediaCodecPlayer, such as Prefetch, Start,
31 // RequestToStop also come on the Media thread. The operations with MediaCodec 32 // RequestToStop also come on the Media thread. The operations with MediaCodec
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // has zero width. 131 // has zero width.
131 // The third parameter means "postpone", it is set to true if the actual 132 // The third parameter means "postpone", it is set to true if the actual
132 // rendering will start in a later point in time. This only happens with 133 // rendering will start in a later point in time. This only happens with
133 // audio after preroll. The MediaCodecPlayer might decide to update the 134 // audio after preroll. The MediaCodecPlayer might decide to update the
134 // current time but not pass it to the upper layer. 135 // current time but not pass it to the upper layer.
135 typedef base::Callback<void(base::TimeDelta, base::TimeDelta, bool)> 136 typedef base::Callback<void(base::TimeDelta, base::TimeDelta, bool)>
136 SetTimeCallback; 137 SetTimeCallback;
137 138
138 // MediaCodecDecoder constructor. 139 // MediaCodecDecoder constructor.
139 // Parameters: 140 // Parameters:
141 // decoder_thread_name:
142 // The thread name to be passed to decoder thread constructor.
140 // media_task_runner: 143 // media_task_runner:
141 // A task runner for the controlling thread. All public methods should be 144 // A task runner for the controlling thread. All public methods should be
142 // called on this thread, and callbacks are delivered on this thread. 145 // called on this thread, and callbacks are delivered on this thread.
143 // The MediaCodecPlayer uses a dedicated (Media) thread for this. 146 // The MediaCodecPlayer uses a dedicated (Media) thread for this.
147 // frame_statistics:
148 // A pointer to FrameStatistics object which gathers playback quality
149 // related data.
144 // external_request_data_cb: 150 // external_request_data_cb:
145 // Called periodically as the amount of internally stored data decreases. 151 // Called periodically as the amount of internally stored data decreases.
146 // The receiver should call OnDemuxerDataAvailable() with more data. 152 // The receiver should call OnDemuxerDataAvailable() with more data.
147 // starvation_cb: 153 // starvation_cb:
148 // Called when starvation is detected. The decoder state does not change. 154 // Called when starvation is detected. The decoder state does not change.
149 // The player is supposed to stop and then prefetch the decoder. 155 // The player is supposed to stop and then prefetch the decoder.
150 // decoder_drained_cb: 156 // decoder_drained_cb:
151 // Called when decoder is drained for reconfiguration. 157 // Called when decoder is drained for reconfiguration.
152 // stop_done_cb: 158 // stop_done_cb:
153 // Called when async stop request is completed. 159 // Called when async stop request is completed.
154 // waiting_for_decryption_key_cb: 160 // waiting_for_decryption_key_cb:
155 // Will be executed whenever the key needed to decrypt the stream is not 161 // Will be executed whenever the key needed to decrypt the stream is not
156 // available. 162 // available.
157 // error_cb: 163 // error_cb:
158 // Called when a MediaCodec error occurred. If this happens, a player has 164 // Called when a MediaCodec error occurred. If this happens, a player has
159 // to either call ReleaseDecoderResources() or destroy the decoder object. 165 // to either call ReleaseDecoderResources() or destroy the decoder object.
160 // decoder_thread_name:
161 // The thread name to be passed to decoder thread constructor.
162 MediaCodecDecoder( 166 MediaCodecDecoder(
167 const char* decoder_thread_name,
163 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 168 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
169 FrameStatistics* frame_statistics,
164 const base::Closure& external_request_data_cb, 170 const base::Closure& external_request_data_cb,
165 const base::Closure& starvation_cb, 171 const base::Closure& starvation_cb,
166 const base::Closure& decoder_drained_cb, 172 const base::Closure& decoder_drained_cb,
167 const base::Closure& stop_done_cb, 173 const base::Closure& stop_done_cb,
168 const base::Closure& waiting_for_decryption_key_cb, 174 const base::Closure& waiting_for_decryption_key_cb,
169 const base::Closure& error_cb, 175 const base::Closure& error_cb);
170 const char* decoder_thread_name); 176
171 virtual ~MediaCodecDecoder(); 177 virtual ~MediaCodecDecoder();
172 178
173 virtual const char* class_name() const; 179 virtual const char* class_name() const;
174 180
175 // MediaCodecDecoder exists through the whole lifetime of the player 181 // MediaCodecDecoder exists through the whole lifetime of the player
176 // to support dynamic addition and removal of the streams. 182 // to support dynamic addition and removal of the streams.
177 // This method returns true if the current stream (audio or video) 183 // This method returns true if the current stream (audio or video)
178 // is currently active. 184 // is currently active.
179 virtual bool HasStream() const = 0; 185 virtual bool HasStream() const = 0;
180 186
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Returns true if we are in the process of sync stop. 309 // Returns true if we are in the process of sync stop.
304 bool InEmergencyStop() const { return GetState() == kInEmergencyStop; } 310 bool InEmergencyStop() const { return GetState() == kInEmergencyStop; }
305 311
306 // Notifies the decoder if the frame is the last one. 312 // Notifies the decoder if the frame is the last one.
307 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); 313 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks);
308 314
309 const char* AsString(RenderMode render_mode); 315 const char* AsString(RenderMode render_mode);
310 316
311 // Protected data. 317 // Protected data.
312 318
319 // We call MediaCodecBridge on this thread for both input and output buffers.
320 base::Thread decoder_thread_;
321
313 // Object for posting tasks on Media thread. 322 // Object for posting tasks on Media thread.
314 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 323 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
315 324
325 // Statistics for UMA.
326 FrameStatistics* frame_statistics_;
327
316 // Controls Android MediaCodec 328 // Controls Android MediaCodec
317 scoped_ptr<MediaCodecBridge> media_codec_bridge_; 329 scoped_ptr<MediaCodecBridge> media_codec_bridge_;
318 330
319 // We call MediaCodecBridge on this thread for both
320 // input and output buffers.
321 base::Thread decoder_thread_;
322
323 // The queue of access units. 331 // The queue of access units.
324 AccessUnitQueue au_queue_; 332 AccessUnitQueue au_queue_;
325 333
326 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently 334 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently
327 // is set by video decoder when the video surface changes. 335 // is set by video decoder when the video surface changes.
328 bool needs_reconfigure_; 336 bool needs_reconfigure_;
329 337
330 // Flag forces to drain decoder in the process of dynamic reconfiguration. 338 // Flag forces to drain decoder in the process of dynamic reconfiguration.
331 bool drain_decoder_; 339 bool drain_decoder_;
332 340
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 453
446 // NOTE: Weak pointers must be invalidated before all other member variables. 454 // NOTE: Weak pointers must be invalidated before all other member variables.
447 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; 455 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_;
448 456
449 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); 457 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder);
450 }; 458 };
451 459
452 } // namespace media 460 } // namespace media
453 461
454 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 462 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/android/media_codec_audio_decoder.cc ('k') | media/base/android/media_codec_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698