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

sink: add arguments to enable/disable audio and scaling

Forward the --audio and --scale arguments to our gst-spawn helper and
parse them via bash for now.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
Andrey Gusakov 2014-07-31 14:41:01 +04:00 committed by David Herrmann
parent e7aa531dca
commit dbf3972619
2 changed files with 26 additions and 3 deletions

View file

@ -4,7 +4,7 @@ DEBUG='0'
AUDIO='0' AUDIO='0'
SCALE='0' SCALE='0'
while getopts "d:as" optname while getopts "d:as:" optname
do do
case "$optname" in case "$optname" in
"d") "d")
@ -15,6 +15,8 @@ while getopts "d:as" optname
;; ;;
"s") "s")
SCALE='1' 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 option $OPTARG"
@ -43,7 +45,7 @@ RUN+="! queue max-size-buffers=0 max-size-time=0 ! h264parse ! avdec_h264 ! vide
if [ $SCALE == '1' ] if [ $SCALE == '1' ]
then then
RUN+="videoscale method=1 ! video/x-raw,width=1280,height=800 ! " RUN+="videoscale method=1 ! video/x-raw,width=${WIDTH},height=${HEIGHT} ! "
fi fi
RUN+="autovideosink " RUN+="autovideosink "

View file

@ -50,6 +50,9 @@ static char *bound_link;
static struct ctl_link *running_link; static struct ctl_link *running_link;
static struct ctl_peer *running_peer; static struct ctl_peer *running_peer;
char *gst_scale_res;
int gst_audio_en = 1;
/* /*
* cmd list * cmd list
*/ */
@ -354,6 +357,12 @@ static void spawn_gst(void)
argv[i++] = (char*) BUILD_BINDIR "/miracle-gst.sh"; argv[i++] = (char*) BUILD_BINDIR "/miracle-gst.sh";
if (cli_max_sev >= 7) if (cli_max_sev >= 7)
argv[i++] = "-d 3"; argv[i++] = "-d 3";
if (gst_audio_en)
argv[i++] = "-a";
if (gst_scale_res) {
argv[i++] = "-s";
argv[i++] = gst_scale_res;
}
argv[i] = NULL; argv[i] = NULL;
execve(argv[0], argv, environ); execve(argv[0], argv, environ);
@ -546,9 +555,11 @@ void cli_fn_help()
" -h --help Show this help\n" " -h --help Show this help\n"
" --version Show package version\n" " --version Show package version\n"
" --log-level <lvl> Maximum level for log messages\n" " --log-level <lvl> Maximum level for log messages\n"
" --audio <0/1> Enable audio support (default %d)\n"
" --scale WxH Scale to resolution\n"
"\n" "\n"
"Commands:\n" "Commands:\n"
, program_invocation_short_name); , program_invocation_short_name, gst_audio_en);
/* /*
* 80-char barrier: * 80-char barrier:
* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 * 01234567890123456789012345678901234567890123456789012345678901234567890123456789
@ -614,11 +625,15 @@ static int parse_argv(int argc, char *argv[])
enum { enum {
ARG_VERSION = 0x100, ARG_VERSION = 0x100,
ARG_LOG_LEVEL, ARG_LOG_LEVEL,
ARG_AUDIO,
ARG_SCALE,
}; };
static const struct option options[] = { static const struct option options[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION }, { "version", no_argument, NULL, ARG_VERSION },
{ "log-level", required_argument, NULL, ARG_LOG_LEVEL }, { "log-level", required_argument, NULL, ARG_LOG_LEVEL },
{ "audio", required_argument, NULL, ARG_AUDIO },
{ "scale", required_argument, NULL, ARG_SCALE },
{} {}
}; };
int c; int c;
@ -633,6 +648,12 @@ static int parse_argv(int argc, char *argv[])
case ARG_LOG_LEVEL: case ARG_LOG_LEVEL:
cli_max_sev = atoi(optarg); cli_max_sev = atoi(optarg);
break; break;
case ARG_AUDIO:
gst_audio_en = atoi(optarg);
break;
case ARG_SCALE:
gst_scale_res = optarg;
break;
case '?': case '?':
return -EINVAL; return -EINVAL;
} }