2015-02-20 14:22:25 +00:00
|
|
|
# GStreamer
|
|
|
|
# Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
|
|
|
|
#
|
|
|
|
# bash/zsh completion support for ges-launch
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
# Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
HELPERDIR="${BASH_SOURCE[0]%/*}/../helpers"
|
|
|
|
|
|
|
|
if [[ ! -d "$HELPERDIR" ]]; then
|
2017-04-04 18:55:18 +00:00
|
|
|
HELPERDIR="$(pkg-config --variable=bashhelpersdir gstreamer-1.0)"
|
2015-02-20 14:22:25 +00:00
|
|
|
else
|
|
|
|
HELPERDIR=`cd "$HELPERDIR"; pwd`
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Common definitions
|
|
|
|
. "$HELPERDIR"/gst
|
|
|
|
|
2017-04-04 18:55:18 +00:00
|
|
|
HELPER="$_GST_HELPER"
|
2017-04-04 20:20:17 +00:00
|
|
|
|
|
|
|
_list_commands ()
|
|
|
|
{
|
|
|
|
ges-launch-1.0 help | grep '^ +' | cut -d' ' -f3
|
|
|
|
}
|
2015-02-20 14:22:25 +00:00
|
|
|
|
|
|
|
_ges___inspect_action_type ()
|
|
|
|
{
|
|
|
|
COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --inspect-action-type | grep '^[^ ]' | cut -d':' -f2)" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___track_types ()
|
|
|
|
{
|
|
|
|
COMPREPLY=( $(compgen -W "audio video audio+video" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___set_scenario () {
|
|
|
|
COMPREPLY=( $(compgen -W "*.scenario $(gst-validate-1.0 -l | awk '$0=$2' FS=[ RS=])" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___load () {
|
|
|
|
COMPREPLY=( $(compgen -W "*.xges" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___outputuri () {
|
|
|
|
COMPREPLY=( $(compgen -W "file://" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___audiosink () {
|
|
|
|
COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='audio/x-raw')" -- $cur) )
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges___videosink () {
|
|
|
|
COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='video/x-raw')" -- $cur) )
|
|
|
|
}
|
|
|
|
|
2015-02-26 12:19:25 +00:00
|
|
|
_ges_clip () {
|
|
|
|
if [[ "$prev" == "$command" ]];
|
|
|
|
then
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-02-26 12:19:25 +00:00
|
|
|
else
|
2017-04-04 20:20:17 +00:00
|
|
|
COMPREPLY=( $(compgen -W "duration= inpoint= start= layer= $(_list_commands)" -- $cur) )
|
2015-04-03 15:38:53 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges_test_clip () {
|
|
|
|
if [[ "$prev" == "$command" ]];
|
|
|
|
then
|
|
|
|
_gst_mandatory_argument
|
|
|
|
else
|
2017-04-04 20:20:17 +00:00
|
|
|
COMPREPLY=( $(compgen -W "duration= inpoint= start= layer= $(_list_commands)" -- $cur) )
|
2015-02-26 12:19:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges_effect () {
|
|
|
|
if [[ "$prev" == "$command" ]];
|
|
|
|
then
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-02-26 12:19:25 +00:00
|
|
|
else
|
2017-04-04 20:20:17 +00:00
|
|
|
COMPREPLY=( $(compgen -W "duration= start= layer= $(_list_commands)" -- $cur) )
|
2015-02-26 12:19:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges_list_options () {
|
2017-04-04 18:55:18 +00:00
|
|
|
_gst_all_arguments ges-launch-1.0
|
2015-02-26 12:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_ges_list_commands () {
|
2017-04-04 20:20:17 +00:00
|
|
|
COMPREPLY=( $(compgen -W "$(_list_commands)" -- $cur) )
|
2015-02-26 12:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_ges_list_properties () {
|
|
|
|
local props
|
|
|
|
|
|
|
|
if [[ "$real_command" == "" ]]
|
|
|
|
then
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-03-13 12:02:30 +00:00
|
|
|
elif [[ "$real_command" == "+clip" ]]
|
2015-04-03 15:38:53 +00:00
|
|
|
then
|
|
|
|
COMPREPLY=( $(compgen -W "set-alpha set-posx set-posy set-width set-height set-volume set-mute" -- $cur) )
|
|
|
|
elif [[ "$real_command" == "+test-clip" ]]
|
2015-02-26 12:19:25 +00:00
|
|
|
then
|
|
|
|
COMPREPLY=( $(compgen -W "set-alpha set-posx set-posy set-width set-height set-volume set-mute" -- $cur) )
|
2015-03-13 12:02:30 +00:00
|
|
|
elif [[ "$real_command" == "+effect" ]]
|
2015-02-26 12:19:25 +00:00
|
|
|
then
|
|
|
|
COMPREPLY=()
|
|
|
|
effect_bin_description="${effect_bin_description//\"/ }"
|
|
|
|
array=(${effect_bin_description//!/ })
|
|
|
|
for i in "${array[@]}"; do
|
|
|
|
props=("$($HELPER --element-properties $i)")
|
|
|
|
for j in $props; do
|
|
|
|
j="${j//=/ }"
|
|
|
|
COMPREPLY+=( $(compgen -W "set-$j" -- $cur) )
|
|
|
|
done
|
|
|
|
done
|
|
|
|
else
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-02-26 12:19:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-03-23 11:27:56 +00:00
|
|
|
_ges___exclude_ () { _gst_mandatory_argument; }
|
|
|
|
_ges___encoding_profile () { _gst_mandatory_argument; }
|
|
|
|
_ges___ges_sample_path () { _gst_mandatory_argument; }
|
|
|
|
_ges___ges_sample_path_recurse () { _gst_mandatory_argument; }
|
|
|
|
_ges___thumbnail () { _gst_mandatory_argument; }
|
|
|
|
_ges___repeat () { _gst_mandatory_argument; }
|
|
|
|
_ges___save () { _gst_mandatory_argument; }
|
2015-02-20 14:22:25 +00:00
|
|
|
|
2015-02-26 12:19:25 +00:00
|
|
|
containsElement () {
|
|
|
|
local e
|
|
|
|
for e in "${@:2}";
|
|
|
|
do
|
|
|
|
[[ "$e" == "$1" ]] && return 0;
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2015-02-20 14:22:25 +00:00
|
|
|
__ges_main ()
|
|
|
|
{
|
2015-02-26 12:19:25 +00:00
|
|
|
local i=1 c=1 command function_exists completion_func commands real_command effect_bin_description
|
|
|
|
|
2017-04-04 20:27:33 +00:00
|
|
|
commands=($(_list_commands))
|
2015-02-26 12:19:25 +00:00
|
|
|
real_command=""
|
|
|
|
effect_bin_description=""
|
|
|
|
|
|
|
|
if [[ "$cur" == "=" ]]; then
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-02-26 12:19:25 +00:00
|
|
|
return
|
|
|
|
fi
|
2015-02-20 14:22:25 +00:00
|
|
|
|
|
|
|
while [[ $i -ne $COMP_CWORD ]];
|
|
|
|
do
|
|
|
|
local var
|
|
|
|
var="${COMP_WORDS[i]}"
|
|
|
|
if [[ "$var" == "--"* ]]
|
|
|
|
then
|
|
|
|
command="$var"
|
2015-02-26 12:19:25 +00:00
|
|
|
elif containsElement "$var" "${commands[@]}";
|
|
|
|
then
|
|
|
|
real_command="$var"
|
|
|
|
command="$var"
|
2015-03-13 12:02:30 +00:00
|
|
|
if [[ "$var" == "+effect" ]]
|
2015-02-26 12:19:25 +00:00
|
|
|
then
|
|
|
|
effect_bin_description="${COMP_WORDS[i+1]}"
|
|
|
|
fi
|
2015-02-20 14:22:25 +00:00
|
|
|
fi
|
|
|
|
i=$[$i+1]
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "$command" == "--gst"* ]]; then
|
|
|
|
completion_func="_${command//-/_}"
|
|
|
|
else
|
2015-04-03 15:38:53 +00:00
|
|
|
completion_func="_ges_${command//-/_}"
|
2015-03-13 12:02:30 +00:00
|
|
|
completion_func="${completion_func//+/}"
|
2015-02-20 14:22:25 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
declare -f $completion_func >/dev/null 2>&1
|
|
|
|
|
|
|
|
function_exists=$?
|
|
|
|
|
2015-02-26 12:19:25 +00:00
|
|
|
if [[ "$cur" == "-"* ]]; then
|
|
|
|
_ges_list_options
|
2015-03-24 16:13:20 +00:00
|
|
|
elif [[ "$cur" == "+"* ]]; then
|
|
|
|
_ges_list_commands
|
2015-02-26 12:19:25 +00:00
|
|
|
elif [[ "$cur" == "="* ]]
|
|
|
|
then
|
2015-03-23 11:27:56 +00:00
|
|
|
_gst_mandatory_argument
|
2015-02-26 12:19:25 +00:00
|
|
|
elif [[ "$cur" == "set-"* ]]
|
|
|
|
then
|
|
|
|
_ges_list_properties
|
2015-02-20 14:22:25 +00:00
|
|
|
elif [ $function_exists -eq 0 ]
|
|
|
|
then
|
|
|
|
$completion_func
|
|
|
|
else
|
2015-02-26 12:19:25 +00:00
|
|
|
_ges_list_commands
|
2015-02-20 14:22:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
__ges_func_wrap ()
|
|
|
|
{
|
|
|
|
local cur prev
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
$1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Setup completion for certain functions defined above by setting common
|
|
|
|
# variables and workarounds.
|
|
|
|
# This is NOT a public function; use at your own risk.
|
|
|
|
__ges_complete ()
|
|
|
|
{
|
|
|
|
local wrapper="__ges_wrap${2}"
|
|
|
|
eval "$wrapper () { __ges_func_wrap $2 ; }"
|
|
|
|
complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
|
|
|
|
|| complete -o default -o nospace -F $wrapper $1
|
|
|
|
}
|
|
|
|
|
|
|
|
_ges ()
|
|
|
|
{
|
|
|
|
__ges_wrap__ges_main
|
|
|
|
}
|
|
|
|
|
|
|
|
__ges_complete ges-launch-1.0 __ges_main
|