[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/livekit/client-sdk-flutter/main/shared_cpp/audio_renderer.cpp [Back]  [Original]

#include "audio_renderer.h"

#include 
#include 

namespace {

std::vector UpsampleAudio(const int16_t *src, int src_frames,
                                   int out_frames, int channels) {
  std::vector out(static_cast(out_frames) * channels);

  // Edge case: a single source frame  just repeat it.
  if (src_frames  0 ? static_cast(std::clamp(
                          sum / count, INT16_MIN, INT16_MAX))
                    : 0;
    }
  }

  return out;
}

} // namespace

RendererAudioFormat RendererAudioFormat::FromValues(
    const std::string &common_format, int sample_rate, int channels) {
  RendererAudioFormat format;
  format.common_format = common_format.empty() ? "int16" : common_format;
  format.sample_rate = sample_rate > 0 ? sample_rate : 48000;
  format.channels = channels > 0 ? channels : 1;
  return format;
}

std::vector ResampleAudio(const int16_t *src, int src_frames,
                                   int src_rate, int target_rate,
                                   int channels, int &out_frames) {
  if (src_rate == target_rate || src_frames 

Web Proxy Viewer  |  New URL  |  Original Page