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

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 4 years 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 DCHECK(config.is_encrypted());
Joey Parrish 2016/12/01 22:28:10 This is protecting the renderer? Might be good to
ddorwin 2016/12/05 23:53:04 There should probably be a comment/TODO with the c
xhwang 2016/12/16 20:12:28 joeyparrish: This is an internal contract between
83 DCHECK(cdm_context); 77 DCHECK(cdm_context);
84 if (!cdm_context->GetDecryptor()) { 78 if (!cdm_context->GetDecryptor()) {
85 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; 79 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
86 base::ResetAndReturn(&init_cb_).Run(false); 80 base::ResetAndReturn(&init_cb_).Run(false);
87 return; 81 return;
88 } 82 }
89 83
90 decryptor_ = cdm_context->GetDecryptor(); 84 decryptor_ = cdm_context->GetDecryptor();
91 } else { 85 } else {
92 // Reinitialization (i.e. upon a config change) 86 // Reinitialization (i.e. upon a config change, the new config can be
ddorwin 2016/12/05 23:53:04 The new text seems like a separate thought and may
xhwang 2016/12/16 20:12:28 Done.
87 // encrypted or clear).
93 decryptor_->DeinitializeDecoder(Decryptor::kAudio); 88 decryptor_->DeinitializeDecoder(Decryptor::kAudio);
94 } 89 }
95 90
96 InitializeDecoder(); 91 InitializeDecoder();
97 } 92 }
98 93
99 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 94 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
100 const DecodeCB& decode_cb) { 95 const DecodeCB& decode_cb) {
101 DVLOG(3) << "Decode()"; 96 DVLOG(3) << "Decode()";
102 DCHECK(task_runner_->BelongsToCurrentThread()); 97 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 351 }
357 352
358 frame->set_timestamp(current_time); 353 frame->set_timestamp(current_time);
359 timestamp_helper_->AddFrames(frame->frame_count()); 354 timestamp_helper_->AddFrames(frame->frame_count());
360 355
361 output_cb_.Run(frame); 356 output_cb_.Run(frame);
362 } 357 }
363 } 358 }
364 359
365 } // namespace media 360 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698