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

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

Issue 2808093008: Fix disabling FFMpeg video decoders on non-Android platforms (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « media/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/filters/decoder_selector.h" 5 #include "media/filters/decoder_selector.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "media/base/audio_decoder.h" 14 #include "media/base/audio_decoder.h"
15 #include "media/base/bind_to_current_loop.h" 15 #include "media/base/bind_to_current_loop.h"
16 #include "media/base/cdm_context.h" 16 #include "media/base/cdm_context.h"
17 #include "media/base/demuxer_stream.h" 17 #include "media/base/demuxer_stream.h"
18 #include "media/base/media_log.h" 18 #include "media/base/media_log.h"
19 #include "media/base/video_decoder.h" 19 #include "media/base/video_decoder.h"
20 #include "media/filters/decoder_stream_traits.h" 20 #include "media/filters/decoder_stream_traits.h"
21 #include "media/filters/decrypting_demuxer_stream.h" 21 #include "media/filters/decrypting_demuxer_stream.h"
22 22
23 #if !defined(OS_ANDROID) 23 #if !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
24 #include "media/filters/decrypting_audio_decoder.h" 24 #include "media/filters/decrypting_audio_decoder.h"
25 #include "media/filters/decrypting_video_decoder.h" 25 #include "media/filters/decrypting_video_decoder.h"
26 #endif 26 #endif
27 27
28 namespace media { 28 namespace media {
29 29
30 static bool HasValidStreamConfig(DemuxerStream* stream) { 30 static bool HasValidStreamConfig(DemuxerStream* stream) {
31 switch (stream->type()) { 31 switch (stream->type()) {
32 case DemuxerStream::AUDIO: 32 case DemuxerStream::AUDIO:
33 return stream->audio_decoder_config().IsValidConfig(); 33 return stream->audio_decoder_config().IsValidConfig();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return; 89 return;
90 } 90 }
91 91
92 traits_ = traits; 92 traits_ = traits;
93 input_stream_ = stream; 93 input_stream_ = stream;
94 output_cb_ = output_cb; 94 output_cb_ = output_cb;
95 95
96 // When there is a CDM attached, always try the decrypting decoder or 96 // When there is a CDM attached, always try the decrypting decoder or
97 // demuxer-stream first. 97 // demuxer-stream first.
98 if (cdm_context_) { 98 if (cdm_context_) {
99 #if !defined(OS_ANDROID) 99 #if !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
100 InitializeDecryptingDecoder(); 100 InitializeDecryptingDecoder();
101 #else 101 #else
102 InitializeDecryptingDemuxerStream(); 102 InitializeDecryptingDemuxerStream();
103 #endif 103 #endif
104 return; 104 return;
105 } 105 }
106 106
107 config_ = StreamTraits::GetDecoderConfig(input_stream_); 107 config_ = StreamTraits::GetDecoderConfig(input_stream_);
108 108
109 // If the input stream is encrypted, CdmContext must be non-null. 109 // If the input stream is encrypted, CdmContext must be non-null.
110 DCHECK(!config_.is_encrypted()); 110 DCHECK(!config_.is_encrypted());
111 111
112 InitializeDecoder(); 112 InitializeDecoder();
113 } 113 }
114 114
115 #if !defined(OS_ANDROID) 115 #if !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
116 template <DemuxerStream::Type StreamType> 116 template <DemuxerStream::Type StreamType>
117 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() { 117 void DecoderSelector<StreamType>::InitializeDecryptingDecoder() {
118 DVLOG(2) << __func__; 118 DVLOG(2) << __func__;
119 decoder_.reset(new typename StreamTraits::DecryptingDecoderType( 119 decoder_.reset(new typename StreamTraits::DecryptingDecoderType(
120 task_runner_, media_log_, waiting_for_decryption_key_cb_)); 120 task_runner_, media_log_, waiting_for_decryption_key_cb_));
121 121
122 traits_->InitializeDecoder( 122 traits_->InitializeDecoder(
123 decoder_.get(), StreamTraits::GetDecoderConfig(input_stream_), 123 decoder_.get(), StreamTraits::GetDecoderConfig(input_stream_),
124 input_stream_->liveness() == DemuxerStream::LIVENESS_LIVE, cdm_context_, 124 input_stream_->liveness() == DemuxerStream::LIVENESS_LIVE, cdm_context_,
125 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 125 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
(...skipping 12 matching lines...) Expand all
138 .Run(std::move(decoder_), std::unique_ptr<DecryptingDemuxerStream>()); 138 .Run(std::move(decoder_), std::unique_ptr<DecryptingDemuxerStream>());
139 return; 139 return;
140 } 140 }
141 141
142 decoder_.reset(); 142 decoder_.reset();
143 143
144 // When we get here decrypt-and-decode is not supported. Try to use 144 // When we get here decrypt-and-decode is not supported. Try to use
145 // DecryptingDemuxerStream to do decrypt-only. 145 // DecryptingDemuxerStream to do decrypt-only.
146 InitializeDecryptingDemuxerStream(); 146 InitializeDecryptingDemuxerStream();
147 } 147 }
148 #endif // !defined(OS_ANDROID) 148 #endif // !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
149 149
150 template <DemuxerStream::Type StreamType> 150 template <DemuxerStream::Type StreamType>
151 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() { 151 void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() {
152 decrypted_stream_.reset(new DecryptingDemuxerStream( 152 decrypted_stream_.reset(new DecryptingDemuxerStream(
153 task_runner_, media_log_, waiting_for_decryption_key_cb_)); 153 task_runner_, media_log_, waiting_for_decryption_key_cb_));
154 154
155 decrypted_stream_->Initialize( 155 decrypted_stream_->Initialize(
156 input_stream_, cdm_context_, 156 input_stream_, cdm_context_,
157 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone, 157 base::Bind(&DecoderSelector<StreamType>::DecryptingDemuxerStreamInitDone,
158 weak_ptr_factory_.GetWeakPtr())); 158 weak_ptr_factory_.GetWeakPtr()));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 // These forward declarations tell the compiler that we will use 240 // These forward declarations tell the compiler that we will use
241 // DecoderSelector with these arguments, allowing us to keep these definitions 241 // DecoderSelector with these arguments, allowing us to keep these definitions
242 // in our .cc without causing linker errors. This also means if anyone tries to 242 // in our .cc without causing linker errors. This also means if anyone tries to
243 // instantiate a DecoderSelector with anything but these two specializations 243 // instantiate a DecoderSelector with anything but these two specializations
244 // they'll most likely get linker errors. 244 // they'll most likely get linker errors.
245 template class DecoderSelector<DemuxerStream::AUDIO>; 245 template class DecoderSelector<DemuxerStream::AUDIO>;
246 template class DecoderSelector<DemuxerStream::VIDEO>; 246 template class DecoderSelector<DemuxerStream::VIDEO>;
247 247
248 } // namespace media 248 } // namespace media
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698