1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

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
This commit is contained in:
albfan 2017-03-25 12:48:04 +01:00
parent 016159bb1e
commit 3628f789b4
3 changed files with 90 additions and 12 deletions

View file

@ -1,4 +1,4 @@
bin_SCRIPTS = miracle-gst gstplayer uibc-viewer bin_SCRIPTS = miracle-gst gstplayer uibc-viewer miracle-omxplayer
EXTRA_DIST = wpa.conf EXTRA_DIST = wpa.conf
dbuspolicydir=$(sysconfdir)/dbus-1/system.d dbuspolicydir=$(sysconfdir)/dbus-1/system.d

69
res/miracle-omxplayer Executable file
View file

@ -0,0 +1,69 @@
#!/bin/bash
function help {
local scriptname="$(basename $0)"
cat >&2 <<EOF
$scriptname [options]
play rtp stream with omxplayer
Options:
-r Resolution
-s <Width>x<height> Scale
-d <level> Log level for gst
-p <port> 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}

View file

@ -61,8 +61,10 @@ int gst_audio_en = 1;
static const int DEFAULT_RSTP_PORT = 1991; static const int DEFAULT_RSTP_PORT = 1991;
bool uibc_option; bool uibc_option;
bool uibc_enabled; bool uibc_enabled;
bool external_player;
int rstp_port; int rstp_port;
int uibc_port; int uibc_port;
char* player;
unsigned int wfd_supported_res_cea = 0x0000001f; /* up to 720x576 */ unsigned int wfd_supported_res_cea = 0x0000001f; /* up to 720x576 */
unsigned int wfd_supported_res_vesa = 0x00000003; /* up to 800x600 */ 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 port[64];
char uibc_portStr[64]; char uibc_portStr[64];
int i = 0; int i = 0;
char* player; if (!external_player) {
if (uibc_enabled) { if (uibc_enabled) {
player = "uibc-viewer"; player = "uibc-viewer";
} else { } else {
player = "miracle-gst"; player = "miracle-gst";
} }
}
argv[i++] = player; argv[i++] = player;
if (uibc_enabled) { if (uibc_enabled) {
@ -680,8 +683,9 @@ void cli_fn_help()
" --gst-debug [cat:]lvl[,...] List of categories an level of debug\n" " --gst-debug [cat:]lvl[,...] List of categories an level of debug\n"
" --audio <0/1> Enable audio support (default %d)\n" " --audio <0/1> Enable audio support (default %d)\n"
" --scale WxH Scale to resolution\n" " --scale WxH Scale to resolution\n"
" --port <port> Port for rtsp (default %d)\n" " -p --port <port> Port for rtsp (default %d)\n"
" --uibc Enables UIBC\n" " --uibc Enables UIBC\n"
" -e --external-player Configure player to use\n"
" --res <n,n,n> Supported resolutions masks (CEA, VESA, HH)\n" " --res <n,n,n> Supported resolutions masks (CEA, VESA, HH)\n"
" default CEA %08X\n" " default CEA %08X\n"
" default VESA %08X\n" " default VESA %08X\n"
@ -767,7 +771,6 @@ static int parse_argv(int argc, char *argv[])
ARG_AUDIO, ARG_AUDIO,
ARG_SCALE, ARG_SCALE,
ARG_RES, ARG_RES,
ARG_PORT,
ARG_UIBC, ARG_UIBC,
}; };
static const struct option options[] = { static const struct option options[] = {
@ -779,17 +782,19 @@ static int parse_argv(int argc, char *argv[])
{ "audio", required_argument, NULL, ARG_AUDIO }, { "audio", required_argument, NULL, ARG_AUDIO },
{ "scale", required_argument, NULL, ARG_SCALE }, { "scale", required_argument, NULL, ARG_SCALE },
{ "res", required_argument, NULL, ARG_RES }, { "res", required_argument, NULL, ARG_RES },
{ "port", required_argument, NULL, ARG_PORT }, { "port", required_argument, NULL, 'p' },
{ "uibc", no_argument, NULL, ARG_UIBC }, { "uibc", no_argument, NULL, ARG_UIBC },
{ "external-player", required_argument, NULL, 'e' },
{} {}
}; };
int c; int c;
uibc_option = false; uibc_option = false;
uibc_enabled = false; uibc_enabled = false;
external_player = false;
rstp_port = DEFAULT_RSTP_PORT; 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) { switch (c) {
case 'h': case 'h':
return cli_help(cli_cmds); return cli_help(cli_cmds);
@ -817,9 +822,13 @@ static int parse_argv(int argc, char *argv[])
&wfd_supported_res_vesa, &wfd_supported_res_vesa,
&wfd_supported_res_hh); &wfd_supported_res_hh);
break; break;
case ARG_PORT: case 'p':
rstp_port = atoi(optarg); rstp_port = atoi(optarg);
break; break;
case 'e':
external_player = true;
player = optarg;
break;
case ARG_UIBC: case ARG_UIBC:
uibc_option = true; uibc_option = true;
break; break;