A Preliminary Study on gstreamer-code analysis

Source: Internet
Author: User

1. Important macro definitions:

 

The following macros are defined inGstutils. hFile.

 

# Define maid (type, type_as_function, parent_type, parent_type_macro )\

Ststst_boilerplate_full (type, type_as_function, parent_type, parent_type_macro ,\

_ Gst_do_nothing)

 

# Define maid (type, type_as_function, parent_type, parent_type_macro, additional_initializations )\

\

Static voidtype_as_function # _ base_init (gpointer g_class );\

Static voidtype_as_function # _ class_init
(Type ## class * g_class );\

Static voidtype_as_function ##_ Init (type * object ,\

Type ## class * g_class );\

Static parent_type # class * parent_class = NULL;
\

Static void \

Type_as_function # _ class_init_trampoline (gpointer g_class ,\

Gpointer data )\

{\

Parent_class = (parent_type ## class *)\

G_type_class_peek_parent (g_class );\

Type_as_function ##_ class_init (type ## class *) g_class );\

}\

\

Gtype \

Type_as_function # _ get_type (void )\

{\

/* The typedef for gtype may be Gulong orgsize, depending on \

* System and whether the compiler is C ++ ornot. The g_once_init _*\

* Functions always take a gsize * though ...*/\

Static volatile gsize gonce_data = 0 ;\

If (g_once_init_enter (& gonce_data )){\

Gtype _ type ;\

_ Type = maid (parent_type_macro ,\

G_intern_static_string (# type ),\

Sizeof (type # class ),\

Type_as_function # _ base_init ,\

Null,/* base_finalize */\

Type_as_function # _ class_init_trampoline ,\

Null,/* class_finalize */\

Null,/* class_data */\

Sizeof (type ),\

0,/* n_preallocs */\

(Ginstanceinitfunc) type_as_function ##_ init ,\

Null ,\

(Gtypeflags) 0 );\

Additional_initializations (_ type );\

G_once_init_leave (& gonce_data, (gsize) _ type );\

}\

Return (gtype) gonce_data ;\

}

 

2. Take gstudpsrc. C as an example:

 

Ststst_boilerplate_full (gstudpsrc, ststst_udpsrc, stststpushsrc, ststst_type_push_src, _ do_init );

The macro definition is as follows:

 

Ststst_boilerplate_full (gstudpsrc, ststst_udpsrc, stststpushsrc, ststst_type_push_src, _ do_init );

====================================>>>>>>>>>>>>>>>>>>>>> >>>>>>>

# Definegst_boilerplate_full (type, type_as_function, parent_type, parent_type_macro, additional_initializations )\

\

Static void maid (gpointer g_class );

Static void maid (gstudpsrcclass * g_class );

Static void maid (gstudpsrc * object, gstudpsrcclass * g_class );

Static ststpushsrcclass * parent_class = NULL;
\

Static void \

Ststst_udpsrc_class_init_trampoline (gpointer g_class,
\

Gpointer data )\

{\

Parent_class = (maid *)\

G_type_class_peek_parent (g_class );\

Ststst_udpsrc_class_init (gstudpsrcclass *) g_class );\

}\

\

Gtype \

Gst_udpsrc_get_type (void )\

{\

/* The typedef for gtype may be Gulong orgsize, depending on \

* System and whether the compiler is C ++ ornot. The g_once_init _*\

* Functions always take a gsize * though ...*/\

Static volatile gsize gonce_data = 0 ;\

If (g_once_init_enter (& gonce_data )){\

Gtype _ type ;\

_ Type =Ststst_type_register_static_full(Parent_type_macro ,\

G_intern_static_string (# type ),\<--- Input the string "gstudpsrc"

Sizeof (gstudpsrcclass ),\

Gst_udpsrc_base_init ,\

Null,/* base_finalize */\

Ststst_udpsrc_class_init_trampoline ,\

Null,/* class_finalize */\

Null,/* class_data */\

Sizeof (type ),\

0,/* n_preallocs */\

(Ginstanceinitfunc) maid ,\

Null ,\

(Gtypeflags) 0 );\

Additional_initializations (_ type );\

G_once_init_leave (& gonce_data, (gsize) _ type );\

}\

Return (gtype) gonce_data ;\

}

 

You may have noticed the function "maid". The implementation of this function can be found in the gstutils. c file,

The excerpt code is as follows:

--------------------------------------------------------------------------

.................

Gtypeinfo Info;

Info. class_size = class_size;
Info. base_init = base_init;
Info. base_finalize = base_finalize;
Info. class_init = class_init;
Info. class_finalize = class_finalize;
Info. class_data = class_data;
Info. instance_size = instance_size;
Info. n_preallocs = n_preallocs;
Info. instance_init = instance_init;
Info. value_table = value_table;

ReturnG_type_register_static(Parent_type, type_name, & info, flags );

 

--------------------------------------

The registration function of the most famous class in the gobject object system is called. For details, see Introduction to the gobject system.

 

Continue watchingGstudpsrc. cThis file implements the previously registered functions in sequence.

Void stst_udpsrc_base_init (gpointer g_class );

 

It can be seen that the gstreamer code is closely related to the glib library. This is the first analysis today. We have time to continue the analysis.

 

Stick to it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.