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

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

Issue 1442933002: media: Pass SetCdmReadyCB in {Audio|Video}Decoder::Initialize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errors Created 5 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
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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "media/base/bind_to_current_loop.h" 13 #include "media/base/bind_to_current_loop.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/media_log.h" 15 #include "media/base/media_log.h"
16 #include "media/base/pipeline.h" 16 #include "media/base/pipeline.h"
17 #include "media/base/video_frame.h" 17 #include "media/base/video_frame.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 const char DecryptingVideoDecoder::kDecoderName[] = "DecryptingVideoDecoder"; 21 const char DecryptingVideoDecoder::kDecoderName[] = "DecryptingVideoDecoder";
22 22
23 DecryptingVideoDecoder::DecryptingVideoDecoder( 23 DecryptingVideoDecoder::DecryptingVideoDecoder(
24 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 24 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
25 const scoped_refptr<MediaLog>& media_log, 25 const scoped_refptr<MediaLog>& media_log,
26 const SetCdmReadyCB& set_cdm_ready_cb,
27 const base::Closure& waiting_for_decryption_key_cb) 26 const base::Closure& waiting_for_decryption_key_cb)
28 : task_runner_(task_runner), 27 : task_runner_(task_runner),
29 media_log_(media_log), 28 media_log_(media_log),
30 state_(kUninitialized), 29 state_(kUninitialized),
31 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), 30 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb),
32 set_cdm_ready_cb_(set_cdm_ready_cb),
33 decryptor_(NULL), 31 decryptor_(NULL),
34 key_added_while_decode_pending_(false), 32 key_added_while_decode_pending_(false),
35 trace_id_(0), 33 trace_id_(0),
36 weak_factory_(this) {} 34 weak_factory_(this) {}
37 35
38 std::string DecryptingVideoDecoder::GetDisplayName() const { 36 std::string DecryptingVideoDecoder::GetDisplayName() const {
39 return kDecoderName; 37 return kDecoderName;
40 } 38 }
41 39
42 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, 40 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
43 bool /* low_delay */, 41 bool /* low_delay */,
42 const SetCdmReadyCB& set_cdm_ready_cb,
44 const InitCB& init_cb, 43 const InitCB& init_cb,
45 const OutputCB& output_cb) { 44 const OutputCB& output_cb) {
46 DVLOG(2) << "Initialize()"; 45 DVLOG(2) << "Initialize()";
47 DCHECK(task_runner_->BelongsToCurrentThread()); 46 DCHECK(task_runner_->BelongsToCurrentThread());
48 DCHECK(state_ == kUninitialized || 47 DCHECK(state_ == kUninitialized ||
49 state_ == kIdle || 48 state_ == kIdle ||
50 state_ == kDecodeFinished) << state_; 49 state_ == kDecodeFinished) << state_;
51 DCHECK(decode_cb_.is_null()); 50 DCHECK(decode_cb_.is_null());
52 DCHECK(reset_cb_.is_null()); 51 DCHECK(reset_cb_.is_null());
53 DCHECK(config.IsValidConfig()); 52 DCHECK(config.IsValidConfig());
54 DCHECK(config.is_encrypted()); 53 DCHECK(config.is_encrypted());
55 54
56 init_cb_ = BindToCurrentLoop(init_cb); 55 init_cb_ = BindToCurrentLoop(init_cb);
57 output_cb_ = BindToCurrentLoop(output_cb); 56 output_cb_ = BindToCurrentLoop(output_cb);
58 weak_this_ = weak_factory_.GetWeakPtr(); 57 weak_this_ = weak_factory_.GetWeakPtr();
59 config_ = config; 58 config_ = config;
60 59
61 if (state_ == kUninitialized) { 60 if (state_ == kUninitialized) {
61 DCHECK(!set_cdm_ready_cb.is_null());
62 state_ = kDecryptorRequested; 62 state_ = kDecryptorRequested;
63 set_cdm_ready_cb_ = set_cdm_ready_cb;
63 set_cdm_ready_cb_.Run(BindToCurrentLoop( 64 set_cdm_ready_cb_.Run(BindToCurrentLoop(
64 base::Bind(&DecryptingVideoDecoder::SetCdm, weak_this_))); 65 base::Bind(&DecryptingVideoDecoder::SetCdm, weak_this_)));
65 return; 66 return;
66 } 67 }
67 68
68 // Reinitialization. 69 // Reinitialization.
69 decryptor_->DeinitializeDecoder(Decryptor::kVideo); 70 decryptor_->DeinitializeDecoder(Decryptor::kVideo);
70 state_ = kPendingDecoderInit; 71 state_ = kPendingDecoderInit;
71 decryptor_->InitializeVideoDecoder(config, BindToCurrentLoop(base::Bind( 72 decryptor_->InitializeVideoDecoder(config, BindToCurrentLoop(base::Bind(
72 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); 73 &DecryptingVideoDecoder::FinishInitialization, weak_this_)));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 324 }
324 325
325 void DecryptingVideoDecoder::DoReset() { 326 void DecryptingVideoDecoder::DoReset() {
326 DCHECK(init_cb_.is_null()); 327 DCHECK(init_cb_.is_null());
327 DCHECK(decode_cb_.is_null()); 328 DCHECK(decode_cb_.is_null());
328 state_ = kIdle; 329 state_ = kIdle;
329 base::ResetAndReturn(&reset_cb_).Run(); 330 base::ResetAndReturn(&reset_cb_).Run();
330 } 331 }
331 332
332 } // namespace media 333 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decrypting_video_decoder.h ('k') | media/filters/decrypting_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698