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

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

Issue 1446713003: Revert of media: Pass SetCdmReadyCB in {Audio|Video}Decoder::Initialize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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,
26 const base::Closure& waiting_for_decryption_key_cb) 27 const base::Closure& waiting_for_decryption_key_cb)
27 : task_runner_(task_runner), 28 : task_runner_(task_runner),
28 media_log_(media_log), 29 media_log_(media_log),
29 state_(kUninitialized), 30 state_(kUninitialized),
30 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), 31 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb),
32 set_cdm_ready_cb_(set_cdm_ready_cb),
31 decryptor_(NULL), 33 decryptor_(NULL),
32 key_added_while_decode_pending_(false), 34 key_added_while_decode_pending_(false),
33 trace_id_(0), 35 trace_id_(0),
34 weak_factory_(this) {} 36 weak_factory_(this) {}
35 37
36 std::string DecryptingVideoDecoder::GetDisplayName() const { 38 std::string DecryptingVideoDecoder::GetDisplayName() const {
37 return kDecoderName; 39 return kDecoderName;
38 } 40 }
39 41
40 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, 42 void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
41 bool /* low_delay */, 43 bool /* low_delay */,
42 const SetCdmReadyCB& set_cdm_ready_cb,
43 const InitCB& init_cb, 44 const InitCB& init_cb,
44 const OutputCB& output_cb) { 45 const OutputCB& output_cb) {
45 DVLOG(2) << "Initialize()"; 46 DVLOG(2) << "Initialize()";
46 DCHECK(task_runner_->BelongsToCurrentThread()); 47 DCHECK(task_runner_->BelongsToCurrentThread());
47 DCHECK(state_ == kUninitialized || 48 DCHECK(state_ == kUninitialized ||
48 state_ == kIdle || 49 state_ == kIdle ||
49 state_ == kDecodeFinished) << state_; 50 state_ == kDecodeFinished) << state_;
50 DCHECK(decode_cb_.is_null()); 51 DCHECK(decode_cb_.is_null());
51 DCHECK(reset_cb_.is_null()); 52 DCHECK(reset_cb_.is_null());
52 DCHECK(config.IsValidConfig()); 53 DCHECK(config.IsValidConfig());
53 DCHECK(config.is_encrypted()); 54 DCHECK(config.is_encrypted());
54 55
55 init_cb_ = BindToCurrentLoop(init_cb); 56 init_cb_ = BindToCurrentLoop(init_cb);
56 output_cb_ = BindToCurrentLoop(output_cb); 57 output_cb_ = BindToCurrentLoop(output_cb);
57 weak_this_ = weak_factory_.GetWeakPtr(); 58 weak_this_ = weak_factory_.GetWeakPtr();
58 config_ = config; 59 config_ = config;
59 60
60 if (state_ == kUninitialized) { 61 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;
64 set_cdm_ready_cb_.Run(BindToCurrentLoop( 63 set_cdm_ready_cb_.Run(BindToCurrentLoop(
65 base::Bind(&DecryptingVideoDecoder::SetCdm, weak_this_))); 64 base::Bind(&DecryptingVideoDecoder::SetCdm, weak_this_)));
66 return; 65 return;
67 } 66 }
68 67
69 // Reinitialization. 68 // Reinitialization.
70 decryptor_->DeinitializeDecoder(Decryptor::kVideo); 69 decryptor_->DeinitializeDecoder(Decryptor::kVideo);
71 state_ = kPendingDecoderInit; 70 state_ = kPendingDecoderInit;
72 decryptor_->InitializeVideoDecoder(config, BindToCurrentLoop(base::Bind( 71 decryptor_->InitializeVideoDecoder(config, BindToCurrentLoop(base::Bind(
73 &DecryptingVideoDecoder::FinishInitialization, weak_this_))); 72 &DecryptingVideoDecoder::FinishInitialization, weak_this_)));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 323 }
325 324
326 void DecryptingVideoDecoder::DoReset() { 325 void DecryptingVideoDecoder::DoReset() {
327 DCHECK(init_cb_.is_null()); 326 DCHECK(init_cb_.is_null());
328 DCHECK(decode_cb_.is_null()); 327 DCHECK(decode_cb_.is_null());
329 state_ = kIdle; 328 state_ = kIdle;
330 base::ResetAndReturn(&reset_cb_).Run(); 329 base::ResetAndReturn(&reset_cb_).Run();
331 } 330 }
332 331
333 } // namespace media 332 } // 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