Index: media/filters/audio_decoder_factory.h |
diff --git a/media/filters/audio_decoder_factory.h b/media/filters/audio_decoder_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..faea61de6e1f9926fbe62a7b79a3b9ef3d6f4d03 |
--- /dev/null |
+++ b/media/filters/audio_decoder_factory.h |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_FILTERS_AUDIO_DECODER_FACTORY_H_ |
+#define MEDIA_FILTERS_AUDIO_DECODER_FACTORY_H_ |
+ |
+#include <list> |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "media/base/audio_decoder.h" |
+#include "media/base/decryptor.h" |
+#include "media/base/demuxer_stream.h" |
+ |
+namespace base { |
+class MessageLoopProxy; |
+} |
+ |
+namespace media { |
+ |
+class DecoderBuffer; |
+class DecryptingDemuxerStream; |
+class Decryptor; |
+ |
+// AudioDecoderFactory (creates if necessary and) initializes the proper |
+// AudioDecoder for a given DemuxerStream. If the given DemuxerStream is |
+// encrypted, a DecryptingDemuxerStream may also be created. |
+class MEDIA_EXPORT AudioDecoderFactory { |
ddorwin
2012/12/11 05:13:34
It's odd for a factory to have state. This factory
xhwang
2012/12/12 23:43:28
It's not factory anymore.
|
+ public: |
+ typedef std::list<scoped_refptr<AudioDecoder> > AudioDecoderList; |
+ |
+ // Indicates completion of AudioDecoder initialization. |
+ // |
+ // First parameter: The initialized AudioDecoder. If it's set to NULL, then |
+ // AudioDecoder initialization failed. |
scherkus (not reviewing)
2012/12/11 20:52:15
nit: this style of indentation is a waste of valua
xhwang
2012/12/12 23:43:28
Done.
|
+ // Second parameter: The initialized DecryptingDemuxerStream. If it's not |
+ // NULL, then a DecryptingDemuxerStream is created and |
+ // initialized to do decryption for the initialized |
+ // AudioDecoder. |
+ typedef base::Callback< |
+ void(const scoped_refptr<AudioDecoder>&, |
+ const scoped_refptr<DecryptingDemuxerStream>&)> InitDoneCB; |
ddorwin
2012/12/11 05:13:34
Should the callback be DecoderCreatedCB?
xhwang
2012/12/12 23:43:28
Changed to DecoderSlectedCB.
xhwang
2012/12/12 23:43:28
Done.
|
+ |
+ // If |request_decryptor_notification_cb| is null, no decryptor will be |
+ // available to perform decryption. |
ddorwin
2012/12/11 05:13:34
I don't understand? The factory will not support d
xhwang
2012/12/11 19:43:04
When --enable-encrypted-media is not set, we don't
ddorwin
2012/12/12 00:30:25
Why not use an explicit control (Boolean)? It does
xhwang
2012/12/12 23:43:28
Yep, will keep what I have here.
|
+ AudioDecoderFactory( |
+ const scoped_refptr<base::MessageLoopProxy>& message_loop, |
ddorwin
2012/12/12 00:30:25
Is there a method/pattern to who parameters are pa
xhwang
2012/12/12 23:43:28
Not sure, keep the code as is unless anybody objec
|
+ const AudioDecoderList& precreated_decoders, |
ddorwin
2012/12/11 05:13:34
"precreated" is an odd term.
xhwang
2012/12/11 19:43:04
How about "default", to match "AddDefaultDecodersT
ddorwin
2012/12/12 00:30:25
Sounds better, BUT not all are default. When we do
|
+ const RequestDecryptorNotificationCB& request_decryptor_notification_cb); |
+ ~AudioDecoderFactory(); |
+ |
+ void InitAudioDecoder(const scoped_refptr<DemuxerStream>& stream, |
ddorwin
2012/12/11 05:13:34
Is this Init or Create?
xhwang
2012/12/11 19:43:04
Well, this is tricky. The accurate name should be
ddorwin
2012/12/12 00:30:25
Select? Get? Obtain?
On a related note, Factories
xhwang
2012/12/12 23:43:28
Renamed to Select. Class name renamed also.
|
+ const StatisticsCB& statistics_cb, |
+ const InitDoneCB& init_done_cb); |
+ |
+ private: |
+ void DecryptingAudioDecoderInitDone(PipelineStatus status); |
+ void DecryptingDemuxerStreamInitDone(PipelineStatus status); |
+ void InitializeNextPrecreatedDecoder(); |
+ void PrecreatedDecoderInitDone(PipelineStatus status); |
+ |
+ scoped_refptr<base::MessageLoopProxy> message_loop_; |
+ AudioDecoderList precreated_decoders_; |
+ RequestDecryptorNotificationCB request_decryptor_notification_cb_; |
+ |
+ scoped_refptr<DemuxerStream> input_stream_; |
+ StatisticsCB statistics_cb_; |
+ InitDoneCB init_done_cb_; |
+ |
+ scoped_refptr<AudioDecoder> audio_decoder_; |
+ scoped_refptr<DecryptingDemuxerStream> decrypted_stream_; |
+ |
+ base::WeakPtrFactory<AudioDecoderFactory> weak_ptr_factory_; |
+ base::WeakPtr<AudioDecoderFactory> weak_this_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioDecoderFactory); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_FILTERS_AUDIO_DECODER_FACTORY_H_ |