Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_BASE_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_DECODER_H_ |
| 6 #define MEDIA_BASE_AUDIO_DECODER_H_ | 6 #define MEDIA_BASE_AUDIO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/channel_layout.h" | 10 #include "media/base/channel_layout.h" |
| 11 #include "media/base/pipeline_status.h" | 11 #include "media/base/pipeline_status.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class Buffer; | 16 class Buffer; |
| 17 class DemuxerStream; | 17 class DemuxerStream; |
| 18 | 18 |
| 19 class MEDIA_EXPORT AudioDecoder | 19 class MEDIA_EXPORT AudioDecoder |
| 20 : public base::RefCountedThreadSafe<AudioDecoder> { | 20 : public base::RefCountedThreadSafe<AudioDecoder> { |
| 21 public: | 21 public: |
| 22 // Status codes for read operations. | |
| 23 enum Status { | |
| 24 kOk, // Everything went as planned. | |
| 25 kAborted, // Read was aborted early. | |
| 26 kDecodeError, // Decoding error happened. | |
|
Ami GONE FROM CHROMIUM
2012/06/26 00:33:21
These comments aren't adding much value.
acolwell GONE FROM CHROMIUM
2012/07/12 01:19:38
Done.
| |
| 27 }; | |
| 28 | |
| 22 // Initialize an AudioDecoder with the given DemuxerStream, executing the | 29 // Initialize an AudioDecoder with the given DemuxerStream, executing the |
| 23 // callback upon completion. | 30 // callback upon completion. |
| 24 // statistics_cb is used to update global pipeline statistics. | 31 // statistics_cb is used to update global pipeline statistics. |
| 25 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 32 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
| 26 const PipelineStatusCB& status_cb, | 33 const PipelineStatusCB& status_cb, |
| 27 const StatisticsCB& statistics_cb) = 0; | 34 const StatisticsCB& statistics_cb) = 0; |
| 28 | 35 |
| 29 // Request samples to be decoded and returned via the provided callback. | 36 // Request samples to be decoded and returned via the provided callback. |
| 30 // Only one read may be in flight at any given time. | 37 // Only one read may be in flight at any given time. |
| 31 // | 38 // |
| 32 // Implementations guarantee that the callback will not be called from within | 39 // Implementations guarantee that the callback will not be called from within |
| 33 // this method. | 40 // this method. |
| 34 // | 41 // |
| 35 // Non-NULL sample buffer pointers will contain decoded audio data or may | 42 // 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 | 43 // 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 | 44 // Read(). This can happen if the DemuxerStream gets flushed and doesn't have |
| 38 // any more data to return. | 45 // any more data to return. |
| 39 typedef base::Callback<void(scoped_refptr<Buffer>)> ReadCB; | 46 typedef base::Callback<void(Status, const scoped_refptr<Buffer>&)> ReadCB; |
| 40 virtual void Read(const ReadCB& read_cb) = 0; | 47 virtual void Read(const ReadCB& read_cb) = 0; |
| 41 | 48 |
| 42 // Reset decoder state, dropping any queued encoded data. | 49 // Reset decoder state, dropping any queued encoded data. |
| 43 virtual void Reset(const base::Closure& closure) = 0; | 50 virtual void Reset(const base::Closure& closure) = 0; |
| 44 | 51 |
| 45 // Returns various information about the decoded audio format. | 52 // Returns various information about the decoded audio format. |
| 46 virtual int bits_per_channel() = 0; | 53 virtual int bits_per_channel() = 0; |
| 47 virtual ChannelLayout channel_layout() = 0; | 54 virtual ChannelLayout channel_layout() = 0; |
| 48 virtual int samples_per_second() = 0; | 55 virtual int samples_per_second() = 0; |
| 49 | 56 |
| 50 protected: | 57 protected: |
| 51 friend class base::RefCountedThreadSafe<AudioDecoder>; | 58 friend class base::RefCountedThreadSafe<AudioDecoder>; |
| 52 virtual ~AudioDecoder(); | 59 virtual ~AudioDecoder(); |
| 53 AudioDecoder(); | 60 AudioDecoder(); |
| 54 | 61 |
| 55 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 62 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 } // namespace media | 65 } // namespace media |
| 59 | 66 |
| 60 #endif // MEDIA_BASE_AUDIO_DECODER_H_ | 67 #endif // MEDIA_BASE_AUDIO_DECODER_H_ |
| OLD | NEW |