BlueGit

ict rusty-teams

Files

rusty-teams / vendor / libwebrtc / src / audio_frame.rs

audio_frame.rs

audio_frame.rs 1.1 KiB Download Raw
1// Copyright 2025 LiveKit, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::borrow::Cow;
16
17#[derive(Debug, Clone)]
18pub struct AudioFrame<'a> {
19 pub data: Cow<'a, [i16]>,
20 pub sample_rate: u32,
21 pub num_channels: u32,
22 pub samples_per_channel: u32,
23}
24
25impl AudioFrame<'_> {
26 // Owned
27 pub fn new(sample_rate: u32, num_channels: u32, samples_per_channel: u32) -> Self {
28 Self {
29 data: vec![0; (num_channels * samples_per_channel) as usize].into(),
30 sample_rate,
31 num_channels,
32 samples_per_channel,
33 }
34 }
35}