fork/rust-sdks
git clone https://git.julia.blue/fork/rust-sdks
2cad45c
main
1/* 2* Copyright 2023 LiveKit 3* 4* Licensed under the Apache License, Version 2.0 (the “License”); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an “AS IS” BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15*/ 16 17#include "livekit/audio_resampler.h" 18 19#include <memory> 20 21#include "audio/remix_resample.h" 22 23namespace livekit { 24 25size_t AudioResampler ::remix_and_resample (const int16_t * src , 26size_t samples_per_channel , 27size_t num_channels , 28int sample_rate , 29size_t dest_num_channels , 30int dest_sample_rate ) { 31frame_ .num_channels_ = dest_num_channels ; 32frame_ .sample_rate_hz_ = dest_sample_rate ; 33 webrtc::voe::RemixAndResample (src ,samples_per_channel ,num_channels , 34sample_rate ,& resampler_ ,& frame_ ); 35 36return frame_ .num_channels ()* frame_ .samples_per_channel ()* sizeof (int16_t ); 37} 38 39const int16_t * AudioResampler ::data ()const { 40return frame_ .data (); 41} 42 43std::unique_ptr < AudioResampler > create_audio_resampler () { 44return std::make_unique < AudioResampler > (); 45} 46 47}// namespace livekit