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

Side by Side Diff: media/filters/decrypting_video_decoder.cc

Issue 11360042: Encrypted Media: Add TRACE_EVENT to trace eme implementation performance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use uint32 for the trace_id_ Created 8 years, 1 month 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
« no previous file with comments | « media/filters/decrypting_video_decoder.h ('k') | webkit/media/crypto/ppapi/clear_key_cdm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "media/filters/decrypting_video_decoder.h" 5 #include "media/filters/decrypting_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h"
9 #include "base/location.h" 10 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
11 #include "media/base/bind_to_loop.h" 12 #include "media/base/bind_to_loop.h"
12 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
13 #include "media/base/decryptor.h" 14 #include "media/base/decryptor.h"
14 #include "media/base/demuxer_stream.h" 15 #include "media/base/demuxer_stream.h"
15 #include "media/base/pipeline.h" 16 #include "media/base/pipeline.h"
16 #include "media/base/video_decoder_config.h" 17 #include "media/base/video_decoder_config.h"
17 #include "media/base/video_frame.h" 18 #include "media/base/video_frame.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 #define BIND_TO_LOOP(function) \ 22 #define BIND_TO_LOOP(function) \
22 media::BindToLoop(message_loop_, base::Bind(function, this)) 23 media::BindToLoop(message_loop_, base::Bind(function, this))
23 24
24 DecryptingVideoDecoder::DecryptingVideoDecoder( 25 DecryptingVideoDecoder::DecryptingVideoDecoder(
25 const MessageLoopFactoryCB& message_loop_factory_cb, 26 const MessageLoopFactoryCB& message_loop_factory_cb,
26 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) 27 const RequestDecryptorNotificationCB& request_decryptor_notification_cb)
27 : message_loop_factory_cb_(message_loop_factory_cb), 28 : message_loop_factory_cb_(message_loop_factory_cb),
28 state_(kUninitialized), 29 state_(kUninitialized),
29 request_decryptor_notification_cb_(request_decryptor_notification_cb), 30 request_decryptor_notification_cb_(request_decryptor_notification_cb),
30 decryptor_(NULL), 31 decryptor_(NULL),
31 key_added_while_pending_decode_(false) { 32 key_added_while_pending_decode_(false),
33 trace_id_(0) {
32 } 34 }
33 35
34 void DecryptingVideoDecoder::Initialize( 36 void DecryptingVideoDecoder::Initialize(
35 const scoped_refptr<DemuxerStream>& stream, 37 const scoped_refptr<DemuxerStream>& stream,
36 const PipelineStatusCB& status_cb, 38 const PipelineStatusCB& status_cb,
37 const StatisticsCB& statistics_cb) { 39 const StatisticsCB& statistics_cb) {
38 DCHECK(!message_loop_); 40 DCHECK(!message_loop_);
39 message_loop_ = base::ResetAndReturn(&message_loop_factory_cb_).Run(); 41 message_loop_ = base::ResetAndReturn(&message_loop_factory_cb_).Run();
40 message_loop_->PostTask(FROM_HERE, base::Bind( 42 message_loop_->PostTask(FROM_HERE, base::Bind(
41 &DecryptingVideoDecoder::DoInitialize, this, 43 &DecryptingVideoDecoder::DoInitialize, this,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 285
284 DCHECK_EQ(status, DemuxerStream::kOk); 286 DCHECK_EQ(status, DemuxerStream::kOk);
285 pending_buffer_to_decode_ = buffer; 287 pending_buffer_to_decode_ = buffer;
286 state_ = kPendingDecode; 288 state_ = kPendingDecode;
287 DecodePendingBuffer(); 289 DecodePendingBuffer();
288 } 290 }
289 291
290 void DecryptingVideoDecoder::DecodePendingBuffer() { 292 void DecryptingVideoDecoder::DecodePendingBuffer() {
291 DCHECK(message_loop_->BelongsToCurrentThread()); 293 DCHECK(message_loop_->BelongsToCurrentThread());
292 DCHECK_EQ(state_, kPendingDecode) << state_; 294 DCHECK_EQ(state_, kPendingDecode) << state_;
295 TRACE_EVENT_ASYNC_BEGIN0(
296 "eme", "DecryptingVideoDecoder::DecodePendingBuffer", ++trace_id_);
293 decryptor_->DecryptAndDecodeVideo( 297 decryptor_->DecryptAndDecodeVideo(
294 pending_buffer_to_decode_, 298 pending_buffer_to_decode_,
295 base::Bind(&DecryptingVideoDecoder::DeliverFrame, this, 299 base::Bind(&DecryptingVideoDecoder::DeliverFrame, this,
296 pending_buffer_to_decode_->GetDataSize())); 300 pending_buffer_to_decode_->GetDataSize()));
297 } 301 }
298 302
299 void DecryptingVideoDecoder::DeliverFrame( 303 void DecryptingVideoDecoder::DeliverFrame(
300 int buffer_size, 304 int buffer_size,
301 Decryptor::Status status, 305 Decryptor::Status status,
302 const scoped_refptr<VideoFrame>& frame) { 306 const scoped_refptr<VideoFrame>& frame) {
303 // We need to force task post here because the VideoDecodeCB can be executed 307 // We need to force task post here because the VideoDecodeCB can be executed
304 // synchronously in Reset()/Stop(). Instead of using more complicated logic in 308 // synchronously in Reset()/Stop(). Instead of using more complicated logic in
305 // those function to fix it, why not force task post here to make everything 309 // those function to fix it, why not force task post here to make everything
306 // simple and clear? 310 // simple and clear?
307 message_loop_->PostTask(FROM_HERE, base::Bind( 311 message_loop_->PostTask(FROM_HERE, base::Bind(
308 &DecryptingVideoDecoder::DoDeliverFrame, this, 312 &DecryptingVideoDecoder::DoDeliverFrame, this,
309 buffer_size, status, frame)); 313 buffer_size, status, frame));
310 } 314 }
311 315
312 void DecryptingVideoDecoder::DoDeliverFrame( 316 void DecryptingVideoDecoder::DoDeliverFrame(
313 int buffer_size, 317 int buffer_size,
314 Decryptor::Status status, 318 Decryptor::Status status,
315 const scoped_refptr<VideoFrame>& frame) { 319 const scoped_refptr<VideoFrame>& frame) {
316 DVLOG(3) << "DoDeliverFrame() - status: " << status; 320 DVLOG(3) << "DoDeliverFrame() - status: " << status;
317 DCHECK(message_loop_->BelongsToCurrentThread()); 321 DCHECK(message_loop_->BelongsToCurrentThread());
322 TRACE_EVENT_ASYNC_END0(
323 "eme", "DecryptingVideoDecoder::DecodePendingBuffer", trace_id_);
318 324
319 if (state_ == kStopped) 325 if (state_ == kStopped)
320 return; 326 return;
321 327
322 DCHECK_EQ(state_, kPendingDecode) << state_; 328 DCHECK_EQ(state_, kPendingDecode) << state_;
323 DCHECK(!read_cb_.is_null()); 329 DCHECK(!read_cb_.is_null());
324 DCHECK(pending_buffer_to_decode_); 330 DCHECK(pending_buffer_to_decode_);
325 331
326 bool need_to_try_again_if_nokey_is_returned = key_added_while_pending_decode_; 332 bool need_to_try_again_if_nokey_is_returned = key_added_while_pending_decode_;
327 key_added_while_pending_decode_ = false; 333 key_added_while_pending_decode_ = false;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 411 }
406 412
407 void DecryptingVideoDecoder::DoReset() { 413 void DecryptingVideoDecoder::DoReset() {
408 DCHECK(init_cb_.is_null()); 414 DCHECK(init_cb_.is_null());
409 DCHECK(read_cb_.is_null()); 415 DCHECK(read_cb_.is_null());
410 state_ = kIdle; 416 state_ = kIdle;
411 base::ResetAndReturn(&reset_cb_).Run(); 417 base::ResetAndReturn(&reset_cb_).Run();
412 } 418 }
413 419
414 } // namespace media 420 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decrypting_video_decoder.h ('k') | webkit/media/crypto/ppapi/clear_key_cdm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698