From 5568cb33f75f8fd89efa1fbee534f8c1323569b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 3 Oct 2022 19:58:38 +0300 Subject: [PATCH] rtp: examples: client-rtpaux: Provide correct caps by payload type and RTX pt map by session Part-of: --- .../tests/examples/rtp/client-rtpaux.c | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-good/tests/examples/rtp/client-rtpaux.c b/subprojects/gst-plugins-good/tests/examples/rtp/client-rtpaux.c index c7aa781d1d..755f1ee5da 100644 --- a/subprojects/gst-plugins-good/tests/examples/rtp/client-rtpaux.c +++ b/subprojects/gst-plugins-good/tests/examples/rtp/client-rtpaux.c @@ -67,6 +67,7 @@ typedef struct _SessionData int ref; GstElement *rtpbin; guint sessionNum; + guint pt, rtxPt; GstCaps *caps; GstElement *output; } SessionData; @@ -129,6 +130,8 @@ make_audio_session (guint sessionNum) "media", G_TYPE_STRING, "audio", "clock-rate", G_TYPE_INT, 8000, "encoding-name", G_TYPE_STRING, "PCMA", NULL); + ret->pt = 8; + ret->rtxPt = 98; return ret; } @@ -154,6 +157,8 @@ make_video_session (guint sessionNum) "media", G_TYPE_STRING, "video", "clock-rate", G_TYPE_INT, 90000, "encoding-name", G_TYPE_STRING, "THEORA", NULL); + ret->pt = 96; + ret->rtxPt = 99; return ret; } @@ -167,10 +172,22 @@ request_pt_map (GstElement * rtpbin, guint session, guint pt, g_print ("Looking for caps for pt %u in session %u, have %u\n", pt, session, data->sessionNum); if (session == data->sessionNum) { - caps_str = gst_caps_to_string (data->caps); + GstCaps *caps; + + if (pt == data->pt) { + caps = gst_caps_ref (data->caps); + } else if (pt == data->rtxPt) { + caps = gst_caps_copy (data->caps); + gst_caps_set_simple (caps, "encoding-name", G_TYPE_STRING, "rtx", NULL); + } else { + return NULL; + } + + caps_str = gst_caps_to_string (caps); g_print ("Returning %s\n", caps_str); g_free (caps_str); - return gst_caps_ref (data->caps); + + return caps; } return NULL; } @@ -254,14 +271,22 @@ request_aux_receiver (GstElement * rtpbin, guint sessid, SessionData * session) GstPad *pad; gchar *name; GstStructure *pt_map; + gchar *media_pt; - GST_INFO ("creating AUX receiver"); + if (sessid != session->sessionNum) + return NULL; + + GST_INFO ("creating AUX receiver for session %u", sessid); bin = gst_bin_new (NULL); rtx = gst_element_factory_make ("rtprtxreceive", NULL); + + media_pt = g_strdup_printf ("%d", session->pt); pt_map = gst_structure_new ("application/x-rtp-pt-map", - "8", G_TYPE_UINT, 98, "96", G_TYPE_UINT, 99, NULL); + media_pt, G_TYPE_UINT, session->rtxPt, NULL); g_object_set (rtx, "payload-type-map", pt_map, NULL); gst_structure_free (pt_map); + g_free (media_pt); + gst_bin_add (GST_BIN (bin), rtx); pad = gst_element_get_static_pad (rtx, "src");