Title: [294879] trunk
Revision
294879
Author
[email protected]
Date
2022-05-26 09:16:12 -0700 (Thu, 26 May 2022)

Log Message

[GStreamer][WebRTC] Local/remote ICE candidates stats gathering support
https://bugs.webkit.org/show_bug.cgi?id=240949

Patch by Philippe Normand <[email protected]> on 2022-05-26
Reviewed by Xabier Rodriguez-Calvar.

The corresponding feature was implemented in GStreamer as part of:
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998

* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/Modules/mediastream/gstreamer/GStreamerStatsCollector.cpp:
(WebCore::iceCandidateType):
(WebCore::fillRTCCandidateStats):
(WebCore::fillRTCCandidatePairStats):
(WebCore::fillReportCallback):

Canonical link: https://commits.webkit.org/251009@main

Modified Paths

Diff

Modified: trunk/LayoutTests/platform/glib/TestExpectations (294878 => 294879)


--- trunk/LayoutTests/platform/glib/TestExpectations	2022-05-26 16:01:38 UTC (rev 294878)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2022-05-26 16:16:12 UTC (rev 294879)
@@ -956,6 +956,9 @@
 # Hits an ASSERT because we don't have a WebRTC provider handling WebRTC-related media-capabilities.
 webkit.org/b/235885 [ Debug ] media/mediacapabilities/mock-encodingInfo.html [ Crash ]
 
+# Expected to pass with GStreamer 1.22.
+webkit.org/b/235885 webrtc/no-port-zero-in-upd-candidates.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of GStreamer-related bugs
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerStatsCollector.cpp (294878 => 294879)


--- trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerStatsCollector.cpp	2022-05-26 16:01:38 UTC (rev 294878)
+++ trunk/Source/WebCore/Modules/mediastream/gstreamer/GStreamerStatsCollector.cpp	2022-05-26 16:16:12 UTC (rev 294879)
@@ -22,7 +22,7 @@
 
 #if ENABLE(WEB_RTC) && USE(GSTREAMER_WEBRTC)
 
-#include "GUniquePtrGStreamer.h"
+#include "GStreamerCommon.h"
 #include "JSDOMMapLike.h"
 #include "JSRTCStatsReport.h"
 
@@ -201,6 +201,75 @@
     // stats.srtpCipher =
 }
 
+static inline std::optional<RTCIceCandidateType> iceCandidateType(const String& type)
+{
+    if (type == "host")
+        return RTCIceCandidateType::Host;
+    if (type == "srflx")
+        return RTCIceCandidateType::Srflx;
+    if (type == "prflx")
+        return RTCIceCandidateType::Prflx;
+    if (type == "relay")
+        return RTCIceCandidateType::Relay;
+
+    return { };
+}
+
+static inline void fillRTCCandidateStats(RTCStatsReport::IceCandidateStats& stats, GstWebRTCStatsType statsType, const GstStructure* structure)
+{
+    stats.type = statsType == GST_WEBRTC_STATS_REMOTE_CANDIDATE ? RTCStatsReport::Type::RemoteCandidate : RTCStatsReport::Type::LocalCandidate;
+
+    fillRTCStats(stats, structure);
+
+    stats.transportId = String::fromLatin1(gst_structure_get_string(structure, "transport-id"));
+    stats.address = String::fromLatin1(gst_structure_get_string(structure, "address"));
+    stats.protocol = String::fromLatin1(gst_structure_get_string(structure, "protocol"));
+    stats.url = "" "url"));
+
+    unsigned port;
+    if (gst_structure_get_uint(structure, "port", &port))
+        stats.port = port;
+
+    auto candidateType = String::fromLatin1(gst_structure_get_string(structure, "candidate-type"));
+    stats.candidateType = iceCandidateType(candidateType);
+
+    uint64_t priority;
+    if (gst_structure_get_uint64(structure, "priority", &priority))
+        stats.priority = priority;
+}
+
+static inline void fillRTCCandidatePairStats(RTCStatsReport::IceCandidatePairStats& stats, const GstStructure* structure)
+{
+    fillRTCStats(stats, structure);
+
+    stats.localCandidateId = String::fromLatin1(gst_structure_get_string(structure, "local-candidate-id"));
+    stats.remoteCandidateId = String::fromLatin1(gst_structure_get_string(structure, "remote-candidate-id"));
+
+    // FIXME
+    // stats.transportId =
+    // stats.state =
+    // stats.priority =
+    // stats.nominated =
+    // stats.writable =
+    // stats.readable =
+    // stats.bytesSent =
+    // stats.bytesReceived =
+    // stats.totalRoundTripTime =
+    // stats.currentRoundTripTime =
+    // stats.availableOutgoingBitrate =
+    // stats.availableIncomingBitrate =
+    // stats.requestsReceived =
+    // stats.requestsSent =
+    // stats.responsesReceived =
+    // stats.responsesSent =
+    // stats.retransmissionsReceived =
+    // stats.retransmissionsSent =
+    // stats.consentRequestsReceived =
+    // stats.consentRequestsSent =
+    // stats.consentResponsesReceived =
+    // stats.consentResponsesSent =
+}
+
 static gboolean fillReportCallback(GQuark, const GValue* value, gpointer userData)
 {
     if (!GST_VALUE_HOLDS_STRUCTURE(value))
@@ -265,11 +334,21 @@
     case GST_WEBRTC_STATS_DATA_CHANNEL:
         GST_FIXME("Missing data-channel stats support");
         break;
-    case GST_WEBRTC_STATS_CANDIDATE_PAIR:
     case GST_WEBRTC_STATS_LOCAL_CANDIDATE:
     case GST_WEBRTC_STATS_REMOTE_CANDIDATE:
-        GST_FIXME("Missing candidate stats support");
+        if (webkitGstCheckVersion(1, 21, 0)) {
+            RTCStatsReport::IceCandidateStats stats;
+            fillRTCCandidateStats(stats, statsType, structure);
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::IceCandidateStats>>(stats.id, WTFMove(stats));
+        }
         break;
+    case GST_WEBRTC_STATS_CANDIDATE_PAIR:
+        if (webkitGstCheckVersion(1, 21, 0)) {
+            RTCStatsReport::IceCandidatePairStats stats;
+            fillRTCCandidatePairStats(stats, structure);
+            report.set<IDLDOMString, IDLDictionary<RTCStatsReport::IceCandidatePairStats>>(stats.id, WTFMove(stats));
+        }
+        break;
     case GST_WEBRTC_STATS_CERTIFICATE:
         GST_FIXME("Missing certificate stats support");
         break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to