RTP: Make codec and hardware support compile-time configurable
This commit is contained in:
parent
dbc6d87cb9
commit
e768c40e11
|
@ -12,20 +12,34 @@ find_packages(RTP_PACKAGES REQUIRED
|
||||||
GstAudio
|
GstAudio
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(RTP_DEFINITIONS)
|
||||||
|
|
||||||
if(GstRtp_VERSION VERSION_GREATER "1.16")
|
if(GstRtp_VERSION VERSION_GREATER "1.16")
|
||||||
set(RTP_DEFINITIONS GST_1_16)
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_16)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GstRtp_VERSION VERSION_GREATER "1.18")
|
if(GstRtp_VERSION VERSION_GREATER "1.18")
|
||||||
set(RTP_DEFINITIONS GST_1_18)
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_18)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Vala_VERSION VERSION_GREATER "0.50")
|
set(RTP_ENABLE_VP9 "no" CACHE BOOL "Enable VP9 support")
|
||||||
set(RTP_DEFINITIONS VALA_0_50)
|
if(RTP_ENABLE_VP9)
|
||||||
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VP9)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Vala_VERSION VERSION_GREATER "0.52")
|
set(RTP_ENABLE_H264 "no" CACHE BOOL "Enable H264 support")
|
||||||
set(RTP_DEFINITIONS VALA_0_52)
|
if(RTP_ENABLE_H264)
|
||||||
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_H264)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(RTP_ENABLE_VAAPI "no" CACHE BOOL "Enable VAAPI support")
|
||||||
|
if(RTP_ENABLE_VAAPI)
|
||||||
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VAAPI)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(RTP_ENABLE_MSDK "no" CACHE BOOL "Enable MSDK support")
|
||||||
|
if(RTP_ENABLE_MSDK)
|
||||||
|
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_MSDK)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WebRTCAudioProcessing_VERSION GREATER "0.4")
|
if(WebRTCAudioProcessing_VERSION GREATER "0.4")
|
||||||
|
|
|
@ -97,11 +97,35 @@ public class Dino.Plugins.Rtp.CodecUtil {
|
||||||
} else if (media == "video") {
|
} else if (media == "video") {
|
||||||
switch (codec) {
|
switch (codec) {
|
||||||
case "h264":
|
case "h264":
|
||||||
return new string[] {/*"msdkh264enc", */"vaapih264enc", "x264enc"};
|
return new string[] {
|
||||||
|
#if ENABLE_MSDK
|
||||||
|
"msdkh264enc",
|
||||||
|
#endif
|
||||||
|
#if ENABLE_VAAPI
|
||||||
|
"vaapih264enc",
|
||||||
|
#endif
|
||||||
|
"x264enc"
|
||||||
|
};
|
||||||
case "vp9":
|
case "vp9":
|
||||||
return new string[] {/*"msdkvp9enc", */"vaapivp9enc", "vp9enc"};
|
return new string[] {
|
||||||
|
#if ENABLE_MSDK
|
||||||
|
"msdkvp9enc",
|
||||||
|
#endif
|
||||||
|
#if ENABLE_VAAPI
|
||||||
|
"vaapivp9enc",
|
||||||
|
#endif
|
||||||
|
"vp9enc"
|
||||||
|
};
|
||||||
case "vp8":
|
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];
|
return new string[0];
|
||||||
|
@ -125,11 +149,35 @@ public class Dino.Plugins.Rtp.CodecUtil {
|
||||||
} else if (media == "video") {
|
} else if (media == "video") {
|
||||||
switch (codec) {
|
switch (codec) {
|
||||||
case "h264":
|
case "h264":
|
||||||
return new string[] {/*"msdkh264dec", */"vaapih264dec"};
|
return new string[] {
|
||||||
|
#if ENABLE_MSDK
|
||||||
|
"msdkh264dec",
|
||||||
|
#endif
|
||||||
|
#if ENABLE_VAAPI
|
||||||
|
"vaapih264dec",
|
||||||
|
#endif
|
||||||
|
null
|
||||||
|
};
|
||||||
case "vp9":
|
case "vp9":
|
||||||
return new string[] {/*"msdkvp9dec", */"vaapivp9dec", "vp9dec"};
|
return new string[] {
|
||||||
|
#if ENABLE_MSDK
|
||||||
|
"msdkvp9dec",
|
||||||
|
#endif
|
||||||
|
#if ENABLE_VAAPI
|
||||||
|
"vaapivp9dec",
|
||||||
|
#endif
|
||||||
|
"vp9dec"
|
||||||
|
};
|
||||||
case "vp8":
|
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];
|
return new string[0];
|
||||||
|
@ -268,7 +316,6 @@ public class Dino.Plugins.Rtp.CodecUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? get_decode_element_name(string media, string? codec) {
|
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;
|
if (get_depay_element_name(media, codec) == null) return null;
|
||||||
foreach (string candidate in get_decode_candidates(media, codec)) {
|
foreach (string candidate in get_decode_candidates(media, codec)) {
|
||||||
if (is_element_supported(candidate)) return candidate;
|
if (is_element_supported(candidate)) return candidate;
|
||||||
|
|
|
@ -438,7 +438,6 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
||||||
if (is_sink && media == "audio") {
|
if (is_sink && media == "audio") {
|
||||||
mixer = (Gst.Base.Aggregator) Gst.ElementFactory.make("audiomixer", @"mixer_$id");
|
mixer = (Gst.Base.Aggregator) Gst.ElementFactory.make("audiomixer", @"mixer_$id");
|
||||||
pipe.add(mixer);
|
pipe.add(mixer);
|
||||||
mixer.link(pipe);
|
|
||||||
if (plugin.echoprobe != null && !plugin.echoprobe.get_static_pad("src").is_linked()) {
|
if (plugin.echoprobe != null && !plugin.echoprobe.get_static_pad("src").is_linked()) {
|
||||||
mixer.link(plugin.echoprobe);
|
mixer.link(plugin.echoprobe);
|
||||||
plugin.echoprobe.link(element);
|
plugin.echoprobe.link(element);
|
||||||
|
|
|
@ -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, pcmu);
|
||||||
yield add_if_supported(list, media, pcma);
|
yield add_if_supported(list, media, pcma);
|
||||||
} else if (media == "video") {
|
} 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<JingleRtp.RtcpFeedback>();
|
var rtcp_fbs = new ArrayList<JingleRtp.RtcpFeedback>();
|
||||||
rtcp_fbs.add(new JingleRtp.RtcpFeedback("goog-remb"));
|
rtcp_fbs.add(new JingleRtp.RtcpFeedback("goog-remb"));
|
||||||
rtcp_fbs.add(new JingleRtp.RtcpFeedback("ccm", "fir"));
|
rtcp_fbs.add(new JingleRtp.RtcpFeedback("ccm", "fir"));
|
||||||
rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack"));
|
rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack"));
|
||||||
rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack", "pli"));
|
rtcp_fbs.add(new JingleRtp.RtcpFeedback("nack", "pli"));
|
||||||
h264.rtcp_fbs.add_all(rtcp_fbs);
|
#if ENABLE_H264
|
||||||
vp9.rtcp_fbs.add_all(rtcp_fbs);
|
var h264 = new JingleRtp.PayloadType() { clockrate = 90000, name = "H264", id = 96 };
|
||||||
vp8.rtcp_fbs.add_all(rtcp_fbs);
|
|
||||||
yield add_if_supported(list, media, h264);
|
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);
|
||||||
yield add_if_supported(list, media, vp9);
|
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);
|
yield add_if_supported(list, media, vp8);
|
||||||
} else {
|
} else {
|
||||||
warning("Unsupported media type: %s", media);
|
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<JingleRtp.PayloadType> payloads) {
|
public override async JingleRtp.PayloadType? pick_payload_type(string media, Gee.List<JingleRtp.PayloadType> payloads) {
|
||||||
if (media == "audio") {
|
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());
|
|
||||||
}
|
|
||||||
} 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
|
|
||||||
foreach (JingleRtp.PayloadType type in payloads) {
|
foreach (JingleRtp.PayloadType type in payloads) {
|
||||||
if (yield is_payload_supported(media, type)) return adjust_payload_type(media, type.clone());
|
if (yield is_payload_supported(media, type)) return adjust_payload_type(media, type.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,7 +505,6 @@ public class Dino.Plugins.Rtp.Stream : Xmpp.Xep.JingleRtp.Stream {
|
||||||
buffer_seq = rtp_buffer.get_seq();
|
buffer_seq = rtp_buffer.get_seq();
|
||||||
rtp_buffer.unmap();
|
rtp_buffer.unmap();
|
||||||
}
|
}
|
||||||
debug("Received RTP %s buffer seq %u with SSRC %u", media, buffer_seq, buffer_ssrc);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (push_recv_data) {
|
if (push_recv_data) {
|
||||||
|
|
Loading…
Reference in a new issue