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

View file

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