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

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

Issue 1423163004: media: Replace DecryptorReadyCB with CdmReadyCB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 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
« no previous file with comments | « media/filters/decoder_selector.h ('k') | media/filters/decoder_stream.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "decoder_selector.h" 5 #include "decoder_selector.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/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (!select_decoder_cb_.is_null()) 71 if (!select_decoder_cb_.is_null())
72 ReturnNullDecoder(); 72 ReturnNullDecoder();
73 73
74 decoder_.reset(); 74 decoder_.reset();
75 decrypted_stream_.reset(); 75 decrypted_stream_.reset();
76 } 76 }
77 77
78 template <DemuxerStream::Type StreamType> 78 template <DemuxerStream::Type StreamType>
79 void DecoderSelector<StreamType>::SelectDecoder( 79 void DecoderSelector<StreamType>::SelectDecoder(
80 DemuxerStream* stream, 80 DemuxerStream* stream,
81 const SetDecryptorReadyCB& set_decryptor_ready_cb, 81 const SetCdmReadyCB& set_cdm_ready_cb,
82 const SelectDecoderCB& select_decoder_cb, 82 const SelectDecoderCB& select_decoder_cb,
83 const typename Decoder::OutputCB& output_cb, 83 const typename Decoder::OutputCB& output_cb,
84 const base::Closure& waiting_for_decryption_key_cb) { 84 const base::Closure& waiting_for_decryption_key_cb) {
85 DVLOG(2) << __FUNCTION__; 85 DVLOG(2) << __FUNCTION__;
86 DCHECK(task_runner_->BelongsToCurrentThread()); 86 DCHECK(task_runner_->BelongsToCurrentThread());
87 DCHECK(stream); 87 DCHECK(stream);
88 DCHECK(select_decoder_cb_.is_null()); 88 DCHECK(select_decoder_cb_.is_null());
89 89
90 set_decryptor_ready_cb_ = set_decryptor_ready_cb; 90 set_cdm_ready_cb_ = set_cdm_ready_cb;
91 waiting_for_decryption_key_cb_ = waiting_for_decryption_key_cb; 91 waiting_for_decryption_key_cb_ = waiting_for_decryption_key_cb;
92 92
93 // Make sure |select_decoder_cb| runs on a different execution stack. 93 // Make sure |select_decoder_cb| runs on a different execution stack.
94 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb); 94 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb);
95 95
96 if (!HasValidStreamConfig(stream)) { 96 if (!HasValidStreamConfig(stream)) {
97 DLOG(ERROR) << "Invalid stream config."; 97 DLOG(ERROR) << "Invalid stream config.";
98 ReturnNullDecoder(); 98 ReturnNullDecoder();
99 return; 99 return;
100 } 100 }
101 101
102 input_stream_ = stream; 102 input_stream_ = stream;
103 output_cb_ = output_cb; 103 output_cb_ = output_cb;
104 104
105 if (!IsStreamEncrypted(input_stream_)) { 105 if (!IsStreamEncrypted(input_stream_)) {
106 InitializeDecoder(); 106 InitializeDecoder();
107 return; 107 return;
108 } 108 }
109 109
110 // This could be null during fallback after decoder reinitialization failure. 110 // This could be null during fallback after decoder reinitialization failure.
111 // See DecoderStream<StreamType>::OnDecoderReinitialized(). 111 // See DecoderStream<StreamType>::OnDecoderReinitialized().
112 if (set_decryptor_ready_cb_.is_null()) { 112 if (set_cdm_ready_cb_.is_null()) {
113 ReturnNullDecoder(); 113 ReturnNullDecoder();
114 return; 114 return;
115 } 115 }
116 116
117 #if !defined(OS_ANDROID) 117 #if !defined(OS_ANDROID)
118 InitializeDecryptingDecoder(); 118 InitializeDecryptingDecoder();
119 #else 119 #else
120 InitializeDecryptingDemuxerStream(); 120 InitializeDecryptingDemuxerStream();
121 #endif 121 #endif
122 } 122 }
123 123
124 #if !defined(OS_ANDROID) 124 #if !defined(OS_ANDROID)
125 template <DemuxerStream::Type StreamType> 125 template <DemuxerStream::Type StreamType>
126 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() { 126 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() {
127 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( 127 decoder_.reset(new typename StreamTraits::DecryptingDecoderType(
128 task_runner_, media_log_, set_decryptor_ready_cb_, 128 task_runner_, media_log_, set_cdm_ready_cb_,
129 waiting_for_decryption_key_cb_)); 129 waiting_for_decryption_key_cb_));
130 130
131 DecoderStreamTraits<StreamType>::InitializeDecoder( 131 DecoderStreamTraits<StreamType>::InitializeDecoder(
132 decoder_.get(), input_stream_, 132 decoder_.get(), input_stream_,
133 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 133 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
134 weak_ptr_factory_.GetWeakPtr()), 134 weak_ptr_factory_.GetWeakPtr()),
135 output_cb_); 135 output_cb_);
136 } 136 }
137 137
138 template <DemuxerStream::Type StreamType> 138 template <DemuxerStream::Type StreamType>
(...skipping 10 matching lines...) Expand all
149 decoder_.reset(); 149 decoder_.reset();
150 150
151 // When we get here decrypt-and-decode is not supported. Try to use 151 // When we get here decrypt-and-decode is not supported. Try to use
152 // DecryptingDemuxerStream to do decrypt-only. 152 // DecryptingDemuxerStream to do decrypt-only.
153 InitializeDecryptingDemuxerStream(); 153 InitializeDecryptingDemuxerStream();
154 } 154 }
155 #endif // !defined(OS_ANDROID) 155 #endif // !defined(OS_ANDROID)
156 156
157 template <DemuxerStream::Type StreamType> 157 template <DemuxerStream::Type StreamType>
158 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() { 158 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() {
159 decrypted_stream_.reset(new DecryptingDemuxerStream( 159 decrypted_stream_.reset(
160 task_runner_, media_log_, set_decryptor_ready_cb_, 160 new DecryptingDemuxerStream(task_runner_, media_log_, set_cdm_ready_cb_,
161 waiting_for_decryption_key_cb_)); 161 waiting_for_decryption_key_cb_));
162 162
163 decrypted_stream_->Initialize( 163 decrypted_stream_->Initialize(
164 input_stream_, 164 input_stream_,
165 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, 165 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone,
166 weak_ptr_factory_.GetWeakPtr())); 166 weak_ptr_factory_.GetWeakPtr()));
167 } 167 }
168 168
169 template <DemuxerStream::Type StreamType> 169 template <DemuxerStream::Type StreamType>
170 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( 170 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone(
171 PipelineStatus status) { 171 PipelineStatus status) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // These forward declarations tell the compiler that we will use 236 // These forward declarations tell the compiler that we will use
237 // DecoderSelector with these arguments, allowing us to keep these definitions 237 // DecoderSelector with these arguments, allowing us to keep these definitions
238 // in our .cc without causing linker errors. This also means if anyone tries to 238 // in our .cc without causing linker errors. This also means if anyone tries to
239 // instantiate a DecoderSelector with anything but these two specializations 239 // instantiate a DecoderSelector with anything but these two specializations
240 // they'll most likely get linker errors. 240 // they'll most likely get linker errors.
241 template class DecoderSelector<DemuxerStream::AUDIO>; 241 template class DecoderSelector<DemuxerStream::AUDIO>;
242 template class DecoderSelector<DemuxerStream::VIDEO>; 242 template class DecoderSelector<DemuxerStream::VIDEO>;
243 243
244 } // namespace media 244 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_selector.h ('k') | media/filters/decoder_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698