uritranscodebin: Fix unref of NULL
[platform/upstream/gstreamer.git] / subprojects / gst-editing-services / data / completions / ges-launch-1.0
1 # GStreamer
2 # Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
3 #
4 # bash/zsh completion support for ges-launch
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Library General Public License for more details.
15 #
16 # You should have received a copy of the GNU Library General Public
17 # License along with this library; if not, write to the
18 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
20
21 HELPERDIR="${BASH_SOURCE[0]%/*}/../helpers"
22
23 if [[ ! -d "$HELPERDIR" ]]; then
24         HELPERDIR="$(pkg-config --variable=bashhelpersdir gstreamer-1.0)"
25 else
26         HELPERDIR=`cd "$HELPERDIR"; pwd`
27 fi
28
29 # Common definitions
30 . "$HELPERDIR"/gst
31
32 HELPER="$_GST_HELPER"
33
34 _list_commands ()
35 {
36   ges-launch-1.0 help | grep '^  +' | cut -d' ' -f3
37 }
38
39 _ges___inspect_action_type ()
40 {
41         COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --inspect-action-type | grep '^[^ ]' | cut -d':' -f2)" -- $cur) )
42 }
43
44 _ges___track_types ()
45 {
46         COMPREPLY=( $(compgen -W "audio video audio+video" -- $cur) )
47 }
48
49 _ges___set_scenario () {
50         COMPREPLY=( $(compgen -W "*.scenario $(gst-validate-1.0 -l | awk '$0=$2' FS=[ RS=])" -- $cur) )
51 }
52
53 _ges___load () {
54         COMPREPLY=( $(compgen -W "*.xges" -- $cur) )
55 }
56
57 _ges___outputuri () {
58         COMPREPLY=( $(compgen -W "file://" -- $cur) )
59 }
60
61 _ges___audiosink () {
62         COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='audio/x-raw')" -- $cur) )
63 }
64
65 _ges___videosink () {
66         COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='video/x-raw')" -- $cur) )
67 }
68
69 _ges_clip () {
70         if [[ "$prev" == "$command" ]];
71         then
72                 _gst_mandatory_argument
73         else
74                 COMPREPLY=( $(compgen -W "duration= inpoint= start= layer= $(_list_commands)" -- $cur) )
75         fi
76 }
77
78 _ges_test_clip () {
79         if [[ "$prev" == "$command" ]];
80         then
81                 _gst_mandatory_argument
82         else
83                 COMPREPLY=( $(compgen -W "duration= inpoint= start= layer= $(_list_commands)" -- $cur) )
84         fi
85 }
86
87 _ges_effect () {
88         if [[ "$prev" == "$command" ]];
89         then
90                 _gst_mandatory_argument
91         else
92                 COMPREPLY=( $(compgen -W "duration= start= layer= $(_list_commands)" -- $cur) )
93         fi
94 }
95
96 _ges_list_options () {
97         _gst_all_arguments ges-launch-1.0
98 }
99
100 _ges_list_commands () {
101         COMPREPLY=( $(compgen -W "$(_list_commands)" -- $cur) )
102 }
103
104 _ges_list_properties () {
105         local props
106
107         if [[ "$real_command" == "" ]]
108         then
109                 _gst_mandatory_argument
110         elif [[ "$real_command" == "+clip" ]]
111         then
112                 COMPREPLY=( $(compgen -W "set-alpha set-posx set-posy set-width set-height set-volume set-mute" -- $cur) )
113         elif [[ "$real_command" == "+test-clip" ]]
114         then
115                 COMPREPLY=( $(compgen -W "set-alpha set-posx set-posy set-width set-height set-volume set-mute" -- $cur) )
116         elif [[ "$real_command" == "+effect" ]]
117         then
118                 COMPREPLY=()
119                 effect_bin_description="${effect_bin_description//\"/ }"
120                 array=(${effect_bin_description//!/ })
121                 for i in "${array[@]}"; do
122                         props=("$($HELPER --element-properties $i)")
123                         for j in $props; do
124                                 j="${j//=/ }"
125                                 COMPREPLY+=( $(compgen -W "set-$j" -- $cur) )
126                         done
127                 done
128         else
129                 _gst_mandatory_argument
130         fi
131 }
132
133 _ges___exclude_ () { _gst_mandatory_argument; }
134 _ges___encoding_profile () { _gst_mandatory_argument; }
135 _ges___ges_sample_path () { _gst_mandatory_argument; }
136 _ges___ges_sample_path_recurse () { _gst_mandatory_argument; }
137 _ges___thumbnail () { _gst_mandatory_argument; }
138 _ges___repeat () { _gst_mandatory_argument; }
139 _ges___save () { _gst_mandatory_argument; }
140
141 containsElement () {
142         local e
143         for e in "${@:2}";
144         do
145                 [[ "$e" == "$1" ]] && return 0;
146         done
147         return 1
148 }
149
150 __ges_main ()
151 {
152         local i=1 c=1 command function_exists completion_func commands real_command effect_bin_description
153
154         commands=($(_list_commands))
155         real_command=""
156         effect_bin_description=""
157
158         if [[ "$cur" == "=" ]]; then
159                 _gst_mandatory_argument
160                 return
161         fi
162
163         while [[ $i -ne $COMP_CWORD ]];
164                 do
165                         local var
166                         var="${COMP_WORDS[i]}"
167                         if [[ "$var" == "--"* ]]
168                         then
169                                 command="$var"
170                         elif containsElement "$var" "${commands[@]}";
171                         then
172                                 real_command="$var"
173                                 command="$var"
174                                 if [[ "$var" == "+effect" ]]
175                                 then
176                                         effect_bin_description="${COMP_WORDS[i+1]}"
177                                 fi
178                         fi
179                 i=$[$i+1]
180                 done
181
182         if [[ "$command" == "--gst"* ]]; then
183                 completion_func="_${command//-/_}"
184         else
185                 completion_func="_ges_${command//-/_}"
186                 completion_func="${completion_func//+/}"
187         fi
188
189         declare -f $completion_func >/dev/null 2>&1
190
191         function_exists=$?
192
193         if [[ "$cur" == "-"* ]]; then
194                 _ges_list_options
195         elif [[ "$cur" == "+"* ]]; then
196                 _ges_list_commands
197         elif [[ "$cur" == "="* ]]
198         then
199                 _gst_mandatory_argument
200         elif [[ "$cur" == "set-"* ]]
201         then
202                 _ges_list_properties
203         elif [ $function_exists -eq 0 ]
204         then
205                 $completion_func
206         else
207                 _ges_list_commands
208         fi
209 }
210
211 __ges_func_wrap ()
212 {
213         local cur prev
214         cur="${COMP_WORDS[COMP_CWORD]}"
215         prev="${COMP_WORDS[COMP_CWORD-1]}"
216         $1
217 }
218
219 # Setup completion for certain functions defined above by setting common
220 # variables and workarounds.
221 # This is NOT a public function; use at your own risk.
222 __ges_complete ()
223 {
224         local wrapper="__ges_wrap${2}"
225         eval "$wrapper () { __ges_func_wrap $2 ; }"
226         complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
227                 || complete -o default -o nospace -F $wrapper $1
228 }
229
230 _ges ()
231 {
232         __ges_wrap__ges_main
233 }
234
235 __ges_complete ges-launch-1.0 __ges_main