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

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

Issue 2701203003: media: Prefer decrypting pipeline when CDM is attached (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.cc ('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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, 53 void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
54 CdmContext* cdm_context, 54 CdmContext* cdm_context,
55 const InitCB& init_cb, 55 const InitCB& init_cb,
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 DCHECK(cdm_context);
61 62
62 weak_this_ = weak_factory_.GetWeakPtr(); 63 weak_this_ = weak_factory_.GetWeakPtr();
63 init_cb_ = BindToCurrentLoop(init_cb); 64 init_cb_ = BindToCurrentLoop(init_cb);
64 output_cb_ = BindToCurrentLoop(output_cb); 65 output_cb_ = BindToCurrentLoop(output_cb);
65 66
66 // TODO(xhwang): We should be able to DCHECK config.IsValidConfig(). 67 // TODO(xhwang): We should be able to DCHECK config.IsValidConfig().
67 if (!config.IsValidConfig()) { 68 if (!config.IsValidConfig()) {
68 DLOG(ERROR) << "Invalid audio stream config."; 69 DLOG(ERROR) << "Invalid audio stream config.";
69 base::ResetAndReturn(&init_cb_).Run(false); 70 base::ResetAndReturn(&init_cb_).Run(false);
70 return; 71 return;
71 } 72 }
72 73
73 config_ = config; 74 config_ = config;
74 75
75 if (state_ == kUninitialized) { 76 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());
80 DCHECK(cdm_context);
81 if (!cdm_context->GetDecryptor()) { 77 if (!cdm_context->GetDecryptor()) {
82 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor"; 78 MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
83 base::ResetAndReturn(&init_cb_).Run(false); 79 base::ResetAndReturn(&init_cb_).Run(false);
84 return; 80 return;
85 } 81 }
86 82
87 decryptor_ = cdm_context->GetDecryptor(); 83 decryptor_ = cdm_context->GetDecryptor();
88 } else { 84 } else {
89 // Reinitialization (i.e. upon a config change). The new config can be 85 // Reinitialization (i.e. upon a config change). The new config can be
90 // encrypted or clear. 86 // encrypted or clear.
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 350 }
355 351
356 frame->set_timestamp(current_time); 352 frame->set_timestamp(current_time);
357 timestamp_helper_->AddFrames(frame->frame_count()); 353 timestamp_helper_->AddFrames(frame->frame_count());
358 354
359 output_cb_.Run(frame); 355 output_cb_.Run(frame);
360 } 356 }
361 } 357 }
362 358
363 } // namespace media 359 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_stream.cc ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698