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

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

Issue 2543623003: media: Allow config change between clear and encrypted streams (Closed)
Patch Set: comments addressed Created 3 years, 10 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
« no previous file with comments | « media/filters/decoder_stream.h ('k') | media/filters/decrypting_audio_decoder_unittest.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_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.
77 // TODO(xhwang): We may also select this decoder for clear stream if a CDM
78 // is attached. Then we need to update this. See http://crbug.com/597443
79 DCHECK(config.is_encrypted());
83 DCHECK(cdm_context); 80 DCHECK(cdm_context);
84 if (!cdm_context->GetDecryptor()) { 81 if (!cdm_context->GetDecryptor()) {
85 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; 82 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
86 base::ResetAndReturn(&init_cb_).Run(false); 83 base::ResetAndReturn(&init_cb_).Run(false);
87 return; 84 return;
88 } 85 }
89 86
90 decryptor_ = cdm_context->GetDecryptor(); 87 decryptor_ = cdm_context->GetDecryptor();
91 } else { 88 } else {
92 // Reinitialization (i.e. upon a config change) 89 // Reinitialization (i.e. upon a config change). The new config can be
90 // encrypted or clear.
93 decryptor_->DeinitializeDecoder(Decryptor::kAudio); 91 decryptor_->DeinitializeDecoder(Decryptor::kAudio);
94 } 92 }
95 93
96 InitializeDecoder(); 94 InitializeDecoder();
97 } 95 }
98 96
99 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 97 void DecryptingAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
100 const DecodeCB& decode_cb) { 98 const DecodeCB& decode_cb) {
101 DVLOG(3) << "Decode()"; 99 DVLOG(3) << "Decode()";
102 DCHECK(task_runner_->BelongsToCurrentThread()); 100 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 354 }
357 355
358 frame->set_timestamp(current_time); 356 frame->set_timestamp(current_time);
359 timestamp_helper_->AddFrames(frame->frame_count()); 357 timestamp_helper_->AddFrames(frame->frame_count());
360 358
361 output_cb_.Run(frame); 359 output_cb_.Run(frame);
362 } 360 }
363 } 361 }
364 362
365 } // namespace media 363 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_stream.h ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698