From: Olivier CrĂȘte Date: Mon, 13 Dec 2021 21:56:37 +0000 (-0500) Subject: webrtc stats: Add more details about codecs into the stats X-Git-Tag: 1.20.0~162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f35435f1f787949b695b1f7fb6d835e02b050392;p=platform%2Fupstream%2Fgstreamer.git webrtc stats: Add more details about codecs into the stats This makes the output a little closer to what the upstream stats are. Part-of: --- diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c index d56c17d..ed9a1aa 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c @@ -31,6 +31,8 @@ #include "utils.h" #include "webrtctransceiver.h" +#include + #define GST_CAT_DEFAULT gst_webrtc_stats_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); @@ -776,9 +778,13 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, _set_base_stats (stats, GST_WEBRTC_STATS_CODEC, ts, id); caps = gst_pad_get_current_caps (pad); + GST_DEBUG_OBJECT (pad, "Pad caps are: %" GST_PTR_FORMAT, caps); if (caps && gst_caps_is_fixed (caps)) { GstStructure *caps_s = gst_caps_get_structure (caps, 0); gint pt; + const gchar *encoding_name, *media, *encoding_params; + GstSDPMedia sdp_media = { 0 }; + guint channels = 0; if (gst_structure_get_int (caps_s, "payload", &pt)) gst_structure_set (stats, "payload-type", G_TYPE_UINT, pt, NULL); @@ -789,7 +795,40 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, if (gst_structure_get_uint (caps_s, "ssrc", &ssrc)) gst_structure_set (stats, "ssrc", G_TYPE_UINT, ssrc, NULL); - /* FIXME: codecType, mimeType, channels, sdpFmtpLine, implementation, transportId */ + media = gst_structure_get_string (caps_s, "media"); + encoding_name = gst_structure_get_string (caps_s, "encoding-name"); + encoding_params = gst_structure_get_string (caps_s, "encoding-params"); + + if (media || encoding_name) { + gchar *mime_type; + + mime_type = g_strdup_printf ("%s/%s", media ? media : "", + encoding_name ? encoding_name : ""); + gst_structure_set (stats, "mime-type", G_TYPE_STRING, mime_type, NULL); + g_free (mime_type); + } + + if (encoding_params) + channels = atoi (encoding_params); + if (channels) + gst_structure_set (stats, "channels", G_TYPE_UINT, channels, NULL); + + if (gst_pad_get_direction (pad) == GST_PAD_SRC) + gst_structure_set (stats, "codec-type", G_TYPE_STRING, "decode", NULL); + else + gst_structure_set (stats, "codec-type", G_TYPE_STRING, "encode", NULL); + + gst_sdp_media_init (&sdp_media); + if (gst_sdp_media_set_media_from_caps (caps, &sdp_media) == GST_SDP_OK) { + const gchar *fmtp = gst_sdp_media_get_attribute_val (&sdp_media, "fmtp"); + + if (fmtp) { + gst_structure_set (stats, "sdp-fmtp-line", G_TYPE_STRING, fmtp, NULL); + } + } + gst_sdp_media_uninit (&sdp_media); + + /* FIXME: transportId */ } if (caps)