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

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

Issue 2161193003: Use __func__ instead of __FUNCTION__. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 4 years, 4 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/chunk_demuxer.cc ('k') | media/filters/decoder_stream.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 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 "media/filters/decoder_selector.h" 5 #include "media/filters/decoder_selector.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ScopedVector<Decoder> decoders, 61 ScopedVector<Decoder> decoders,
62 const scoped_refptr<MediaLog>& media_log) 62 const scoped_refptr<MediaLog>& media_log)
63 : task_runner_(task_runner), 63 : task_runner_(task_runner),
64 decoders_(std::move(decoders)), 64 decoders_(std::move(decoders)),
65 media_log_(media_log), 65 media_log_(media_log),
66 input_stream_(nullptr), 66 input_stream_(nullptr),
67 weak_ptr_factory_(this) {} 67 weak_ptr_factory_(this) {}
68 68
69 template <DemuxerStream::Type StreamType> 69 template <DemuxerStream::Type StreamType>
70 DecoderSelector<StreamType>::~DecoderSelector() { 70 DecoderSelector<StreamType>::~DecoderSelector() {
71 DVLOG(2) << __FUNCTION__; 71 DVLOG(2) << __func__;
72 DCHECK(task_runner_->BelongsToCurrentThread()); 72 DCHECK(task_runner_->BelongsToCurrentThread());
73 73
74 if (!select_decoder_cb_.is_null()) 74 if (!select_decoder_cb_.is_null())
75 ReturnNullDecoder(); 75 ReturnNullDecoder();
76 76
77 decoder_.reset(); 77 decoder_.reset();
78 decrypted_stream_.reset(); 78 decrypted_stream_.reset();
79 } 79 }
80 80
81 template <DemuxerStream::Type StreamType> 81 template <DemuxerStream::Type StreamType>
82 void DecoderSelector<StreamType>::SelectDecoder( 82 void DecoderSelector<StreamType>::SelectDecoder(
83 StreamTraits* traits, 83 StreamTraits* traits,
84 DemuxerStream* stream, 84 DemuxerStream* stream,
85 CdmContext* cdm_context, 85 CdmContext* cdm_context,
86 const SelectDecoderCB& select_decoder_cb, 86 const SelectDecoderCB& select_decoder_cb,
87 const typename Decoder::OutputCB& output_cb, 87 const typename Decoder::OutputCB& output_cb,
88 const base::Closure& waiting_for_decryption_key_cb) { 88 const base::Closure& waiting_for_decryption_key_cb) {
89 DVLOG(2) << __FUNCTION__; 89 DVLOG(2) << __func__;
90 DCHECK(task_runner_->BelongsToCurrentThread()); 90 DCHECK(task_runner_->BelongsToCurrentThread());
91 DCHECK(traits); 91 DCHECK(traits);
92 DCHECK(stream); 92 DCHECK(stream);
93 DCHECK(select_decoder_cb_.is_null()); 93 DCHECK(select_decoder_cb_.is_null());
94 94
95 cdm_context_ = cdm_context; 95 cdm_context_ = cdm_context;
96 waiting_for_decryption_key_cb_ = waiting_for_decryption_key_cb; 96 waiting_for_decryption_key_cb_ = waiting_for_decryption_key_cb;
97 97
98 // Make sure |select_decoder_cb| runs on a different execution stack. 98 // Make sure |select_decoder_cb| runs on a different execution stack.
99 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb); 99 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb);
(...skipping 23 matching lines...) Expand all
123 #if !defined(OS_ANDROID) 123 #if !defined(OS_ANDROID)
124 InitializeDecryptingDecoder(); 124 InitializeDecryptingDecoder();
125 #else 125 #else
126 InitializeDecryptingDemuxerStream(); 126 InitializeDecryptingDemuxerStream();
127 #endif 127 #endif
128 } 128 }
129 129
130 #if !defined(OS_ANDROID) 130 #if !defined(OS_ANDROID)
131 template <DemuxerStream::Type StreamType> 131 template <DemuxerStream::Type StreamType>
132 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() { 132 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() {
133 DVLOG(2) << __FUNCTION__; 133 DVLOG(2) << __func__;
134 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( 134 decoder_.reset(new typename StreamTraits::DecryptingDecoderType(
135 task_runner_, media_log_, waiting_for_decryption_key_cb_)); 135 task_runner_, media_log_, waiting_for_decryption_key_cb_));
136 136
137 traits_->InitializeDecoder( 137 traits_->InitializeDecoder(
138 decoder_.get(), input_stream_, cdm_context_, 138 decoder_.get(), input_stream_, cdm_context_,
139 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 139 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
140 weak_ptr_factory_.GetWeakPtr()), 140 weak_ptr_factory_.GetWeakPtr()),
141 output_cb_); 141 output_cb_);
142 } 142 }
143 143
144 template <DemuxerStream::Type StreamType> 144 template <DemuxerStream::Type StreamType>
145 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) { 145 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(bool success) {
146 DVLOG(2) << __FUNCTION__; 146 DVLOG(2) << __func__;
147 DCHECK(task_runner_->BelongsToCurrentThread()); 147 DCHECK(task_runner_->BelongsToCurrentThread());
148 148
149 if (success) { 149 if (success) {
150 base::ResetAndReturn(&select_decoder_cb_) 150 base::ResetAndReturn(&select_decoder_cb_)
151 .Run(std::move(decoder_), std::unique_ptr<DecryptingDemuxerStream>()); 151 .Run(std::move(decoder_), std::unique_ptr<DecryptingDemuxerStream>());
152 return; 152 return;
153 } 153 }
154 154
155 decoder_.reset(); 155 decoder_.reset();
156 156
(...skipping 10 matching lines...) Expand all
167 167
168 decrypted_stream_->Initialize( 168 decrypted_stream_->Initialize(
169 input_stream_, cdm_context_, 169 input_stream_, cdm_context_,
170 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, 170 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone,
171 weak_ptr_factory_.GetWeakPtr())); 171 weak_ptr_factory_.GetWeakPtr()));
172 } 172 }
173 173
174 template <DemuxerStream::Type StreamType> 174 template <DemuxerStream::Type StreamType>
175 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( 175 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone(
176 PipelineStatus status) { 176 PipelineStatus status) {
177 DVLOG(2) << __FUNCTION__; 177 DVLOG(2) << __func__;
178 DCHECK(task_runner_->BelongsToCurrentThread()); 178 DCHECK(task_runner_->BelongsToCurrentThread());
179 179
180 // If DecryptingDemuxerStream initialization succeeded, we'll use it to do 180 // If DecryptingDemuxerStream initialization succeeded, we'll use it to do
181 // decryption and use a decoder to decode the clear stream. Otherwise, we'll 181 // decryption and use a decoder to decode the clear stream. Otherwise, we'll
182 // try to see whether any decoder can decrypt-and-decode the encrypted stream 182 // try to see whether any decoder can decrypt-and-decode the encrypted stream
183 // directly. So in both cases, we'll initialize the decoders. 183 // directly. So in both cases, we'll initialize the decoders.
184 184
185 if (status == PIPELINE_OK) { 185 if (status == PIPELINE_OK) {
186 input_stream_ = decrypted_stream_.get(); 186 input_stream_ = decrypted_stream_.get();
187 DCHECK(!IsStreamEncrypted(input_stream_)); 187 DCHECK(!IsStreamEncrypted(input_stream_));
188 } else { 188 } else {
189 decrypted_stream_.reset(); 189 decrypted_stream_.reset();
190 DCHECK(IsStreamEncrypted(input_stream_)); 190 DCHECK(IsStreamEncrypted(input_stream_));
191 } 191 }
192 192
193 InitializeDecoder(); 193 InitializeDecoder();
194 } 194 }
195 195
196 template <DemuxerStream::Type StreamType> 196 template <DemuxerStream::Type StreamType>
197 void DecoderSelector<StreamType>::InitializeDecoder() { 197 void DecoderSelector<StreamType>::InitializeDecoder() {
198 DVLOG(2) << __FUNCTION__; 198 DVLOG(2) << __func__;
199 DCHECK(task_runner_->BelongsToCurrentThread()); 199 DCHECK(task_runner_->BelongsToCurrentThread());
200 DCHECK(!decoder_); 200 DCHECK(!decoder_);
201 201
202 if (decoders_.empty()) { 202 if (decoders_.empty()) {
203 ReturnNullDecoder(); 203 ReturnNullDecoder();
204 return; 204 return;
205 } 205 }
206 206
207 decoder_.reset(decoders_.front()); 207 decoder_.reset(decoders_.front());
208 decoders_.weak_erase(decoders_.begin()); 208 decoders_.weak_erase(decoders_.begin());
209 209
210 traits_->InitializeDecoder( 210 traits_->InitializeDecoder(
211 decoder_.get(), input_stream_, cdm_context_, 211 decoder_.get(), input_stream_, cdm_context_,
212 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, 212 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone,
213 weak_ptr_factory_.GetWeakPtr()), 213 weak_ptr_factory_.GetWeakPtr()),
214 output_cb_); 214 output_cb_);
215 } 215 }
216 216
217 template <DemuxerStream::Type StreamType> 217 template <DemuxerStream::Type StreamType>
218 void DecoderSelector<StreamType>::DecoderInitDone(bool success) { 218 void DecoderSelector<StreamType>::DecoderInitDone(bool success) {
219 DVLOG(2) << __FUNCTION__; 219 DVLOG(2) << __func__;
220 DCHECK(task_runner_->BelongsToCurrentThread()); 220 DCHECK(task_runner_->BelongsToCurrentThread());
221 221
222 if (!success) { 222 if (!success) {
223 decoder_.reset(); 223 decoder_.reset();
224 InitializeDecoder(); 224 InitializeDecoder();
225 return; 225 return;
226 } 226 }
227 227
228 base::ResetAndReturn(&select_decoder_cb_) 228 base::ResetAndReturn(&select_decoder_cb_)
229 .Run(std::move(decoder_), std::move(decrypted_stream_)); 229 .Run(std::move(decoder_), std::move(decrypted_stream_));
230 } 230 }
231 231
232 template <DemuxerStream::Type StreamType> 232 template <DemuxerStream::Type StreamType>
233 void DecoderSelector<StreamType>::ReturnNullDecoder() { 233 void DecoderSelector<StreamType>::ReturnNullDecoder() {
234 DVLOG(2) << __FUNCTION__; 234 DVLOG(2) << __func__;
235 DCHECK(task_runner_->BelongsToCurrentThread()); 235 DCHECK(task_runner_->BelongsToCurrentThread());
236 base::ResetAndReturn(&select_decoder_cb_) 236 base::ResetAndReturn(&select_decoder_cb_)
237 .Run(std::unique_ptr<Decoder>(), 237 .Run(std::unique_ptr<Decoder>(),
238 std::unique_ptr<DecryptingDemuxerStream>()); 238 std::unique_ptr<DecryptingDemuxerStream>());
239 } 239 }
240 240
241 // These forward declarations tell the compiler that we will use 241 // These forward declarations tell the compiler that we will use
242 // DecoderSelector with these arguments, allowing us to keep these definitions 242 // DecoderSelector with these arguments, allowing us to keep these definitions
243 // in our .cc without causing linker errors. This also means if anyone tries to 243 // in our .cc without causing linker errors. This also means if anyone tries to
244 // instantiate a DecoderSelector with anything but these two specializations 244 // instantiate a DecoderSelector with anything but these two specializations
245 // they'll most likely get linker errors. 245 // they'll most likely get linker errors.
246 template class DecoderSelector<DemuxerStream::AUDIO>; 246 template class DecoderSelector<DemuxerStream::AUDIO>;
247 template class DecoderSelector<DemuxerStream::VIDEO>; 247 template class DecoderSelector<DemuxerStream::VIDEO>;
248 248
249 } // namespace media 249 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/decoder_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698