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

Side by Side Diff: chromecast/media/cma/pipeline/av_pipeline_impl.cc

Issue 2361103002: [Chromecast] Make sure that Stop() stops buffer decryption (Closed)
Patch Set: Created 4 years, 2 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 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 "chromecast/media/cma/pipeline/av_pipeline_impl.h" 5 #include "chromecast/media/cma/pipeline/av_pipeline_impl.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 29 matching lines...) Expand all
40 : bytes_decoded_since_last_update_(0), 40 : bytes_decoded_since_last_update_(0),
41 decoder_(decoder), 41 decoder_(decoder),
42 client_(client), 42 client_(client),
43 state_(kUninitialized), 43 state_(kUninitialized),
44 buffered_time_(::media::kNoTimestamp), 44 buffered_time_(::media::kNoTimestamp),
45 playable_buffered_time_(::media::kNoTimestamp), 45 playable_buffered_time_(::media::kNoTimestamp),
46 enable_feeding_(false), 46 enable_feeding_(false),
47 pending_read_(false), 47 pending_read_(false),
48 cast_cdm_context_(NULL), 48 cast_cdm_context_(NULL),
49 player_tracker_callback_id_(kNoCallbackId), 49 player_tracker_callback_id_(kNoCallbackId),
50 weak_factory_(this) { 50 weak_factory_(this),
51 decrypt_weak_factory_(this) {
51 DCHECK(decoder_); 52 DCHECK(decoder_);
52 decoder_->SetDelegate(this); 53 decoder_->SetDelegate(this);
53 weak_this_ = weak_factory_.GetWeakPtr(); 54 weak_this_ = weak_factory_.GetWeakPtr();
54 thread_checker_.DetachFromThread(); 55 thread_checker_.DetachFromThread();
55 } 56 }
56 57
57 AvPipelineImpl::~AvPipelineImpl() { 58 AvPipelineImpl::~AvPipelineImpl() {
58 DCHECK(thread_checker_.CalledOnValidThread()); 59 DCHECK(thread_checker_.CalledOnValidThread());
59 60
60 if (cast_cdm_context_ && player_tracker_callback_id_ != kNoCallbackId) 61 if (cast_cdm_context_ && player_tracker_callback_id_ != kNoCallbackId)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DCHECK_EQ(state_, kFlushing); 141 DCHECK_EQ(state_, kFlushing);
141 set_state(kFlushed); 142 set_state(kFlushed);
142 base::ResetAndReturn(&flush_cb_).Run(); 143 base::ResetAndReturn(&flush_cb_).Run();
143 } 144 }
144 145
145 void AvPipelineImpl::Stop() { 146 void AvPipelineImpl::Stop() {
146 DCHECK(thread_checker_.CalledOnValidThread()); 147 DCHECK(thread_checker_.CalledOnValidThread());
147 CMALOG(kLogControl) << __FUNCTION__; 148 CMALOG(kLogControl) << __FUNCTION__;
148 // Stop feeding the pipeline. 149 // Stop feeding the pipeline.
149 enable_feeding_ = false; 150 enable_feeding_ = false;
151 // Drop any pending asynchronous decryption.
152 decrypt_weak_factory_.InvalidateWeakPtrs();
150 set_state(kStopped); 153 set_state(kStopped);
151 } 154 }
152 155
153 void AvPipelineImpl::SetCdm(CastCdmContext* cast_cdm_context) { 156 void AvPipelineImpl::SetCdm(CastCdmContext* cast_cdm_context) {
154 DCHECK(thread_checker_.CalledOnValidThread()); 157 DCHECK(thread_checker_.CalledOnValidThread());
155 DCHECK(cast_cdm_context); 158 DCHECK(cast_cdm_context);
156 159
157 if (cast_cdm_context_ && player_tracker_callback_id_ != kNoCallbackId) 160 if (cast_cdm_context_ && player_tracker_callback_id_ != kNoCallbackId)
158 cast_cdm_context_->UnregisterPlayer(player_tracker_callback_id_); 161 cast_cdm_context_->UnregisterPlayer(player_tracker_callback_id_);
159 162
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 client_.wait_for_key_cb.Run(); 231 client_.wait_for_key_cb.Run();
229 return; 232 return;
230 } 233 }
231 234
232 DCHECK_NE(decrypt_context->GetKeySystem(), KEY_SYSTEM_NONE); 235 DCHECK_NE(decrypt_context->GetKeySystem(), KEY_SYSTEM_NONE);
233 236
234 // If we can get the clear content, decrypt the pending buffer 237 // If we can get the clear content, decrypt the pending buffer
235 if (decrypt_context->CanDecryptToBuffer()) { 238 if (decrypt_context->CanDecryptToBuffer()) {
236 auto buffer = pending_buffer_; 239 auto buffer = pending_buffer_;
237 pending_buffer_ = nullptr; 240 pending_buffer_ = nullptr;
238 DecryptDecoderBuffer( 241 DecryptDecoderBuffer(buffer, decrypt_context.get(),
239 buffer, decrypt_context.get(), 242 base::Bind(&AvPipelineImpl::OnBufferDecrypted,
240 base::Bind(&AvPipelineImpl::OnBufferDecrypted, weak_this_, 243 decrypt_weak_factory_.GetWeakPtr(),
241 base::Passed(&decrypt_context))); 244 base::Passed(&decrypt_context)));
242 245
243 return; 246 return;
244 } 247 }
245 248
246 pending_buffer_->set_decrypt_context(std::move(decrypt_context)); 249 pending_buffer_->set_decrypt_context(std::move(decrypt_context));
247 } 250 }
248 251
249 PushPendingBuffer(); 252 PushPendingBuffer();
250 } 253 }
251 254
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 400 }
398 } 401 }
399 402
400 // The frame is playable: remove it from the list of non playable frames. 403 // The frame is playable: remove it from the list of non playable frames.
401 non_playable_frames_.pop_front(); 404 non_playable_frames_.pop_front();
402 } 405 }
403 } 406 }
404 407
405 } // namespace media 408 } // namespace media
406 } // namespace chromecast 409 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698