Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMECAST_INTERNAL_MEDIA_DECODER_CAST_AUDIO_DECODER_H_ | |
| 6 #define CHROMECAST_INTERNAL_MEDIA_DECODER_CAST_AUDIO_DECODER_H_ | |
|
halliwell
2015/12/02 19:51:23
nit: update header guard
kmackay
2015/12/02 21:11:53
Done.
| |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class SingleThreadTaskRunner; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace chromecast { | |
| 17 namespace media { | |
| 18 struct AudioConfig; | |
| 19 class DecoderBufferBase; | |
| 20 } | |
|
halliwell
2015/12/02 19:51:23
I think CastAudioDecoder should also be in chromec
kmackay
2015/12/02 21:11:53
Done.
| |
| 21 | |
| 22 // Audio decoder interface. | |
| 23 class CastAudioDecoder { | |
| 24 public: | |
| 25 enum Status { | |
| 26 kDecodeOk, | |
| 27 kDecodeError, | |
| 28 }; | |
| 29 | |
| 30 enum OutputFormat { | |
| 31 kOutputSigned16, // Output signed 16-bit interleaved samples. | |
| 32 kOutputPlanarFloat, // Output planar float samples. | |
| 33 }; | |
| 34 | |
| 35 // The callback that is called when the decoder initialization is complete. | |
| 36 // |success| is true if initialization was successful; if |success| is false | |
| 37 // then the CastAudioDecoder instance is unusable and should be destroyed. | |
| 38 typedef base::Callback<void(bool success)> InitializedCallback; | |
| 39 typedef base::Callback<void( | |
| 40 Status status, | |
| 41 const scoped_refptr<media::DecoderBufferBase>& decoded)> DecodeCallback; | |
| 42 | |
| 43 // Creates a CastAudioDecoder instance for the given |config|. Decoding must | |
| 44 // occur on the same thread as |task_runner|. Returns an empty scoped_ptr if | |
| 45 // the decoder could not be created. | |
| 46 static scoped_ptr<CastAudioDecoder> Create( | |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
| 48 const media::AudioConfig& config, | |
| 49 OutputFormat output_format, | |
| 50 const InitializedCallback& initialized_callback); | |
| 51 | |
| 52 // Given a CastAudioDecoder::OutputFormat, return the size of each sample in | |
| 53 // that OutputFormat in bytes. | |
| 54 static int OutputFormatSizeInBytes(CastAudioDecoder::OutputFormat format); | |
| 55 | |
| 56 CastAudioDecoder() {} | |
| 57 virtual ~CastAudioDecoder() {} | |
| 58 | |
| 59 // Converts encoded data to the |output_format|. Must be called on the same | |
| 60 // thread as |task_runner|. Decoded data will be passed to |decode_callback|. | |
| 61 // It is OK to call Decode before the |initialized_callback| has been called; | |
| 62 // those buffers will be queued until initialization completes, at which point | |
| 63 // they will be decoded in order (if initialization was successful), or | |
| 64 // ignored if initialization failed. | |
| 65 // It is OK to pass an end-of-stream DecoderBuffer as |data|. | |
| 66 // Returns |false| if the decoder is not ready yet. | |
| 67 virtual bool Decode(const scoped_refptr<media::DecoderBufferBase>& data, | |
| 68 const DecodeCallback& decode_callback) = 0; | |
| 69 | |
| 70 private: | |
| 71 DISALLOW_COPY_AND_ASSIGN(CastAudioDecoder); | |
| 72 }; | |
| 73 | |
| 74 } // namespace chromecast | |
| 75 | |
| 76 #endif // CHROMECAST_INTERNAL_MEDIA_DECODER_CAST_AUDIO_DECODER_H_ | |
| OLD | NEW |