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

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: 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 class 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // decoder_thread_name: 159 // decoder_thread_name:
159 // The thread name to be passed to decoder thread constructor. 160 // The thread name to be passed to decoder thread constructor.
160 MediaCodecDecoder( 161 MediaCodecDecoder(
161 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 162 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
162 const base::Closure& external_request_data_cb, 163 const base::Closure& external_request_data_cb,
163 const base::Closure& starvation_cb, 164 const base::Closure& starvation_cb,
164 const base::Closure& decoder_drained_cb, 165 const base::Closure& decoder_drained_cb,
165 const base::Closure& stop_done_cb, 166 const base::Closure& stop_done_cb,
166 const base::Closure& key_required_cb, 167 const base::Closure& key_required_cb,
167 const base::Closure& error_cb, 168 const base::Closure& error_cb,
168 const char* decoder_thread_name); 169 const char* decoder_thread_name,
170 FrameStatistics* frame_statistics);
171
169 virtual ~MediaCodecDecoder(); 172 virtual ~MediaCodecDecoder();
170 173
171 virtual const char* class_name() const; 174 virtual const char* class_name() const;
172 175
173 // MediaCodecDecoder exists through the whole lifetime of the player 176 // MediaCodecDecoder exists through the whole lifetime of the player
174 // to support dynamic addition and removal of the streams. 177 // to support dynamic addition and removal of the streams.
175 // This method returns true if the current stream (audio or video) 178 // This method returns true if the current stream (audio or video)
176 // is currently active. 179 // is currently active.
177 virtual bool HasStream() const = 0; 180 virtual bool HasStream() const = 0;
178 181
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 #endif 297 #endif
295 298
296 // Helper methods. 299 // Helper methods.
297 300
298 // Synchroniously stop decoder thread. 301 // Synchroniously stop decoder thread.
299 void DoEmergencyStop(); 302 void DoEmergencyStop();
300 303
301 // Returns true if we are in the process of sync stop. 304 // Returns true if we are in the process of sync stop.
302 bool InEmergencyStop() const { return GetState() == kInEmergencyStop; } 305 bool InEmergencyStop() const { return GetState() == kInEmergencyStop; }
303 306
304 // Notifies the decoder if the frame is the last one. 307 // Notifies the decoder if the frame is the last one. Returns true if the
305 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); 308 // current frame is the last frame.
309 bool CheckLastFrame(bool eos_encountered, bool has_delayed_tasks);
306 310
307 const char* AsString(RenderMode render_mode); 311 const char* AsString(RenderMode render_mode);
308 312
309 // Protected data. 313 // Protected data.
310 314
311 // Object for posting tasks on Media thread. 315 // Object for posting tasks on Media thread.
312 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 316 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
313 317
314 // Controls Android MediaCodec 318 // Controls Android MediaCodec
315 scoped_ptr<MediaCodecBridge> media_codec_bridge_; 319 scoped_ptr<MediaCodecBridge> media_codec_bridge_;
316 320
317 // We call MediaCodecBridge on this thread for both 321 // We call MediaCodecBridge on this thread for both
318 // input and output buffers. 322 // input and output buffers.
319 base::Thread decoder_thread_; 323 base::Thread decoder_thread_;
320 324
321 // The queue of access units. 325 // The queue of access units.
322 AccessUnitQueue au_queue_; 326 AccessUnitQueue au_queue_;
323 327
328 // Statistics for UMA.
329 FrameStatistics* frame_statistics_;
330
324 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently 331 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently
325 // is set by video decoder when the video surface changes. 332 // is set by video decoder when the video surface changes.
326 bool needs_reconfigure_; 333 bool needs_reconfigure_;
327 334
328 // Flag forces to drain decoder in the process of dynamic reconfiguration. 335 // Flag forces to drain decoder in the process of dynamic reconfiguration.
329 bool drain_decoder_; 336 bool drain_decoder_;
330 337
331 // For tests only. Forces to always reconfigure for |kConfigChanged| unit. 338 // For tests only. Forces to always reconfigure for |kConfigChanged| unit.
332 bool always_reconfigure_for_tests_; 339 bool always_reconfigure_for_tests_;
333 340
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 450
444 // NOTE: Weak pointers must be invalidated before all other member variables. 451 // NOTE: Weak pointers must be invalidated before all other member variables.
445 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; 452 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_;
446 453
447 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); 454 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder);
448 }; 455 };
449 456
450 } // namespace media 457 } // namespace media
451 458
452 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 459 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698