From d048447e6bee06400acd3854f999e4c264172ac0 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 2 Oct 2014 23:25:28 +0200 Subject: renamed the sydra utility to sydra-rtp --- doc/Makefile | 14 +- doc/sydra-rtp.8 | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/sydra-rtp.8.txt | 272 ++++++++++++++++++++++++++++++++++++ doc/sydra.8 | 389 ---------------------------------------------------- doc/sydra.8.txt | 272 ------------------------------------ src/Makefile | 4 +- src/configure | 4 +- src/datatypes.h | 2 +- src/log_targets.h | 4 +- src/options.c | 4 +- src/options.h | 2 +- src/pipelines.c | 4 +- src/sydra-rtp.c | 327 +++++++++++++++++++++++++++++++++++++++++++ src/sydra.c | 327 ------------------------------------------- 14 files changed, 1007 insertions(+), 1007 deletions(-) create mode 100644 doc/sydra-rtp.8 create mode 100644 doc/sydra-rtp.8.txt delete mode 100644 doc/sydra.8 delete mode 100644 doc/sydra.8.txt create mode 100644 src/sydra-rtp.c delete mode 100644 src/sydra.c diff --git a/doc/Makefile b/doc/Makefile index 8f609a7..09e6b49 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -39,17 +39,17 @@ VERSION=$(shell cat ../version) all: manpage -sydra.8: sydra.8.txt +sydra-rtp.8: sydra-rtp.8.txt a2x -f manpage $< - @ sed -i -e 's/\[FIXME: source\]/sydra ${VERSION}/' $@ - @ sed -i -e 's/\[FIXME: manual\]/sydra user manual/' $@ - @ sed -i -e 's/^sydra$$/\\fBsydra\\fR/' $@ + @ sed -i -e 's/\[FIXME: source\]/sydra-rtp ${VERSION}/' $@ + @ sed -i -e 's/\[FIXME: manual\]/sydra-rtp user manual/' $@ + @ sed -i -e 's/^sydra-rtp$$/\\fBsydra-rtp\\fR/' $@ @ sed -i -e 's/^ \[ \([^ ]*\)/ [ \\fB\1\\fR/' $@ -manpage: sydra.8 +manpage: sydra-rtp.8 clean: - rm -f sydra.8.xml + rm -f sydra-rtp.8.xml realclean: clean - rm -f sydra.8 + rm -f sydra-rtp.8 diff --git a/doc/sydra-rtp.8 b/doc/sydra-rtp.8 new file mode 100644 index 0000000..48a739f --- /dev/null +++ b/doc/sydra-rtp.8 @@ -0,0 +1,389 @@ +'\" t +.\" Title: sydra-rtp +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 10/02/2014 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: English +.\" +.TH "SYDRA\-RTP" "8" "10/02/2014" "\ \&" "\ \&" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +sydra-rtp \- tool for RTP based streams +.SH "SYNOPSIS" +.sp +.nf +sydra\-rtp + [ \fB\-h|\-\-help\fR ] + [ \fB\-D|\-\-nodaemonize\fR ] + [ \fB\-u|\-\-username\fR ] + [ \fB\-g|\-\-groupname\fR ] + [ \fB\-C|\-\-chroot\fR ] + [ \fB\-P|\-\-write\-pid\fR ] + [ \fB\-L|\-\-log\fR :[,[,[\&.\&.]]] ] + [ \fB\-U|\-\-debug\fR ] + [ \fB\-n|\-\-appname\fR ] + [ \fB\-m|\-\-mode\fR (sender|reciever) ] + [ \fB\-\-source\fR ] + [ \fB\-\-video\-encoder\fR ] + [ \fB\-\-video\-payloader\fR ] + [ \fB\-\-previewsink\fR ] + [ \fB\-\-audio\-encoder\fR ] + [ \fB\-\-audio\-payloader\fR ] + [ \fB\-\-video\-caps\fR ] + [ \fB\-\-video\-depayloader\fR ] + [ \fB\-\-video\-decoder\fR ] + [ \fB\-\-audio\-caps\fR ] + [ \fB\-\-audio\-depayloader\fR ] + [ \fB\-\-audio\-decoder\fR ] + [ \fB\-\-sink\fR ] + [ \fB\-a|\-\-rtp\-host\fR ] + [ \fB\-o|\-\-rtp\-port\-base\fR ] + [ \fB\-A|\-\-rtp\-addr\-local\fR
] + [ \fB\-O|\-\-rtp\-port\-base\-local\fR ] + [ \fB\-c|\-\-no\-auto\-client\fR ] + [ \fB\-t|\-\-timeout\fR ] + [ \fB\-k|\-\-keepalive\-interval\fR ] + [ \fB\-\-rec\-video\-encoder\fR ] + [ \fB\-\-rec\-audio\-encoder\fR ] + [ \fB\-\-rec\-mux\fR ] + [ \fB\-\-rec\-name\-format\fR ] +.fi +.SH "DESCRIPTION" +.sp +\fBsydra\fR is a toolbox which allows you to set up multiple bidirectional Video/Audio streams from external locations\&. \fBsydra\fR has been written to be used for the Elevate Festival in Graz Austria in order to involve external locations to present themselves at the festival\&. This manpage describes \fBsydra\-rtp\fR the basic utility for the task which is based on GStreamer and is written in C\&. The \fBsydra\-rtp\fR utility creates a gstreamer pipeline to send or receive RTP\-based Audio/Video streams\&. For a bidirectional connection 2 instances of \fBsydra\-rtp\fR are required on both sides of the communication\&. \fBsydra\-rtp\fR has automatic client detection capabilities in the form of keep alive messages\&. These message are sent out by receivers to request RTP packets from a sender\&. The sender will send RTP packets to one or more receivers which request the stream\&. It also uses the keep alive messages to remove stale client \fIconnections\fR\&. A receiver can also request to be removed from the list of receivers\&. This ensures a fast and clean shutdown\&. The keepalive messages are also a simple way to work around NAT and firewalls (UDP hole punching)\&. +.SH "OPTIONS" +.sp +The following options can be passed to the \fBsydra\-rtp\fR daemon: +.sp +\fBglobal options\fR +.PP +\fB\-D, \-\-nodaemonize\fR +.RS 4 +This option instructs +\fBsydra\-rtp\fR +to run in foreground instead of becoming a daemon which is the default\&. +.RE +.PP +\fB\-u, \-\-username \fR +.RS 4 +run as this user\&. If no group is specified (\fB\-g\fR) the default group of the user is used\&. The default is to not drop privileges\&. +.RE +.PP +\fB\-g, \-\-groupname \fR +.RS 4 +run as this group\&. If no username is specified (\fB\-u\fR) this gets ignored\&. The default is to not drop privileges\&. +.RE +.PP +\fB\-C, \-\-chroot \fR +.RS 4 +Instruct +\fBsydra\-rtp\fR +to run in a chroot jail\&. The default is to not run in chroot\&. +.RE +.PP +\fB\-P, \-\-write\-pid \fR +.RS 4 +Instruct +\fBsydra\-rtp\fR +to write it\(cqs pid to this file\&. The default is to not create a pid file\&. +.RE +.PP +\fB\-L, \-\-log :[,[,[\&.\&.]]]\fR +.RS 4 +add log target to logging system\&. This can be invoked several times in order to log to different targets at the same time\&. Every target has its own log level which is a number between 0 and 5\&. Where 0 means disabling log and 5 means debug messages are enabled\&. + +The file target can be used more than once with different levels\&. If no target is provided at the command line a single target with the config +\fBsyslog:3,sydra\-rtp,daemon\fR +is added\&. + +The following targets are supported: +.PP +\fBsyslog\fR +.RS 4 +log to syslog daemon, parameters [,[,]] +.RE +.PP +\fBfile\fR +.RS 4 +log to file, parameters [,] +.RE +.PP +\fBstdout\fR +.RS 4 +log to standard output, parameters +.RE +.PP +\fBstderr\fR +.RS 4 +log to standard error, parameters +.RE +.RE +.PP +\fB\-U, \-\-debug\fR +.RS 4 +This option instructs +\fBsydra\-rtp\fR +to run in debug mode\&. It implicits +\fB\-D\fR +(don\(cqt daemonize) and adds a log target with the configuration +\fBstdout:5\fR +(logging with maximum level)\&. In future releases there might be additional output when this option is supplied\&. +.RE +.PP +\fB\-n, \-\-appname \fR +.RS 4 +This set the application name using +\fIg_set_prgname()\fR\&. It will be used for example by xvimagesink for window title\&. +.RE +.PP +\fB\-m, \-\-mode (sender|reciever)\fR +.RS 4 +This sets the main mode of +\fBsydra\-rtp\fR\&. The sender will read raw video and audio from the source bin and send it via RTP to one or more receivers\&. +.RE +.sp +\fBsender\-mode only options\fR +.PP +\fB\-\-source \fR +.RS 4 +A gst\-launch\-style description for the raw video and audio bin\&. This bin must contain an element called +\fIvideosrc\fR +and an element called +\fIaudiosrc\fR +which should each contain a pad called +\fIsrc\fR\&. Theses pads will get connected to the encoder bins\&. Example: +\fIv4l2src ! videoconvert ! videoscale ! video/x\-raw,format=I420,width=864,height=480 ! identity name="videosrc" autoaudiosrc ! audio/x\-raw,format=S16LE,channels=1,rate=48000 ! identity name="audiosrc"\fR +.RE +.PP +\fB\-\-video\-encoder \fR +.RS 4 +Bin description for the video encoder\&. Example: +\fIvideoconvert ! vp8enc\fR +.RE +.PP +\fB\-\-video\-payloader \fR +.RS 4 +A RTP payloader element for the video codec in use\&. Example: +\fIrtpvp8pay\fR +.RE +.PP +\fB\-\-previewsink \fR +.RS 4 +A video sink element for local preview\&. Example: +\fIvideoconvert ! textoverlay test="preview" ! xvimagesink\fR +.RE +.PP +\fB\-\-audio\-encoder \fR +.RS 4 +Bin description for the audio encoder\&. Example: +\fIaudioconveert ! opusenc\fR +.RE +.PP +\fB\-\-audio\-payloader \fR +.RS 4 +A RTP payloader element for the audio codec in use\&. Example: +\fIrtpopuspay\fR +.RE +.sp +\fBreceiver\-mode only options\fR +.PP +\fB\-\-video\-caps \fR +.RS 4 +These caps will get assigned to incoming RTP packets for video\&. Example: +\fIapplication/x\-rtp,media=video,clock\-rate=90000,encoding\-name=VP8\-DRAFT\-IETF\-01,caps="video/x\-vp8"\fR +.RE +.PP +\fB\-\-video\-depayloader \fR +.RS 4 +A RTP depayloader element for the video codec in use\&. Example: +\fIrtpvp8depay\fR +.RE +.PP +\fB\-\-video\-decoder \fR +.RS 4 +Bin description for the video decoder\&. Example: +\fIvp8dec\fR +.RE +.PP +\fB\-\-audio\-caps \fR +.RS 4 +These caps will get assigned to incoming RTP packets for audio\&. Example: +\fIapplication/x\-rtp,media=audio,clock\-rate=48000,payload=96,encoding\-name=X\-GST\-OPUS\-DRAFT\-SPITTKA\-00,caps="audio/x\-opus"\fR +.RE +.PP +\fB\-\-audio\-depayloader \fR +.RS 4 +A RTP depayloader element for the audio codec in use\&. Example: +\fIrtpopusdepay\fR +.RE +.PP +\fB\-\-audio\-decoder \fR +.RS 4 +Bin description for the audio decoder\&. Example: +\fIopusdec\fR +.RE +.PP +\fB\-\-sink \fR +.RS 4 +A gst\-launch\-style description for the raw video and audio bin\&. This bin must contain an element called +\fIvideosink\fR +and an element called +\fIaudiosink\fR +which should each contain a pad called +\fIsink\fR\&. Theses pads will get connected to the decoder bins\&. Example: +\fIvideoconvert name="videosink" ! videoscale add\-borders=true ! xvimagesink audioconvert name="audiosink" ! autoaudiosink\fR +.RE +.sp +\fBoptions for RTP\fR +.PP +\fB\-a, \-\-rtp\-host \fR +.RS 4 +In +\fIsender\fR +mode this sets the address or hostname of the remote RTP receiver\&. Please mind that the remote RTP host is always added as a receiver and it shouldn\(cqt be configured to send keepalives\&. This would re\-add the receiver to the list of clients and as a result duplicate packages will be sent\&. Also the remote RTP host is excluded from client timeout handling and remove requests from it will get ignored\&. When you omit this in sender mode the automatic client detection will be used to add receivers\&. In +\fIreceiver\fR +mode keepalive messages will be sent to this host\&. Leave empty to disable keepalive messages\&. +.RE +.PP +\fB\-o, \-\-rtp\-port\-base \fR +.RS 4 +The base number for remote ports\&. +\fBsydra\-rtp\fR +will send the RTP/RTCP packets using the following mapping: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +rtp\-port\-base + 0: RTP Video +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +rtp\-port\-base + 1: RTCP Video +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +rtp\-port\-base + 2: RTP Audio +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +rtp\-port\-base + 3: RTCP Audio +.RE +.RE +.PP +\fB\-A, \-\-rtp\-addr\-local
\fR +.RS 4 +The local address to wait for incoming UDP messages\&. Leave empty to listen on any address\&. +.RE +.PP +\fB\-O, \-\-rtp\-port\-base\-local \fR +.RS 4 +The base number for local ports to bind to\&. The same mapping as for the remote port\-base is used to map incoming RTP packets to the RTP bin\&. +.RE +.PP +\fB\-c, \-\-no\-auto\-client\fR +.RS 4 +This disables auto\-detection for clients in +\fIsender\fR +mode\&. Mind that if you disable the automatic client detection and also omit the rtp\-host option +\fBsydra\-rtp\fR +won\(cqt send any RTP messages\&. If configured recording will work but this is most probably not what you want\&. +.RE +.PP +\fB\-t, \-\-timeout \fR +.RS 4 +This sets the client timeout in seconds in +\fIsender\fR +mode\&. A value of 0 disables client timeouts\&. This is not recommended\&. +.RE +.PP +\fB\-k, \-\-keepalive\-interval \fR +.RS 4 +This sets the interval in seconds for sending out keepalive messages in +\fIreceiver\fR +mode\&. A value of 0 disables keepalive messages and therefor the client auto detection won\(cqt work for this client\&. +.RE +.sp +\fBoptions for recording\fR +.PP +\fB\-\-rec\-video\-encoder \fR +.RS 4 +A bin description for the video encoder used for recording\&. If you leave this empty the output from the RTP video encoder is used\&. Example: +\fIvideoconvert ! jpegenc\fR +.RE +.PP +\fB\-\-rec\-audio\-encoder \fR +.RS 4 +A bin description for the audio encoder used for recording\&. If you leave this empty the output from the RTP audio encoder is used\&. Example: +\fIaudioconvert ! vorbisenc\fR +.RE +.PP +\fB\-\-rec\-mux \fR +.RS 4 +A gstreamer muxer element used for recording\&. If you leave this empty recording will be disabled\&. Example: +\fImatroskamux\fR +.RE +.PP +\fB\-\-rec\-name\-format \fR +.RS 4 +A +\fIstrftime\fR +based format string which will be used to create the name for the recorded file\&. Example: \&./recordings/%Y\-%m\-%d_%H\-%M\-%S\&.mkv +.RE +.SH "BUGS" +.sp +Most likely there are some bugs in \fBsydra\-rtp\fR\&. If you find a bug, please let the developers know at equinox@spreadspace\&.org\&. Of course, patches are preferred\&. +.SH "SEE ALSO" +.sp +\fBstrftime\fR(3), \fBgst\-launch\fR(1) +.SH "AUTHORS" +.sp +Christian Pointner +.SH "COPYING" +.sp +Copyright (C) 2014 Christian Pointner\&. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version\&. diff --git a/doc/sydra-rtp.8.txt b/doc/sydra-rtp.8.txt new file mode 100644 index 0000000..4fd87b0 --- /dev/null +++ b/doc/sydra-rtp.8.txt @@ -0,0 +1,272 @@ +sydra-rtp(8) +============ + +NAME +---- + +sydra-rtp - tool for RTP based streams + + +SYNOPSIS +-------- + +.... +sydra-rtp + [ -h|--help ] + [ -D|--nodaemonize ] + [ -u|--username ] + [ -g|--groupname ] + [ -C|--chroot ] + [ -P|--write-pid ] + [ -L|--log :[,[,[..]]] ] + [ -U|--debug ] + [ -n|--appname ] + [ -m|--mode (sender|reciever) ] + [ --source ] + [ --video-encoder ] + [ --video-payloader ] + [ --previewsink ] + [ --audio-encoder ] + [ --audio-payloader ] + [ --video-caps ] + [ --video-depayloader ] + [ --video-decoder ] + [ --audio-caps ] + [ --audio-depayloader ] + [ --audio-decoder ] + [ --sink ] + [ -a|--rtp-host ] + [ -o|--rtp-port-base ] + [ -A|--rtp-addr-local
] + [ -O|--rtp-port-base-local ] + [ -c|--no-auto-client ] + [ -t|--timeout ] + [ -k|--keepalive-interval ] + [ --rec-video-encoder ] + [ --rec-audio-encoder ] + [ --rec-mux ] + [ --rec-name-format ] +.... + + +DESCRIPTION +----------- + +*sydra* is a toolbox which allows you to set up multiple bidirectional +Video/Audio streams from external locations. +*sydra* has been written to be used for the Elevate Festival in Graz +Austria in order to involve external locations to present themselves +at the festival. +This manpage describes *sydra-rtp* the basic utility for the task which is +based on GStreamer and is written in C. +The *sydra-rtp* utility creates a gstreamer pipeline to send or receive +RTP-based Audio/Video streams. For a bidirectional connection 2 instances +of *sydra-rtp* are required on both sides of the communication. *sydra-rtp* has +automatic client detection capabilities in the form of keep alive messages. +These message are sent out by receivers to request RTP packets from a sender. +The sender will send RTP packets to one or more receivers which request +the stream. It also uses the keep alive messages to remove stale client +'connections'. A receiver can also request to be removed from the list of +receivers. This ensures a fast and clean shutdown. +The keepalive messages are also a simple way to work around NAT and +firewalls (UDP hole punching). + +OPTIONS +------- + +The following options can be passed to the *sydra-rtp* daemon: + +*global options* + +*-D, --nodaemonize*:: + This option instructs *sydra-rtp* to run in foreground + instead of becoming a daemon which is the default. + +*-u, --username *:: + run as this user. If no group is specified (*-g*) the default group of + the user is used. The default is to not drop privileges. + +*-g, --groupname *:: + run as this group. If no username is specified (*-u*) this gets ignored. + The default is to not drop privileges. + +*-C, --chroot *:: + Instruct *sydra-rtp* to run in a chroot jail. The default is + to not run in chroot. + +*-P, --write-pid *:: + Instruct *sydra-rtp* to write it's pid to this file. The default is + to not create a pid file. + +*-L, --log :[,[,[..]]]*:: + add log target to logging system. This can be invoked several times + in order to log to different targets at the same time. Every target + has its own log level which is a number between 0 and 5. Where 0 means + disabling log and 5 means debug messages are enabled. + + The file target can be used more than once with different levels. + If no target is provided at the command line a single target with the + config *syslog:3,sydra-rtp,daemon* is added. + + The following targets are supported: + + *syslog*;; log to syslog daemon, parameters [,[,]] + *file*;; log to file, parameters [,] + *stdout*;; log to standard output, parameters + *stderr*;; log to standard error, parameters + +*-U, --debug*:: + This option instructs *sydra-rtp* to run in debug mode. It implicits *-D* + (don't daemonize) and adds a log target with the configuration + *stdout:5* (logging with maximum level). In future releases there might + be additional output when this option is supplied. + +*-n, --appname *:: + This set the application name using 'g_set_prgname()'. It will be used for example + by xvimagesink for window title. + +*-m, --mode (sender|reciever)*:: + This sets the main mode of *sydra-rtp*. The sender will read raw video and audio + from the source bin and send it via RTP to one or more receivers. + + +*sender-mode only options* + +*--source *:: + A gst-launch-style description for the raw video and audio bin. This bin must contain + an element called 'videosrc' and an element called 'audiosrc' which should each + contain a pad called 'src'. Theses pads will get connected to the encoder bins. + Example: + 'v4l2src ! videoconvert ! videoscale ! video/x-raw,format=I420,width=864,height=480 ! identity name="videosrc" + autoaudiosrc ! audio/x-raw,format=S16LE,channels=1,rate=48000 ! identity name="audiosrc"' + +*--video-encoder *:: + Bin description for the video encoder. Example: 'videoconvert ! vp8enc' + +*--video-payloader *:: + A RTP payloader element for the video codec in use. Example: 'rtpvp8pay' + +*--previewsink *:: + A video sink element for local preview. Example: 'videoconvert ! textoverlay test="preview" ! xvimagesink' + +*--audio-encoder *:: + Bin description for the audio encoder. Example: 'audioconveert ! opusenc' + +*--audio-payloader *:: + A RTP payloader element for the audio codec in use. Example: 'rtpopuspay' + + +*receiver-mode only options* + +*--video-caps *:: + These caps will get assigned to incoming RTP packets for video. Example: + 'application/x-rtp,media=video,clock-rate=90000,encoding-name=VP8-DRAFT-IETF-01,caps="video/x-vp8"' + +*--video-depayloader *:: + A RTP depayloader element for the video codec in use. Example: 'rtpvp8depay' + +*--video-decoder *:: + Bin description for the video decoder. Example: 'vp8dec' + +*--audio-caps *:: + These caps will get assigned to incoming RTP packets for audio. Example: + 'application/x-rtp,media=audio,clock-rate=48000,payload=96,encoding-name=X-GST-OPUS-DRAFT-SPITTKA-00,caps="audio/x-opus"' + +*--audio-depayloader *:: + A RTP depayloader element for the audio codec in use. Example: 'rtpopusdepay' + +*--audio-decoder *:: + Bin description for the audio decoder. Example: 'opusdec' + +*--sink *:: + A gst-launch-style description for the raw video and audio bin. This bin must contain + an element called 'videosink' and an element called 'audiosink' which should each + contain a pad called 'sink'. Theses pads will get connected to the decoder bins. + Example: + 'videoconvert name="videosink" ! videoscale add-borders=true ! xvimagesink + audioconvert name="audiosink" ! autoaudiosink' + +*options for RTP* + +*-a, --rtp-host *:: + In 'sender' mode this sets the address or hostname of the remote RTP receiver. Please + mind that the remote RTP host is always added as a receiver and it shouldn't be + configured to send keepalives. This would re-add the receiver to the list of clients + and as a result duplicate packages will be sent. + Also the remote RTP host is excluded from client timeout handling and remove requests + from it will get ignored. + When you omit this in sender mode the automatic client detection will be used to add + receivers. + In 'receiver' mode keepalive messages will be sent to this host. Leave empty to disable + keepalive messages. + +*-o, --rtp-port-base *:: + The base number for remote ports. *sydra-rtp* will send the RTP/RTCP packets using the following + mapping: + * rtp-port-base + 0: RTP Video + * rtp-port-base + 1: RTCP Video + * rtp-port-base + 2: RTP Audio + * rtp-port-base + 3: RTCP Audio + +*-A, --rtp-addr-local
*:: + The local address to wait for incoming UDP messages. Leave empty to listen on any address. + +*-O, --rtp-port-base-local *:: + The base number for local ports to bind to. The same mapping as for the remote port-base is + used to map incoming RTP packets to the RTP bin. + +*-c, --no-auto-client*:: + This disables auto-detection for clients in 'sender' mode. Mind that if you disable the + automatic client detection and also omit the rtp-host option *sydra-rtp* won't send any RTP + messages. If configured recording will work but this is most probably not what you want. + +*-t, --timeout *:: + This sets the client timeout in seconds in 'sender' mode. A value of 0 disables client + timeouts. This is not recommended. + +*-k, --keepalive-interval *:: + This sets the interval in seconds for sending out keepalive messages in 'receiver' mode. + A value of 0 disables keepalive messages and therefor the client auto detection won't + work for this client. + +*options for recording* + +*--rec-video-encoder *:: + A bin description for the video encoder used for recording. If you leave this empty the + output from the RTP video encoder is used. Example: 'videoconvert ! jpegenc' + +*--rec-audio-encoder *:: + A bin description for the audio encoder used for recording. If you leave this empty the + output from the RTP audio encoder is used. Example: 'audioconvert ! vorbisenc' + +*--rec-mux *:: + A gstreamer muxer element used for recording. If you leave this empty recording will be + disabled. Example: 'matroskamux' + +*--rec-name-format *:: + A 'strftime' based format string which will be used to create the name for the + recorded file. Example: ./recordings/%Y-%m-%d_%H-%M-%S.mkv + + +BUGS +---- +Most likely there are some bugs in *sydra-rtp*. If you find a bug, please let +the developers know at equinox@spreadspace.org. Of course, patches are preferred. + + +SEE ALSO +-------- + +*strftime*(3), *gst-launch*(1) + +AUTHORS +------- + +Christian Pointner + + +COPYING +------- + +Copyright \(C) 2014 Christian Pointner. This program is free +software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or any later version. diff --git a/doc/sydra.8 b/doc/sydra.8 deleted file mode 100644 index 31d22c0..0000000 --- a/doc/sydra.8 +++ /dev/null @@ -1,389 +0,0 @@ -'\" t -.\" Title: sydra -.\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 10/02/2014 -.\" Manual: \ \& -.\" Source: \ \& -.\" Language: English -.\" -.TH "SYDRA" "8" "10/02/2014" "\ \&" "\ \&" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "NAME" -sydra \- toolbox for RTP based streams -.SH "SYNOPSIS" -.sp -.nf -\fBsydra\fR - [ \fB\-h|\-\-help\fR ] - [ \fB\-D|\-\-nodaemonize\fR ] - [ \fB\-u|\-\-username\fR ] - [ \fB\-g|\-\-groupname\fR ] - [ \fB\-C|\-\-chroot\fR ] - [ \fB\-P|\-\-write\-pid\fR ] - [ \fB\-L|\-\-log\fR :[,[,[\&.\&.]]] ] - [ \fB\-U|\-\-debug\fR ] - [ \fB\-n|\-\-appname\fR ] - [ \fB\-m|\-\-mode\fR (sender|reciever) ] - [ \fB\-\-source\fR ] - [ \fB\-\-video\-encoder\fR ] - [ \fB\-\-video\-payloader\fR ] - [ \fB\-\-previewsink\fR ] - [ \fB\-\-audio\-encoder\fR ] - [ \fB\-\-audio\-payloader\fR ] - [ \fB\-\-video\-caps\fR ] - [ \fB\-\-video\-depayloader\fR ] - [ \fB\-\-video\-decoder\fR ] - [ \fB\-\-audio\-caps\fR ] - [ \fB\-\-audio\-depayloader\fR ] - [ \fB\-\-audio\-decoder\fR ] - [ \fB\-\-sink\fR ] - [ \fB\-a|\-\-rtp\-host\fR ] - [ \fB\-o|\-\-rtp\-port\-base\fR ] - [ \fB\-A|\-\-rtp\-addr\-local\fR
] - [ \fB\-O|\-\-rtp\-port\-base\-local\fR ] - [ \fB\-c|\-\-no\-auto\-client\fR ] - [ \fB\-t|\-\-timeout\fR ] - [ \fB\-k|\-\-keepalive\-interval\fR ] - [ \fB\-\-rec\-video\-encoder\fR ] - [ \fB\-\-rec\-audio\-encoder\fR ] - [ \fB\-\-rec\-mux\fR ] - [ \fB\-\-rec\-name\-format\fR ] -.fi -.SH "DESCRIPTION" -.sp -\fBsydra\fR is a toolbox which allows you to set up multiple bidirectional Video/Audio streams from external locations\&. \fBsydra\fR has been written to be used for the Elevate Festival in Graz Austria in order to involve external locations to present themselves at the festival\&. This manpage describes \fBsydra\fR the basic utility for the task which is based on GStreamer and is written in C\&. The \fBsydra\fR utility creates a gstreamer pipeline to send or receive RTP\-based Audio/Video streams\&. For a bidirectional connection 2 instances of \fBsydra\fR are required on both sides of the communication\&. \fBsydra\fR has automatic client detection capabilities in the form of keep alive messages\&. These message are sent out by receivers to request RTP packets from a sender\&. The sender will send RTP packets to one or more receivers which request the stream\&. It also uses the keep alive messages to remove stale client \fIconnections\fR\&. A receiver can also request to be removed from the list of receivers\&. This ensures a fast and clean shutdown\&. The keepalive messages are also a simple way to work around NAT and firewalls (UDP hole punching)\&. -.SH "OPTIONS" -.sp -The following options can be passed to the \fBsydra\fR daemon: -.sp -\fBglobal options\fR -.PP -\fB\-D, \-\-nodaemonize\fR -.RS 4 -This option instructs -\fBsydra\fR -to run in foreground instead of becoming a daemon which is the default\&. -.RE -.PP -\fB\-u, \-\-username \fR -.RS 4 -run as this user\&. If no group is specified (\fB\-g\fR) the default group of the user is used\&. The default is to not drop privileges\&. -.RE -.PP -\fB\-g, \-\-groupname \fR -.RS 4 -run as this group\&. If no username is specified (\fB\-u\fR) this gets ignored\&. The default is to not drop privileges\&. -.RE -.PP -\fB\-C, \-\-chroot \fR -.RS 4 -Instruct -\fBsydra\fR -to run in a chroot jail\&. The default is to not run in chroot\&. -.RE -.PP -\fB\-P, \-\-write\-pid \fR -.RS 4 -Instruct -\fBsydra\fR -to write it\(cqs pid to this file\&. The default is to not create a pid file\&. -.RE -.PP -\fB\-L, \-\-log :[,[,[\&.\&.]]]\fR -.RS 4 -add log target to logging system\&. This can be invoked several times in order to log to different targets at the same time\&. Every target has its own log level which is a number between 0 and 5\&. Where 0 means disabling log and 5 means debug messages are enabled\&. - -The file target can be used more than once with different levels\&. If no target is provided at the command line a single target with the config -\fBsyslog:3,sydra,daemon\fR -is added\&. - -The following targets are supported: -.PP -\fBsyslog\fR -.RS 4 -log to syslog daemon, parameters [,[,]] -.RE -.PP -\fBfile\fR -.RS 4 -log to file, parameters [,] -.RE -.PP -\fBstdout\fR -.RS 4 -log to standard output, parameters -.RE -.PP -\fBstderr\fR -.RS 4 -log to standard error, parameters -.RE -.RE -.PP -\fB\-U, \-\-debug\fR -.RS 4 -This option instructs -\fBsydra\fR -to run in debug mode\&. It implicits -\fB\-D\fR -(don\(cqt daemonize) and adds a log target with the configuration -\fBstdout:5\fR -(logging with maximum level)\&. In future releases there might be additional output when this option is supplied\&. -.RE -.PP -\fB\-n, \-\-appname \fR -.RS 4 -This set the application name using -\fIg_set_prgname()\fR\&. It will be used for example by xvimagesink for window title\&. -.RE -.PP -\fB\-m, \-\-mode (sender|reciever)\fR -.RS 4 -This sets the main mode of -\fBsydra\fR\&. The sender will read raw video and audio from the source bin and send it via RTP to one or more receivers\&. -.RE -.sp -\fBsender\-mode only options\fR -.PP -\fB\-\-source \fR -.RS 4 -A gst\-launch\-style description for the raw video and audio bin\&. This bin must contain an element called -\fIvideosrc\fR -and an element called -\fIaudiosrc\fR -which should each contain a pad called -\fIsrc\fR\&. Theses pads will get connected to the encoder bins\&. Example: -\fIv4l2src ! videoconvert ! videoscale ! video/x\-raw,format=I420,width=864,height=480 ! identity name="videosrc" autoaudiosrc ! audio/x\-raw,format=S16LE,channels=1,rate=48000 ! identity name="audiosrc"\fR -.RE -.PP -\fB\-\-video\-encoder \fR -.RS 4 -Bin description for the video encoder\&. Example: -\fIvideoconvert ! vp8enc\fR -.RE -.PP -\fB\-\-video\-payloader \fR -.RS 4 -A RTP payloader element for the video codec in use\&. Example: -\fIrtpvp8pay\fR -.RE -.PP -\fB\-\-previewsink \fR -.RS 4 -A video sink element for local preview\&. Example: -\fIvideoconvert ! textoverlay test="preview" ! xvimagesink\fR -.RE -.PP -\fB\-\-audio\-encoder \fR -.RS 4 -Bin description for the audio encoder\&. Example: -\fIaudioconveert ! opusenc\fR -.RE -.PP -\fB\-\-audio\-payloader \fR -.RS 4 -A RTP payloader element for the audio codec in use\&. Example: -\fIrtpopuspay\fR -.RE -.sp -\fBreceiver\-mode only options\fR -.PP -\fB\-\-video\-caps \fR -.RS 4 -These caps will get assigned to incoming RTP packets for video\&. Example: -\fIapplication/x\-rtp,media=video,clock\-rate=90000,encoding\-name=VP8\-DRAFT\-IETF\-01,caps="video/x\-vp8"\fR -.RE -.PP -\fB\-\-video\-depayloader \fR -.RS 4 -A RTP depayloader element for the video codec in use\&. Example: -\fIrtpvp8depay\fR -.RE -.PP -\fB\-\-video\-decoder \fR -.RS 4 -Bin description for the video decoder\&. Example: -\fIvp8dec\fR -.RE -.PP -\fB\-\-audio\-caps \fR -.RS 4 -These caps will get assigned to incoming RTP packets for audio\&. Example: -\fIapplication/x\-rtp,media=audio,clock\-rate=48000,payload=96,encoding\-name=X\-GST\-OPUS\-DRAFT\-SPITTKA\-00,caps="audio/x\-opus"\fR -.RE -.PP -\fB\-\-audio\-depayloader \fR -.RS 4 -A RTP depayloader element for the audio codec in use\&. Example: -\fIrtpopusdepay\fR -.RE -.PP -\fB\-\-audio\-decoder \fR -.RS 4 -Bin description for the audio decoder\&. Example: -\fIopusdec\fR -.RE -.PP -\fB\-\-sink \fR -.RS 4 -A gst\-launch\-style description for the raw video and audio bin\&. This bin must contain an element called -\fIvideosink\fR -and an element called -\fIaudiosink\fR -which should each contain a pad called -\fIsink\fR\&. Theses pads will get connected to the decoder bins\&. Example: -\fIvideoconvert name="videosink" ! videoscale add\-borders=true ! xvimagesink audioconvert name="audiosink" ! autoaudiosink\fR -.RE -.sp -\fBoptions for RTP\fR -.PP -\fB\-a, \-\-rtp\-host \fR -.RS 4 -In -\fIsender\fR -mode this sets the address or hostname of the remote RTP receiver\&. Please mind that the remote RTP host is always added as a receiver and it shouldn\(cqt be configured to send keepalives\&. This would re\-add the receiver to the list of clients and as a result duplicate packages will be sent\&. Also the remote RTP host is excluded from client timeout handling and remove requests from it will get ignored\&. When you omit this in sender mode the automatic client detection will be used to add receivers\&. In -\fIreceiver\fR -mode keepalive messages will be sent to this host\&. Leave empty to disable keepalive messages\&. -.RE -.PP -\fB\-o, \-\-rtp\-port\-base \fR -.RS 4 -The base number for remote ports\&. -\fBsydra\fR -will send the RTP/RTCP packets using the following mapping: -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -rtp\-port\-base + 0: RTP Video -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -rtp\-port\-base + 1: RTCP Video -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -rtp\-port\-base + 2: RTP Audio -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -rtp\-port\-base + 3: RTCP Audio -.RE -.RE -.PP -\fB\-A, \-\-rtp\-addr\-local
\fR -.RS 4 -The local address to wait for incoming UDP messages\&. Leave empty to listen on any address\&. -.RE -.PP -\fB\-O, \-\-rtp\-port\-base\-local \fR -.RS 4 -The base number for local ports to bind to\&. The same mapping as for the remote port\-base is used to map incoming RTP packets to the RTP bin\&. -.RE -.PP -\fB\-c, \-\-no\-auto\-client\fR -.RS 4 -This disables auto\-detection for clients in -\fIsender\fR -mode\&. Mind that if you disable the automatic client detection and also omit the rtp\-host option -\fBsydra\fR -won\(cqt send any RTP messages\&. If configured recording will work but this is most probably not what you want\&. -.RE -.PP -\fB\-t, \-\-timeout \fR -.RS 4 -This sets the client timeout in seconds in -\fIsender\fR -mode\&. A value of 0 disables client timeouts\&. This is not recommended\&. -.RE -.PP -\fB\-k, \-\-keepalive\-interval \fR -.RS 4 -This sets the interval in seconds for sending out keepalive messages in -\fIreceiver\fR -mode\&. A value of 0 disables keepalive messages and therefor the client auto detection won\(cqt work for this client\&. -.RE -.sp -\fBoptions for recording\fR -.PP -\fB\-\-rec\-video\-encoder \fR -.RS 4 -A bin description for the video encoder used for recording\&. If you leave this empty the output from the RTP video encoder is used\&. Example: -\fIvideoconvert ! jpegenc\fR -.RE -.PP -\fB\-\-rec\-audio\-encoder \fR -.RS 4 -A bin description for the audio encoder used for recording\&. If you leave this empty the output from the RTP audio encoder is used\&. Example: -\fIaudioconvert ! vorbisenc\fR -.RE -.PP -\fB\-\-rec\-mux \fR -.RS 4 -A gstreamer muxer element used for recording\&. If you leave this empty recording will be disabled\&. Example: -\fImatroskamux\fR -.RE -.PP -\fB\-\-rec\-name\-format \fR -.RS 4 -A -\fIstrftime\fR -based format string which will be used to create the name for the recorded file\&. Example: \&./recordings/%Y\-%m\-%d_%H\-%M\-%S\&.mkv -.RE -.SH "BUGS" -.sp -Most likely there are some bugs in \fBsydra\fR\&. If you find a bug, please let the developers know at equinox@spreadspace\&.org\&. Of course, patches are preferred\&. -.SH "SEE ALSO" -.sp -\fBstrftime\fR(3), \fBgst\-launch\fR(1) -.SH "AUTHORS" -.sp -Christian Pointner -.SH "COPYING" -.sp -Copyright (C) 2014 Christian Pointner\&. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version\&. diff --git a/doc/sydra.8.txt b/doc/sydra.8.txt deleted file mode 100644 index 3dc037c..0000000 --- a/doc/sydra.8.txt +++ /dev/null @@ -1,272 +0,0 @@ -sydra(8) -======== - -NAME ----- - -sydra - toolbox for RTP based streams - - -SYNOPSIS --------- - -.... -sydra - [ -h|--help ] - [ -D|--nodaemonize ] - [ -u|--username ] - [ -g|--groupname ] - [ -C|--chroot ] - [ -P|--write-pid ] - [ -L|--log :[,[,[..]]] ] - [ -U|--debug ] - [ -n|--appname ] - [ -m|--mode (sender|reciever) ] - [ --source ] - [ --video-encoder ] - [ --video-payloader ] - [ --previewsink ] - [ --audio-encoder ] - [ --audio-payloader ] - [ --video-caps ] - [ --video-depayloader ] - [ --video-decoder ] - [ --audio-caps ] - [ --audio-depayloader ] - [ --audio-decoder ] - [ --sink ] - [ -a|--rtp-host ] - [ -o|--rtp-port-base ] - [ -A|--rtp-addr-local
] - [ -O|--rtp-port-base-local ] - [ -c|--no-auto-client ] - [ -t|--timeout ] - [ -k|--keepalive-interval ] - [ --rec-video-encoder ] - [ --rec-audio-encoder ] - [ --rec-mux ] - [ --rec-name-format ] -.... - - -DESCRIPTION ------------ - -*sydra* is a toolbox which allows you to set up multiple bidirectional -Video/Audio streams from external locations. -*sydra* has been written to be used for the Elevate Festival in Graz -Austria in order to involve external locations to present themselves -at the festival. -This manpage describes *sydra* the basic utility for the task which is -based on GStreamer and is written in C. -The *sydra* utility creates a gstreamer pipeline to send or receive -RTP-based Audio/Video streams. For a bidirectional connection 2 instances -of *sydra* are required on both sides of the communication. *sydra* has -automatic client detection capabilities in the form of keep alive messages. -These message are sent out by receivers to request RTP packets from a sender. -The sender will send RTP packets to one or more receivers which request -the stream. It also uses the keep alive messages to remove stale client -'connections'. A receiver can also request to be removed from the list of -receivers. This ensures a fast and clean shutdown. -The keepalive messages are also a simple way to work around NAT and -firewalls (UDP hole punching). - -OPTIONS -------- - -The following options can be passed to the *sydra* daemon: - -*global options* - -*-D, --nodaemonize*:: - This option instructs *sydra* to run in foreground - instead of becoming a daemon which is the default. - -*-u, --username *:: - run as this user. If no group is specified (*-g*) the default group of - the user is used. The default is to not drop privileges. - -*-g, --groupname *:: - run as this group. If no username is specified (*-u*) this gets ignored. - The default is to not drop privileges. - -*-C, --chroot *:: - Instruct *sydra* to run in a chroot jail. The default is - to not run in chroot. - -*-P, --write-pid *:: - Instruct *sydra* to write it's pid to this file. The default is - to not create a pid file. - -*-L, --log :[,[,[..]]]*:: - add log target to logging system. This can be invoked several times - in order to log to different targets at the same time. Every target - has its own log level which is a number between 0 and 5. Where 0 means - disabling log and 5 means debug messages are enabled. + - The file target can be used more than once with different levels. - If no target is provided at the command line a single target with the - config *syslog:3,sydra,daemon* is added. + - The following targets are supported: - - *syslog*;; log to syslog daemon, parameters [,[,]] - *file*;; log to file, parameters [,] - *stdout*;; log to standard output, parameters - *stderr*;; log to standard error, parameters - -*-U, --debug*:: - This option instructs *sydra* to run in debug mode. It implicits *-D* - (don't daemonize) and adds a log target with the configuration - *stdout:5* (logging with maximum level). In future releases there might - be additional output when this option is supplied. - -*-n, --appname *:: - This set the application name using 'g_set_prgname()'. It will be used for example - by xvimagesink for window title. - -*-m, --mode (sender|reciever)*:: - This sets the main mode of *sydra*. The sender will read raw video and audio - from the source bin and send it via RTP to one or more receivers. - - -*sender-mode only options* - -*--source *:: - A gst-launch-style description for the raw video and audio bin. This bin must contain - an element called 'videosrc' and an element called 'audiosrc' which should each - contain a pad called 'src'. Theses pads will get connected to the encoder bins. - Example: - 'v4l2src ! videoconvert ! videoscale ! video/x-raw,format=I420,width=864,height=480 ! identity name="videosrc" - autoaudiosrc ! audio/x-raw,format=S16LE,channels=1,rate=48000 ! identity name="audiosrc"' - -*--video-encoder *:: - Bin description for the video encoder. Example: 'videoconvert ! vp8enc' - -*--video-payloader *:: - A RTP payloader element for the video codec in use. Example: 'rtpvp8pay' - -*--previewsink *:: - A video sink element for local preview. Example: 'videoconvert ! textoverlay test="preview" ! xvimagesink' - -*--audio-encoder *:: - Bin description for the audio encoder. Example: 'audioconveert ! opusenc' - -*--audio-payloader *:: - A RTP payloader element for the audio codec in use. Example: 'rtpopuspay' - - -*receiver-mode only options* - -*--video-caps *:: - These caps will get assigned to incoming RTP packets for video. Example: - 'application/x-rtp,media=video,clock-rate=90000,encoding-name=VP8-DRAFT-IETF-01,caps="video/x-vp8"' - -*--video-depayloader *:: - A RTP depayloader element for the video codec in use. Example: 'rtpvp8depay' - -*--video-decoder *:: - Bin description for the video decoder. Example: 'vp8dec' - -*--audio-caps *:: - These caps will get assigned to incoming RTP packets for audio. Example: - 'application/x-rtp,media=audio,clock-rate=48000,payload=96,encoding-name=X-GST-OPUS-DRAFT-SPITTKA-00,caps="audio/x-opus"' - -*--audio-depayloader *:: - A RTP depayloader element for the audio codec in use. Example: 'rtpopusdepay' - -*--audio-decoder *:: - Bin description for the audio decoder. Example: 'opusdec' - -*--sink *:: - A gst-launch-style description for the raw video and audio bin. This bin must contain - an element called 'videosink' and an element called 'audiosink' which should each - contain a pad called 'sink'. Theses pads will get connected to the decoder bins. - Example: - 'videoconvert name="videosink" ! videoscale add-borders=true ! xvimagesink - audioconvert name="audiosink" ! autoaudiosink' - -*options for RTP* - -*-a, --rtp-host *:: - In 'sender' mode this sets the address or hostname of the remote RTP receiver. Please - mind that the remote RTP host is always added as a receiver and it shouldn't be - configured to send keepalives. This would re-add the receiver to the list of clients - and as a result duplicate packages will be sent. - Also the remote RTP host is excluded from client timeout handling and remove requests - from it will get ignored. - When you omit this in sender mode the automatic client detection will be used to add - receivers. - In 'receiver' mode keepalive messages will be sent to this host. Leave empty to disable - keepalive messages. - -*-o, --rtp-port-base *:: - The base number for remote ports. *sydra* will send the RTP/RTCP packets using the following - mapping: - * rtp-port-base + 0: RTP Video - * rtp-port-base + 1: RTCP Video - * rtp-port-base + 2: RTP Audio - * rtp-port-base + 3: RTCP Audio - -*-A, --rtp-addr-local
*:: - The local address to wait for incoming UDP messages. Leave empty to listen on any address. - -*-O, --rtp-port-base-local *:: - The base number for local ports to bind to. The same mapping as for the remote port-base is - used to map incoming RTP packets to the RTP bin. - -*-c, --no-auto-client*:: - This disables auto-detection for clients in 'sender' mode. Mind that if you disable the - automatic client detection and also omit the rtp-host option *sydra* won't send any RTP - messages. If configured recording will work but this is most probably not what you want. - -*-t, --timeout *:: - This sets the client timeout in seconds in 'sender' mode. A value of 0 disables client - timeouts. This is not recommended. - -*-k, --keepalive-interval *:: - This sets the interval in seconds for sending out keepalive messages in 'receiver' mode. - A value of 0 disables keepalive messages and therefor the client auto detection won't - work for this client. - -*options for recording* - -*--rec-video-encoder *:: - A bin description for the video encoder used for recording. If you leave this empty the - output from the RTP video encoder is used. Example: 'videoconvert ! jpegenc' - -*--rec-audio-encoder *:: - A bin description for the audio encoder used for recording. If you leave this empty the - output from the RTP audio encoder is used. Example: 'audioconvert ! vorbisenc' - -*--rec-mux *:: - A gstreamer muxer element used for recording. If you leave this empty recording will be - disabled. Example: 'matroskamux' - -*--rec-name-format *:: - A 'strftime' based format string which will be used to create the name for the - recorded file. Example: ./recordings/%Y-%m-%d_%H-%M-%S.mkv - - -BUGS ----- -Most likely there are some bugs in *sydra*. If you find a bug, please let -the developers know at equinox@spreadspace.org. Of course, patches are preferred. - - -SEE ALSO --------- - -*strftime*(3), *gst-launch*(1) - -AUTHORS -------- - -Christian Pointner - - -COPYING -------- - -Copyright \(C) 2014 Christian Pointner. This program is free -software: you can redistribute it and/or modify it under the terms -of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or any later version. diff --git a/src/Makefile b/src/Makefile index 3fcf405..ac211d8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,14 +37,14 @@ ifneq ($(MAKECMDGOALS),distclean) include include.mk endif -EXECUTABLE := sydra +EXECUTABLE := sydra-rtp C_OBJS := log.o \ options.o \ utils.o \ pipelines.o \ udp.o \ - sydra.o + sydra-rtp.o C_SRCS := $(C_OBJS:%.o=%.c) diff --git a/src/configure b/src/configure index acb7a20..515399f 100755 --- a/src/configure +++ b/src/configure @@ -150,7 +150,7 @@ DATE=`date +"%d.%m.%Y %H:%M:%S %Z"` cat > config.h < config.h < -typedef enum { SENDER, RECEIVER } sydra_mode_t; +typedef enum { SENDER, RECEIVER } sydra_rtp_mode_t; struct addr_port { enum { IPv4, IPv6 } type_; diff --git a/src/log_targets.h b/src/log_targets.h index c27cc1a..71e56b9 100644 --- a/src/log_targets.h +++ b/src/log_targets.h @@ -87,7 +87,7 @@ int log_target_syslog_init(log_target_t* self, const char* conf) char* logname; const char* end = NULL; if(!conf) - logname = strdup("sydra"); + logname = strdup("sydra-rtp"); else { end = strchr(conf, ','); if(end) { @@ -216,7 +216,7 @@ int log_target_file_init(log_target_t* self, const char* conf) char* logfilename; if(!conf) - logfilename = strdup("sydra.log"); + logfilename = strdup("sydra-rtp.log"); else { const char* end = strchr(conf, ','); if(end) { diff --git a/src/options.c b/src/options.c index 89c55fc..483d6d7 100644 --- a/src/options.c +++ b/src/options.c @@ -49,7 +49,7 @@ static void options_defaults(options_t* opt) if(!opt) return; - opt->progname_ = g_strdup("sydra"); + opt->progname_ = g_strdup("sydra-rtp"); opt->daemonize_ = TRUE; opt->username_ = NULL; opt->groupname_ = NULL; @@ -335,7 +335,7 @@ static int options_parse_post(options_t* opt) if(!g_strv_length(opt->log_targets_)) { opt->log_targets_ = g_new(gchar*, 2); if(!opt->log_targets_) return -127; - opt->log_targets_[0] = g_strdup("syslog:3,sydra,daemon"); + opt->log_targets_[0] = g_strdup("syslog:3,sydra-rtp,daemon"); if(!(opt->log_targets_[0])) return -127; opt->log_targets_[1] = NULL; } diff --git a/src/options.h b/src/options.h index 9ebcb01..afc5ae6 100644 --- a/src/options.h +++ b/src/options.h @@ -49,7 +49,7 @@ struct options_struct { gboolean debug_; gchar* appname_; - sydra_mode_t mode_; + sydra_rtp_mode_t mode_; gchar* source_; gchar* sink_; diff --git a/src/pipelines.c b/src/pipelines.c index 114a2c5..fa33562 100644 --- a/src/pipelines.c +++ b/src/pipelines.c @@ -353,7 +353,7 @@ static gboolean create_recorder_elements(options_t* opt, GstElement* pipeline, s GstElement* create_sender_pipeline(options_t* opt, struct udp_sinks *udp) { - GstElement *pipeline = gst_pipeline_new ("sydra-sender"); + GstElement *pipeline = gst_pipeline_new ("sydra-rtp-sender"); if(!pipeline) { log_printf(ERROR, "Creating pipeline failed!"); return NULL; @@ -434,7 +434,7 @@ static void rtpbin_pad_added(GstElement* rtp, GstPad* pad, gpointer user_data) GstElement* create_receiver_pipeline(options_t* opt, struct udp_sources *udp) { - GstElement *pipeline = gst_pipeline_new ("sydra-receiver"); + GstElement *pipeline = gst_pipeline_new ("sydra-rtp-receiver"); if(!pipeline) { log_printf(ERROR, "Creating pipeline failed!"); return NULL; diff --git a/src/sydra-rtp.c b/src/sydra-rtp.c new file mode 100644 index 0000000..c8c15da --- /dev/null +++ b/src/sydra-rtp.c @@ -0,0 +1,327 @@ +/* + * sydra + * + * sydra is a toolbox which allows you to set up multiple bidirectional + * Video/Audio streams from external locations. + * sydra has been written to be used for the Elevate Festival in Graz + * Austria in order to involve external locations to present themselves + * at the festival. + * Sydra is based on GStreamer and is written in C. + * + * + * Copyright (C) 2014 Christian Pointner + * + * This file is part of sydra. + * + * sydra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * sydra is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with sydra. If not, see . + * + * In addition, as a special exception, the copyright holders hereby + * grant permission for non-GPL-compatible GStreamer plugins to be used + * and distributed together with GStreamer and sydra. + * This permission goes above and beyond the permissions granted by the + * GPL license sydra is covered by. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "datatypes.h" +#include "options.h" +#include "log.h" +#include "daemon.h" +#include "utils.h" +#include "pipelines.h" +#include "udp.h" + + +static gboolean sig_handler_terminate(gpointer user_data) +{ + GMainLoop *loop = (GMainLoop *)user_data; + + log_printf(NOTICE, "signal received, closing application"); + g_main_loop_quit(loop); + return TRUE; +} + +static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) +{ + GMainLoop *loop = (GMainLoop *)data; + + switch (GST_MESSAGE_TYPE(msg)) { + case GST_MESSAGE_EOS: { + log_printf(NOTICE, "End of stream"); + g_main_loop_quit(loop); + break; + } + case GST_MESSAGE_INFO: { + GError *info; + gst_message_parse_info(msg, &info, NULL); + log_printf(INFO, "%s", info->message); + g_error_free(info); + break; + } + case GST_MESSAGE_WARNING: { + GError *warning; + gst_message_parse_warning(msg, &warning, NULL); + log_printf(WARNING, "%s", warning->message); + g_error_free(warning); + break; + } + case GST_MESSAGE_ERROR: { + GError *error; + gst_message_parse_error(msg, &error, NULL); + log_printf(ERROR, "%s", error->message); + g_error_free(error); + g_main_loop_quit(loop); + break; + } + case GST_MESSAGE_STATE_CHANGED: { + GstState old_state, new_state; + gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); + log_printf(DEBUG, "Element '%s' changed state from %s to %s", + (msg->src ? GST_OBJECT_NAME(msg->src) : "NULL"), + gst_element_state_get_name(old_state), + gst_element_state_get_name(new_state)); + break; + } + case GST_MESSAGE_NEW_CLOCK: + { + GstClock *clock; + gst_message_parse_new_clock(msg, &clock); + log_printf(NOTICE, "New clock: %s", (clock ? GST_OBJECT_NAME (clock) : "NULL")); + break; + } + case GST_MESSAGE_QOS: { + guint64 running_time, stream_time, timestamp, duration; + gst_message_parse_qos(msg, NULL, &running_time, &stream_time, ×tamp, &duration); + log_printf(WARNING, "Element '%s' dropped frames running_time=%lu, stream_time=%lu, timestamp=%lu, duration=%lu", + (msg->src ? GST_OBJECT_NAME(msg->src) : "NULL"), running_time, stream_time, timestamp, duration); + break; + } + /* case GST_MESSAGE_STREAM_STATUS: */ + /* { */ + /* GstStreamStatusType type; */ + /* GstElement *owner; */ + /* const GValue *val; */ + /* gchar *path, *ownerstr; */ + /* GstTask *task = NULL; */ + + /* gst_message_parse_stream_status (msg, &type, &owner); */ + /* val = gst_message_get_stream_status_object (msg); */ + + /* path = gst_object_get_path_string (GST_MESSAGE_SRC (msg)); */ + /* ownerstr = gst_object_get_path_string (GST_OBJECT (owner)); */ + /* log_printf(DEBUG,"Recevied Stream-Status message type: %d, source: %s, owner: %s, object: type %s, value %p", */ + /* type, path, ownerstr, G_VALUE_TYPE_NAME (val), g_value_get_object (val)); */ + /* g_free (path); */ + /* g_free (ownerstr); */ + + /* /\* see if we know how to deal with this object *\/ */ + /* if (G_VALUE_TYPE (val) == GST_TYPE_TASK) { */ + /* task = g_value_get_object (val); */ + /* } */ + + /* switch (type) { */ + /* case GST_STREAM_STATUS_TYPE_CREATE: */ + /* log_printf(DEBUG," created task %p", task); */ + /* break; */ + /* case GST_STREAM_STATUS_TYPE_ENTER: */ + /* /\* log_printf(DEBUG," raising task priority"); *\/ */ + /* /\* setpriority (PRIO_PROCESS, 0, -10); *\/ */ + /* break; */ + /* case GST_STREAM_STATUS_TYPE_LEAVE: */ + /* break; */ + /* default: */ + /* break; */ + /* } */ + /* break; */ + /* } */ + default: + /* log_printf(DEBUG, "unkonwn message %s from %s", GST_MESSAGE_TYPE_NAME(msg), GST_MESSAGE_SRC_NAME(msg)); */ + return TRUE; + } + return TRUE; +} + +int main_loop(options_t* opt) +{ + log_printf(NOTICE, "entering main loop"); + + struct udp_sinks sinks = { { NULL, NULL }, { NULL, NULL }, + { NULL, NULL }, { NULL, NULL }, opt->timeout_ }; + struct udp_sources sources = { NULL, NULL, NULL, NULL, opt->keepalive_int_, NULL , opt->rtp_port_base_ }; + GstElement *pipeline = opt->mode_ == SENDER ? create_sender_pipeline(opt, &sinks) : + create_receiver_pipeline(opt, &sources); + if(!pipeline) { + log_printf(ERROR, "creating pipeline failed - exitting"); + return -1; + } + + GMainLoop *loop = g_main_loop_new(NULL, FALSE); + + GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); + gst_bus_add_watch(bus, bus_call, loop); + gst_object_unref(GST_OBJECT(bus)); + + gulong deep_notify_id = 0; + if(opt->debug_) { + deep_notify_id = g_signal_connect(pipeline, "deep-notify", + G_CALLBACK(gst_object_default_deep_notify), NULL); + } + + log_printf(NOTICE, "Set State: Paused"); + gst_element_set_state(pipeline, GST_STATE_PAUSED); + + if((opt->mode_ == SENDER && opt->auto_client_ && !attach_udpsinks(&sinks)) || + (opt->mode_ == RECEIVER && !attach_udpsources(&sources, opt->rtp_host_))) + return -1; + + log_printf(NOTICE, "Set State: Playing"); + gst_element_set_state(pipeline, GST_STATE_PLAYING); + + g_unix_signal_add(SIGHUP, sig_handler_terminate, loop); + g_unix_signal_add(SIGINT, sig_handler_terminate, loop); + g_unix_signal_add(SIGTERM, sig_handler_terminate, loop); + g_main_loop_run(loop); + + if(opt->mode_ == RECEIVER) + detach_udpsources(&sources); + + if (deep_notify_id != 0) + g_signal_handler_disconnect(pipeline, deep_notify_id); + + log_printf(NOTICE, "Stopping pipeline"); + gst_element_set_state(pipeline, GST_STATE_NULL); + gst_object_unref(GST_OBJECT(pipeline)); + + return 0; +} + +int main(int argc, char* argv[]) +{ + log_init(); + log_close(); + + options_t opt; + int ret = options_parse(&opt, argc, argv); + if(ret) { + if(ret == -1) { + options_print_version(); + ret = 0; + } + options_clear(&opt); + log_close(); + exit(ret); + } + + guint len = g_strv_length(opt.log_targets_); + guint i; + for(i = 0; i < len; ++i) { + ret = log_add_target(opt.log_targets_[i]); + if(ret) { + switch(ret) { + case -2: fprintf(stderr, "memory error on log_add_target, exitting\n"); break; + case -3: fprintf(stderr, "unknown log target: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; + case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; + default: fprintf(stderr, "syntax error near: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; + } + + options_clear(&opt); + log_close(); + exit(ret); + } + } + + log_printf(NOTICE, "just started..."); + + if(opt.debug_) + options_print(&opt); + + if(opt.appname_) + g_set_prgname (opt.appname_); + else + g_set_prgname (opt.progname_); + + priv_info_t priv; + if(opt.username_) + if(priv_init(&priv, opt.username_, opt.groupname_)) { + options_clear(&opt); + log_close(); + exit(-1); + } + + FILE* pid_file = NULL; + if(opt.pid_file_) { + pid_file = fopen(opt.pid_file_, "w"); + if(!pid_file) { + log_printf(WARNING, "unable to open pid file: %s", strerror(errno)); + } + } + + if(opt.chroot_dir_) + if(do_chroot(opt.chroot_dir_)) { + options_clear(&opt); + log_close(); + exit(-1); + } + if(opt.username_) + if(priv_drop(&priv)) { + options_clear(&opt); + log_close(); + exit(-1); + } + + if(opt.daemonize_) { + pid_t oldpid = getpid(); + daemonize(); + log_printf(INFO, "running in background now (old pid: %d)", oldpid); + } + + if(pid_file) { + pid_t pid = getpid(); + fprintf(pid_file, "%d", pid); + fclose(pid_file); + } + + const gchar *nano_str; + guint major, minor, micro, nano; + gst_version(&major, &minor, µ, &nano); + if (nano == 1) + nano_str = " (CVS)"; + else if (nano == 2) + nano_str = " (Prerelease)"; + else + nano_str = ""; + log_printf(NOTICE, "sydra-rtp linked against GStreamer %d.%d.%d%s", major, minor, micro, nano_str); + + ret = main_loop(&opt); + + options_clear(&opt); + + log_printf(NOTICE, "sydra-rtp shutdown"); + + gst_deinit(); + log_close(); + + return ret; +} diff --git a/src/sydra.c b/src/sydra.c deleted file mode 100644 index 70b9e56..0000000 --- a/src/sydra.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * sydra - * - * sydra is a toolbox which allows you to set up multiple bidirectional - * Video/Audio streams from external locations. - * sydra has been written to be used for the Elevate Festival in Graz - * Austria in order to involve external locations to present themselves - * at the festival. - * Sydra is based on GStreamer and is written in C. - * - * - * Copyright (C) 2014 Christian Pointner - * - * This file is part of sydra. - * - * sydra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * sydra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with sydra. If not, see . - * - * In addition, as a special exception, the copyright holders hereby - * grant permission for non-GPL-compatible GStreamer plugins to be used - * and distributed together with GStreamer and sydra. - * This permission goes above and beyond the permissions granted by the - * GPL license sydra is covered by. - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "datatypes.h" -#include "options.h" -#include "log.h" -#include "daemon.h" -#include "utils.h" -#include "pipelines.h" -#include "udp.h" - - -static gboolean sig_handler_terminate(gpointer user_data) -{ - GMainLoop *loop = (GMainLoop *)user_data; - - log_printf(NOTICE, "signal received, closing application"); - g_main_loop_quit(loop); - return TRUE; -} - -static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) -{ - GMainLoop *loop = (GMainLoop *)data; - - switch (GST_MESSAGE_TYPE(msg)) { - case GST_MESSAGE_EOS: { - log_printf(NOTICE, "End of stream"); - g_main_loop_quit(loop); - break; - } - case GST_MESSAGE_INFO: { - GError *info; - gst_message_parse_info(msg, &info, NULL); - log_printf(INFO, "%s", info->message); - g_error_free(info); - break; - } - case GST_MESSAGE_WARNING: { - GError *warning; - gst_message_parse_warning(msg, &warning, NULL); - log_printf(WARNING, "%s", warning->message); - g_error_free(warning); - break; - } - case GST_MESSAGE_ERROR: { - GError *error; - gst_message_parse_error(msg, &error, NULL); - log_printf(ERROR, "%s", error->message); - g_error_free(error); - g_main_loop_quit(loop); - break; - } - case GST_MESSAGE_STATE_CHANGED: { - GstState old_state, new_state; - gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); - log_printf(DEBUG, "Element '%s' changed state from %s to %s", - (msg->src ? GST_OBJECT_NAME(msg->src) : "NULL"), - gst_element_state_get_name(old_state), - gst_element_state_get_name(new_state)); - break; - } - case GST_MESSAGE_NEW_CLOCK: - { - GstClock *clock; - gst_message_parse_new_clock(msg, &clock); - log_printf(NOTICE, "New clock: %s", (clock ? GST_OBJECT_NAME (clock) : "NULL")); - break; - } - case GST_MESSAGE_QOS: { - guint64 running_time, stream_time, timestamp, duration; - gst_message_parse_qos(msg, NULL, &running_time, &stream_time, ×tamp, &duration); - log_printf(WARNING, "Element '%s' dropped frames running_time=%lu, stream_time=%lu, timestamp=%lu, duration=%lu", - (msg->src ? GST_OBJECT_NAME(msg->src) : "NULL"), running_time, stream_time, timestamp, duration); - break; - } - /* case GST_MESSAGE_STREAM_STATUS: */ - /* { */ - /* GstStreamStatusType type; */ - /* GstElement *owner; */ - /* const GValue *val; */ - /* gchar *path, *ownerstr; */ - /* GstTask *task = NULL; */ - - /* gst_message_parse_stream_status (msg, &type, &owner); */ - /* val = gst_message_get_stream_status_object (msg); */ - - /* path = gst_object_get_path_string (GST_MESSAGE_SRC (msg)); */ - /* ownerstr = gst_object_get_path_string (GST_OBJECT (owner)); */ - /* log_printf(DEBUG,"Recevied Stream-Status message type: %d, source: %s, owner: %s, object: type %s, value %p", */ - /* type, path, ownerstr, G_VALUE_TYPE_NAME (val), g_value_get_object (val)); */ - /* g_free (path); */ - /* g_free (ownerstr); */ - - /* /\* see if we know how to deal with this object *\/ */ - /* if (G_VALUE_TYPE (val) == GST_TYPE_TASK) { */ - /* task = g_value_get_object (val); */ - /* } */ - - /* switch (type) { */ - /* case GST_STREAM_STATUS_TYPE_CREATE: */ - /* log_printf(DEBUG," created task %p", task); */ - /* break; */ - /* case GST_STREAM_STATUS_TYPE_ENTER: */ - /* /\* log_printf(DEBUG," raising task priority"); *\/ */ - /* /\* setpriority (PRIO_PROCESS, 0, -10); *\/ */ - /* break; */ - /* case GST_STREAM_STATUS_TYPE_LEAVE: */ - /* break; */ - /* default: */ - /* break; */ - /* } */ - /* break; */ - /* } */ - default: - /* log_printf(DEBUG, "unkonwn message %s from %s", GST_MESSAGE_TYPE_NAME(msg), GST_MESSAGE_SRC_NAME(msg)); */ - return TRUE; - } - return TRUE; -} - -int main_loop(options_t* opt) -{ - log_printf(NOTICE, "entering main loop"); - - struct udp_sinks sinks = { { NULL, NULL }, { NULL, NULL }, - { NULL, NULL }, { NULL, NULL }, opt->timeout_ }; - struct udp_sources sources = { NULL, NULL, NULL, NULL, opt->keepalive_int_, NULL , opt->rtp_port_base_ }; - GstElement *pipeline = opt->mode_ == SENDER ? create_sender_pipeline(opt, &sinks) : - create_receiver_pipeline(opt, &sources); - if(!pipeline) { - log_printf(ERROR, "creating pipeline failed - exitting"); - return -1; - } - - GMainLoop *loop = g_main_loop_new(NULL, FALSE); - - GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); - gst_bus_add_watch(bus, bus_call, loop); - gst_object_unref(GST_OBJECT(bus)); - - gulong deep_notify_id = 0; - if(opt->debug_) { - deep_notify_id = g_signal_connect(pipeline, "deep-notify", - G_CALLBACK(gst_object_default_deep_notify), NULL); - } - - log_printf(NOTICE, "Set State: Paused"); - gst_element_set_state(pipeline, GST_STATE_PAUSED); - - if((opt->mode_ == SENDER && opt->auto_client_ && !attach_udpsinks(&sinks)) || - (opt->mode_ == RECEIVER && !attach_udpsources(&sources, opt->rtp_host_))) - return -1; - - log_printf(NOTICE, "Set State: Playing"); - gst_element_set_state(pipeline, GST_STATE_PLAYING); - - g_unix_signal_add(SIGHUP, sig_handler_terminate, loop); - g_unix_signal_add(SIGINT, sig_handler_terminate, loop); - g_unix_signal_add(SIGTERM, sig_handler_terminate, loop); - g_main_loop_run(loop); - - if(opt->mode_ == RECEIVER) - detach_udpsources(&sources); - - if (deep_notify_id != 0) - g_signal_handler_disconnect(pipeline, deep_notify_id); - - log_printf(NOTICE, "Stopping pipeline"); - gst_element_set_state(pipeline, GST_STATE_NULL); - gst_object_unref(GST_OBJECT(pipeline)); - - return 0; -} - -int main(int argc, char* argv[]) -{ - log_init(); - log_close(); - - options_t opt; - int ret = options_parse(&opt, argc, argv); - if(ret) { - if(ret == -1) { - options_print_version(); - ret = 0; - } - options_clear(&opt); - log_close(); - exit(ret); - } - - guint len = g_strv_length(opt.log_targets_); - guint i; - for(i = 0; i < len; ++i) { - ret = log_add_target(opt.log_targets_[i]); - if(ret) { - switch(ret) { - case -2: fprintf(stderr, "memory error on log_add_target, exitting\n"); break; - case -3: fprintf(stderr, "unknown log target: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; - case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; - default: fprintf(stderr, "syntax error near: '%s', exitting\n", (char*)(opt.log_targets_[i])); break; - } - - options_clear(&opt); - log_close(); - exit(ret); - } - } - - log_printf(NOTICE, "just started..."); - - if(opt.debug_) - options_print(&opt); - - if(opt.appname_) - g_set_prgname (opt.appname_); - else - g_set_prgname (opt.progname_); - - priv_info_t priv; - if(opt.username_) - if(priv_init(&priv, opt.username_, opt.groupname_)) { - options_clear(&opt); - log_close(); - exit(-1); - } - - FILE* pid_file = NULL; - if(opt.pid_file_) { - pid_file = fopen(opt.pid_file_, "w"); - if(!pid_file) { - log_printf(WARNING, "unable to open pid file: %s", strerror(errno)); - } - } - - if(opt.chroot_dir_) - if(do_chroot(opt.chroot_dir_)) { - options_clear(&opt); - log_close(); - exit(-1); - } - if(opt.username_) - if(priv_drop(&priv)) { - options_clear(&opt); - log_close(); - exit(-1); - } - - if(opt.daemonize_) { - pid_t oldpid = getpid(); - daemonize(); - log_printf(INFO, "running in background now (old pid: %d)", oldpid); - } - - if(pid_file) { - pid_t pid = getpid(); - fprintf(pid_file, "%d", pid); - fclose(pid_file); - } - - const gchar *nano_str; - guint major, minor, micro, nano; - gst_version(&major, &minor, µ, &nano); - if (nano == 1) - nano_str = " (CVS)"; - else if (nano == 2) - nano_str = " (Prerelease)"; - else - nano_str = ""; - log_printf(NOTICE, "sydra linked against GStreamer %d.%d.%d%s", major, minor, micro, nano_str); - - ret = main_loop(&opt); - - options_clear(&opt); - - log_printf(NOTICE, "sydra shutdown"); - - gst_deinit(); - log_close(); - - return ret; -} -- cgit v1.2.3