Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove AudioFrame.remix_and_resample #385

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions livekit-rtc/livekit/rtc/audio_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# limitations under the License.

import ctypes
from ._ffi_client import FfiHandle, FfiClient
from ._ffi_client import FfiHandle
from ._proto import audio_frame_pb2 as proto_audio
from ._proto import ffi_pb2 as proto_ffi
from ._utils import get_address
from typing import Any, Union

Expand Down Expand Up @@ -93,28 +92,6 @@ def _from_owned_info(owned_info: proto_audio.OwnedAudioFrameBuffer) -> "AudioFra
FfiHandle(owned_info.handle.id)
return AudioFrame(data, info.sample_rate, info.num_channels, info.samples_per_channel)

def remix_and_resample(self, sample_rate: int, num_channels: int) -> "AudioFrame":
"""Resample the audio frame to the given sample rate and number of channels.

.. warning::
This method is deprecated and will be removed in a future release.
Please use the `rtc.AudioResampler` class instead.
"""
req = proto_ffi.FfiRequest()
req.new_audio_resampler.CopyFrom(proto_audio.NewAudioResamplerRequest())

resp = FfiClient.instance.request(req)
resampler_handle = FfiHandle(resp.new_audio_resampler.resampler.handle.id)

resample_req = proto_ffi.FfiRequest()
resample_req.remix_and_resample.resampler_handle = resampler_handle.handle
resample_req.remix_and_resample.buffer.CopyFrom(self._proto_info())
resample_req.remix_and_resample.sample_rate = sample_rate
resample_req.remix_and_resample.num_channels = num_channels

resp = FfiClient.instance.request(resample_req)
return AudioFrame._from_owned_info(resp.remix_and_resample.buffer)

def _proto_info(self) -> proto_audio.AudioFrameBufferInfo:
audio_info = proto_audio.AudioFrameBufferInfo()
audio_info.data_ptr = get_address(memoryview(self._data))
Expand Down
Loading