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

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

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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_demuxer_stream.h" 5 #include "media/filters/decrypting_demuxer_stream.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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); 153 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB());
154 if (!init_cb_.is_null()) 154 if (!init_cb_.is_null())
155 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); 155 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
156 if (!read_cb_.is_null()) 156 if (!read_cb_.is_null())
157 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); 157 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
158 if (!reset_cb_.is_null()) 158 if (!reset_cb_.is_null())
159 base::ResetAndReturn(&reset_cb_).Run(); 159 base::ResetAndReturn(&reset_cb_).Run();
160 pending_buffer_to_decrypt_ = NULL; 160 pending_buffer_to_decrypt_ = NULL;
161 } 161 }
162 162
163 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { 163 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor,
164 base::Closure done_cb) {
164 DVLOG(2) << __FUNCTION__; 165 DVLOG(2) << __FUNCTION__;
165 DCHECK(task_runner_->BelongsToCurrentThread()); 166 DCHECK(task_runner_->BelongsToCurrentThread());
166 DCHECK_EQ(state_, kDecryptorRequested) << state_; 167 DCHECK_EQ(state_, kDecryptorRequested) << state_;
167 DCHECK(!init_cb_.is_null()); 168 DCHECK(!init_cb_.is_null());
168 DCHECK(!set_decryptor_ready_cb_.is_null()); 169 DCHECK(!set_decryptor_ready_cb_.is_null());
169 170
170 set_decryptor_ready_cb_.Reset(); 171 set_decryptor_ready_cb_.Reset();
171 172
172 if (!decryptor) { 173 if (!decryptor) {
173 state_ = kUninitialized; 174 state_ = kUninitialized;
174 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 175 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
176 if (!done_cb.is_null())
177 done_cb.Run();
175 return; 178 return;
176 } 179 }
177 180
178 decryptor_ = decryptor; 181 decryptor_ = decryptor;
179 182
180 decryptor_->RegisterNewKeyCB( 183 decryptor_->RegisterNewKeyCB(
181 GetDecryptorStreamType(), 184 GetDecryptorStreamType(),
182 BindToCurrentLoop( 185 BindToCurrentLoop(
183 base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_))); 186 base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
184 187
185 state_ = kIdle; 188 state_ = kIdle;
186 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); 189 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
190 if (!done_cb.is_null())
191 done_cb.Run();
187 } 192 }
188 193
189 void DecryptingDemuxerStream::DecryptBuffer( 194 void DecryptingDemuxerStream::DecryptBuffer(
190 DemuxerStream::Status status, 195 DemuxerStream::Status status,
191 const scoped_refptr<DecoderBuffer>& buffer) { 196 const scoped_refptr<DecoderBuffer>& buffer) {
192 DVLOG(3) << __FUNCTION__; 197 DVLOG(3) << __FUNCTION__;
193 DCHECK(task_runner_->BelongsToCurrentThread()); 198 DCHECK(task_runner_->BelongsToCurrentThread());
194 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; 199 DCHECK_EQ(state_, kPendingDemuxerRead) << state_;
195 DCHECK(!read_cb_.is_null()); 200 DCHECK(!read_cb_.is_null());
196 DCHECK_EQ(buffer.get() != NULL, status == kOk) << status; 201 DCHECK_EQ(buffer.get() != NULL, status == kOk) << status;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 break; 386 break;
382 } 387 }
383 388
384 default: 389 default:
385 NOTREACHED(); 390 NOTREACHED();
386 return; 391 return;
387 } 392 }
388 } 393 }
389 394
390 } // namespace media 395 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698