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

Unified Diff: media/filters/decoder_selector.h

Issue 2837613004: media: Support better decoder switching (Closed)
Patch Set: Mock*Decoder name Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/decoder_selector.h
diff --git a/media/filters/decoder_selector.h b/media/filters/decoder_selector.h
index 3ce4df6b201333d54617973dc02c8f7043a53598..0a30989b137db40c773f5c9a9bedce9b56ee4fd5 100644
--- a/media/filters/decoder_selector.h
+++ b/media/filters/decoder_selector.h
@@ -39,6 +39,11 @@ class MEDIA_EXPORT DecoderSelector {
typedef typename StreamTraits::DecoderType Decoder;
typedef typename StreamTraits::DecoderConfigType DecoderConfig;
+ // Callback to create a list of decoders to select from.
+ // TODO(xhwang): Use a DecoderFactory to create decoders one by one as needed,
+ // instead of creating a list of decoders all at once.
+ using CreateDecodersCB = base::RepeatingCallback<ScopedVector<Decoder>()>;
+
// Indicates completion of Decoder selection.
// - First parameter: The initialized Decoder. If it's set to NULL, then
// Decoder initialization failed.
@@ -48,18 +53,17 @@ class MEDIA_EXPORT DecoderSelector {
// Note: The caller owns selected Decoder and DecryptingDemuxerStream.
// The caller should call DecryptingDemuxerStream::Reset() before
// calling Decoder::Reset() to release any pending decryption or read.
- typedef base::Callback<void(std::unique_ptr<Decoder>,
- std::unique_ptr<DecryptingDemuxerStream>)>
- SelectDecoderCB;
+ using SelectDecoderCB =
+ base::Callback<void(std::unique_ptr<Decoder>,
+ std::unique_ptr<DecryptingDemuxerStream>)>;
- // |decoders| contains the Decoders to use when initializing.
DecoderSelector(
- const scoped_refptr<base::SingleThreadTaskRunner>& message_loop,
- ScopedVector<Decoder> decoders,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ CreateDecodersCB create_decoders_cb,
MediaLog* media_log);
// Aborts pending Decoder selection and fires |select_decoder_cb| with
- // NULL and NULL immediately if it's pending.
+ // null and null immediately if it's pending.
~DecoderSelector();
// Initializes and selects the first Decoder that can decode the |stream|.
@@ -67,13 +71,20 @@ class MEDIA_EXPORT DecoderSelector {
// the |select_decoder_cb|.
// Notes:
// 1. This must not be called again before |select_decoder_cb| is run.
- // 2. Decoders that fail to initialize will be deleted. Future calls will
- // select from the decoders following the decoder that was last returned.
- // 3. |cdm_context| is optional. If |cdm_context| is
- // null, no CDM will be available to perform decryption.
+ // 2. |create_decoders_cb| will be called to create a list of candidate
+ // decoders to select from.
+ // 3. The |blacklisted_decoder| will be skipped in the decoder selection
+ // process, unless DecryptingDemuxerStream is chosen. This is because
+ // DecryptingDemuxerStream updates the |config_|, and the blacklist should
+ // only be applied to the original |stream| config.
+ // 4. All decoders that are not selected will be deleted upon returning
+ // |select_decoder_cb|.
+ // 5. |cdm_context| is optional. If |cdm_context| is null, no CDM will be
+ // available to perform decryption.
void SelectDecoder(StreamTraits* traits,
DemuxerStream* stream,
CdmContext* cdm_context,
+ const std::string& blacklisted_decoder,
const SelectDecoderCB& select_decoder_cb,
const typename Decoder::OutputCB& output_cb,
const base::Closure& waiting_for_decryption_key_cb);
@@ -90,7 +101,7 @@ class MEDIA_EXPORT DecoderSelector {
void ReturnNullDecoder();
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- ScopedVector<Decoder> decoders_;
+ CreateDecodersCB create_decoders_cb_;
MediaLog* media_log_;
StreamTraits* traits_;
@@ -100,10 +111,13 @@ class MEDIA_EXPORT DecoderSelector {
DemuxerStream* input_stream_;
CdmContext* cdm_context_;
+ std::string blacklisted_decoder_;
SelectDecoderCB select_decoder_cb_;
typename Decoder::OutputCB output_cb_;
base::Closure waiting_for_decryption_key_cb_;
+ ScopedVector<Decoder> decoders_;
+
std::unique_ptr<Decoder> decoder_;
std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_;

Powered by Google App Engine
This is Rietveld 408576698