| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 5 #ifndef MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
| 6 #define MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 6 #define MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "media/base/sinc_resampler.h" | 13 #include "media/base/sinc_resampler.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 class AudioBus; | 16 class AudioBus; |
| 17 | 17 |
| 18 // MultiChannelResampler is a multi channel wrapper for SincResampler; allowing | 18 // MultiChannelResampler is a multi channel wrapper for SincResampler; allowing |
| 19 // high quality sample rate conversion of multiple channels at once. | 19 // high quality sample rate conversion of multiple channels at once. |
| 20 class MEDIA_EXPORT MultiChannelResampler { | 20 class MEDIA_EXPORT MultiChannelResampler { |
| 21 public: | 21 public: |
| 22 // Callback type for providing more data into the resampler. Expects AudioBus | 22 // Callback type for providing more data into the resampler. Expects AudioBus |
| 23 // to be completely filled with data upon return; zero padded if not enough | 23 // to be completely filled with data upon return; zero padded if not enough |
| 24 // frames are available to satisfy the request. | 24 // frames are available to satisfy the request. |frame_delay| is the number |
| 25 typedef base::Callback<void(AudioBus* audio_bus)> ReadCB; | 25 // of output frames already processed and can be used to estimate delay. |
| 26 typedef base::Callback<void(int frame_delay, AudioBus* audio_bus)> ReadCB; |
| 26 | 27 |
| 27 // Constructs a MultiChannelResampler with the specified |read_cb|, which is | 28 // Constructs a MultiChannelResampler with the specified |read_cb|, which is |
| 28 // used to acquire audio data for resampling. |io_sample_rate_ratio| is the | 29 // used to acquire audio data for resampling. |io_sample_rate_ratio| is the |
| 29 // ratio of input / output sample rates. | 30 // ratio of input / output sample rates. |
| 30 MultiChannelResampler(int channels, double io_sample_rate_ratio, | 31 MultiChannelResampler(int channels, double io_sample_rate_ratio, |
| 31 const ReadCB& read_cb); | 32 const ReadCB& read_cb); |
| 32 virtual ~MultiChannelResampler(); | 33 virtual ~MultiChannelResampler(); |
| 33 | 34 |
| 34 // Resamples |frames| of data from |read_cb_| into AudioBus. | 35 // Resamples |frames| of data from |read_cb_| into AudioBus. |
| 35 void Resample(AudioBus* audio_bus, int frames); | 36 void Resample(AudioBus* audio_bus, int frames); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 // Source of data for resampling. | 50 // Source of data for resampling. |
| 50 ReadCB read_cb_; | 51 ReadCB read_cb_; |
| 51 | 52 |
| 52 // Each channel has its own high quality resampler. | 53 // Each channel has its own high quality resampler. |
| 53 ScopedVector<SincResampler> resamplers_; | 54 ScopedVector<SincResampler> resamplers_; |
| 54 | 55 |
| 55 // Buffers for audio data going into SincResampler from ReadCB. | 56 // Buffers for audio data going into SincResampler from ReadCB. |
| 56 scoped_ptr<AudioBus> resampler_audio_bus_; | 57 scoped_ptr<AudioBus> resampler_audio_bus_; |
| 57 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; | 58 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; |
| 58 std::vector<float*> resampler_audio_data_; | 59 std::vector<float*> resampler_audio_data_; |
| 60 |
| 61 // The number of output frames that have successfully been processed during |
| 62 // the current Resample() call. |
| 63 int output_frames_ready_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 } // namespace media | 68 } // namespace media |
| 62 | 69 |
| 63 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 70 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
| OLD | NEW |