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

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

Issue 935243002: Decryptors can report kNoKey to WebMediaPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android changes Created 5 years, 9 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_audio_decoder.h" 5 #include "media/filters/decrypting_audio_decoder.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
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 16 matching lines...) Expand all
27 const base::TimeDelta& timestamp_2) { 27 const base::TimeDelta& timestamp_2) {
28 // Out of sync of 100ms would be pretty noticeable and we should keep any 28 // Out of sync of 100ms would be pretty noticeable and we should keep any
29 // drift below that. 29 // drift below that.
30 const int64 kOutOfSyncThresholdInMilliseconds = 100; 30 const int64 kOutOfSyncThresholdInMilliseconds = 100;
31 return std::abs(timestamp_1.InMilliseconds() - timestamp_2.InMilliseconds()) > 31 return std::abs(timestamp_1.InMilliseconds() - timestamp_2.InMilliseconds()) >
32 kOutOfSyncThresholdInMilliseconds; 32 kOutOfSyncThresholdInMilliseconds;
33 } 33 }
34 34
35 DecryptingAudioDecoder::DecryptingAudioDecoder( 35 DecryptingAudioDecoder::DecryptingAudioDecoder(
36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
37 const SetDecryptorReadyCB& set_decryptor_ready_cb) 37 const SetDecryptorReadyCB& set_decryptor_ready_cb,
38 const base::Closure& waiting_for_decryption_key_cb)
38 : task_runner_(task_runner), 39 : task_runner_(task_runner),
39 state_(kUninitialized), 40 state_(kUninitialized),
41 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb),
40 set_decryptor_ready_cb_(set_decryptor_ready_cb), 42 set_decryptor_ready_cb_(set_decryptor_ready_cb),
41 decryptor_(NULL), 43 decryptor_(NULL),
42 key_added_while_decode_pending_(false), 44 key_added_while_decode_pending_(false),
43 weak_factory_(this) {} 45 weak_factory_(this) {
46 }
44 47
45 std::string DecryptingAudioDecoder::GetDisplayName() const { 48 std::string DecryptingAudioDecoder::GetDisplayName() const {
46 return "DecryptingAudioDecoder"; 49 return "DecryptingAudioDecoder";
47 } 50 }
48 51
49 void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, 52 void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
50 const PipelineStatusCB& status_cb, 53 const PipelineStatusCB& status_cb,
51 const OutputCB& output_cb) { 54 const OutputCB& output_cb) {
52 DVLOG(2) << "Initialize()"; 55 DVLOG(2) << "Initialize()";
53 DCHECK(task_runner_->BelongsToCurrentThread()); 56 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // pending buffer again when new key is added to the decryptor. 284 // pending buffer again when new key is added to the decryptor.
282 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode; 285 pending_buffer_to_decode_ = scoped_pending_buffer_to_decode;
283 286
284 if (need_to_try_again_if_nokey_is_returned) { 287 if (need_to_try_again_if_nokey_is_returned) {
285 // The |state_| is still kPendingDecode. 288 // The |state_| is still kPendingDecode.
286 DecodePendingBuffer(); 289 DecodePendingBuffer();
287 return; 290 return;
288 } 291 }
289 292
290 state_ = kWaitingForKey; 293 state_ = kWaitingForKey;
294 waiting_for_decryption_key_cb_.Run();
291 return; 295 return;
292 } 296 }
293 297
294 if (status == Decryptor::kNeedMoreData) { 298 if (status == Decryptor::kNeedMoreData) {
295 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; 299 DVLOG(2) << "DeliverFrame() - kNeedMoreData";
296 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished 300 state_ = scoped_pending_buffer_to_decode->end_of_stream() ? kDecodeFinished
297 : kIdle; 301 : kIdle;
298 base::ResetAndReturn(&decode_cb_).Run(kOk); 302 base::ResetAndReturn(&decode_cb_).Run(kOk);
299 return; 303 return;
300 } 304 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 360 }
357 361
358 frame->set_timestamp(current_time); 362 frame->set_timestamp(current_time);
359 timestamp_helper_->AddFrames(frame->frame_count()); 363 timestamp_helper_->AddFrames(frame->frame_count());
360 364
361 output_cb_.Run(frame); 365 output_cb_.Run(frame);
362 } 366 }
363 } 367 }
364 368
365 } // namespace media 369 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698