Chromium Code Reviews| Index: media/filters/audio_file_reader.h |
| =================================================================== |
| --- media/filters/audio_file_reader.h (revision 0) |
| +++ media/filters/audio_file_reader.h (revision 0) |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2010 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_FILE_READER_H_ |
| +#define MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
| + |
| +#include <vector> |
| +#include "media/filters/ffmpeg_glue.h" |
| + |
| +struct AVCodec; |
| +struct AVCodecContext; |
| +struct AVFormatContext; |
| + |
| +namespace base { class TimeDelta; } |
| + |
| +namespace media { |
| + |
| +class FFmpegURLProtocol; |
| + |
| +class AudioFileReader { |
| + public: |
| + // Audio file data will be read using the given protocol. |
| + // Optionally, NULL may be passed in and SetProtocal() can be called |
|
scherkus (not reviewing)
2010/12/11 02:31:12
comment needs updating
Chris Rogers
2010/12/13 20:25:27
Done.
|
| + // later on before Open() is called. |
| + explicit AudioFileReader(FFmpegURLProtocol* protocol); |
|
scherkus (not reviewing)
2010/12/11 02:31:12
can you add comment on ownership? is AudioFileRea
Chris Rogers
2010/12/13 20:25:27
Done.
|
| + virtual ~AudioFileReader(); |
| + |
| + // Open() reads the audio data format so that the sample_rate(), |
| + // channels(), duration(), and number_of_frames() methods can be called. |
| + // It returns |true| on success. |
| + bool Open(); |
| + void Close(); |
| + |
| + // After a call to Open(), reads |number_of_frames| into |audio_data|. |
| + // |audio_data| must be of the same size as channels(). |
| + // The audio data will be decoded as floating-point linear PCM with |
| + // a nominal range of -1.0 -> +1.0. |
| + // Returns |true| on success. |
| + bool Read(const std::vector<float*>& audio_data, size_t number_of_frames); |
| + |
| + // These methods can be called once Open() has been called. |
| + int channels() const; |
| + int sample_rate() const; |
| + base::TimeDelta duration() const; |
| + int64 number_of_frames() const; |
| + |
| + private: |
| + FFmpegURLProtocol* protocol_; |
| + AVFormatContext* format_context_; |
| + AVCodecContext* codec_context_; |
| + AVCodec* codec_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
| +}; |
| + |
| +class InMemoryDataReader : public FFmpegURLProtocol { |
| + public: |
| + InMemoryDataReader(const char* data, int64 size); |
|
scherkus (not reviewing)
2010/12/11 02:31:12
can you add comment on ownership? is InMemoryData
Chris Rogers
2010/12/13 20:25:27
Done.
|
| + |
| + virtual int Read(int size, uint8* data); |
| + virtual bool GetPosition(int64* position_out); |
| + virtual bool SetPosition(int64 position); |
| + virtual bool GetSize(int64* size_out); |
| + virtual bool IsStreaming(); |
| + |
| + private: |
| + const char* data_; |
| + int64 size_; |
| + int64 position_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InMemoryDataReader); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
| Property changes on: media/filters/audio_file_reader.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |