Skip to main content

gosuto_libwebrtc/
rtp_parameters.rs

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 crate::rtp_transceiver::RtpTransceiverDirection;
16
17#[derive(Debug, Copy, Clone, PartialEq, Eq)]
18pub enum Priority {
19    VeryLow,
20    Low,
21    Medium,
22    High,
23}
24
25#[derive(Debug, Clone)]
26pub struct RtpHeaderExtensionParameters {
27    pub uri: String,
28    pub id: i32,
29    pub encrypted: bool,
30}
31
32#[derive(Debug, Clone, Default)]
33pub struct RtpParameters {
34    pub codecs: Vec<RtpCodecParameters>,
35    pub header_extensions: Vec<RtpHeaderExtensionParameters>,
36    pub rtcp: RtcpParameters,
37}
38
39#[derive(Debug, Clone, Default)]
40pub struct RtpCodecParameters {
41    pub payload_type: u8,
42    pub mime_type: String, // read-only
43    pub clock_rate: Option<u64>,
44    pub channels: Option<u16>,
45}
46
47#[derive(Debug, Clone, Default)]
48pub struct RtcpParameters {
49    pub cname: String,
50    pub reduced_size: bool,
51}
52
53#[derive(Debug, Clone)]
54pub struct RtpEncodingParameters {
55    pub active: bool,
56    pub max_bitrate: Option<u64>,
57    pub max_framerate: Option<f64>,
58    pub priority: Priority,
59    pub rid: String,
60    pub scale_resolution_down_by: Option<f64>,
61}
62
63#[derive(Debug, Clone)]
64pub struct RtpCodecCapability {
65    pub channels: Option<u16>,
66    pub clock_rate: Option<u64>,
67    pub mime_type: String,
68    pub sdp_fmtp_line: Option<String>,
69}
70
71#[derive(Debug, Clone)]
72pub struct RtpHeaderExtensionCapability {
73    pub uri: String,
74    pub direction: RtpTransceiverDirection,
75}
76
77#[derive(Debug, Clone)]
78pub struct RtpCapabilities {
79    pub codecs: Vec<RtpCodecCapability>,
80    pub header_extensions: Vec<RtpHeaderExtensionCapability>,
81}
82
83impl Default for RtpEncodingParameters {
84    fn default() -> Self {
85        Self {
86            active: true,
87            max_bitrate: None,
88            max_framerate: None,
89            priority: Priority::Low,
90            rid: String::default(),
91            scale_resolution_down_by: None,
92        }
93    }
94}