应用层API详解
g_main_loop_new
g_main_loop_new 调用g_main_context_default创建一个GMainContext,并赋值为
GMainLoop的context成员中。
GMainLoop *g_main_loop_new (GMainContext *context,
gboolean is_running)
{
GMainLoop *loop;
if (!context)
context = g_main_context_default();
g_main_context_ref (context);
loop = g_new0 (GMainLoop, 1);
loop->context = context;
loop->is_running = is_running != FALSE;
loop->ref_count = 1;
TRACE (GLIB_MAIN_LOOP_NEW (loop, context));
return loop;
}
#mermaid-svg-IntFxpsUbQdQ8C4M{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-IntFxpsUbQdQ8C4M .error-icon{fill:#552222;}#mermaid-svg-IntFxpsUbQdQ8C4M .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-IntFxpsUbQdQ8C4M .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-IntFxpsUbQdQ8C4M .marker{fill:#333333;stroke:#333333;}#mermaid-svg-IntFxpsUbQdQ8C4M .marker.cross{stroke:#333333;}#mermaid-svg-IntFxpsUbQdQ8C4M svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-IntFxpsUbQdQ8C4M p{margin:0;}#mermaid-svg-IntFxpsUbQdQ8C4M .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster-label text{fill:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster-label span{color:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster-label span p{background-color:transparent;}#mermaid-svg-IntFxpsUbQdQ8C4M .label text,#mermaid-svg-IntFxpsUbQdQ8C4M span{fill:#333;color:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M .node rect,#mermaid-svg-IntFxpsUbQdQ8C4M .node circle,#mermaid-svg-IntFxpsUbQdQ8C4M .node ellipse,#mermaid-svg-IntFxpsUbQdQ8C4M .node polygon,#mermaid-svg-IntFxpsUbQdQ8C4M .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-IntFxpsUbQdQ8C4M .rough-node .label text,#mermaid-svg-IntFxpsUbQdQ8C4M .node .label text,#mermaid-svg-IntFxpsUbQdQ8C4M .image-shape .label,#mermaid-svg-IntFxpsUbQdQ8C4M .icon-shape .label{text-anchor:middle;}#mermaid-svg-IntFxpsUbQdQ8C4M .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-IntFxpsUbQdQ8C4M .rough-node .label,#mermaid-svg-IntFxpsUbQdQ8C4M .node .label,#mermaid-svg-IntFxpsUbQdQ8C4M .image-shape .label,#mermaid-svg-IntFxpsUbQdQ8C4M .icon-shape .label{text-align:center;}#mermaid-svg-IntFxpsUbQdQ8C4M .node.clickable{cursor:pointer;}#mermaid-svg-IntFxpsUbQdQ8C4M .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-IntFxpsUbQdQ8C4M .arrowheadPath{fill:#333333;}#mermaid-svg-IntFxpsUbQdQ8C4M .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-IntFxpsUbQdQ8C4M .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-IntFxpsUbQdQ8C4M .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-IntFxpsUbQdQ8C4M .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-IntFxpsUbQdQ8C4M .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-IntFxpsUbQdQ8C4M .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster text{fill:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M .cluster span{color:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-IntFxpsUbQdQ8C4M .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-IntFxpsUbQdQ8C4M rect.text{fill:none;stroke-width:0;}#mermaid-svg-IntFxpsUbQdQ8C4M .icon-shape,#mermaid-svg-IntFxpsUbQdQ8C4M .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-IntFxpsUbQdQ8C4M .icon-shape p,#mermaid-svg-IntFxpsUbQdQ8C4M .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-IntFxpsUbQdQ8C4M .icon-shape .label rect,#mermaid-svg-IntFxpsUbQdQ8C4M .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-IntFxpsUbQdQ8C4M .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-IntFxpsUbQdQ8C4M .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-IntFxpsUbQdQ8C4M :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} g_main_context_default调用g_main_context_new
g_main_context_new_with_flags
初始化context的相关成员变量
GMainContext *
g_main_context_new_with_flags (GMainContextFlags flags)
{
static gsize initialised;
GMainContext *context;
if (g_once_init_enter (&initialised))
{
#ifdef G_MAIN_POLL_DEBUG
if (g_getenv ("G_MAIN_POLL_DEBUG") != NULL)
_g_main_poll_debug = TRUE;
#endif
g_once_init_leave (&initialised, TRUE);
}
context = g_new0 (GMainContext, 1);
TRACE (GLIB_MAIN_CONTEXT_NEW (context));
g_mutex_init (&context->mutex);
g_cond_init (&context->cond);
context->sources = g_hash_table_new (NULL, NULL);
context->owner = NULL;
context->flags = flags;
context->waiters = NULL;
context->ref_count = 1;
context->next_id = 1;
context->source_lists = NULL;
context->poll_func = g_poll;
context->cached_poll_array = NULL;
context->cached_poll_array_size = 0;
context->pending_dispatches = g_ptr_array_new ();
context->time_is_fresh = FALSE;
context->wakeup = g_wakeup_new ();
g_wakeup_get_pollfd (context->wakeup, &context->wake_up_rec);
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
G_LOCK (main_context_list);
main_context_list = g_slist_append (main_context_list, context);
#ifdef G_MAIN_POLL_DEBUG
if (_g_main_poll_debug)
g_print ("created context=%p\n", context);
#endif
G_UNLOCK (main_context_list);
return context;
}
gst_pipeline_new
创建一个pipeline的element,pipeline和其他的element有一定的区别,
pipeline是一系列element具有相互关系的一个集合,而bin可以包含多个pipeline。
pipeline继承于bin,而bin继承了element
GstElement *gst_pipeline_new (const gchar * name)
{
return gst_element_factory_make ("pipeline", name);
}
gst_pipeline_get_bus
获取pipeline的element成员的bus成员,
同样还有一个child_bus用来给pipeline中的element发送总线信息
GstBus *gst_pipeline_get_bus (GstPipeline * pipeline)
{
return gst_element_get_bus (GST_ELEMENT_CAST (pipeline));
}
gst_bin_add_many
gst_bin_add_many 主要是调用gst_bin_add,最后调用bbin_class->add_element的函数,
在gstbin.c文件中
void gst_bin_add_many (GstBin * bin, GstElement * element_1, ...)
{
va_list args;
g_return_if_fail (GST_IS_BIN (bin));
g_return_if_fail (GST_IS_ELEMENT (element_1));
va_start (args, element_1);
while (element_1) {
gst_bin_add (bin, element_1);
element_1 = va_arg (args, GstElement *);
}
va_end (args);
}
#mermaid-svg-givrWbQMwI7qHoVL{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-givrWbQMwI7qHoVL .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-givrWbQMwI7qHoVL .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-givrWbQMwI7qHoVL .error-icon{fill:#552222;}#mermaid-svg-givrWbQMwI7qHoVL .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-givrWbQMwI7qHoVL .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-givrWbQMwI7qHoVL .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-givrWbQMwI7qHoVL .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-givrWbQMwI7qHoVL .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-givrWbQMwI7qHoVL .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-givrWbQMwI7qHoVL .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-givrWbQMwI7qHoVL .marker{fill:#333333;stroke:#333333;}#mermaid-svg-givrWbQMwI7qHoVL .marker.cross{stroke:#333333;}#mermaid-svg-givrWbQMwI7qHoVL svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-givrWbQMwI7qHoVL p{margin:0;}#mermaid-svg-givrWbQMwI7qHoVL .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-givrWbQMwI7qHoVL .cluster-label text{fill:#333;}#mermaid-svg-givrWbQMwI7qHoVL .cluster-label span{color:#333;}#mermaid-svg-givrWbQMwI7qHoVL .cluster-label span p{background-color:transparent;}#mermaid-svg-givrWbQMwI7qHoVL .label text,#mermaid-svg-givrWbQMwI7qHoVL span{fill:#333;color:#333;}#mermaid-svg-givrWbQMwI7qHoVL .node rect,#mermaid-svg-givrWbQMwI7qHoVL .node circle,#mermaid-svg-givrWbQMwI7qHoVL .node ellipse,#mermaid-svg-givrWbQMwI7qHoVL .node polygon,#mermaid-svg-givrWbQMwI7qHoVL .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-givrWbQMwI7qHoVL .rough-node .label text,#mermaid-svg-givrWbQMwI7qHoVL .node .label text,#mermaid-svg-givrWbQMwI7qHoVL .image-shape .label,#mermaid-svg-givrWbQMwI7qHoVL .icon-shape .label{text-anchor:middle;}#mermaid-svg-givrWbQMwI7qHoVL .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-givrWbQMwI7qHoVL .rough-node .label,#mermaid-svg-givrWbQMwI7qHoVL .node .label,#mermaid-svg-givrWbQMwI7qHoVL .image-shape .label,#mermaid-svg-givrWbQMwI7qHoVL .icon-shape .label{text-align:center;}#mermaid-svg-givrWbQMwI7qHoVL .node.clickable{cursor:pointer;}#mermaid-svg-givrWbQMwI7qHoVL .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-givrWbQMwI7qHoVL .arrowheadPath{fill:#333333;}#mermaid-svg-givrWbQMwI7qHoVL .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-givrWbQMwI7qHoVL .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-givrWbQMwI7qHoVL .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-givrWbQMwI7qHoVL .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-givrWbQMwI7qHoVL .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-givrWbQMwI7qHoVL .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-givrWbQMwI7qHoVL .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-givrWbQMwI7qHoVL .cluster text{fill:#333;}#mermaid-svg-givrWbQMwI7qHoVL .cluster span{color:#333;}#mermaid-svg-givrWbQMwI7qHoVL div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-givrWbQMwI7qHoVL .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-givrWbQMwI7qHoVL rect.text{fill:none;stroke-width:0;}#mermaid-svg-givrWbQMwI7qHoVL .icon-shape,#mermaid-svg-givrWbQMwI7qHoVL .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-givrWbQMwI7qHoVL .icon-shape p,#mermaid-svg-givrWbQMwI7qHoVL .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-givrWbQMwI7qHoVL .icon-shape .label rect,#mermaid-svg-givrWbQMwI7qHoVL .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-givrWbQMwI7qHoVL .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-givrWbQMwI7qHoVL .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-givrWbQMwI7qHoVL :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} gst_element_set_bus
gst_element_set_clock
gst_element_set_basetime
gst_element_set_starttime
gst_bin_add 调用bclass->add_element
设置GObject类型的bin为GObject类型的elementd的parent父对象
g_list_prepend将element加入bin的Glist类型的child成员上
设置bin的child_bus为element的bus
设置bin的clock为element的clock
设置bin的basetime为element的basetime
设置bin的startime为element的startime
gst_element_set_state
gst_element_set_state 设置state的过程中会调用gst_element_change_state
在设置state的过程中只能按照顺序NULL->READY->PUASE->PLAYING->PUSED->READY->NULL的
顺序进行状态转换
GstStateChangeReturn gst_element_change_state (GstElement * element,
GstStateChange transition)
{
GstElementClass *oclass;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
oclass = GST_ELEMENT_GET_CLASS (element);
......
/* call the state change function so it can set the state */
//调用element的change_state函数
if (oclass->change_state)
ret = (oclass->change_state) (element, transition);
}
g_main_loop_run
g_main_loop_run是整个过程中的核心函数
void g_main_loop_run (GMainLoop *loop)
{
GThread *self = G_THREAD_SELF;
g_return_if_fail (loop != NULL);
g_return_if_fail (g_atomic_int_get (&loop->ref_count) > 0);
/* Hold a reference in case the loop is unreffed from a callback function */
g_atomic_int_inc (&loop->ref_count);
LOCK_CONTEXT (loop->context);
if (!g_main_context_acquire_unlocked (loop->context))
{
gboolean got_ownership = FALSE;
/* Another thread owns this context */
g_atomic_int_set (&loop->is_running, TRUE);
while (g_atomic_int_get (&loop->is_running) && !got_ownership)
got_ownership = g_main_context_wait_internal (loop->context,
&loop->context->cond,
&loop->context->mutex);
if (!g_atomic_int_get (&loop->is_running))
{
if (got_ownership)
g_main_context_release_unlocked (loop->context);
UNLOCK_CONTEXT (loop->context);
g_main_loop_unref (loop);
return;
}
g_assert (got_ownership);
}
if G_UNLIKELY (loop->context->in_check_or_prepare)
{
g_warning ("g_main_loop_run(): called recursively from within a source's "
"check() or prepare() member, iteration not possible.");
g_main_context_release_unlocked (loop->context);
UNLOCK_CONTEXT (loop->context);
g_main_loop_unref (loop);
return;
}
g_atomic_int_set (&loop->is_running, TRUE);
while (g_atomic_int_get (&loop->is_running))
g_main_context_iterate_unlocked (loop->context, TRUE, TRUE, self);
g_main_context_release_unlocked (loop->context);
UNLOCK_CONTEXT (loop->context);
g_main_loop_unref (loop);
}
g_main_loop_run 的调用
#mermaid-svg-fgwBo1cfd4LN4QxO{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-fgwBo1cfd4LN4QxO .error-icon{fill:#552222;}#mermaid-svg-fgwBo1cfd4LN4QxO .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-fgwBo1cfd4LN4QxO .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-fgwBo1cfd4LN4QxO .marker{fill:#333333;stroke:#333333;}#mermaid-svg-fgwBo1cfd4LN4QxO .marker.cross{stroke:#333333;}#mermaid-svg-fgwBo1cfd4LN4QxO svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-fgwBo1cfd4LN4QxO p{margin:0;}#mermaid-svg-fgwBo1cfd4LN4QxO .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster-label text{fill:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster-label span{color:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster-label span p{background-color:transparent;}#mermaid-svg-fgwBo1cfd4LN4QxO .label text,#mermaid-svg-fgwBo1cfd4LN4QxO span{fill:#333;color:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO .node rect,#mermaid-svg-fgwBo1cfd4LN4QxO .node circle,#mermaid-svg-fgwBo1cfd4LN4QxO .node ellipse,#mermaid-svg-fgwBo1cfd4LN4QxO .node polygon,#mermaid-svg-fgwBo1cfd4LN4QxO .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-fgwBo1cfd4LN4QxO .rough-node .label text,#mermaid-svg-fgwBo1cfd4LN4QxO .node .label text,#mermaid-svg-fgwBo1cfd4LN4QxO .image-shape .label,#mermaid-svg-fgwBo1cfd4LN4QxO .icon-shape .label{text-anchor:middle;}#mermaid-svg-fgwBo1cfd4LN4QxO .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-fgwBo1cfd4LN4QxO .rough-node .label,#mermaid-svg-fgwBo1cfd4LN4QxO .node .label,#mermaid-svg-fgwBo1cfd4LN4QxO .image-shape .label,#mermaid-svg-fgwBo1cfd4LN4QxO .icon-shape .label{text-align:center;}#mermaid-svg-fgwBo1cfd4LN4QxO .node.clickable{cursor:pointer;}#mermaid-svg-fgwBo1cfd4LN4QxO .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-fgwBo1cfd4LN4QxO .arrowheadPath{fill:#333333;}#mermaid-svg-fgwBo1cfd4LN4QxO .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-fgwBo1cfd4LN4QxO .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-fgwBo1cfd4LN4QxO .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-fgwBo1cfd4LN4QxO .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-fgwBo1cfd4LN4QxO .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-fgwBo1cfd4LN4QxO .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster text{fill:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO .cluster span{color:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-fgwBo1cfd4LN4QxO .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-fgwBo1cfd4LN4QxO rect.text{fill:none;stroke-width:0;}#mermaid-svg-fgwBo1cfd4LN4QxO .icon-shape,#mermaid-svg-fgwBo1cfd4LN4QxO .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-fgwBo1cfd4LN4QxO .icon-shape p,#mermaid-svg-fgwBo1cfd4LN4QxO .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-fgwBo1cfd4LN4QxO .icon-shape .label rect,#mermaid-svg-fgwBo1cfd4LN4QxO .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-fgwBo1cfd4LN4QxO .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-fgwBo1cfd4LN4QxO .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-fgwBo1cfd4LN4QxO :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} g_main_loop_run
g_main_context_acquire_unlocked
GMainContext的成员owner_count++
g_main_context_iterate_unlocked
g_main_context_release_unlocked
GMainContext的成员owner_count--
g_main_context_iterate_unlocked 的调用
#mermaid-svg-6L99RH6ZxlYfeH5d{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-6L99RH6ZxlYfeH5d .error-icon{fill:#552222;}#mermaid-svg-6L99RH6ZxlYfeH5d .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-6L99RH6ZxlYfeH5d .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-6L99RH6ZxlYfeH5d .marker{fill:#333333;stroke:#333333;}#mermaid-svg-6L99RH6ZxlYfeH5d .marker.cross{stroke:#333333;}#mermaid-svg-6L99RH6ZxlYfeH5d svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-6L99RH6ZxlYfeH5d p{margin:0;}#mermaid-svg-6L99RH6ZxlYfeH5d .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster-label text{fill:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster-label span{color:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster-label span p{background-color:transparent;}#mermaid-svg-6L99RH6ZxlYfeH5d .label text,#mermaid-svg-6L99RH6ZxlYfeH5d span{fill:#333;color:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d .node rect,#mermaid-svg-6L99RH6ZxlYfeH5d .node circle,#mermaid-svg-6L99RH6ZxlYfeH5d .node ellipse,#mermaid-svg-6L99RH6ZxlYfeH5d .node polygon,#mermaid-svg-6L99RH6ZxlYfeH5d .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-6L99RH6ZxlYfeH5d .rough-node .label text,#mermaid-svg-6L99RH6ZxlYfeH5d .node .label text,#mermaid-svg-6L99RH6ZxlYfeH5d .image-shape .label,#mermaid-svg-6L99RH6ZxlYfeH5d .icon-shape .label{text-anchor:middle;}#mermaid-svg-6L99RH6ZxlYfeH5d .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-6L99RH6ZxlYfeH5d .rough-node .label,#mermaid-svg-6L99RH6ZxlYfeH5d .node .label,#mermaid-svg-6L99RH6ZxlYfeH5d .image-shape .label,#mermaid-svg-6L99RH6ZxlYfeH5d .icon-shape .label{text-align:center;}#mermaid-svg-6L99RH6ZxlYfeH5d .node.clickable{cursor:pointer;}#mermaid-svg-6L99RH6ZxlYfeH5d .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-6L99RH6ZxlYfeH5d .arrowheadPath{fill:#333333;}#mermaid-svg-6L99RH6ZxlYfeH5d .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-6L99RH6ZxlYfeH5d .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-6L99RH6ZxlYfeH5d .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6L99RH6ZxlYfeH5d .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-6L99RH6ZxlYfeH5d .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6L99RH6ZxlYfeH5d .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster text{fill:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d .cluster span{color:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-6L99RH6ZxlYfeH5d .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-6L99RH6ZxlYfeH5d rect.text{fill:none;stroke-width:0;}#mermaid-svg-6L99RH6ZxlYfeH5d .icon-shape,#mermaid-svg-6L99RH6ZxlYfeH5d .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6L99RH6ZxlYfeH5d .icon-shape p,#mermaid-svg-6L99RH6ZxlYfeH5d .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-6L99RH6ZxlYfeH5d .icon-shape .label rect,#mermaid-svg-6L99RH6ZxlYfeH5d .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6L99RH6ZxlYfeH5d .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-6L99RH6ZxlYfeH5d .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-6L99RH6ZxlYfeH5d :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} g_main_context_iterate_unlocked
g_main_context_wait_internal
g_slist_append或者g_slist_remove waiter
g_main_context_poll_unlocked
调用context的poll_fun函数
g_main_context_check_unlocked
g_wakeup_acknowledge
Source成员的source_funcs->check函数
g_main_context_dispatch_unlocked
g_main_dispatch分发子element的消息
g_object_set
g_object_set 函数主要是设置elment的相关属性。
g_object_set (gpointer _object,
const gchar *first_property_name,
...)
{
GObject *object = _object;
va_list var_args;
g_return_if_fail (G_IS_OBJECT (object));
va_start (var_args, first_property_name);
g_object_set_valist (object, first_property_name, var_args);
va_end (var_args);
}
#mermaid-svg-L7TzKg3TWWJJK8ye{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-L7TzKg3TWWJJK8ye .error-icon{fill:#552222;}#mermaid-svg-L7TzKg3TWWJJK8ye .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-L7TzKg3TWWJJK8ye .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-L7TzKg3TWWJJK8ye .marker{fill:#333333;stroke:#333333;}#mermaid-svg-L7TzKg3TWWJJK8ye .marker.cross{stroke:#333333;}#mermaid-svg-L7TzKg3TWWJJK8ye svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-L7TzKg3TWWJJK8ye p{margin:0;}#mermaid-svg-L7TzKg3TWWJJK8ye .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster-label text{fill:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster-label span{color:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster-label span p{background-color:transparent;}#mermaid-svg-L7TzKg3TWWJJK8ye .label text,#mermaid-svg-L7TzKg3TWWJJK8ye span{fill:#333;color:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye .node rect,#mermaid-svg-L7TzKg3TWWJJK8ye .node circle,#mermaid-svg-L7TzKg3TWWJJK8ye .node ellipse,#mermaid-svg-L7TzKg3TWWJJK8ye .node polygon,#mermaid-svg-L7TzKg3TWWJJK8ye .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-L7TzKg3TWWJJK8ye .rough-node .label text,#mermaid-svg-L7TzKg3TWWJJK8ye .node .label text,#mermaid-svg-L7TzKg3TWWJJK8ye .image-shape .label,#mermaid-svg-L7TzKg3TWWJJK8ye .icon-shape .label{text-anchor:middle;}#mermaid-svg-L7TzKg3TWWJJK8ye .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-L7TzKg3TWWJJK8ye .rough-node .label,#mermaid-svg-L7TzKg3TWWJJK8ye .node .label,#mermaid-svg-L7TzKg3TWWJJK8ye .image-shape .label,#mermaid-svg-L7TzKg3TWWJJK8ye .icon-shape .label{text-align:center;}#mermaid-svg-L7TzKg3TWWJJK8ye .node.clickable{cursor:pointer;}#mermaid-svg-L7TzKg3TWWJJK8ye .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-L7TzKg3TWWJJK8ye .arrowheadPath{fill:#333333;}#mermaid-svg-L7TzKg3TWWJJK8ye .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-L7TzKg3TWWJJK8ye .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-L7TzKg3TWWJJK8ye .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-L7TzKg3TWWJJK8ye .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-L7TzKg3TWWJJK8ye .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-L7TzKg3TWWJJK8ye .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster text{fill:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye .cluster span{color:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-L7TzKg3TWWJJK8ye .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-L7TzKg3TWWJJK8ye rect.text{fill:none;stroke-width:0;}#mermaid-svg-L7TzKg3TWWJJK8ye .icon-shape,#mermaid-svg-L7TzKg3TWWJJK8ye .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-L7TzKg3TWWJJK8ye .icon-shape p,#mermaid-svg-L7TzKg3TWWJJK8ye .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-L7TzKg3TWWJJK8ye .icon-shape .label rect,#mermaid-svg-L7TzKg3TWWJJK8ye .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-L7TzKg3TWWJJK8ye .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-L7TzKg3TWWJJK8ye .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-L7TzKg3TWWJJK8ye :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} find_pspec
g_object_unref
g_object_set_valist
设置GObkect类型的bin为GObkect类型的element的父对象
g_main_context_wait_internal
设置bin的child_bus为element的bus
GObjectClass->set_property
gst_bus_add_watch
gst_bus_add_watch 先调用gst_bus_create_watch创建一个GBusSource,GBusSource是GSource对象的子类,将默认的函数指针到生成的Source上
static guint
gst_bus_add_watch_full_unlocked (GstBus * bus, gint priority,
GstBusFunc func, gpointer user_data, GDestroyNotify notify)
{
GMainContext *ctx;
guint id;
GSource *source;
if (bus->priv->signal_watch) {
GST_ERROR_OBJECT (bus,
"Tried to add new watch while one was already there");
return 0;
}
source = gst_bus_create_watch (bus);
if (!source) {
g_critical ("Creating bus watch failed");
return 0;
}
if (priority != G_PRIORITY_DEFAULT)
g_source_set_priority (source, priority);
g_source_set_callback (source, (GSourceFunc) func, user_data, notify);
ctx = g_main_context_get_thread_default ();
id = g_source_attach (source, ctx);
g_source_unref (source);
if (id) {
bus->priv->signal_watch = source;
}
GST_DEBUG_OBJECT (bus, "New source %p with id %u", source, id);
return id;
}
#mermaid-svg-kAdCD392hYcVebN0{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-kAdCD392hYcVebN0 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-kAdCD392hYcVebN0 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-kAdCD392hYcVebN0 .error-icon{fill:#552222;}#mermaid-svg-kAdCD392hYcVebN0 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-kAdCD392hYcVebN0 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-kAdCD392hYcVebN0 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-kAdCD392hYcVebN0 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-kAdCD392hYcVebN0 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-kAdCD392hYcVebN0 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-kAdCD392hYcVebN0 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-kAdCD392hYcVebN0 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-kAdCD392hYcVebN0 .marker.cross{stroke:#333333;}#mermaid-svg-kAdCD392hYcVebN0 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-kAdCD392hYcVebN0 p{margin:0;}#mermaid-svg-kAdCD392hYcVebN0 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-kAdCD392hYcVebN0 .cluster-label text{fill:#333;}#mermaid-svg-kAdCD392hYcVebN0 .cluster-label span{color:#333;}#mermaid-svg-kAdCD392hYcVebN0 .cluster-label span p{background-color:transparent;}#mermaid-svg-kAdCD392hYcVebN0 .label text,#mermaid-svg-kAdCD392hYcVebN0 span{fill:#333;color:#333;}#mermaid-svg-kAdCD392hYcVebN0 .node rect,#mermaid-svg-kAdCD392hYcVebN0 .node circle,#mermaid-svg-kAdCD392hYcVebN0 .node ellipse,#mermaid-svg-kAdCD392hYcVebN0 .node polygon,#mermaid-svg-kAdCD392hYcVebN0 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-kAdCD392hYcVebN0 .rough-node .label text,#mermaid-svg-kAdCD392hYcVebN0 .node .label text,#mermaid-svg-kAdCD392hYcVebN0 .image-shape .label,#mermaid-svg-kAdCD392hYcVebN0 .icon-shape .label{text-anchor:middle;}#mermaid-svg-kAdCD392hYcVebN0 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-kAdCD392hYcVebN0 .rough-node .label,#mermaid-svg-kAdCD392hYcVebN0 .node .label,#mermaid-svg-kAdCD392hYcVebN0 .image-shape .label,#mermaid-svg-kAdCD392hYcVebN0 .icon-shape .label{text-align:center;}#mermaid-svg-kAdCD392hYcVebN0 .node.clickable{cursor:pointer;}#mermaid-svg-kAdCD392hYcVebN0 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-kAdCD392hYcVebN0 .arrowheadPath{fill:#333333;}#mermaid-svg-kAdCD392hYcVebN0 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-kAdCD392hYcVebN0 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-kAdCD392hYcVebN0 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-kAdCD392hYcVebN0 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-kAdCD392hYcVebN0 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-kAdCD392hYcVebN0 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-kAdCD392hYcVebN0 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-kAdCD392hYcVebN0 .cluster text{fill:#333;}#mermaid-svg-kAdCD392hYcVebN0 .cluster span{color:#333;}#mermaid-svg-kAdCD392hYcVebN0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-kAdCD392hYcVebN0 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-kAdCD392hYcVebN0 rect.text{fill:none;stroke-width:0;}#mermaid-svg-kAdCD392hYcVebN0 .icon-shape,#mermaid-svg-kAdCD392hYcVebN0 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-kAdCD392hYcVebN0 .icon-shape p,#mermaid-svg-kAdCD392hYcVebN0 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-kAdCD392hYcVebN0 .icon-shape .label rect,#mermaid-svg-kAdCD392hYcVebN0 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-kAdCD392hYcVebN0 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-kAdCD392hYcVebN0 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-kAdCD392hYcVebN0 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 1
2
3
4
gst_bus_add_watch_full_unlocked
gst_bus_create_watch创建一个GBusSource对象
g_source_set_priority设置优先级
g_source_set_callback设置回调函数bus_call函数处理消息
g_source_attach到GMainContext的hash table的sources成员上
gst_bus_create_watch
gst_bus_create_watch添加默认的source的函数指针到生成的Source上
static GSourceFuncs gst_bus_source_funcs = {
gst_bus_source_prepare,
gst_bus_source_check,
gst_bus_source_dispatch,
gst_bus_source_finalize
};
GSource * gst_bus_create_watch (GstBus * bus)
{
GstBusSource *source;
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
g_return_val_if_fail (bus->priv->poll != NULL, NULL);
source = (GstBusSource *) g_source_new (&gst_bus_source_funcs,
sizeof (GstBusSource));
g_source_set_name ((GSource *) source, "GStreamer message bus watch");
#if GLIB_CHECK_VERSION(2,63,3)
g_source_set_dispose_function ((GSource *) source, gst_bus_source_dispose);
#endif
source->bus = gst_object_ref (bus);
g_source_add_poll ((GSource *) source, &bus->priv->pollfd);
return (GSource *) source;
}
gst_bus_source_dispatch
gst_bus_source_funcs 函数指针结构体中的gst_bus_source_dispatch会使用注册的回调处理函数处理Message
static gboolean
gst_bus_source_dispatch (GSource * source, GSourceFunc callback,
gpointer user_data)
{
GstBusFunc handler = (GstBusFunc) callback;
GstBusSource *bsource = (GstBusSource *) source;
GstMessage *message;
gboolean keep;
GstBus *bus;
g_return_val_if_fail (bsource != NULL, FALSE);
bus = bsource->bus;
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
message = gst_bus_pop (bus);
/* The message queue might be empty if some other thread or callback set
* the bus to flushing between check/prepare and dispatch */
if (G_UNLIKELY (message == NULL))
return TRUE;
if (!handler)
goto no_handler;
GST_DEBUG_OBJECT (bus, "source %p calling dispatch with %" GST_PTR_FORMAT,
source, message);
//handle函数就是bus_call函数
keep = handler (bus, message, user_data);
gst_message_unref (message);
GST_DEBUG_OBJECT (bus, "source %p handler returns %d", source, keep);
return keep;
no_handler:
{
g_warning ("GstBus watch dispatched without callback\n"
"You must call g_source_set_callback().");
gst_message_unref (message);
return FALSE;
}
}
gst-lauch-1.0应用程序
gst-lauch-1.0就是通过命令行的分析将各个插件加入pipeline中,然后调用gst_element_set_state设置pipeline的状态,当状态到达PLAYING状态时,就使用event_loop阻塞函数,监听message,当有结束的相关message时就停止阻塞并执行gst_element_set_state直到NULL。整个pipeline执行完毕。
#mermaid-svg-6yVWnTEo6jaAnles{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-6yVWnTEo6jaAnles .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-6yVWnTEo6jaAnles .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-6yVWnTEo6jaAnles .error-icon{fill:#552222;}#mermaid-svg-6yVWnTEo6jaAnles .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-6yVWnTEo6jaAnles .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-6yVWnTEo6jaAnles .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-6yVWnTEo6jaAnles .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-6yVWnTEo6jaAnles .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-6yVWnTEo6jaAnles .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-6yVWnTEo6jaAnles .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-6yVWnTEo6jaAnles .marker{fill:#333333;stroke:#333333;}#mermaid-svg-6yVWnTEo6jaAnles .marker.cross{stroke:#333333;}#mermaid-svg-6yVWnTEo6jaAnles svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-6yVWnTEo6jaAnles p{margin:0;}#mermaid-svg-6yVWnTEo6jaAnles .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-6yVWnTEo6jaAnles .cluster-label text{fill:#333;}#mermaid-svg-6yVWnTEo6jaAnles .cluster-label span{color:#333;}#mermaid-svg-6yVWnTEo6jaAnles .cluster-label span p{background-color:transparent;}#mermaid-svg-6yVWnTEo6jaAnles .label text,#mermaid-svg-6yVWnTEo6jaAnles span{fill:#333;color:#333;}#mermaid-svg-6yVWnTEo6jaAnles .node rect,#mermaid-svg-6yVWnTEo6jaAnles .node circle,#mermaid-svg-6yVWnTEo6jaAnles .node ellipse,#mermaid-svg-6yVWnTEo6jaAnles .node polygon,#mermaid-svg-6yVWnTEo6jaAnles .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-6yVWnTEo6jaAnles .rough-node .label text,#mermaid-svg-6yVWnTEo6jaAnles .node .label text,#mermaid-svg-6yVWnTEo6jaAnles .image-shape .label,#mermaid-svg-6yVWnTEo6jaAnles .icon-shape .label{text-anchor:middle;}#mermaid-svg-6yVWnTEo6jaAnles .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-6yVWnTEo6jaAnles .rough-node .label,#mermaid-svg-6yVWnTEo6jaAnles .node .label,#mermaid-svg-6yVWnTEo6jaAnles .image-shape .label,#mermaid-svg-6yVWnTEo6jaAnles .icon-shape .label{text-align:center;}#mermaid-svg-6yVWnTEo6jaAnles .node.clickable{cursor:pointer;}#mermaid-svg-6yVWnTEo6jaAnles .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-6yVWnTEo6jaAnles .arrowheadPath{fill:#333333;}#mermaid-svg-6yVWnTEo6jaAnles .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-6yVWnTEo6jaAnles .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-6yVWnTEo6jaAnles .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6yVWnTEo6jaAnles .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-6yVWnTEo6jaAnles .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6yVWnTEo6jaAnles .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-6yVWnTEo6jaAnles .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-6yVWnTEo6jaAnles .cluster text{fill:#333;}#mermaid-svg-6yVWnTEo6jaAnles .cluster span{color:#333;}#mermaid-svg-6yVWnTEo6jaAnles div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-6yVWnTEo6jaAnles .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-6yVWnTEo6jaAnles rect.text{fill:none;stroke-width:0;}#mermaid-svg-6yVWnTEo6jaAnles .icon-shape,#mermaid-svg-6yVWnTEo6jaAnles .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6yVWnTEo6jaAnles .icon-shape p,#mermaid-svg-6yVWnTEo6jaAnles .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-6yVWnTEo6jaAnles .icon-shape .label rect,#mermaid-svg-6yVWnTEo6jaAnles .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6yVWnTEo6jaAnles .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-6yVWnTEo6jaAnles .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-6yVWnTEo6jaAnles :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 1
2
3
4
5
no err
with err
main函数
gst_parse_launchv创建一个pipeline对象
gst_bin_add加入pipeline中
gst_bus_set_sync_handler设置回调bus_sync_handler给pipeline的bus处理消息
gst_element_set_state到PAUSED状态
event_loop捕捉err
gst_element_set_state到PLAYING状态
gst_element_set_state逐级设置到NULL状态