Commit graph

859 commits

Author SHA1 Message Date
Mathieu Duponchelle
7da98a2278 gst-inspect: Print GstValueArray properties nicely
https://bugzilla.gnome.org/show_bug.cgi?id=787924
2017-09-22 00:53:12 +02:00
Tim-Philipp Müller
92ad74052b gst-launch: fix compiler warnings for SIGHUP handlers on windows
Fix unused variable/function compiler warnings on windows.
The SIGHUP handling is only available under unix.

https://bugzilla.gnome.org/show_bug.cgi?id=783661
2017-07-20 17:31:41 +01:00
Graham Leggett
cfe59c285c Generate a gstreamer pipeline diagram on SIGHUP.
Useful for debugging a pipeline that refuses to enter a given state.

https://bugzilla.gnome.org/show_bug.cgi?id=783661
2017-07-13 14:02:33 +01:00
Scott D Phillips
f37688ef4d tools: gst-stats: Use standard character escapes
Having '\e' expand to '\x1b' is a gnu extension. I didn't see any
document describing the behavior, but gcc also seems to expand
'\[' to '['.

https://bugzilla.gnome.org/show_bug.cgi?id=782028
2017-07-09 20:10:31 +01:00
Jimmy Ohn
a8acba142f gst-inspect: Fix memory leak in print_pad_templates_info
gst_static_caps_get function returned allocated memory.
So, It should be free using gst_caps_unref.

https://bugzilla.gnome.org/show_bug.cgi?id=784311
2017-06-29 15:26:36 +01:00
Thibault Saunier
55ccfd4760 meson: Add configinc as include_directory in tools/
Otherwise when the glib is used as a subproject config.h is the glib
one, not ours.
2017-06-28 09:38:35 -04:00
Tim-Philipp Müller
9f05e66154 tools: dist new gst-stats man page
Fixes meson build from tarball.
2017-05-20 16:44:56 +01:00
Koop Mast
97cacb78e3 Meson: also build and install gst-stats-1.0 and it's man page.
https://bugzilla.gnome.org/show_bug.cgi?id=781585
2017-04-21 10:55:55 -03:00
Koop Mast
8b06627df9 Add very simple man page for gst-stats.
https://bugzilla.gnome.org/show_bug.cgi?id=781585
2017-04-21 10:55:55 -03:00
Tim-Philipp Müller
921b0f40d8 tools: gst-launch: print structure property notifies nicer
One less layer of escaping, but still lots of ugly \.
2017-03-27 18:27:59 +01:00
Tim-Philipp Müller
b84cb75200 tools: replace mentions of 'mad' on the gst-launch-1.0 man page
The 'mad' plugin has been removed. Mention mpg123audiodec instead.

https://bugzilla.gnome.org/show_bug.cgi?id=776140
2017-03-20 16:54:22 +00:00
Mark Nauwelaerts
31f96fc7a6 tools: update gst-inspect man page 2017-01-05 15:26:08 +01:00
Thibault Saunier
221d65a5e0 gst-launch: Add a '--types' option to filter elements by types to print
This way the user can easily figure out what are the available audio
encoder for example doing:

  gst-inspect-1.0 --types Encoder/Audio

https://bugzilla.gnome.org/show_bug.cgi?id=776392
2016-12-23 08:24:12 -03:00
Nicolas Dechesne
2d5dba8d05 tools: gst-launch: set GST_GL_XINITTHREADS
This ensure that XInitThreads is called and so gl contexts are properly
initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=776401
2016-12-23 12:20:52 +02:00
Stefan Sauer
1bfd04a5fe tracers/stats: log optional fields instead of GST_CLOCK_TIME_NONE
Simplify the traces and avoid trace analyzer to know that ((1<<64) - 1) means
we had no value.
2016-12-16 15:55:21 +01:00
Edward Hervey
9cc36e511c tools: Remove files to be cleaned
manpages are no longer auto-generated
cov-related files should not be there (if needed we could use gitignore)
2016-11-23 18:56:20 +01:00
Tim-Philipp Müller
94cd315595 tools: fix distcheck and .gitignore 2016-11-23 09:58:44 +00:00
Antonio Ospite
38b9aa4c33 meson: tools: install the man pages
https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-23 09:38:25 +00:00
Antonio Ospite
2a5a8dd3c7 tools: ship the final man pages directly, no more man pages templates
Don't use templates for the man pages, the API version change is a rare
event, so it's not really worth keeping in place the "sed" boilerplate
to have it set at build time.

Shipping the final man pages directly also makes it easer to install the
man pages with meson (in a future commit).

Note that now all the occurrences of the programs names have the API
version as a suffix.

Traditionally the example command lines looked like:

  gst-launch ...

Now they look like:

  gst-launch-1.0 ...

This reflects the actual programs names and makes it easier to copy and
paste the example commands.

Also, the .gitignore file is adjusted not to ignore the final man pages
anymore.

You may need to clean your src/build directory before pulling in this
patch.

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-23 09:09:05 +00:00
Antonio Ospite
4eb64cd276 meson: tools: generate the targets dynamically
The three targets are the same except for input and output
files, use a loop and generate them dynamically.

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-11 10:01:16 +00:00
Antonio Ospite
ef3a60793b tools: don't mention gst-feedback in man pages
gst-feedback no longer exists.

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-11 09:59:40 +00:00
Antonio Ospite
76656050b5 tools: put the examples descriptions before the commands in man page
Put the description of the example command lines before the command
instead of after them. The new way is more intuitive.

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-11 09:58:40 +00:00
Antonio Ospite
7521d5b3cf tools: don't start lines with single quotes in man page
When a line starts with a single quote it's treated in a special way by
man, which may result in paragraphs of the man page not rendered by the
man pager, so just avoid that.

A possible solution could have been to escape the singe quote with
a \(cq sequence but this is rather unreadable, instead the text has been
reformatted to have the problematic quoted 'ppc' string on the previous
line.

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-11 09:57:39 +00:00
Antonio Ospite
64c097d296 tools: escape dashes in the man pages
The portable way to have the dashes to be rendered as ASCII minuses is
to use the sequence backslash-dash, use this style at least for text
that can be copied and pasted (e.g. command names, file names, element
options).

Also use backslash-dash in the NAME section as suggested by lexgrog(1).

https://bugzilla.gnome.org/show_bug.cgi?id=773917
2016-11-11 09:55:16 +00:00
Antonio Ospite
050f486d10 tools: gst-launch: fix minor memory leak when failing to parse options
Commit 215cfcf993 (gstreamer: Fix memory leaks when context parse
fails) fixes some memory leak, but in one of the newly added calls to
g_clear_error() the wrong variable was passed.

When failing to parse command line options, free the "err" variable, not
the "error" one.

https://bugzilla.gnome.org/show_bug.cgi?id=773907
2016-11-04 16:59:36 +02:00
Jan Schmidt
5a5ae1be1f parse-launch: Support linking all pads with new operator
Introduce a new operator ':' - e.g. element1 ':' element2

For example, 'uridecodebin : encodebin' -
if the encodebin has multiple profiles compatible with the
decodebin, multiple links will be created.

With '!' , after one delayed link is successfully done, the
pad-added callback is disconnected.

https://bugzilla.gnome.org/show_bug.cgi?id=751450
2016-11-02 12:04:33 +11:00
Tim-Philipp Müller
ad537a2d51 tools: gst-inspect: add * for pointer signal arguments where needed
Print GObject argument properly with pointer marker:

  "client-added" :  void user_function (GstElement* object,
                                        GObject* arg0,
                                        gpointer user_data);

instead of

  "client-added" :  void user_function (GstElement* object,
                                        GObject arg0,
                                        gpointer user_data);

for gst-inspect-1.0 tcpserversink.
2016-09-04 20:39:31 +01:00
Tim-Philipp Müller
3cae933579 tools: gst-inspect: don't print internal pad request function name
This just confuses people, they look at it and try to call it
directly by name, instead of using the public GstElement API.
It stands to reason that it goes without saying that when an
element provides request pads that they can actually be
requested using the standard API, and there's no point in
printing internal implementation details of the element.
2016-08-28 16:04:27 +01:00
Nirbheek Chauhan
b2f9808722 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-19 21:26:14 +01:00
Jan Schmidt
9e23670671 Update the examples in the gst-launch-1.0 manpage
Replace elements that don't exist any more with ones
that do, and insert elements like mpegaudioparse where
they are needed.

https://bugzilla.gnome.org/show_bug.cgi?id=727105
2016-05-13 18:05:39 +10:00
Guillaume Desmottes
4fe32b923f inspect: fix feature leak
https://bugzilla.gnome.org/show_bug.cgi?id=765957
2016-05-04 10:09:43 +03:00
Tim-Philipp Müller
939a7fee6c tools: gst-launch: fix up caps printing in verbose mode
Add missing 'else' and print caps and taglists without the
annoying duplicate string escaping, making both nicer to read.

Fixes string leak and coverity CID 1358492.
2016-04-13 16:42:31 +01:00
Tim-Philipp Müller
d09dc8cbc0 tools: gst-launch: use new async property change notification API
https://bugzilla.gnome.org/show_bug.cgi?id=763142
2016-04-08 13:28:06 +01:00
Stefan Sauer
f69382c5f9 tracer/gststats: fix mismatch between '.class' and tracer args
Clean up from the recent changes. The logging descriptiors did not match what we logged.
2016-01-20 09:14:12 +01:00
Tim-Philipp Müller
8641d7c911 tracers: fix thread-id casts to 64-bit ints on 32-bit systems
https://bugzilla.gnome.org/show_bug.cgi?id=760762
2016-01-18 11:28:28 +00:00
Stefan Sauer
765cf11ff8 gst-stats: update to latest tarcer api
The thread-ids are serialized as uint64. The 'elem-ix' got changed to
'element-ix'. Make the code a bit more robust.
2016-01-16 21:02:39 +01:00
Nicolas Dufresne
4127407823 gst-launch: Fix process return value on error
In case of a run-time error message, the process return value was left
unset. This would lead to error not being caught at shell level.

https://bugzilla.gnome.org/show_bug.cgi?id=759019
2015-12-04 10:45:44 -05:00
Nicolas Dufresne
f3a5c17464 Revert "tools: gst-launch: return non-0 exit code on async error"
This reverts commit 2ee4cba248.
2015-12-04 10:45:44 -05:00
Tim-Philipp Müller
2ee4cba248 tools: gst-launch: return non-0 exit code on async error
When an error happens in playing state, still return a
non-0 exit code.

https://bugzilla.gnome.org/show_bug.cgi?id=759019
2015-12-04 15:09:39 +00:00
Luis de Bethencourt
587b95a857 stats: always free log
We always want to free the open file log if fopen() succeeded. Independently
of if fgets() succeeds or fails.

CID 1326055

https://bugzilla.gnome.org/show_bug.cgi?id=756864
2015-10-21 11:19:14 +01:00
Tim-Philipp Müller
bc5c199bc5 docs: mention xdot utility to view .dot files directly 2015-10-16 15:59:49 +01:00
Stefan Sauer
e5eb05741b stats: TIMESTAMP -> PTS 2015-10-05 20:59:39 +02:00
Stefan Sauer
d9901e7019 stats: fix cpu stats printing
Only print them if we have them. Also scale them by 10.0 as the are in
per-mille now.
2015-10-05 20:59:39 +02:00
Stefan Sauer
f09dd66cf6 stats: don't warn on ".class" log lines 2015-10-05 20:59:39 +02:00
Stefan Sauer
dbb1897e9b rusage: implement windowing of cpuload
Add a local help to the rusage plugin that supports windowing of values. We want
to generalize this for use in other plugins.
2015-10-05 20:59:39 +02:00
Stefan Sauer
018858980b rusage: announce the data format
Rusage will now announce what is meassures and how it is logged. Use the new format in stats.
Cleanup the the code and naming.
2015-10-05 20:59:39 +02:00
Stefan Sauer
c13ee1f2e9 stats: improve cpu load meassurements
Rename variables for clarity. Handle the initial disparity between debug time
and the time already spent in the proc and main thread.
2015-10-05 20:59:39 +02:00
Stefan Sauer
b90ee2a84c gst-stats: use the rusage stats
Add cpuload info from rusage traces.
2015-10-05 20:59:39 +02:00
Stefan Sauer
ff7ba1eb8d gst-stats: filter complete thread section if we have no pads 2015-10-05 20:59:39 +02:00
Stefan Sauer
0c26387e62 stats: improve the handling of parentage
Log new object after we did the check for parents.
2015-10-05 20:59:39 +02:00
Stefan Sauer
81e617fa70 stats: print thread key for stats and filter empty pad-sections 2015-10-05 20:59:39 +02:00
Stefan Sauer
f8390caf2c stats: update buffer flags
Remove some buffer flags that were leftovers from 0.10 and handle new 1.0 buffer
flags.
2015-10-05 20:59:39 +02:00
Stefan Sauer
b8eef6ba2c stats: add a stats frontend
Parse the log and collect data from tracer messages.
2015-10-05 20:59:39 +02:00
Stefan Sauer
6e9f018dc4 inspect: add support for the new factory
Handle tracer modules.
2015-10-05 20:59:39 +02:00
Vineeth TM
456ef2aa1d tests/gst-launch: Fix sample memory leak
When sample is got using gst_tag_list_get_sample_index, it should
be free'd.

https://bugzilla.gnome.org/show_bug.cgi?id=756069
2015-10-05 12:08:30 +01:00
Vineeth TM
215cfcf993 gstreamer: Fix memory leaks when context parse fails
When g_option_context_parse fails, context and error variables are not getting free'd
which results in memory leaks. Free'ing the same.

And replacing g_error_free with g_clear_error, which checks if the error being passed
is not NULL and sets the variable to NULL on free'ing.

https://bugzilla.gnome.org/show_bug.cgi?id=753851
2015-10-02 17:31:11 +03:00
Tim-Philipp Müller
6a9b191fb2 tools: gst-launch: fix --exclude command line option
This has not worked (as in: crashed) since 2005, so
perhaps it should just be removed instead.
2015-09-05 11:19:53 +01:00
Vivia Nikolaidou
957a81eef9 gst-indent: Add support for gindent as executable name
gst-indent used to support gnuindent and indent as executable names.
However, on OSX one can "brew install gnu-indent" and then the
executable name will be gindent. Added support for that.

https://bugzilla.gnome.org/show_bug.cgi?id=750351
2015-06-03 18:09:24 +02:00
Tim-Philipp Müller
8e6561be91 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 17:49:44 +01:00
Mathieu Duponchelle
5d96658874 tools: remove outdated completion script
+ Remove the associated test

https://bugzilla.gnome.org/show_bug.cgi?id=744877#c21
2015-03-18 14:16:48 +01:00
Stefan Sauer
a4e561c7f8 gst-inspect: only print presets line if num-presets > 0
Also check for an empty strv.
2015-01-04 23:26:19 +01:00
Stefan Sauer
d3958b912e gst-inspect: fix output for -a
Use n_print to ensure all lines are prefixed with the element name.
2015-01-04 22:52:19 +01:00
Stefan Sauer
a536c62ed6 gst-inspect: print preset names
If the element supports presets and ships some, print them.
Fixes #741427
2014-12-21 14:15:54 +01:00
Sebastian Dröge
154eefecc9 Don't compare booleans for equality to TRUE and FALSE
TRUE is 1, but every other non-zero value is also considered true. Comparing
for equality with TRUE would only consider 1 but not the others.

Also normalize booleans in a few places.
2014-12-01 09:51:37 +01:00
Aurélien Zanelli
c2390c8943 gst-inspect: add G_PARAM_DEPRECATED to known flags
Display 'deprecated' instead of flag value when using G_PARAM_DEPRECATED
in element properties.

https://bugzilla.gnome.org/show_bug.cgi?id=739518
2014-11-02 12:50:04 +00:00
Jan Schmidt
8f4b4a9497 gst-indent: Run indent twice. Once is not idempotent, twice seems to be. 2014-10-20 23:55:47 +11:00
Stefan Sauer
d5518edf12 fixme: bump leftover 0.11 fixme comments 2014-09-25 21:27:03 +02:00
Tim-Philipp Müller
d3de22d802 tools: gst-inspect: don't list pad functions
Don't print all the different pad functions, it's just
confusing and no one has ever needed to know this for
anything ever anyway, it's just useless information.
Besides, we also label the default implementations as
'custom' implementations (the code that tries to
prevent that doesn't actually work it seems).

https://bugzilla.gnome.org/show_bug.cgi?id=736377
2014-09-12 14:13:54 +01:00
Руслан Ижбулатов
35fc309544 gst-launch: Support SIGINT (Ctrl+C) on W32
W32 has no SIGINT, but it does have SetConsoleCtrlHandler(), which sets up
a handler for Ctrl+C.

https://bugzilla.gnome.org/show_bug.cgi?id=733814
2014-07-28 09:21:40 +02:00
Sebastian Dröge
7f9c0d06dd docs: There is no decodebin2 anymore, don't pretend otherwise 2014-07-08 11:18:05 +02:00
Tim-Philipp Müller
721a1c7553 tools: suppress GLib warnings when gst-inspecting deprecated properties
GLib in git will spew a g_warning() when a property marked as
deprecated via param spec flags is accessed. Suppress this by
setting the appropriate environment variable.
2014-07-04 19:40:28 +01:00
Olivier Crête
7992174a1a DeviceProvider: Rename from DeviceMonitor 2014-06-26 14:45:30 -04:00
Wim Taymans
df7bfb6a10 inspect: print structure values of properties 2014-04-12 07:13:02 +02:00
Edward Hervey
98ea309bea gst-launch.1: Playbin2 is dead, long live playbin
Looks like that was the last remaining mention in core ...
2014-04-03 07:37:11 +02:00
Sebastian Dröge
338a150a1b gst-inspect: Add missing \n in output 2014-04-02 23:52:24 +02:00
Wim Taymans
f85ce91e9d launch: place the deep-notify on the right pipeline
If the toplevel bin is not not a pipeline, we place the bin in a
pipeline. Also make sure that we connect to the deep-notify of this new
pipeline because we will g_signal_handler_disconnect() from it later.
2014-03-25 12:38:07 +01:00
Olivier Crête
59611a01ac gst-inpect: Print device monitor 2014-03-16 20:50:53 -04:00
Sebastian Dröge
be32ae0252 gst-inspect: Fix yet another compiler warning
https://bugzilla.gnome.org/show_bug.cgi?id=724045
2014-02-10 17:09:59 +01:00
Sebastian Dröge
53d8460bfd gst-inspect: Make clang happy with our g_vprintf() wrapper 2014-02-08 16:42:55 +01:00
Sebastian Dröge
c1ec592ec2 tools: Support non-ASCII tags
By calling setlocale() to get us multi-byte/UTF-8 support.

https://bugzilla.gnome.org/show_bug.cgi?id=723164
2014-01-30 21:25:48 +01:00
Edward Hervey
12b3a37b5e gst-launch: Handle taglist copy failure
If we couldn't copy the tags, just return instead of trying to use bogus
values.
2013-12-10 18:30:03 -05:00
Edward Hervey
60b94c6498 gst-inspect: Index features are no more
So remove code that will never be used
2013-12-10 18:25:22 -05:00
Tim-Philipp Müller
208e303568 tools: gst-launch: don't try to remove already-removed GSource from main loop
It's considered a programming error in recent GLib versions now.
We may already have removed the source by returning FALSE from
the callback if it was fired. Fixes warning with newer GLibs
when interrupting a pipeline with Control-C.
2013-12-05 00:26:13 +00:00
Philippe Normand
6e4cab6541 gst-launch: exit with an error code when an error occured
If the pipeline failed to pre-roll or the user interrupted the
execution then set the exit code to a positive value.

https://bugzilla.gnome.org/show_bug.cgi?id=712300
2013-11-25 12:12:39 +01:00
Stefan Sauer
24c741554c typefind: use g_get_prgname() for error message 2013-11-07 21:01:27 +01:00
Reynaldo H. Verdejo Pinochet
afe174d38d gst-inspect: Remove some dead code 2013-11-04 13:56:37 -08:00
Matthieu Bouron
a0e2eb6169 gst-launch: fix potential uninitialized variable warning
https://bugzilla.gnome.org/show_bug.cgi?id=710758
2013-11-01 15:15:29 +01:00
Sebastian Dröge
aacedb9da4 gst-launch: Update for GstContext changes 2013-09-18 21:42:42 +02:00
Tim-Philipp Müller
954776ab38 tools: move gst-plot-timeline.py into scripts directory
So it's not in PATH in an uninstalled setup (thwarting
gst-play autocompletion).
2013-09-04 10:43:16 +01:00
Tim-Philipp Müller
71422a9a70 tools: gst-launch: don't print properties being reset when shutting down
It's just noise.
2013-08-26 13:19:10 +01:00
Руслан Ижбулатов
797fcd1d49 info: Add debug color mode option
This allows to explicitely set the debug output color
mode to UNIX on every platform, enable it (use platform
default color mode) or enable it.

https://bugzilla.gnome.org/show_bug.cgi?id=674320
2013-07-18 14:30:44 +02:00
Sebastian Dröge
ff47fe72ab gst-launch: Remove unref that should not be there
We keep a reference to the context around all the time.

https://bugzilla.gnome.org/show_bug.cgi?id=701985
2013-06-11 10:25:02 +02:00
Sebastian Dröge
b7ad14984b gst-launch: Improve GstContext handling
https://bugzilla.gnome.org/show_bug.cgi?id=700967
2013-06-09 17:20:22 +02:00
David Rothlisberger
9f5e9c8632 tools/gstreamer-completion: Allow 1.0 and 0.10 scripts installed simultaneously
As long as the scripts' filenames are different, and the _gst_inspect
and _gst_launch functions are named differently, the completion scripts
for GStreamer 1.0 and 0.10 can be installed side-by-side in
/etc/bash_completion.d.

On my 0.10 branch† the completion script is renamed to
"gstreamer-completion-0.10" and the functions are renamed to
"_gst_inspect_0_10" and "_gst_launch_0_10". The remaining helper
functions should remain identical (the command-line interface to
gst-inspect hasn't changed, nor has the format of the gst-launch
pipeline), so it doesn't matter if the 1.0 script overrides the 0.10
script's definitions.

Note that I don't expect there to be another GStreamer 0.10 release, so
the 0.10 completion script will probably never be officially released;
but it is still worthwhile allowing both scripts to be installed
alongside each other, for those who install the 0.10 completion script
manually.

Fixes: #690515https://github.com/drothlis/gstreamer/blob/bash-completion-0.10/tools/gstreamer-completion-0.10
2013-04-29 21:17:23 +02:00
David Rothlisberger
5d6635f9b4 tools/gstreamer-completion: Complete option & property values on bash 3.2
Bash 3's completion doesn't split words by characters in
COMP_WORDBREAKS. In particular it doesn't split at "=" signs. Now
_gst_launch_parse handles both bash 3 and 4 format of COMP_WORDS.

Note that "${cur%%=*}" means cur's value with the longest possible match
of "=*" deleted from the end; "${cur#*=}" means cur's value with the
shortest possible match of "*=" deleted from the beginning. See
http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

Regardless of the version of bash running the unit tests, I can test for
both behaviours because the unit test populates COMP_WORDS manually. So
this tests the bash 3 behaviour:

    test_gst_inspect_completion --gst-debug-level=4

and this tests the bash 4 behaviour:

    test_gst_inspect_completion --gst-debug-level = 4
2013-04-29 21:12:42 +02:00
David Rothlisberger
f586e34a50 tools/gstreamer-completion: Bash 3.2 compatibility fixes
Compatible with bash 3.2; doesn't require the bash-completion package at
all (though the easiest way to install this script is still to install
bash-completion, and then drop this script into /etc/bash_completion.d).

Note that bash 3 doesn't break COMP_WORDS according to characters in
COMP_WORDBREAKS, so "property=val" looks like a single word, so this
won't complete property values (on bash 3). Similarly,
"--gst-debug-level=<TAB>" won't complete properly (on bash 3), but
"--gst-debug-level <TAB>" will.

For that reason, I now offer "--gst-debug-level" etc as completions
instead of "--gst-debug-level=".

Functions "_init_completion" and "_parse_help" were provided by the
bash-completion package >= 2.0; now I roll my own equivalent of
"_parse_help", and instead of "_init_completion" I use
"_get_comp_words_by_ref" which is available from bash-completion 1.2
onwards. If the bash-completion package isn't available at all I use
bash's raw facilities, at the expense of not completing properly when
the cursor is in the middle of a word.

The builtin "compopt" doesn't exist in bash 3; those users will just
have to live with the inconvenience of "property=" completing to
"property= " with a trailing space. Property values aren't completed
properly anyway on bash 3 (see above).

"[[ -v var ]]" to test whether a variable is set, also doesn't exist in
bash 3. Neither does ";;&" to fall through in a "case" statement.

In the unit tests:

* On my system (OS X), "#!/bin/bash" is bash 3.2, whereas
  "#!/usr/bin/env bash" is the 4.2 version I built myself.
* I have to initialise array variables like "expected=()", or bash 3
  treats "+=" as appending to an array already populated with one empty
  string.
2013-04-29 21:12:42 +02:00
David Rothlisberger
020dd3bbf3 tools/gstreamer-completion: Support gst-inspect, and gst-launch element properties
Completes options like "--gst-debug-level" and the values of some of
those options; completes gst-launch pipeline element names, property
names, and even property values (for enum or boolean properties only).

Doesn't complete all caps specifications, nor element names specified
earlier in the pipeline with "name=...".

The GStreamer version number is hard-coded into the completion script:
This patch is off the master branch and has the version hard-coded as
"1.0"; it needs to be updated if backported to the 0.10 branch. You
could always create a "gstreamer-completion.in" that has the appropriate
version inserted by "configure", but I'd rather not do that. The
hard-coded version is consistent with the previous implementation of
gstreamer-completion, which had the registry path hard-coded as
~/.gstreamer-1.0/registry.xml.

Note that GStreamer 0.10 installs "gst-inspect" and "gst-inspect-0.10".
"gst-inspect --help" only prints 4 flags (--help, --print, --gst-mm,
gst-list-mm) whereas "gst-inspect-0.10 --help-all" prints the full list
of flags. The same applies to "gst-launch" and "gst-launch-0.10".
GStreamer 1.0 only installs "gst-inspect-1.0", not "gst-inspect".

Requires bash 4; only tested with bash 4.2. Requires "bash-completion"
(which you install with your system's package manager).

Put this in /etc/bash_completion.d/ or in `pkg-config
--variable=compatdir bash-completion`, where it will be loaded at the
beginning of every new terminal session;
or in `pgk-config --variable=completionsdir bash-completion`, renamed to
match the name of the command it completes (e.g. "gst-launch-1.0", with
an additional symlink named "gst-inspect-1.0"), where it will be
autoloaded when needed.

test-gstreamer-completion.sh is (for now) in tests/misc -- it might be
worth creating "tests/check/tools", with all the necessary automake
boilerplate, and moving test-gstreamer-completion.sh there, and have it
run automatically with "make check".

IF YOU'RE NEW TO BASH COMPLETION SCRIPTS
----------------------------------------

"complete -F _gst_launch gst-launch-1.0" means that bash will run the
function "_gst_launch" to generate possible completions for the command
"gst-launch-1.0".

"_gst_launch" must return the possible completions in the array variable
COMPREPLY. (Note on bash syntax: "V=(a b c)" assigns three elements to
the array "V").

"compgen" prints a list of possible completions to standard output. Try
it:

    compgen -W "abc1 abc2 def" -- "a"
    compgen -f -- "/"

The last argument is the word currently being completed; compgen uses it
to filter out the non-matching completions. We put "--" first, in case
the word currently being completed starts with "-" or "--", so that it
isn't treated as a flag to compgen.

For the documentation of COMP_WORDS, COMP_CWORD, etc see
http://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-COMP_005fCWORD-180

See also:
* http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html
* http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html

The bash-completion package provides the helper function
"_init_completion" which populates variables "cur", "prev", and "words".
See
http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=blob;f=bash_completion;h=870811b4;hb=HEAD#l634

Note that by default, bash appends a space to the completed word. When
the completion is "property=" we don't want a trailing space; calling
"compopt -o nospace" modifies the currently-executing completion
accordingly. See
http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#index-compopt
2013-04-29 21:12:42 +02:00
David Rothlisberger
271c707c45 tools/gstreamer-completion: Updated to work with the binary registry
The original registry was in xml format (~/.gstreamer-*/registry.xml). A
binary registry format was added in 2007 (commit ebf0c9d3) and made the
default in 2008 (commit 3f39fd7e). In 0.10 you could still choose at
"configure" time to use the xml registry instead; in 1.0 the binary
registry is your only choice.

This change to gstreamer-completion should work with either format
because it parses the output of "gst-inspect" instead of reading the
registry file directly.

Note that _gst_launch no longer needs an explicit "return 0" because,
unlike the previous grep command, compgen always returns 0 (unless a
genuine error occurs).

Just like the previous implementation by David Schleef, this "only
completes names of features, but that's 90% of what I want it for."
2013-04-29 21:12:42 +02:00
Tim-Philipp Müller
7954ac2ad7 tools: update for latest context API changes 2013-04-18 10:13:30 +01:00
Sebastian Dröge
8f8036f344 gst-launch: Add GstContext support
gst-launch will collect all the contexts from the pipeline elements
and update the overall pipeline context with it.
2013-04-17 13:47:35 +02:00