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,88 @@ |
| +// 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 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 |
| + // later on before Open() is called. |
| + explicit AudioFileReader(FFmpegURLProtocol* protocol); |
| + virtual ~AudioFileReader(); |
| + |
| + // SetProtocol() may be set before a call to Open(). |
| + void SetProtocol(FFmpegURLProtocol* protocol) { protocol_ = protocol; } |
| + |
| + int Open(); |
|
scherkus (not reviewing)
2010/12/09 17:35:40
what's the result of this operation?
it looks lik
Chris Rogers
2010/12/10 23:34:00
You're right, returning bool is better - switched
|
| + void Close(); |
| + |
| + // After a call to Open(), reads |number_of_frames| into |audio_data|. |
| + // |audio_data| must be of the same size as NumberOfChannels(). |
| + // The audio data will be decoded as floating-point linear PCM with |
| + // a nominal range of -1.0 -> +1.0. |
| + // Returns 0 on success. |
| + int Read(const std::vector<float*>& audio_data, size_t number_of_frames); |
| + |
| + size_t NumberOfChannels() const; |
|
scherkus (not reviewing)
2010/12/09 17:35:40
these look like simple accessors and should be nam
Chris Rogers
2010/12/10 23:34:00
Done.
|
| + double GetSampleRate() const; |
| + double GetDuration() const; |
| + size_t Length() const; |
|
scherkus (not reviewing)
2010/12/09 17:35:40
what is length computing?
judging by the call per
Chris Rogers
2010/12/10 23:34:00
changed method name to number_of_frames()
On 2010
|
| + |
| + private: |
| + FFmpegURLProtocol* protocol_; |
| + AVFormatContext* format_context_; |
| + AVCodecContext* codec_context_; |
| + AVCodec* codec_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
| +}; |
| + |
| +class InMemoryDataReader : public FFmpegURLProtocol { |
| + public: |
| + explicit InMemoryDataReader(const char* data, int64 size); |
|
scherkus (not reviewing)
2010/12/09 17:35:40
no need for explicit
Chris Rogers
2010/12/10 23:34:00
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); |
| +}; |
| + |
| +class InMemoryAudioFileReader : public AudioFileReader { |
|
scherkus (not reviewing)
2010/12/09 17:35:40
will we ever have different AudioFileReaders?
I'm
Chris Rogers
2010/12/10 23:34:00
I've switched the code to use option (2). Strange
|
| + public: |
| + InMemoryAudioFileReader(const char* data, size_t data_size) |
| + : AudioFileReader(NULL), |
| + data_reader_(data, data_size) { |
| + SetProtocol(&data_reader_); |
| + } |
| + |
| + private: |
| + InMemoryDataReader data_reader_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InMemoryAudioFileReader); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
| Property changes on: media/filters/audio_file_reader.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |