From 3628f789b4912a9c7936e6f4d0e77e99ffebdc6b Mon Sep 17 00:00:00 2001 From: albfan Date: Sat, 25 Mar 2017 12:48:04 +0100 Subject: [PATCH] Add external player config Allow to run custom player. It will be run within a wrapper that respect -p/--port, option at least fixes #87 --- res/Makefile.am | 2 +- res/miracle-omxplayer | 69 +++++++++++++++++++++++++++++++++++++++++++ src/ctl/sinkctl.c | 31 ++++++++++++------- 3 files changed, 90 insertions(+), 12 deletions(-) create mode 100755 res/miracle-omxplayer diff --git a/res/Makefile.am b/res/Makefile.am index b51bdbc..e4d879e 100644 --- a/res/Makefile.am +++ b/res/Makefile.am @@ -1,4 +1,4 @@ -bin_SCRIPTS = miracle-gst gstplayer uibc-viewer +bin_SCRIPTS = miracle-gst gstplayer uibc-viewer miracle-omxplayer EXTRA_DIST = wpa.conf dbuspolicydir=$(sysconfdir)/dbus-1/system.d diff --git a/res/miracle-omxplayer b/res/miracle-omxplayer new file mode 100755 index 0000000..dfa9152 --- /dev/null +++ b/res/miracle-omxplayer @@ -0,0 +1,69 @@ +#!/bin/bash + +function help { + local scriptname="$(basename $0)" + cat >&2 <x Scale + -d Log level for gst + -p Port for stream + -a Enables audio + -h Show this help + +Examples: + + # play stream on port 7236 + $ $scriptname -p 7236 + +EOF +} + +DEBUG='0' +AUDIO='0' +SCALE='0' + +while getopts "r:d:as:p:h" optname + do + case "$optname" in + "h") + help + exit 0 + ;; + "d") + DEBUG=`echo ${OPTARG} | tr -d ' '` + ;; + "r") + RESOLUTION=`echo ${OPTARG} | tr -d ' '` + ;; + "a") + AUDIO='1' + ;; + "p") + PORT=`echo ${OPTARG} | tr -d ' '` + ;; + "s") + SCALE='1' + WIDTH=`echo ${OPTARG} | tr -d ' ' | cut -dx -f 1` + HEIGHT=`echo ${OPTARG} | tr -d ' ' | cut -dx -f 2` + ;; + "?") + echo "Unknown option $OPTARG" + ;; + *) + echo "Unknown parameter $OPTARG" + help + exit 1 + ;; + esac + done + +RUN="omxplayer -live -b - o hdmi rtp://localhost:$PORT" + +echo "running: $RUN" +exec ${RUN} diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index 49eac82..c1b8b68 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -61,8 +61,10 @@ int gst_audio_en = 1; static const int DEFAULT_RSTP_PORT = 1991; bool uibc_option; bool uibc_enabled; +bool external_player; int rstp_port; int uibc_port; +char* player; unsigned int wfd_supported_res_cea = 0x0000001f; /* up to 720x576 */ unsigned int wfd_supported_res_vesa = 0x00000003; /* up to 800x600 */ @@ -388,12 +390,13 @@ void launch_player(struct ctl_sink *s) { char port[64]; char uibc_portStr[64]; int i = 0; - char* player; - if (uibc_enabled) { - player = "uibc-viewer"; - } else { - player = "miracle-gst"; - } + if (!external_player) { + if (uibc_enabled) { + player = "uibc-viewer"; + } else { + player = "miracle-gst"; + } + } argv[i++] = player; if (uibc_enabled) { @@ -680,8 +683,9 @@ void cli_fn_help() " --gst-debug [cat:]lvl[,...] List of categories an level of debug\n" " --audio <0/1> Enable audio support (default %d)\n" " --scale WxH Scale to resolution\n" - " --port Port for rtsp (default %d)\n" + " -p --port Port for rtsp (default %d)\n" " --uibc Enables UIBC\n" + " -e --external-player Configure player to use\n" " --res Supported resolutions masks (CEA, VESA, HH)\n" " default CEA %08X\n" " default VESA %08X\n" @@ -767,7 +771,6 @@ static int parse_argv(int argc, char *argv[]) ARG_AUDIO, ARG_SCALE, ARG_RES, - ARG_PORT, ARG_UIBC, }; static const struct option options[] = { @@ -779,17 +782,19 @@ static int parse_argv(int argc, char *argv[]) { "audio", required_argument, NULL, ARG_AUDIO }, { "scale", required_argument, NULL, ARG_SCALE }, { "res", required_argument, NULL, ARG_RES }, - { "port", required_argument, NULL, ARG_PORT }, + { "port", required_argument, NULL, 'p' }, { "uibc", no_argument, NULL, ARG_UIBC }, + { "external-player", required_argument, NULL, 'e' }, {} }; int c; uibc_option = false; uibc_enabled = false; + external_player = false; rstp_port = DEFAULT_RSTP_PORT; - while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "he:p", options, NULL)) >= 0) { switch (c) { case 'h': return cli_help(cli_cmds); @@ -817,9 +822,13 @@ static int parse_argv(int argc, char *argv[]) &wfd_supported_res_vesa, &wfd_supported_res_hh); break; - case ARG_PORT: + case 'p': rstp_port = atoi(optarg); break; + case 'e': + external_player = true; + player = optarg; + break; case ARG_UIBC: uibc_option = true; break;