diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-09-27 20:13:56 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-09-27 20:13:56 +0200 |
commit | e7ca89be606fc88c740d48b6cbdeff520a8d9ece (patch) | |
tree | d76566dfff7eeaa6169b881a38a7ab8988a51373 /src/pipelines.c | |
parent | idx vs. session (diff) |
creating udp sources works now
Diffstat (limited to 'src/pipelines.c')
-rw-r--r-- | src/pipelines.c | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/src/pipelines.c b/src/pipelines.c index 54400a9..7478a7b 100644 --- a/src/pipelines.c +++ b/src/pipelines.c @@ -110,7 +110,7 @@ static gboolean create_udp_sinks(options_t* opt, GstElement* pipeline, GstElemen if(!(sinks->rtp_video_.udp_) || !(sinks->rtcp_video_.udp_) || !(sinks->rtp_audio_.udp_) || !(sinks->rtcp_audio_.udp_)) return FALSE; - log_printf(DEBUG, "udp elements created successfully!"); + log_printf(DEBUG, "udp sinks created successfully!"); int rtp_port_local = opt->rtp_port_base_local_; g_object_set(G_OBJECT(sinks->rtp_video_.udp_), "bind-port", rtp_port_local++, NULL); @@ -132,7 +132,9 @@ static gboolean create_udp_sinks(options_t* opt, GstElement* pipeline, GstElemen g_object_set(G_OBJECT(sinks->rtcp_audio_.udp_), "bind-address", opt->rtp_addr_local_, NULL); } - gst_bin_add_many(GST_BIN (pipeline), sinks->rtp_video_.udp_, sinks->rtcp_video_.udp_, sinks->rtp_audio_.udp_, sinks->rtcp_audio_.udp_, NULL); + log_printf(DEBUG, "udp sinks configured successfully!"); + + gst_bin_add_many(GST_BIN(pipeline), sinks->rtp_video_.udp_, sinks->rtcp_video_.udp_, sinks->rtp_audio_.udp_, sinks->rtcp_audio_.udp_, NULL); if(!sydra_link_static_static(rtp, "send_rtp_src_0", sinks->rtp_video_.udp_, "sink") || !sydra_link_request_static(rtp, "send_rtcp_src_0", sinks->rtcp_video_.udp_, "sink") || @@ -140,7 +142,55 @@ static gboolean create_udp_sinks(options_t* opt, GstElement* pipeline, GstElemen !sydra_link_request_static(rtp, "send_rtcp_src_1", sinks->rtcp_audio_.udp_, "sink")) return FALSE; - log_printf(DEBUG, "udp elements linked successfully!"); + log_printf(DEBUG, "udp sinks linked successfully!"); + + return TRUE; +} + +static gboolean create_udp_sources(options_t* opt, GstElement* pipeline, GstElement* rtp, struct udp_sources *sources) +{ + sources->rtp_video_ = sydra_create_element("udpsrc", "udprtpv"); + sources->rtcp_video_ = sydra_create_element("udpsrc", "udprtcpv"); + sources->rtp_audio_ = sydra_create_element("udpsrc", "udprtpa"); + sources->rtcp_audio_ = sydra_create_element("udpsrc", "udprtcpa"); + + if(!(sources->rtp_video_) || !(sources->rtcp_video_) || !(sources->rtp_audio_) || !(sources->rtcp_audio_)) + return FALSE; + + log_printf(DEBUG, "udp sources created successfully!"); + + GstCaps *video_caps = gst_caps_from_string(opt->video_caps_); + GstCaps *audio_caps = gst_caps_from_string(opt->audio_caps_); + if(!video_caps || !audio_caps) { + log_printf(ERROR, "parsing video or audio caps failed!"); + return FALSE; + } + int rtp_port_local = opt->rtp_port_base_local_; + g_object_set(G_OBJECT(sources->rtp_video_), "port", rtp_port_local++, "caps", video_caps, NULL); + g_object_set(G_OBJECT(sources->rtcp_video_), "port", rtp_port_local++, NULL); + g_object_set(G_OBJECT(sources->rtp_audio_), "port", rtp_port_local++, "caps", audio_caps, NULL); + g_object_set(G_OBJECT(sources->rtcp_audio_), "port", rtp_port_local++, NULL); + gst_caps_unref(video_caps); + gst_caps_unref(audio_caps); + + if(opt->rtp_addr_local_) { + g_object_set(G_OBJECT(sources->rtp_video_), "address", opt->rtp_addr_local_, NULL); + g_object_set(G_OBJECT(sources->rtcp_video_), "address", opt->rtp_addr_local_, NULL); + g_object_set(G_OBJECT(sources->rtp_audio_), "address", opt->rtp_addr_local_, NULL); + g_object_set(G_OBJECT(sources->rtcp_audio_), "address", opt->rtp_addr_local_, NULL); + } + + log_printf(DEBUG, "udp sources configured successfully!"); + + gst_bin_add_many(GST_BIN(pipeline), sources->rtp_video_, sources->rtcp_video_, sources->rtp_audio_, sources->rtcp_audio_, NULL); + + if(!sydra_link_static_request(sources->rtp_video_, "src", rtp, "recv_rtp_sink_0") || + !sydra_link_static_request(sources->rtcp_video_, "src", rtp, "recv_rtcp_sink_0") || + !sydra_link_static_request(sources->rtp_audio_, "src", rtp, "recv_rtp_sink_1") || + !sydra_link_static_request(sources->rtcp_audio_, "src", rtp, "recv_rtcp_sink_1")) + return FALSE; + + log_printf(DEBUG, "udp sources linked successfully!"); return TRUE; } @@ -301,6 +351,10 @@ GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp) } log_printf(DEBUG, "rtpbin created successfully!"); + if(!create_udp_sources(opt, pipeline, rtp, udp)) { + return NULL; + } + log_printf(DEBUG, "receiver pipeline created successfully!"); return pipeline; } |