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

Side by Side Diff: media/filters/decrypting_demuxer_stream.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_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"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "media/base/audio_decoder_config.h" 12 #include "media/base/audio_decoder_config.h"
13 #include "media/base/video_decoder_config.h" 13 #include "media/base/video_decoder_config.h"
14 #include "media/base/bind_to_loop.h" 14 #include "media/base/bind_to_loop.h"
15 #include "media/base/decoder_buffer.h" 15 #include "media/base/decoder_buffer.h"
16 #include "media/base/decryptor.h" 16 #include "media/base/decryptor.h"
17 #include "media/base/demuxer_stream.h" 17 #include "media/base/demuxer_stream.h"
18 #include "media/base/pipeline.h" 18 #include "media/base/pipeline.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 #define BIND_TO_LOOP(function) \ 22 #define BIND_TO_LOOP(function) \
23 media::BindToLoop(message_loop_, base::Bind(function, this)) 23 media::BindToLoop(message_loop_, base::Bind(function, this))
24 24
25 DecryptingDemuxerStream::DecryptingDemuxerStream( 25 DecryptingDemuxerStream::DecryptingDemuxerStream(
26 const scoped_refptr<base::MessageLoopProxy>& message_loop, 26 const scoped_refptr<base::MessageLoopProxy>& message_loop,
27 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) 27 const SetDecryptorReadyCB& set_decryptor_ready_cb)
28 : message_loop_(message_loop), 28 : message_loop_(message_loop),
29 state_(kUninitialized), 29 state_(kUninitialized),
30 stream_type_(UNKNOWN), 30 stream_type_(UNKNOWN),
31 request_decryptor_notification_cb_(request_decryptor_notification_cb), 31 set_decryptor_ready_cb_(set_decryptor_ready_cb),
32 decryptor_(NULL), 32 decryptor_(NULL),
33 key_added_while_decrypt_pending_(false) { 33 key_added_while_decrypt_pending_(false) {
34 } 34 }
35 35
36 void DecryptingDemuxerStream::Initialize( 36 void DecryptingDemuxerStream::Initialize(
37 const scoped_refptr<DemuxerStream>& stream, 37 const scoped_refptr<DemuxerStream>& stream,
38 const PipelineStatusCB& status_cb) { 38 const PipelineStatusCB& status_cb) {
39 if (!message_loop_->BelongsToCurrentThread()) { 39 if (!message_loop_->BelongsToCurrentThread()) {
40 message_loop_->PostTask(FROM_HERE, base::Bind( 40 message_loop_->PostTask(FROM_HERE, base::Bind(
41 &DecryptingDemuxerStream::DoInitialize, this, stream, status_cb)); 41 &DecryptingDemuxerStream::DoInitialize, this, stream, status_cb));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 status_cb.Run(DEMUXER_ERROR_NO_SUPPORTED_STREAMS); 132 status_cb.Run(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
133 return; 133 return;
134 } 134 }
135 135
136 DCHECK(!demuxer_stream_); 136 DCHECK(!demuxer_stream_);
137 demuxer_stream_ = stream; 137 demuxer_stream_ = stream;
138 stream_type_ = stream->type(); 138 stream_type_ = stream->type();
139 init_cb_ = status_cb; 139 init_cb_ = status_cb;
140 140
141 state_ = kDecryptorRequested; 141 state_ = kDecryptorRequested;
142 request_decryptor_notification_cb_.Run( 142 set_decryptor_ready_cb_.Run(
143 BIND_TO_LOOP(&DecryptingDemuxerStream::SetDecryptor)); 143 BIND_TO_LOOP(&DecryptingDemuxerStream::SetDecryptor));
144 } 144 }
145 145
146 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { 146 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) {
147 DVLOG(2) << "SetDecryptor()"; 147 DVLOG(2) << "SetDecryptor()";
148 DCHECK(message_loop_->BelongsToCurrentThread()); 148 DCHECK(message_loop_->BelongsToCurrentThread());
149 DCHECK_EQ(state_, kDecryptorRequested) << state_; 149 DCHECK_EQ(state_, kDecryptorRequested) << state_;
150 DCHECK(!init_cb_.is_null()); 150 DCHECK(!init_cb_.is_null());
151 DCHECK(!request_decryptor_notification_cb_.is_null()); 151 DCHECK(!set_decryptor_ready_cb_.is_null());
152 152
153 request_decryptor_notification_cb_.Reset(); 153 set_decryptor_ready_cb_.Reset();
154 decryptor_ = decryptor; 154 decryptor_ = decryptor;
155 155
156 switch (stream_type_) { 156 switch (stream_type_) {
157 case AUDIO: { 157 case AUDIO: {
158 const AudioDecoderConfig& input_audio_config = 158 const AudioDecoderConfig& input_audio_config =
159 demuxer_stream_->audio_decoder_config(); 159 demuxer_stream_->audio_decoder_config();
160 audio_config_.reset(new AudioDecoderConfig()); 160 audio_config_.reset(new AudioDecoderConfig());
161 audio_config_->Initialize(input_audio_config.codec(), 161 audio_config_->Initialize(input_audio_config.codec(),
162 input_audio_config.bits_per_channel(), 162 input_audio_config.bits_per_channel(),
163 input_audio_config.channel_layout(), 163 input_audio_config.channel_layout(),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 state_ = kIdle; 342 state_ = kIdle;
343 base::ResetAndReturn(&reset_cb_).Run(); 343 base::ResetAndReturn(&reset_cb_).Run();
344 } 344 }
345 345
346 Decryptor::StreamType DecryptingDemuxerStream::GetDecryptorStreamType() const { 346 Decryptor::StreamType DecryptingDemuxerStream::GetDecryptorStreamType() const {
347 DCHECK(stream_type_ == AUDIO || stream_type_ == VIDEO); 347 DCHECK(stream_type_ == AUDIO || stream_type_ == VIDEO);
348 return stream_type_ == AUDIO ? Decryptor::kAudio : Decryptor::kVideo; 348 return stream_type_ == AUDIO ? Decryptor::kAudio : Decryptor::kVideo;
349 } 349 }
350 350
351 } // namespace media 351 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698