From e768c40e1122c4a8ef8785aef6a07044f6e869e1 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 11 Feb 2022 19:55:19 +0100 Subject: RTP: Make codec and hardware support compile-time configurable --- plugins/rtp/CMakeLists.txt | 26 ++++++++++++++---- plugins/rtp/src/codec_util.vala | 61 ++++++++++++++++++++++++++++++++++++----- plugins/rtp/src/device.vala | 1 - plugins/rtp/src/module.vala | 24 +++++++--------- plugins/rtp/src/stream.vala | 1 - 5 files changed, 84 insertions(+), 29 deletions(-) (limited to 'plugins') diff --git a/plugins/rtp/CMakeLists.txt b/plugins/rtp/CMakeLists.txt index 4c159c1b..87ca4dcb 100644 --- a/plugins/rtp/CMakeLists.txt +++ b/plugins/rtp/CMakeLists.txt @@ -12,20 +12,34 @@ find_packages(RTP_PACKAGES REQUIRED GstAudio ) +set(RTP_DEFINITIONS) + if(GstRtp_VERSION VERSION_GREATER "1.16") - set(RTP_DEFINITIONS GST_1_16) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_16) endif() if(GstRtp_VERSION VERSION_GREATER "1.18") - set(RTP_DEFINITIONS GST_1_18) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_18) +endif() + +set(RTP_ENABLE_VP9 "no" CACHE BOOL "Enable VP9 support") +if(RTP_ENABLE_VP9) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VP9) +endif() + +set(RTP_ENABLE_H264 "no" CACHE BOOL "Enable H264 support") +if(RTP_ENABLE_H264) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_H264) endif() -if(Vala_VERSION VERSION_GREATER "0.50") - set(RTP_DEFINITIONS VALA_0_50) +set(RTP_ENABLE_VAAPI "no" CACHE BOOL "Enable VAAPI support") +if(RTP_ENABLE_VAAPI) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VAAPI) endif() -if(Vala_VERSION VERSION_GREATER "0.52") - set(RTP_DEFINITIONS VALA_0_52) +set(RTP_ENABLE_MSDK "no" CACHE BOOL "Enable MSDK support") +if(RTP_ENABLE_MSDK) + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_MSDK) endif() if(WebRTCAudioProcessing_VERSION GREATER "0.4") diff --git a/plugins/rtp/src/codec_util.vala b/plugins/rtp/src/codec_util.vala index 443baa7e..ac8c7f98 100644 --- a/plugins/rtp/src/codec_util.vala +++ b/plugins/rtp/src/codec_util.vala @@ -97,11 +97,35 @@ public class Dino.Plugins.Rtp.CodecUtil { } else if (media == "video") { switch (codec) { case "h264": - return new string[] {/*"msdkh264enc", */"vaapih264enc", "x264enc"}; + return new string[] { +#if ENABLE_MSDK + "msdkh264enc", +#endif +#if ENABLE_VAAPI + "vaapih264enc", +#endif + "x264enc" + }; case "vp9": - return new string[] {/*"msdkvp9enc", */"vaapivp9enc", "vp9enc"}; + return new string[] { +#if ENABLE_MSDK + "msdkvp9enc", +#endif +#if ENABLE_VAAPI + "vaapivp9enc", +#endif + "vp9enc" + }; case "vp8": - return new string[] {/*"msdkvp8enc", */"vaapivp8enc", "vp8enc"}; + return new string[] { +#if ENABLE_MSDK + "msdkvp8enc", +#endif +#if ENABLE_VAAPI + "vaapivp8enc", +#endif + "vp8enc" + }; } } return new string[0]; @@ -125,11 +149,35 @@ public class Dino.Plugins.Rtp.CodecUtil { } else if (media == "video") { switch (codec) { case "h264": - return new string[] {/*"msdkh264dec", */"vaapih264dec"}; + return new string[] { +#if ENABLE_MSDK + "msdkh264dec", +#endif +#if ENABLE_VAAPI + "vaapih264dec", +#endif + null + }; case "vp9": - return new string[] {/*"msdkvp9dec", */"vaapivp9dec", "vp9dec"}; + return new string[] { +#if ENABLE_MSDK + "msdkvp9dec", +#endif +#if ENABLE_VAAPI + "vaapivp9dec", +#endif + "vp9dec" + }; case "vp8": - return new string[] {/*"msdkvp8dec", */"vaapivp8dec", "vp8dec"}; + return new string[] { +#if ENABLE_MSDK + "msdkvp8dec", +#endif +#if ENABLE_VAAPI + "vaapivp8dec", +#endif + "vp8dec" + }; } } return new string[0]; @@ -268,7 +316,6 @@ public class Dino.Plugins.Rtp.CodecUtil { } public string? get_decode_element_name(string media, string? codec) { - if (codec == "vp9") return null; // Temporary unsupport VP9 if (get_depay_element_name(media, codec) == null) return null; foreach (string candidate in get_decode_candidates(media, codec)) { if (is_element_supported(candidate)) return candidate; diff --git a/plugins/rtp/src/device.vala b/plugins/rtp/src/device.vala index e97a0d04..aca97578 100644 --- a/plugins/rtp/src/device.vala +++ b/plugins/rtp/src/device.vala @@ -438,7 +438,6 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object { if (is_sink && media == "audio") { mixer = (Gst.Base.Aggregator) Gst.ElementFactory.make("audiomixer", @"mixer_$id"); pipe.add(mixer); - mixer.link(pipe); if (plugin.echoprobe != null && !plugin.echoprobe.get_static_pad("src").is_linked()) { mixer.link(plugin.echoprobe); plugin.echoprobe.link(element); diff --git a/plugins/rtp/src/module.vala b/plugins/rtp/src/module.vala index ca1a6a5b..be153b10 100644 --- a/plugins/rtp/src/module.vala +++ b/plugins/rtp/src/module.vala @@ -147,19 +147,23 @@ public class Dino.Plugins.Rtp.Module : JingleRtp.Module { yield add_if_supported(list, media, pcmu); yield add_if_supported(list, media, pcma); } else if (media == "video") { - var h264 = new JingleRtp.PayloadType() { clockrate = 90000, name = "H264", id = 96 }; - var vp9 = new JingleRtp.PayloadType() { clockrate = 90000, name = "VP9", id = 97 }; - var vp8 = new JingleRtp.PayloadType() { clockrate = 90000, name = "VP8", id = 98 }; var rtcp_fbs = new ArrayList(); rtcp_fbs.add(new JingleRtp.RtcpFeedback("goog-remb")); rtcp_fbs.add(new JingleRtp.RtcpFeedback("ccm", "fir")); rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack")); rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack", "pli")); +#if ENABLE_H264 + var h264 = new JingleRtp.PayloadType() { clockrate = 90000, name = "H264", id = 96 }; + yield add_if_supported(list, media, h264); h264.rtcp_fbs.add_all(rtcp_fbs); +#endif +#if ENABLE_VP9 + var vp9 = new JingleRtp.PayloadType() { clockrate = 90000, name = "VP9", id = 97 }; vp9.rtcp_fbs.add_all(rtcp_fbs); - vp8.rtcp_fbs.add_all(rtcp_fbs); - yield add_if_supported(list, media, h264); yield add_if_supported(list, media, vp9); +#endif + var vp8 = new JingleRtp.PayloadType() { clockrate = 90000, name = "VP8", id = 98 }; + vp8.rtcp_fbs.add_all(rtcp_fbs); yield add_if_supported(list, media, vp8); } else { warning("Unsupported media type: %s", media); @@ -168,15 +172,7 @@ public class Dino.Plugins.Rtp.Module : JingleRtp.Module { } public override async JingleRtp.PayloadType? pick_payload_type(string media, Gee.List payloads) { - if (media == "audio") { - foreach (JingleRtp.PayloadType type in payloads) { - if (yield is_payload_supported(media, type)) return adjust_payload_type(media, type.clone()); - } - } else if (media == "video") { - // We prefer H.264 (best support for hardware acceleration and good overall codec quality) - JingleRtp.PayloadType? h264 = payloads.first_match((it) => it.name.up() == "H264"); - if (h264 != null && yield is_payload_supported(media, h264)) return adjust_payload_type(media, h264.clone()); - // Take first of the list that we do support otherwise + if (media == "audio" || media == "video") { foreach (JingleRtp.PayloadType type in payloads) { if (yield is_payload_supported(media, type)) return adjust_payload_type(media, type.clone()); } diff --git a/plugins/rtp/src/stream.vala b/plugins/rtp/src/stream.vala index 25a1ed2c..ef9ffe96 100644 --- a/plugins/rtp/src/stream.vala +++ b/plugins/rtp/src/stream.vala @@ -505,7 +505,6 @@ public class Dino.Plugins.Rtp.Stream : Xmpp.Xep.JingleRtp.Stream { buffer_seq = rtp_buffer.get_seq(); rtp_buffer.unmap(); } - debug("Received RTP %s buffer seq %u with SSRC %u", media, buffer_seq, buffer_ssrc); } #endif if (push_recv_data) { -- cgit v1.2.3-54-g00ecf