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

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

Issue 2543623003: media: Allow config change between clear and encrypted streams (Closed)
Patch Set: media: Allow config change between clear and encrypted streams Created 3 years, 11 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 (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_audio_decoder.h" 5 #include "media/filters/decrypting_audio_decoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cstdlib> 9 #include <cstdlib>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const OutputCB& output_cb) { 56 const OutputCB& output_cb) {
57 DVLOG(2) << "Initialize()"; 57 DVLOG(2) << "Initialize()";
58 DCHECK(task_runner_->BelongsToCurrentThread()); 58 DCHECK(task_runner_->BelongsToCurrentThread());
59 DCHECK(decode_cb_.is_null()); 59 DCHECK(decode_cb_.is_null());
60 DCHECK(reset_cb_.is_null()); 60 DCHECK(reset_cb_.is_null());
61 61
62 weak_this_ = weak_factory_.GetWeakPtr(); 62 weak_this_ = weak_factory_.GetWeakPtr();
63 init_cb_ = BindToCurrentLoop(init_cb); 63 init_cb_ = BindToCurrentLoop(init_cb);
64 output_cb_ = BindToCurrentLoop(output_cb); 64 output_cb_ = BindToCurrentLoop(output_cb);
65 65
66 // TODO(xhwang): We should be able to DCHECK config.IsValidConfig() and 66 // TODO(xhwang): We should be able to DCHECK config.IsValidConfig().
67 // config.is_encrypted().
68 if (!config.IsValidConfig()) { 67 if (!config.IsValidConfig()) {
69 DLOG(ERROR) << "Invalid audio stream config."; 68 DLOG(ERROR) << "Invalid audio stream config.";
70 base::ResetAndReturn(&init_cb_).Run(false); 69 base::ResetAndReturn(&init_cb_).Run(false);
71 return; 70 return;
72 } 71 }
73 72
74 // DecryptingAudioDecoder only accepts potentially encrypted stream.
75 if (!config.is_encrypted()) {
76 base::ResetAndReturn(&init_cb_).Run(false);
77 return;
78 }
79
80 config_ = config; 73 config_ = config;
81 74
82 if (state_ == kUninitialized) { 75 if (state_ == kUninitialized) {
76 // DecoderSelector only chooses |this| when the stream is encrypted.
ddorwin 2017/02/12 04:28:52 This will change in the next CL, right? Maybe add
xhwang 2017/02/14 23:59:32 Done.
77 DCHECK(config.is_encrypted());
83 DCHECK(cdm_context); 78 DCHECK(cdm_context);
84 if (!cdm_context->GetDecryptor()) { 79 if (!cdm_context->GetDecryptor()) {
85 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; 80 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
86 base::ResetAndReturn(&init_cb_).Run(false); 81 base::ResetAndReturn(&init_cb_).Run(false);
87 return; 82 return;
88 } 83 }
89 84
90 decryptor_ = cdm_context->GetDecryptor(); 85 decryptor_ = cdm_context->GetDecryptor();
91 } else { 86 } else {
92 // Reinitialization (i.e. upon a config change) 87 // Reinitialization (i.e. upon a config change). The new config can be
88 // encrypted or clear.
93 decryptor_->DeinitializeDecoder(Decryptor::kAudio); 89 decryptor_->DeinitializeDecoder(Decryptor::kAudio);
94 } 90 }
95 91
96 InitializeDecoder(); 92 InitializeDecoder();
97 } 93 }
98 94
99 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 95 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
100 const DecodeCB& decode_cb) { 96 const DecodeCB& decode_cb) {
101 DVLOG(3) << "Decode()"; 97 DVLOG(3) << "Decode()";
102 DCHECK(task_runner_->BelongsToCurrentThread()); 98 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 352 }
357 353
358 frame->set_timestamp(current_time); 354 frame->set_timestamp(current_time);
359 timestamp_helper_->AddFrames(frame->frame_count()); 355 timestamp_helper_->AddFrames(frame->frame_count());
360 356
361 output_cb_.Run(frame); 357 output_cb_.Run(frame);
362 } 358 }
363 } 359 }
364 360
365 } // namespace media 361 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698