webrtc: conditional compile for features with 1_22 dependency

Few features being used in webrtcsink like
the signal `request-aux-sender` are introduced
to webrtcbin in gstreamer release 1.22.

Rename the feature gst1_22 to v1_22 for uniformity.

Add v1_22 to default features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1241>
This commit is contained in:
Taruntej Kanakamalla 2023-06-12 18:47:25 +05:30
parent f2a7a34abf
commit 50e905fe4b
2 changed files with 14 additions and 4 deletions

View file

@ -74,9 +74,10 @@ path = "src/lib.rs"
gst-plugin-version-helper = { path = "../../version-helper" }
[features]
default = ["v1_22"]
static = []
capi = []
gst1_22 = ["gst/v1_22", "gst-app/v1_22", "gst-video/v1_22", "gst-webrtc/v1_22", "gst-sdp/v1_22", "gst-rtp/v1_22"]
v1_22 = ["gst/v1_22", "gst-app/v1_22", "gst-video/v1_22", "gst-webrtc/v1_22", "gst-sdp/v1_22", "gst-rtp/v1_22"]
doc = []
[package.metadata.capi]

View file

@ -52,8 +52,11 @@ const DEFAULT_MIN_BITRATE: u32 = 1000;
* my local network, possibly related to chrome's pretty low UDP
* buffer sizes */
const DEFAULT_MAX_BITRATE: u32 = 8192000;
const DEFAULT_CONGESTION_CONTROL: WebRTCSinkCongestionControl =
WebRTCSinkCongestionControl::GoogleCongestionControl;
const DEFAULT_CONGESTION_CONTROL: WebRTCSinkCongestionControl = if cfg!(feature = "v1_22") {
WebRTCSinkCongestionControl::GoogleCongestionControl
} else {
WebRTCSinkCongestionControl::Disabled
};
const DEFAULT_DO_FEC: bool = true;
const DEFAULT_DO_RETRANSMISSION: bool = true;
const DEFAULT_ENABLE_DATA_CHANNEL_NAVIGATION: bool = false;
@ -61,6 +64,7 @@ const DEFAULT_ICE_TRANSPORT_POLICY: WebRTCICETransportPolicy = WebRTCICETranspor
const DEFAULT_START_BITRATE: u32 = 2048000;
/* Start adding some FEC when the bitrate > 2Mbps as we found experimentally
* that it is not worth it below that threshold */
#[cfg(feature = "v1_22")]
const DO_FEC_THRESHOLD: u32 = 2000000;
#[derive(Debug, Clone, Copy)]
@ -236,6 +240,7 @@ struct Session {
pipeline: gst::Pipeline,
webrtcbin: gst::Element,
#[cfg(feature = "v1_22")]
rtprtxsend: Option<gst::Element>,
webrtc_pads: HashMap<u32, WebRTCPad>,
peer_id: String,
@ -500,7 +505,7 @@ impl Default for Settings {
stun_server: DEFAULT_STUN_SERVER.map(String::from),
turn_servers: gst::Array::new(Vec::new() as Vec<glib::SendValue>),
cc_info: CCInfo {
heuristic: WebRTCSinkCongestionControl::GoogleCongestionControl,
heuristic: DEFAULT_CONGESTION_CONTROL,
min_bitrate: DEFAULT_MIN_BITRATE,
max_bitrate: DEFAULT_MAX_BITRATE,
start_bitrate: DEFAULT_START_BITRATE,
@ -1141,6 +1146,7 @@ impl Session {
webrtcbin,
peer_id,
cc_info,
#[cfg(feature = "v1_22")]
rtprtxsend: None,
congestion_controller,
rtpgccbwe,
@ -2365,6 +2371,7 @@ impl BaseWebRTCSink {
}
let rtpgccbwe = match settings.cc_info.heuristic {
#[cfg(feature = "v1_22")]
WebRTCSinkCongestionControl::GoogleCongestionControl => {
let rtpgccbwe = match gst::ElementFactory::make("rtpgccbwe").build() {
Err(err) => {
@ -2877,6 +2884,7 @@ impl BaseWebRTCSink {
webrtcbin.emit_by_name::<()>("get-stats", &[&None::<gst::Pad>, &promise]);
}
#[cfg(feature = "v1_22")]
fn set_rtptrxsend(
&self,
element: &super::BaseWebRTCSink,
@ -2890,6 +2898,7 @@ impl BaseWebRTCSink {
}
}
#[cfg(feature = "v1_22")]
fn set_bitrate(&self, element: &super::BaseWebRTCSink, session_id: &str, bitrate: u32) {
let settings = element.imp().settings.lock().unwrap();
let mut state = element.imp().state.lock().unwrap();