summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-29 00:10:13 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-29 00:10:13 +0200
commit9b4950c7db3605ecf62ddf65f83420cc3249172e (patch)
tree233b820bed2c5e3964abed72405ee7e6ca06539d /src
parentRTP bin SSRC callbacks (diff)
linking depayloaders worsk now
Diffstat (limited to 'src')
-rw-r--r--src/pipelines.c58
1 files changed, 50 insertions, 8 deletions
diff --git a/src/pipelines.c b/src/pipelines.c
index 3a092a4..41fee4f 100644
--- a/src/pipelines.c
+++ b/src/pipelines.c
@@ -37,6 +37,7 @@
#include <gst/gst.h>
#include <stdio.h>
+#include <string.h>
#include "options.h"
#include "utils.h"
@@ -336,14 +337,47 @@ GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp)
rtpbin. ! $V_DEPAY ! tee ! queue ! $V_DECODER ! tee ! queue ! $V_SINK
rtpbin. ! $A_DEPAY ! tee ! queue ! $A_DECODER ! tee ! queue ! $A_SINK
*/
-static void rtp_new_ssrc(GstElement *rtpbin, guint session, guint ssrc, gpointer user_data)
-{
- log_printf(DEBUG, "rtpbin: new SSRC %u for session %u", ssrc, session);
-}
-static void rtp_ssrc_validated(GstElement *rtpbin, guint session, guint ssrc, gpointer user_data)
+static void rtpbin_pad_added(GstElement* rtp, GstPad* pad, gpointer user_data)
{
- log_printf(DEBUG, "rtpbin: SSRC %u for session %u got validated", ssrc, session);
+ GstElement **depays = (GstElement**)user_data;
+
+ GstPadTemplate *pad_template = gst_pad_get_pad_template(pad);
+ if(pad_template == NULL) return;
+ if(strcmp("recv_rtp_src_%u_%u_%u", GST_PAD_TEMPLATE_NAME_TEMPLATE(pad_template))) {
+ gst_object_unref(GST_OBJECT(pad_template));
+ return;
+ }
+ gst_object_unref(GST_OBJECT(pad_template));
+
+ gchar* src_pad_name = gst_element_get_name(pad);
+ log_printf(DEBUG, "rtpbin: new pad created %s", src_pad_name);
+
+ guint i;
+ for(i = 0; i < 2; i++) {
+ GstPad *sink_pad = gst_element_get_static_pad(depays[i], "sink");
+ if(gst_pad_is_linked(sink_pad) || !gst_pad_can_link(pad, sink_pad)) {
+ gst_object_unref(GST_OBJECT(sink_pad));
+ continue;
+ }
+ GstPadLinkReturn ret = gst_pad_link(pad, sink_pad);
+ gst_object_unref(GST_OBJECT(sink_pad));
+
+ if(GST_PAD_LINK_FAILED(ret)) {
+ gchar* src_name = gst_element_get_name(rtp);
+ gchar* sink_name = gst_element_get_name(depays[i]);
+ log_printf(ERROR, "Error linking pad '%s' of '%s' with pad '%s' of '%s'",
+ src_pad_name, src_name, "sink", sink_name);
+ g_free(src_name);
+ g_free(sink_name);
+ continue;
+ }
+ break;
+ }
+ if(!gst_pad_is_linked(pad)) {
+ log_printf(ERROR, "rtpbin :no compatible element found for pad %s", src_pad_name);
+ }
+ g_free(src_pad_name);
}
GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp)
@@ -358,8 +392,16 @@ GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp)
return NULL;
}
log_printf(DEBUG, "rtpbin created successfully!");
- g_signal_connect(rtp, "on-new-ssrc", G_CALLBACK(rtp_new_ssrc), NULL);
- g_signal_connect(rtp, "on-ssrc-validated", G_CALLBACK(rtp_ssrc_validated), NULL);
+
+ GstElement **depays = g_new(GstElement*, 2);
+ depays[0] = sydra_create_element(opt->video_depayloader_, NULL);
+ depays[1] = sydra_create_element(opt->audio_depayloader_, NULL);
+ if(!depays[0] || !depays[1]) {
+ log_printf(ERROR, "creating depayloaders failed");
+ return NULL;
+ }
+ gst_bin_add_many(GST_BIN(pipeline), depays[0], depays[1], NULL);
+ g_signal_connect_closure(rtp, "pad-added", g_cclosure_new(G_CALLBACK(rtpbin_pad_added), depays, NULL), FALSE);
if(!create_udp_sources(opt, pipeline, rtp, udp)) {
return NULL;