之前总结过category的定义和使用,基于这个基础,发现利用gstreamer的categories和log系统,调试起来效率会提升很多。
首先,通过gst-launch-1.0 --help-gst
可以列出来gstreamer支持命令行参数,比如--gst-debug-help
就可以打印出来所有的categories,这个在通过log来调试的时候非常方便。
$ gst-launch-1.0 --help-gst
Usage:
gst-launch-1.0 [OPTION…] PIPELINE-DESCRIPTION
GStreamer Options
--gst-version Print the GStreamer version
--gst-fatal-warnings Make all warnings fatal
--gst-debug-help Print available debug categories and exit
--gst-debug-level=LEVEL Default debug level from 1 (only error) to 9 (anything) or 0 for no output
--gst-debug=LIST Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3
--gst-debug-no-color Disable colored debugging output
--gst-debug-color-mode Changes coloring mode of the debug log. Possible modes: off, on, disable, auto, unix
--gst-debug-disable Disable debugging
--gst-plugin-spew Enable verbose plugin loading diagnostics
--gst-plugin-path=PATHS Colon-separated paths containing plugins
--gst-plugin-load=PLUGINS Comma-separated list of plugins to preload in addition to the list stored in environment variable GST_PLUGIN_PATH
--gst-disable-segtrap Disable trapping of segmentation faults during plugin loading
--gst-disable-registry-update Disable updating the registry
--gst-disable-registry-fork Disable spawning a helper process while scanning the registry
通过gst-launch-1.0 --gst-debug-help
可以列出所有的category,加上grep GST
过滤后,列出来的就是GST_
开头的categories:
$ gst-launch-1.0 --gst-debug-help | grep GST
GST_BUFFER 0 no description
GST_BUFFER_LIST 0 no description
GST_BUS 0 no description
GST_CALL_TRACE 0 no description
GST_CAPS 0 no description
GST_CLOCK 0 no description
GST_CONTEXT 0 no description
GST_DATAFLOW 0 dataflow inside pads
GST_DEBUG 0 debugging subsystem
GST_DEVICE_PROVIDER_FACTORY 0 device provider factories keep information about installed device providers
GST_DYNAMIC_TYPE_FACTORY 0 dynamic type factories allow automatically loading a type from a plugin
GST_ELEMENT_FACTORY 0 element factories keep information about installed elements
GST_ELEMENT_PADS 0 no description
GST_ERROR_SYSTEM 0 no description
GST_EVENT 0 no description
GST_INIT 0 no description
GST_LOCKING 0 locking
GST_MEMORY 0 memory
GST_MESSAGE 0 no description
GST_META 0 meta
GST_NEGOTIATION 0 no description
GST_PADS 0 no description
GST_PARAMS 0 no description
GST_PARENTAGE 0 no description
GST_PERFORMANCE 0 no description
GST_PIPELINE 0 no description
GST_PLUGIN_INFO 0 no description
GST_PLUGIN_LOADING 0 no description
GST_POLL 0 poll
GST_PROBE 0 pad probes
GST_PROPERTIES 0 no description
GST_PROTECTION 0 protection
GST_QOS 0 QoS
GST_REFCOUNTING 0 no description
GST_REGISTRY 0 registry
GST_SCHEDULING 0 no description
GST_SIGNAL 0 no description
GST_STATES 0 no description
GST_TRACER 0 tracing subsystem
GST_TYPEFIND 0 typefinding subsystem
GST_URI 0 handling of URIs
举个例子,如下,使用playbin播放http mp4的时候,我想知道都创建了那些element,通过指定GST_ELEMENT_FACTORY:5
和grep created
过滤,就可以列出所有创建的lement:
GST_DEBUG=GST_ELEMENT_FACTORY:5 gst-play-1.0 http://192.168.31.124/mov/mp4/panda.mp4 2>&1 | grep created
0:00:00.129453815 12086 0x8c9980 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "playbin"
0:00:00.131668332 12086 0x8c9980 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "uridecodebin"
0:00:00.148187229 12086 0x8c9980 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "souphttpsrc"
0:00:00.151771407 12086 0x8c9980 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "typefind"
0:00:00.288990553 12086 0x8d1db0 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "typefind"
0:00:00.289591194 12086 0x8d1db0 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "decodebin"
0:00:00.290801143 12086 0x8d1db0 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "queue2"
0:00:00.471883367 12086 0xf6803260 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "qtdemux"
0:00:00.492200114 12086 0xf6803260 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "multiqueue"
0:00:00.520578784 12086 0xf6803260 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "h264parse"
0:00:00.544318831 12086 0xf6803260 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "capsfilter"
0:00:00.616704420 12086 0xf6803260 DEBUG GST_ELEMENT_FACTORY gstelementfactory.c:391:gst_element_factory_create: created element "aacparse"
又比如GST_CONTEXT:5
,观察context的创建:
$ GST_DEBUG=GST_CONTEXT:5 gst-play-1.0 http://192.168.31.124/mov/mp4/panda.mp4 2>&1
Now playing http://192.168.31.124/mov/mp4/panda.mp4
0:00:00.171488200 11386 0x1fb0180 LOG GST_CONTEXT gstcontext.c:174:gst_context_new: creating new context 0x1fb8580
0:00:00.171677162 11386 0x1fb0180 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<source> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.308191351 11386 0x1fb85b0 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<decodebin0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.308318895 11386 0x1fb85b0 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<typefind> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.309390123 11386 0x1fb85b0 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<queue2-0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.503178186 11386 0xf6603260 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<qtdemux0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.526549903 11386 0xf6603260 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<multiqueue0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.540391154 11386 0xf6603260 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<h264parse0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.549850535 11386 0xf6603260 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<capsfilter0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
0:00:00.597613528 11386 0xf6603260 DEBUG GST_CONTEXT gstelement.c:3473:gst_element_set_context:<aacparse0> set context 0x1fb8580 context, session=(SoupSession)NULL, force=(boolean)false;
这两个例子都是Gstreamer中基础的部分,其他的element的category通过这个方法查找,再也不怕写错了。