webrtc: Simplify fmtp handling in codec stats
authorPhilippe Normand <philn@igalia.com>
Tue, 10 Dec 2024 16:15:09 +0000 (16:15 +0000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 11 Dec 2024 09:23:41 +0000 (09:23 +0000)
Parsing the whole caps as SDP media only to retrieve the fmtp field afterwards
seems a bit superfluous. By looking up the a-fmtp attribute directly the number
of allocations in this function gets down a bit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8125>

subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c

index d859005f28f9b9abe590a714c26d57b215b192f1..2edb46b1d8133f9186cdab8429d4f9baf1691192 100644 (file)
@@ -815,8 +815,8 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad,
     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;
+    const gchar *fmtp;
 
     if (gst_structure_get_int (caps_s, "payload", &pt))
       gst_structure_set (stats, "payload-type", G_TYPE_UINT, pt, NULL);
@@ -852,15 +852,10 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad,
     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);
-      }
+    fmtp = gst_structure_get_string (caps_s, "a-fmtp");
+    if (fmtp) {
+      gst_structure_set (stats, "sdp-fmtp-line", G_TYPE_STRING, fmtp, NULL);
     }
-    gst_sdp_media_uninit (&sdp_media);
 
     /* FIXME: transportId */
   }