From e7aa531dcaf576631dd48bd5193bc08c3e3b6c94 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Fri, 29 Aug 2014 14:43:52 +0400 Subject: sink: move GST pipeline construction to bash script The sinkctl tool is currently a hack to make Miracast sinks work. The embedded gst-launch invocation is kinda ugly to handle. Move it into a bash-script so we can experiment a bit more with different pipelines. Ultimatively, the goal is obviously to make this work as its own gst element. Signed-off-by: Andrey Gusakov Signed-off-by: David Herrmann --- Makefile.am | 6 ++++++ res/miracle-gst.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ctl/ctl-sink.c | 2 +- src/ctl/sinkctl.c | 21 ++------------------ 4 files changed, 66 insertions(+), 20 deletions(-) create mode 100755 res/miracle-gst.sh diff --git a/Makefile.am b/Makefile.am index d42d946..d251817 100644 --- a/Makefile.am +++ b/Makefile.am @@ -195,6 +195,12 @@ miracled_LDADD = \ $(DEPS_LIBS) miracled_LDFLAGS = $(AM_LDFLAGS) +# +# miracle-gst.sh +# + +bin_SCRIPTS = res/miracle-gst.sh + # # Tests # diff --git a/res/miracle-gst.sh b/res/miracle-gst.sh new file mode 100755 index 0000000..1b4ca51 --- /dev/null +++ b/res/miracle-gst.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +DEBUG='0' +AUDIO='0' +SCALE='0' + +while getopts "d:as" optname + do + case "$optname" in + "d") + DEBUG=`echo ${OPTARG} | tr -d ' '` + ;; + "a") + AUDIO='1' + ;; + "s") + SCALE='1' + ;; + "?") + echo "Unknown option $OPTARG" + ;; + *) + # Should not occur + echo "Unknown error while processing options" + ;; + esac + done + +RUN="/usr/bin/gst-launch-1.0 -v " +if [ $DEBUG != '0' ] +then + RUN+="--gst-debug=${DEBUG} " +fi + +RUN+="udpsrc port=1991 caps=\"application/x-rtp, media=video\" ! rtpjitterbuffer latency=100 ! rtpmp2tdepay ! tsdemux " + +if [ $AUDIO == '1' ] +then + RUN+="name=demuxer demuxer. " +fi + +RUN+="! queue max-size-buffers=0 max-size-time=0 ! h264parse ! avdec_h264 ! videoconvert ! " + +if [ $SCALE == '1' ] +then + RUN+="videoscale method=1 ! video/x-raw,width=1280,height=800 ! " +fi + +RUN+="autovideosink " + +if [ $AUDIO == '1' ] +then + RUN+="demuxer. ! queue max-size-buffers=0 max-size-time=0 ! aacparse ! avdec_aac ! audioconvert ! audioresample ! autoaudiosink " +fi + +echo "running: $RUN" +exec ${RUN} diff --git a/src/ctl/ctl-sink.c b/src/ctl/ctl-sink.c index bc32bf9..303103a 100644 --- a/src/ctl/ctl-sink.c +++ b/src/ctl/ctl-sink.c @@ -123,7 +123,7 @@ static void sink_handle_get_parameter(struct ctl_sink *s, r = rtsp_message_append(rep, "{&&&&}", "wfd_content_protection: none", "wfd_video_formats: 00 00 01 01 0000007f 003fffff 00000000 00 0000 0000 00 none none", - "wfd_audio_codecs: LPCM 00000003 00", + "wfd_audio_codecs: AAC 00000007 00", "wfd_client_rtp_ports: RTP/AVP/UDP;unicast 1991 0 mode=play"); if (r < 0) return cli_vERR(r); diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index f865b1d..1d25980 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -351,26 +351,9 @@ static void spawn_gst(void) } i = 0; - argv[i++] = (char*) "/usr/bin/gst-launch-1.0"; - argv[i++] = "-v"; + argv[i++] = (char*) BUILD_BINDIR "/miracle-gst.sh"; if (cli_max_sev >= 7) - argv[i++] = "--gst-debug=3"; - argv[i++] = "udpsrc"; - argv[i++] = "port=1991"; - argv[i++] = "caps=\"application/x-rtp, media=video\""; - argv[i++] = "!"; - argv[i++] = "rtpjitterbuffer"; - argv[i++] = "!"; - argv[i++] = "rtpmp2tdepay"; - argv[i++] = "!"; - argv[i++] = "tsdemux"; - argv[i++] = "!"; - argv[i++] = "h264parse"; - argv[i++] = "!"; - argv[i++] = "avdec_h264"; - argv[i++] = "!"; - argv[i++] = "autovideosink"; - argv[i++] = "sync=false"; + argv[i++] = "-d 3"; argv[i] = NULL; execve(argv[0], argv, environ); -- cgit v1.2.3