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

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

Issue 11492003: Encrypted Media: Support Audio Decrypt-Only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments mostly resolved (I believe); need to add/update tests if this looks good Created 8 years 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 | Annotate | Revision Log
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 18 matching lines...) Expand all
29 const base::TimeDelta& timestamp_2) { 29 const base::TimeDelta& timestamp_2) {
30 // Out of sync of 100ms would be pretty noticeable and we should keep any 30 // Out of sync of 100ms would be pretty noticeable and we should keep any
31 // drift below that. 31 // drift below that.
32 const int64 kOutOfSyncThresholdInMicroseconds = 100000; 32 const int64 kOutOfSyncThresholdInMicroseconds = 100000;
33 return std::abs(timestamp_1.InMicroseconds() - timestamp_2.InMicroseconds()) > 33 return std::abs(timestamp_1.InMicroseconds() - timestamp_2.InMicroseconds()) >
34 kOutOfSyncThresholdInMicroseconds; 34 kOutOfSyncThresholdInMicroseconds;
35 } 35 }
36 36
37 DecryptingAudioDecoder::DecryptingAudioDecoder( 37 DecryptingAudioDecoder::DecryptingAudioDecoder(
38 const scoped_refptr<base::MessageLoopProxy>& message_loop, 38 const scoped_refptr<base::MessageLoopProxy>& message_loop,
39 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) 39 const SetDecryptorReadyCB& set_decryptor_ready_cb)
40 : message_loop_(message_loop), 40 : message_loop_(message_loop),
41 state_(kUninitialized), 41 state_(kUninitialized),
42 request_decryptor_notification_cb_(request_decryptor_notification_cb), 42 set_decryptor_ready_cb_(set_decryptor_ready_cb),
43 decryptor_(NULL), 43 decryptor_(NULL),
44 key_added_while_decode_pending_(false), 44 key_added_while_decode_pending_(false),
45 bits_per_channel_(0), 45 bits_per_channel_(0),
46 channel_layout_(CHANNEL_LAYOUT_NONE), 46 channel_layout_(CHANNEL_LAYOUT_NONE),
47 samples_per_second_(0), 47 samples_per_second_(0),
48 bytes_per_sample_(0), 48 bytes_per_sample_(0),
49 output_timestamp_base_(kNoTimestamp()), 49 output_timestamp_base_(kNoTimestamp()),
50 total_samples_decoded_(0) { 50 total_samples_decoded_(0) {
51 } 51 }
52 52
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return; 146 return;
147 } 147 }
148 148
149 DCHECK(!demuxer_stream_); 149 DCHECK(!demuxer_stream_);
150 demuxer_stream_ = stream; 150 demuxer_stream_ = stream;
151 statistics_cb_ = statistics_cb; 151 statistics_cb_ = statistics_cb;
152 152
153 init_cb_ = status_cb; 153 init_cb_ = status_cb;
154 154
155 state_ = kDecryptorRequested; 155 state_ = kDecryptorRequested;
156 request_decryptor_notification_cb_.Run( 156 set_decryptor_ready_cb_.Run(
157 BIND_TO_LOOP(&DecryptingAudioDecoder::SetDecryptor)); 157 BIND_TO_LOOP(&DecryptingAudioDecoder::SetDecryptor));
158 } 158 }
159 159
160 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) { 160 void DecryptingAudioDecoder::SetDecryptor(Decryptor* decryptor) {
161 DVLOG(2) << "SetDecryptor()"; 161 DVLOG(2) << "SetDecryptor()";
162 DCHECK(message_loop_->BelongsToCurrentThread()); 162 DCHECK(message_loop_->BelongsToCurrentThread());
163 DCHECK_EQ(state_, kDecryptorRequested) << state_; 163 DCHECK_EQ(state_, kDecryptorRequested) << state_;
164 DCHECK(!init_cb_.is_null()); 164 DCHECK(!init_cb_.is_null());
165 DCHECK(!request_decryptor_notification_cb_.is_null()); 165 DCHECK(!set_decryptor_ready_cb_.is_null());
166 166
167 request_decryptor_notification_cb_.Reset(); 167 set_decryptor_ready_cb_.Reset();
168 decryptor_ = decryptor; 168 decryptor_ = decryptor;
169 169
170 scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig()); 170 scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig());
171 scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config()); 171 scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config());
172 172
173 state_ = kPendingDecoderInit; 173 state_ = kPendingDecoderInit;
174 decryptor_->InitializeAudioDecoder( 174 decryptor_->InitializeAudioDecoder(
175 scoped_config.Pass(), 175 scoped_config.Pass(),
176 BIND_TO_LOOP(&DecryptingAudioDecoder::FinishInitialization)); 176 BIND_TO_LOOP(&DecryptingAudioDecoder::FinishInitialization));
177 } 177 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( 453 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration(
454 int number_of_samples) const { 454 int number_of_samples) const {
455 DCHECK(samples_per_second_); 455 DCHECK(samples_per_second_);
456 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * 456 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond *
457 number_of_samples / 457 number_of_samples /
458 samples_per_second_); 458 samples_per_second_);
459 } 459 }
460 460
461 } // namespace media 461 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698