summaryrefslogtreecommitdiff
path: root/src/sydra.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2014-09-04 02:20:34 +0200
committerChristian Pointner <equinox@spreadspace.org>2014-09-04 02:20:34 +0200
commit72aad834774598a50cbaf4bedc22e8101b02cef5 (patch)
tree081d07f3e41a757e2aaa15bb388196a9181b5ead /src/sydra.c
parentremoved useless sysexec (diff)
added send stream pipeline with options
Diffstat (limited to 'src/sydra.c')
-rw-r--r--src/sydra.c61
1 files changed, 55 insertions, 6 deletions
diff --git a/src/sydra.c b/src/sydra.c
index ec87af8..b4b8d9b 100644
--- a/src/sydra.c
+++ b/src/sydra.c
@@ -27,11 +27,13 @@
* along with sydra. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/select.h>
+#include <time.h>
#include <gst/gst.h>
@@ -75,17 +77,19 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
break;
}
default:
+ log_printf(WARNING, "unkonwn message %d", GST_MESSAGE_TYPE(msg));
break;
}
return TRUE;
}
+
int main_loop(options_t* opt)
{
log_printf(INFO, "entering main loop");
GMainLoop *loop;
- GstElement *pipeline, *source;
+ GstElement *pipeline, *sender;
GstBus *bus;
loop = g_main_loop_new(NULL, FALSE);
@@ -95,17 +99,62 @@ int main_loop(options_t* opt)
return -1;
}
+ struct timespec now;
+ clock_gettime(CLOCK_REALTIME, &now);
+ struct tm bd_time;
+ localtime_r(&(now.tv_sec), &bd_time);
+ char recfile[1024]; //TODO: fix this hardcoded length
+ strftime(recfile, sizeof(recfile), opt->rec_name_format_, &bd_time);
+
+ int rtp_port_v = opt->rtp_port_base_;
+ int rtcp_port_v = opt->rtp_port_base_ + 100;
+ int rtp_port_a = opt->rtp_port_base_ + 200;
+ int rtcp_port_a = opt->rtp_port_base_ + 300;
+
+ char* sender_str;
+ int slen = asprintf(&sender_str, "rtpbin name=rtpbin \
+ %s ! tee name=vt \
+ vt. ! queue silent=true ! %s ! tee name=cvt \
+ cvt. ! %s ! rtpbin.send_rtp_sink_0 \
+ rtpbin.send_rtp_src_0 ! udpsink port=%d host=%s \
+ rtpbin.send_rtcp_src_0 ! udpsink port=%d host=%s sync=false async=false \
+ %s ! tee name=at \
+ at. ! queue silent=true ! %s ! %s ! rtpbin.send_rtp_sink_1 \
+ rtpbin.send_rtp_src_1 ! udpsink port=%d host=%s \
+ rtpbin.send_rtcp_src_1 ! udpsink port=%d host=%s sync=false async=false \
+ %s name=recmux ! filesink location=\"%s\" \
+ cvt. ! queue silent=true ! recmux. \
+ at. ! queue silent=true ! %s ! recmux. \
+ vt. ! queue silent=true ! textoverlay text=\" local \" shaded-background=true halignment=center valignment=baseline font-desc=\"Sans 18\" ! %s",
+ opt->video_src_, opt->video_enc_, opt->video_payloader_, rtp_port_v, opt->rtp_host_, rtcp_port_v, opt->rtp_host_,
+ opt->audio_src_, opt->audio_enc_stream_, opt->audio_payloader_, rtp_port_a, opt->rtp_host_, rtcp_port_a, opt->rtp_host_,
+ opt->rec_mux_, recfile, opt->audio_enc_rec_, opt->videosink_);
+
+ if(slen < 0) {
+ log_printf(ERROR, "memory error while constructing sender pipeline");
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(loop));
+ return -1;
+ }
+
+ printf("\n\n\n");
+ printf("%s", sender_str);
+ printf("\n\n\n");
+
+
GError *error = NULL;
- source = gst_parse_bin_from_description("videotestsrc ! xvimagesink", TRUE, &error);
- if(!source || error) {
- log_printf(ERROR, "Source Bin Description Parser Error: %s", error ? error->message : "unknown");
+ sender = gst_parse_bin_from_description(sender_str, TRUE, &error);
+ if(!sender || error) {
+ log_printf(ERROR, "Sending Bin Description Parser Error: %s", error ? error->message : "unknown");
g_error_free(error);
+ free(sender_str);
gst_object_unref(GST_OBJECT(pipeline));
gst_object_unref(GST_OBJECT(loop));
return -1;
}
+ free(sender_str);
- gst_bin_add_many(GST_BIN(pipeline), source, NULL);
+ gst_bin_add_many(GST_BIN(pipeline), sender, NULL);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, bus_call, loop);
gst_object_unref(bus);
@@ -140,7 +189,7 @@ int main(int argc, char* argv[])
if(ret == -3)
options_print_version();
if(ret == -4)
- fprintf(stderr, "the interval must be bigger than 0\n");
+ fprintf(stderr, "the port number is invalid\n");
if(ret != -2 && ret != -3 && ret != -4)
options_print_usage();