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

Side by Side Diff: media/filters/audio_file_reader.h

Issue 5550006: Implement WebKitClientImpl::loadAudioResource() to decode in-memory audio fil... (Closed) Base URL: http://src.chromium.org/svn/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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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_FILTERS_AUDIO_FILE_READER_H_
6 #define MEDIA_FILTERS_AUDIO_FILE_READER_H_
7
8 #include <vector>
9 #include "media/filters/ffmpeg_glue.h"
10
11 struct AVCodec;
12 struct AVCodecContext;
13 struct AVFormatContext;
14
15 namespace base { class TimeDelta; }
16
17 namespace media {
18
19 class FFmpegURLProtocol;
20
21 class AudioFileReader {
22 public:
23 // Audio file data will be read using the given protocol.
24 // 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.
25 // later on before Open() is called.
26 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.
27 virtual ~AudioFileReader();
28
29 // Open() reads the audio data format so that the sample_rate(),
30 // channels(), duration(), and number_of_frames() methods can be called.
31 // It returns |true| on success.
32 bool Open();
33 void Close();
34
35 // After a call to Open(), reads |number_of_frames| into |audio_data|.
36 // |audio_data| must be of the same size as channels().
37 // The audio data will be decoded as floating-point linear PCM with
38 // a nominal range of -1.0 -> +1.0.
39 // Returns |true| on success.
40 bool Read(const std::vector<float*>& audio_data, size_t number_of_frames);
41
42 // These methods can be called once Open() has been called.
43 int channels() const;
44 int sample_rate() const;
45 base::TimeDelta duration() const;
46 int64 number_of_frames() const;
47
48 private:
49 FFmpegURLProtocol* protocol_;
50 AVFormatContext* format_context_;
51 AVCodecContext* codec_context_;
52 AVCodec* codec_;
53
54 DISALLOW_COPY_AND_ASSIGN(AudioFileReader);
55 };
56
57 class InMemoryDataReader : public FFmpegURLProtocol {
58 public:
59 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.
60
61 virtual int Read(int size, uint8* data);
62 virtual bool GetPosition(int64* position_out);
63 virtual bool SetPosition(int64 position);
64 virtual bool GetSize(int64* size_out);
65 virtual bool IsStreaming();
66
67 private:
68 const char* data_;
69 int64 size_;
70 int64 position_;
71
72 DISALLOW_COPY_AND_ASSIGN(InMemoryDataReader);
73 };
74
75 } // namespace media
76
77 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698