tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

acm_resampler.h (1393B)


      1 /*
      2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef MODULES_AUDIO_CODING_ACM2_ACM_RESAMPLER_H_
     12 #define MODULES_AUDIO_CODING_ACM2_ACM_RESAMPLER_H_
     13 
     14 #include <stddef.h>
     15 #include <stdint.h>
     16 
     17 #include <array>
     18 
     19 #include "api/audio/audio_frame.h"
     20 #include "common_audio/resampler/include/push_resampler.h"
     21 
     22 namespace webrtc {
     23 namespace acm2 {
     24 
     25 // Helper class to perform resampling if needed, meant to be used after
     26 // receiving the audio_frame from NetEq. Provides reasonably glitch free
     27 // transitions between different output sample rates from NetEq.
     28 class ResamplerHelper {
     29 public:
     30  ResamplerHelper();
     31 
     32  // Resamples audio_frame if it is not already in desired_sample_rate_hz.
     33  bool MaybeResample(int desired_sample_rate_hz, AudioFrame* audio_frame);
     34 
     35 private:
     36  PushResampler<int16_t> resampler_;
     37  bool resampled_last_output_frame_ = true;
     38  std::array<int16_t, AudioFrame::kMaxDataSizeSamples> last_audio_buffer_;
     39 };
     40 
     41 }  // namespace acm2
     42 }  // namespace webrtc
     43 
     44 #endif  // MODULES_AUDIO_CODING_ACM2_ACM_RESAMPLER_H_