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

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: 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 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_decryption_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_decryption_key_cb_ = waiting_for_decryption_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_, waiting_for_decryption_key_cb_));
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_);
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(new DecryptingDemuxerStream(
134 new DecryptingDemuxerStream(task_runner_, set_decryptor_ready_cb_)); 136 task_runner_, set_decryptor_ready_cb_, waiting_for_decryption_key_cb_));
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()));
140 } 142 }
141 143
142 template <DemuxerStream::Type StreamType> 144 template <DemuxerStream::Type StreamType>
143 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone( 145 void DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone(
144 PipelineStatus status) { 146 PipelineStatus status) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 204
203 // These forward declarations tell the compiler that we will use 205 // These forward declarations tell the compiler that we will use
204 // DecoderSelector with these arguments, allowing us to keep these definitions 206 // 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 207 // in our .cc without causing linker errors. This also means if anyone tries to
206 // instantiate a DecoderSelector with anything but these two specializations 208 // instantiate a DecoderSelector with anything but these two specializations
207 // they'll most likely get linker errors. 209 // they'll most likely get linker errors.
208 template class DecoderSelector<DemuxerStream::AUDIO>; 210 template class DecoderSelector<DemuxerStream::AUDIO>;
209 template class DecoderSelector<DemuxerStream::VIDEO>; 211 template class DecoderSelector<DemuxerStream::VIDEO>;
210 212
211 } // namespace media 213 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698