OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 MEDIA_BASE_AUDIO_DECODER_H_ |
| 6 #define MEDIA_BASE_AUDIO_DECODER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/channel_layout.h" |
| 11 #include "media/base/pipeline_status.h" |
| 12 #include "media/base/media_export.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 class Buffer; |
| 17 class DemuxerStream; |
| 18 |
| 19 class MEDIA_EXPORT AudioDecoder |
| 20 : public base::RefCountedThreadSafe<AudioDecoder> { |
| 21 public: |
| 22 // Initialize an AudioDecoder with the given DemuxerStream, executing the |
| 23 // callback upon completion. |
| 24 // stats_callback is used to update global pipeline statistics. |
| 25 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 26 const PipelineStatusCB& callback, |
| 27 const StatisticsCallback& stats_callback) = 0; |
| 28 |
| 29 // Request samples to be decoded and returned via the provided callback. |
| 30 // Only one read may be in flight at any given time. |
| 31 // |
| 32 // Implementations guarantee that the callback will not be called from within |
| 33 // this method. |
| 34 // |
| 35 // Non-NULL sample buffer pointers will contain decoded audio data or may |
| 36 // indicate the end of the stream. A NULL buffer pointer indicates an aborted |
| 37 // Read(). This can happen if the DemuxerStream gets flushed and doesn't have |
| 38 // any more data to return. |
| 39 typedef base::Callback<void(scoped_refptr<Buffer>)> ReadCB; |
| 40 virtual void Read(const ReadCB& callback) = 0; |
| 41 |
| 42 // Reset decoder state, dropping any queued encoded data. |
| 43 virtual void Reset(const base::Closure& closure) = 0; |
| 44 |
| 45 // Returns various information about the decoded audio format. |
| 46 virtual int bits_per_channel() = 0; |
| 47 virtual ChannelLayout channel_layout() = 0; |
| 48 virtual int samples_per_second() = 0; |
| 49 |
| 50 protected: |
| 51 friend class base::RefCountedThreadSafe<AudioDecoder>; |
| 52 virtual ~AudioDecoder(); |
| 53 AudioDecoder(); |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
| 56 }; |
| 57 |
| 58 } // namespace media |
| 59 |
| 60 #endif // MEDIA_BASE_AUDIO_DECODER_H_ |
OLD | NEW |