mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1448>
This commit is contained in:
parent
31f4444724
commit
f35435f1f7
1 changed files with 40 additions and 1 deletions
|
@ -31,6 +31,8 @@
|
|||
#include "utils.h"
|
||||
#include "webrtctransceiver.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#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)
|
||||
|
|
Loading…
Reference in a new issue