当前位置:网站首页>gst-launch的-v参数
gst-launch的-v参数
2022-07-05 19:33:00 【HUI的技術筆記】
-v参数
先看一个简单的例子:
gst-launch的pipeline,增加-v参数就可以输出caps的详细信息,包括我们想要的codec_data,那么,这个-v参数是怎么输出这些的,就需要深入跟踪下代码,因为这个输出不受GST_DEBUG的控制,是直接输出到terminal的。
$ gst-launch-1.0 filesrc location=~/h264.mp4 ! qtdemux ! fakesink -v
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstFakeSink:fakesink0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, \
level=(string)3.1, profile=(string)high, codec_data=(buffer)0164001fffe100196764001facd9405005ba1000000300100000030320f183196001000568ebecb22c, \
width=(int)1280, height=(int)720, framerate=(fraction)25/1, pixel-aspect-ratio=(fraction)1/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.001151180
Setting pipeline to NULL ...
Freeing pipeline ...
在gst-launch的代码中,-v参数的作用是输出状态信息和属性通知,如果有verbose参数,会先增加deep_notify处理函数:
{
"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
N_("Output status information and property notifications"), NULL},
if (verbose) {
deep_notify_id =
gst_element_add_property_deep_notify_watch (pipeline, NULL, TRUE);
}
gst_element_property_deep_notify_cb
gst_element_property_deep_notify_cb在这里是deep_notify信号回调函数:
gulong
gst_element_add_property_deep_notify_watch (GstElement * element,
const gchar * property_name, gboolean include_value)
{
const gchar *sep;
gchar *signal_name;
gulong id;
g_return_val_if_fail (GST_IS_ELEMENT (element), 0);
sep = (property_name != NULL) ? "::" : NULL;
signal_name = g_strconcat ("deep-notify", sep, property_name, NULL);
id = g_signal_connect (element, signal_name,
G_CALLBACK (gst_element_property_deep_notify_cb),
GINT_TO_POINTER (include_value));
g_free (signal_name);
return id;
}
跟踪进入gst_element_property_deep_notify_cb函数,gst_message_new_property_notify会先创建新的property消息,然后post message。
gst_message_new_property_notify
gst_message_new_property_notify中构造MESSAGE_PROPERTY_NOTIFY类型的message,message post之后,就会在gst-launch中接收处理。
GstMessage *
gst_message_new_property_notify (GstObject * src, const gchar * property_name,
GValue * val)
{
GstStructure *structure;
GValue name_val = G_VALUE_INIT;
g_return_val_if_fail (property_name != NULL, NULL);
structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
g_value_init (&name_val, G_TYPE_STRING);
/* should already be interned, but let's make sure */
g_value_set_static_string (&name_val, g_intern_string (property_name));
gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
if (val != NULL)
gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
}
gst-lauch之GST_MESSAGE_PROPERTY_NOTIFY
在gst-launch的中,GST_MESSAGE_PROPERTY_NOTIFY的处理分支,会先解析message的val,然后在最后通过gst_print打印出来,这就是为什么通过增加-v参数就能获取codec_data了。
case GST_MESSAGE_PROPERTY_NOTIFY:{
const GValue *val;
const gchar *name;
GstObject *obj;
gchar *val_str = NULL;
gchar **ex_prop, *obj_name;
if (quiet)
break;
gst_message_parse_property_notify (message, &obj, &name, &val);
/* Let's not print anything for excluded properties... */
ex_prop = exclude_args;
while (ex_prop != NULL && *ex_prop != NULL) {
if (strcmp (name, *ex_prop) == 0)
break;
ex_prop++;
}
if (ex_prop != NULL && *ex_prop != NULL)
break;
obj_name = gst_object_get_path_string (GST_OBJECT (obj));
if (val != NULL) {
if (G_VALUE_HOLDS_STRING (val))
val_str = g_value_dup_string (val);
else if (G_VALUE_TYPE (val) == GST_TYPE_CAPS)
val_str = gst_caps_to_string (g_value_get_boxed (val));
else if (G_VALUE_TYPE (val) == GST_TYPE_TAG_LIST)
val_str = gst_tag_list_to_string (g_value_get_boxed (val));
else if (G_VALUE_TYPE (val) == GST_TYPE_STRUCTURE)
val_str = gst_structure_to_string (g_value_get_boxed (val));
else
val_str = gst_value_serialize (val);
} else {
val_str = g_strdup ("(no value)");
}
gst_print ("%s: %s = %s\n", obj_name, name, val_str);
g_free (obj_name);
g_free (val_str);
break;
同样的,在codec-select的代码中,有deep_notify信号回调函数gst_object_default_deep_notify:
gst-plugins-base/tests/examples/dynamic/codec-select.c
g_signal_connect (pipeline, "deep_notify",
G_CALLBACK (gst_object_default_deep_notify), NULL);
gst_object_default_deep_notify:
void
gst_object_default_deep_notify (GObject * object, GstObject * orig,
GParamSpec * pspec, gchar ** excluded_props)
{
GValue value = {
0, }; /* the important thing is that value.type = 0 */
gchar *str = NULL;
gchar *name = NULL;
if (pspec->flags & G_PARAM_READABLE) {
/* let's not print these out for excluded properties... */
while (excluded_props != NULL && *excluded_props != NULL) {
if (strcmp (pspec->name, *excluded_props) == 0)
return;
excluded_props++;
}
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (orig), pspec->name, &value);
if (G_VALUE_HOLDS_STRING (&value))
str = g_value_dup_string (&value);
else
str = gst_value_serialize (&value);
name = gst_object_get_path_string (orig);
// 打印-v参数
g_print ("%s: %s = %s\n", name, pspec->name, str);
g_free (name);
g_free (str);
g_value_unset (&value);
} else {
name = gst_object_get_path_string (orig);
g_warning ("Parameter %s not readable in %s.", pspec->name, name);
g_free (name);
}
}
边栏推荐
- Postman core function analysis - parameterization and test report
- PG基础篇--逻辑结构管理(用户及权限管理)
- Inventory of the most complete low code / no code platforms in the whole network: Jiandao cloud, partner cloud, Mingdao cloud, Qingliu, xurong cloud, Jijian cloud, treelab, nailing · Yida, Tencent clo
- 通过POI追加数据到excel中小案例
- 【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
- 毫米波雷达人体感应器,智能感知静止存在,人体存在检测应用
- How to apply smart contracts more wisely in 2022?
- Oracle故障处理:Ora-10873:file * needs to be either taken out of backup or media recovered
- HAC cluster modifying administrator user password
- Which securities company is better and which platform is safer for mobile account opening
猜你喜欢

测试外包公司怎么样?

【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法

Oracle故障处理:Ora-10873:file * needs to be either taken out of backup or media recovered
Successful entry into Baidu, 35K monthly salary, 2022 Android development interview answer

2022 the latest big company Android interview real problem analysis, Android development will be able to technology

Ultrasonic ranging based on FPGA

Decision tree and random forest

The basic grammatical structure of C language

IFD-x 微型红外成像仪(模块)关于温度测量和成像精度的关系
MySql中的longtext字段的返回问题及解决
随机推荐
【合集- 行业解决方案】如何搭建高性能的数据加速与数据编排平台
PG basics -- Logical Structure Management (user and permission management)
The relationship between temperature measurement and imaging accuracy of ifd-x micro infrared imager (module)
webuploader文件上传 拖拽上传 进度监听 类型控制 上传结果监听控件
Debezium系列之:postgresql从偏移量加载正确的最后一次提交 LSN
从零实现深度学习框架——LSTM从理论到实战【实战】
成功入职百度月薪35K,2022Android开发面试解答
Fundamentals of shell programming (Chapter 9: loop)
IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
Pandora IOT development board learning (HAL Library) - Experiment 8 timer interrupt experiment (learning notes)
众昂矿业:2022年全球萤石行业市场供给现状分析
What does software testing do? What are the requirements for learning?
Django uses mysqlclient service to connect and write to the database
Fundamentals of shell programming (Part 8: branch statements -case in)
The problem of returning the longtext field in MySQL and its solution
Fundamentals of machine learning (III) -- KNN / naive Bayes / cross validation / grid search
Do you know several assertion methods commonly used by JMeter?
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
What do software test engineers do? How about the prospect of treatment?
Reptile exercises (II)