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

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

Issue 2655783004: Decode entire in-memory file for WebAudio (Closed)
Patch Set: Remove old implmenetation and update tests Created 3 years, 10 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_FILTERS_AUDIO_FILE_READER_H_ 5 #ifndef MEDIA_FILTERS_AUDIO_FILE_READER_H_
6 #define MEDIA_FILTERS_AUDIO_FILE_READER_H_ 6 #define MEDIA_FILTERS_AUDIO_FILE_READER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "media/base/audio_codecs.h" 12 #include "media/base/audio_codecs.h"
12 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
13 #include "media/ffmpeg/ffmpeg_deleters.h" 14 #include "media/ffmpeg/ffmpeg_deleters.h"
14 #include "media/filters/ffmpeg_glue.h" 15 #include "media/filters/ffmpeg_glue.h"
15 16
16 struct AVCodecContext; 17 struct AVCodecContext;
17 struct AVPacket; 18 struct AVPacket;
18 struct AVStream; 19 struct AVStream;
(...skipping 12 matching lines...) Expand all
31 // simply maintains a weak reference to it. 32 // simply maintains a weak reference to it.
32 explicit AudioFileReader(FFmpegURLProtocol* protocol); 33 explicit AudioFileReader(FFmpegURLProtocol* protocol);
33 virtual ~AudioFileReader(); 34 virtual ~AudioFileReader();
34 35
35 // Open() reads the audio data format so that the sample_rate(), 36 // Open() reads the audio data format so that the sample_rate(),
36 // channels(), GetDuration(), and GetNumberOfFrames() methods can be called. 37 // channels(), GetDuration(), and GetNumberOfFrames() methods can be called.
37 // It returns |true| on success. 38 // It returns |true| on success.
38 bool Open(); 39 bool Open();
39 void Close(); 40 void Close();
40 41
41 // After a call to Open(), attempts to fully fill |audio_bus| with decoded 42 // Returns true if (an estimated) duration of the audio data is
42 // audio data. Any unfilled frames will be zeroed out. 43 // known. Must be called after Open();
43 // |audio_data| must be of the same size as channels(). 44 bool HasKnownDuration() const;
44 // The audio data will be decoded as floating-point linear PCM with 45
45 // a nominal range of -1.0 -> +1.0. 46 // After a call to Open(), attempts to decode the entire data,
46 // Returns the number of sample-frames actually read which will always be 47 // updating |decodedAudioPackets| with each decoded packet in order.
47 // <= audio_bus->frames() 48 // The caller must convert these packets into one complete set of
48 int Read(AudioBus* audio_bus); 49 // decoded audio data. The audio data will be decoded as
50 // floating-point linear PCM with a nominal range of -1.0 -> +1.0.
51 // Returns the number of sample-frames actually read which will
52 // always be the total size of all the frames in
53 // |decodedAudioPackets|.
54 int Read(std::vector<std::unique_ptr<AudioBus>>& decodedAudioPackets);
DaleCurtis 2017/02/09 18:47:36 Pass by pointer instead of ref. decoded_audio_pack
Raymond Toy 2017/02/09 18:56:12 Good point. I expect the size of this vector to be
Raymond Toy 2017/02/09 21:45:06 Passing by pointer. Decided to keep a vector beca
49 55
50 // These methods can be called once Open() has been called. 56 // These methods can be called once Open() has been called.
51 int channels() const { return channels_; } 57 int channels() const { return channels_; }
52 int sample_rate() const { return sample_rate_; } 58 int sample_rate() const { return sample_rate_; }
53 59
54 // Please note that GetDuration() and GetNumberOfFrames() attempt to be 60 // Please note that GetDuration() and GetNumberOfFrames() attempt to be
55 // accurate, but are only estimates. For some encoded formats, the actual 61 // accurate, but are only estimates. For some encoded formats, the actual
56 // duration of the file can only be determined once all the file data has been 62 // duration of the file can only be determined once all the file data has been
57 // read. The Read() method returns the actual number of sample-frames it has 63 // read. The Read() method returns the actual number of sample-frames it has
58 // read. 64 // read.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 102
97 // AVSampleFormat initially requested; not Chrome's SampleFormat. 103 // AVSampleFormat initially requested; not Chrome's SampleFormat.
98 int av_sample_format_; 104 int av_sample_format_;
99 105
100 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); 106 DISALLOW_COPY_AND_ASSIGN(AudioFileReader);
101 }; 107 };
102 108
103 } // namespace media 109 } // namespace media
104 110
105 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ 111 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698