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

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

Issue 935243002: Decryptors can report kNoKey to WebMediaPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "decoder_selector.h" 5 #include "decoder_selector.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/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 decoder_.reset(); 69 decoder_.reset();
70 decrypted_stream_.reset(); 70 decrypted_stream_.reset();
71 } 71 }
72 72
73 template <DemuxerStream::Type StreamType> 73 template <DemuxerStream::Type StreamType>
74 void DecoderSelector<StreamType>::SelectDecoder( 74 void DecoderSelector<StreamType>::SelectDecoder(
75 DemuxerStream* stream, 75 DemuxerStream* stream,
76 const SetDecryptorReadyCB& set_decryptor_ready_cb, 76 const SetDecryptorReadyCB& set_decryptor_ready_cb,
77 const SelectDecoderCB& select_decoder_cb, 77 const SelectDecoderCB& select_decoder_cb,
78 const typename Decoder::OutputCB& output_cb) { 78 const typename Decoder::OutputCB& output_cb,
79 const base::Closure& waiting_for_encryption_key_cb) {
79 DVLOG(2) << __FUNCTION__; 80 DVLOG(2) << __FUNCTION__;
80 DCHECK(task_runner_->BelongsToCurrentThread()); 81 DCHECK(task_runner_->BelongsToCurrentThread());
81 DCHECK(stream); 82 DCHECK(stream);
82 DCHECK(select_decoder_cb_.is_null()); 83 DCHECK(select_decoder_cb_.is_null());
83 84
84 set_decryptor_ready_cb_ = set_decryptor_ready_cb; 85 set_decryptor_ready_cb_ = set_decryptor_ready_cb;
86 waiting_for_encryption_key_cb_ = waiting_for_encryption_key_cb;
85 87
86 // Make sure |select_decoder_cb| runs on a different execution stack. 88 // Make sure |select_decoder_cb| runs on a different execution stack.
87 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb); 89 select_decoder_cb_ = BindToCurrentLoop(select_decoder_cb);
88 90
89 if (!HasValidStreamConfig(stream)) { 91 if (!HasValidStreamConfig(stream)) {
90 DLOG(ERROR) << "Invalid stream config."; 92 DLOG(ERROR) << "Invalid stream config.";
91 ReturnNullDecoder(); 93 ReturnNullDecoder();
92 return; 94 return;
93 } 95 }
94 96
95 input_stream_ = stream; 97 input_stream_ = stream;
96 output_cb_ = output_cb; 98 output_cb_ = output_cb;
97 99
98 if (!IsStreamEncrypted(input_stream_)) { 100 if (!IsStreamEncrypted(input_stream_)) {
99 InitializeDecoder(); 101 InitializeDecoder();
100 return; 102 return;
101 } 103 }
102 104
103 // This could be null if Encrypted Media Extension (EME) is not enabled. 105 // This could be null if Encrypted Media Extension (EME) is not enabled.
104 if (set_decryptor_ready_cb_.is_null()) { 106 if (set_decryptor_ready_cb_.is_null()) {
105 ReturnNullDecoder(); 107 ReturnNullDecoder();
106 return; 108 return;
107 } 109 }
108 110
109 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( 111 decoder_.reset(new typename StreamTraits::DecryptingDecoderType(
110 task_runner_, set_decryptor_ready_cb_)); 112 task_runner_, set_decryptor_ready_cb_));
ddorwin 2015/02/19 05:33:17 Can we just pass waiting_for_encryption_key_cb_ he
jrummell 2015/02/23 22:06:32 Done.
111 113
112 DecoderStreamTraits<StreamType>::InitializeDecoder( 114 DecoderStreamTraits<StreamType>::InitializeDecoder(
113 decoder_.get(), input_stream_, 115 decoder_.get(), input_stream_,
114 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 116 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
115 weak_ptr_factory_.GetWeakPtr()), 117 weak_ptr_factory_.GetWeakPtr()),
116 output_cb_); 118 output_cb_, waiting_for_encryption_key_cb_);
117 } 119 }
118 120
119 template <DemuxerStream::Type StreamType> 121 template <DemuxerStream::Type StreamType>
120 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( 122 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(
121 PipelineStatus status) { 123 PipelineStatus status) {
122 DVLOG(2) << __FUNCTION__; 124 DVLOG(2) << __FUNCTION__;
123 DCHECK(task_runner_->BelongsToCurrentThread()); 125 DCHECK(task_runner_->BelongsToCurrentThread());
124 126
125 if (status == PIPELINE_OK) { 127 if (status == PIPELINE_OK) {
126 base::ResetAndReturn(&select_decoder_cb_) 128 base::ResetAndReturn(&select_decoder_cb_)
127 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); 129 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>());
128 return; 130 return;
129 } 131 }
130 132
131 decoder_.reset(); 133 decoder_.reset();
132 134
133 decrypted_stream_.reset( 135 decrypted_stream_.reset(
134 new DecryptingDemuxerStream(task_runner_, set_decryptor_ready_cb_)); 136 new DecryptingDemuxerStream(task_runner_, set_decryptor_ready_cb_));
ddorwin 2015/02/19 05:33:17 ditto
jrummell 2015/02/23 22:06:32 Done.
135 137
136 decrypted_stream_->Initialize( 138 decrypted_stream_->Initialize(
137 input_stream_, 139 input_stream_,
138 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, 140 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone,
139 weak_ptr_factory_.GetWeakPtr())); 141 weak_ptr_factory_.GetWeakPtr()),
142 waiting_for_encryption_key_cb_);
140 } 143 }
141 144
142 template <DemuxerStream::Type StreamType> 145 template <DemuxerStream::Type StreamType>
143 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( 146 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone(
144 PipelineStatus status) { 147 PipelineStatus status) {
145 DVLOG(2) << __FUNCTION__; 148 DVLOG(2) << __FUNCTION__;
146 DCHECK(task_runner_->BelongsToCurrentThread()); 149 DCHECK(task_runner_->BelongsToCurrentThread());
147 150
148 if (status != PIPELINE_OK) { 151 if (status != PIPELINE_OK) {
149 ReturnNullDecoder(); 152 ReturnNullDecoder();
(...skipping 16 matching lines...) Expand all
166 return; 169 return;
167 } 170 }
168 171
169 decoder_.reset(decoders_.front()); 172 decoder_.reset(decoders_.front());
170 decoders_.weak_erase(decoders_.begin()); 173 decoders_.weak_erase(decoders_.begin());
171 174
172 DecoderStreamTraits<StreamType>::InitializeDecoder( 175 DecoderStreamTraits<StreamType>::InitializeDecoder(
173 decoder_.get(), input_stream_, 176 decoder_.get(), input_stream_,
174 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone, 177 base::Bind(&DecoderSelector<StreamType>::DecoderInitDone,
175 weak_ptr_factory_.GetWeakPtr()), 178 weak_ptr_factory_.GetWeakPtr()),
176 output_cb_); 179 output_cb_, waiting_for_encryption_key_cb_);
177 } 180 }
178 181
179 template <DemuxerStream::Type StreamType> 182 template <DemuxerStream::Type StreamType>
180 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) { 183 void DecoderSelector<StreamType>::DecoderInitDone(PipelineStatus status) {
181 DVLOG(2) << __FUNCTION__; 184 DVLOG(2) << __FUNCTION__;
182 DCHECK(task_runner_->BelongsToCurrentThread()); 185 DCHECK(task_runner_->BelongsToCurrentThread());
183 186
184 if (status != PIPELINE_OK) { 187 if (status != PIPELINE_OK) {
185 decoder_.reset(); 188 decoder_.reset();
186 InitializeDecoder(); 189 InitializeDecoder();
(...skipping 15 matching lines...) Expand all
202 205
203 // These forward declarations tell the compiler that we will use 206 // These forward declarations tell the compiler that we will use
204 // DecoderSelector with these arguments, allowing us to keep these definitions 207 // DecoderSelector with these arguments, allowing us to keep these definitions
205 // in our .cc without causing linker errors. This also means if anyone tries to 208 // in our .cc without causing linker errors. This also means if anyone tries to
206 // instantiate a DecoderSelector with anything but these two specializations 209 // instantiate a DecoderSelector with anything but these two specializations
207 // they'll most likely get linker errors. 210 // they'll most likely get linker errors.
208 template class DecoderSelector<DemuxerStream::AUDIO>; 211 template class DecoderSelector<DemuxerStream::AUDIO>;
209 template class DecoderSelector<DemuxerStream::VIDEO>; 212 template class DecoderSelector<DemuxerStream::VIDEO>;
210 213
211 } // namespace media 214 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698