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

Patch by Philippe Normand <philn@igalia.com> 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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
philn authored and webkit-commit-queue committed May 26, 2022
1 parent ed441f1 commit 28df7dd79dacf29467f640a1b8920ed388bcf840
Showing 2 changed files with 85 additions and 3 deletions.
@@ -956,6 +956,9 @@ webkit.org/b/235885 webrtc/vp9.html [ Failure ]
# 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
#////////////////////////////////////////////////////////////////////////////////////////
@@ -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 @@ static inline void fillRTCTransportStats(RTCStatsReport::TransportStats& stats,
// 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 = String::fromLatin1(gst_structure_get_string(structure, "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,10 +334,20 @@ static gboolean fillReportCallback(GQuark, const GValue* value, gpointer userDat
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");

0 comments on commit 28df7dd

Please sign in to comment.