Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Unified Diff: media/filters/audio_file_reader.h

Issue 5880002: (Committing on behalf of Chris Rogers -- original CL... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_util.cc ('k') | media/filters/audio_file_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,79 @@
+// 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.
+ // The AudioFileReader does not take ownership of |protocol| and
+ // simply maintains a weak reference to it.
+ explicit AudioFileReader(FFmpegURLProtocol* protocol);
+ 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:
+ // Ownership of |data| is not taken, instead it simply maintains
+ // a weak reference.
+ InMemoryDataReader(const char* data, int64 size);
+
+ 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
« no previous file with comments | « media/audio/audio_util.cc ('k') | media/filters/audio_file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698