2009年2月16日星期一

gst看一下1

1. 目录结构
gstreamer-0.10.21 目录
gst 核心文件,实现gst元件工厂等功能
plugins gstreamer-0.10.21提供的元件
lib 不可被应用调用的元件,但他是某些元件的parent class
pkgconfig install tools 都是make install需要拷贝的东西
po 各种语言的翻译文件
tests 测试gstreamer-0.10.21的元件

gst-plugins-base-0.10.21 目录
gst base提供的元件
gst-libs base提供的元件的parent class,应用不可用的元件
ext 需要额外源码库的元件
sys 系统相关的元件(x11,v4l)这2个window就没有

2.细数元件
看gst有哪些元件就看哪些文件调用了gst_element_register
grep -nr 'gst_element_register' --include=*.c ./

gstreamer的元件统一注册,别的元件基本都是单独注册
static struct _elements_entry _elements[] = {
{"capsfilter", GST_RANK_NONE, gst_capsfilter_get_type},
{"fakesrc", GST_RANK_NONE, gst_fake_src_get_type},
{"fakesink", GST_RANK_NONE, gst_fake_sink_get_type},
#ifdef HAVE_SYS_SOCKET_H
{"fdsrc", GST_RANK_NONE, gst_fd_src_get_type},
{"fdsink", GST_RANK_NONE, gst_fd_sink_get_type},
#endif
{"filesrc", GST_RANK_PRIMARY, gst_file_src_get_type},
{"identity", GST_RANK_NONE, gst_identity_get_type},
{"queue", GST_RANK_NONE, gst_queue_get_type},
{"filesink", GST_RANK_PRIMARY, gst_file_sink_get_type},
{"tee", GST_RANK_NONE, gst_tee_get_type},
{"typefind", GST_RANK_NONE, gst_type_find_element_get_type},
{"multiqueue", GST_RANK_NONE, gst_multi_queue_get_type},
{NULL, 0},
};

3.playbin(只说playbin播放视频的情况)
playbin元件算是整合的元件,内部建立工厂管道,用到很多元件。

3.1元件流程图
filesrc --> (typefind) -->decodebin -->|--> abin (audioconvert-->audioresample-->volume-->osssink)
··························································|--> vbin (identity-->ffmpegcolorspace-->videoscale-->fbdevsink)

3.2代码分析
应用程序建立playbin元件后就调用get_element_set_state将playbin设置为NULL,READY,PAUSED,PLAYING, 在READY-->PAUSED时候(GST_STATE_CHANGE_READY_TO_PAUSED),playbin就把管道建立起来了

gst_play_base_bin_change_state
|----setup_source
|----|----gen_source_element 建立source元件,也就是filesrc
|----|----|----if (play_base_bin->suburi) setup_subtitle 如果playbin的suburi属性被设置了就配置字幕元件
|----|----|----gst_element_make_from_uri
|----|----|----|----get_element_factories_from_uri_protocol根据字符串头uri协议search_by_entry确定工厂类型,比如file://则建立filesrc
|----|----|----gst_element_factory_create根据确定的工厂类型建立元件(filesrc)

|----|----analyse_source分析源是否是raw数据/有动态pad/有输出pad再做相应处理
|----|----|----几种情况都会走到group_commit
|----|----|----|----GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
setup_output_pads 也就是gstplaybin.c的setup_sinks

|----|----|----|----|----有音频需要可视化调用gen_vis_element
|----|----|----|----|----有音频不需要可视化调用gen_audio_element
|----|----|----|----|----有视频调用gen_video_element

|----|----make_decoder
|----|----|----gst_element_factory_make("decodebin", NULL)建立decodebin元件
|----|----gst_element_link (play_base_bin->source, decoder)把filesrc和decodebin链接起来

3.3 playbin目录
目录是gst-plugins-base-0.10.21/gst/playback/
原本看着文件挺多,不过是2套playbin,其中一套是非稳定版本playbin2,所以其实真正要看的文件不多 。
gstplayback.c注册playbin和playbin2
playbin用到的C文件有(主要是playbin, playbasebin, decodebin)
gstplaybin.c
gstplaybasebin.c
gstdecodebin.c
gststreaminfo.c
gststreamselector.c
gstplaymarshal.c

playbin2用到的C文件有(与playbin,playbasebin, decodebin等价的是playbin2,playsink, decodebin2)
gstplaybin2.c
gstplaysink.c
gstdecodebin2.c
及剩下的一些文件,gsturidecodebin.c和gstdecodebin2.c也是非稳定版本

3.4 playbin元件用到的parent class

filesrc的parent_class是basesrc,从下面可以看出来,
GST_BOILERPLATE_FULL (GstFileSrc, gst_file_src, GstBaseSrc, GST_TYPE_BASE_SRC,
_do_init);

当用户调用set_state时对应内部change_state, 会调用该元件的parent class的change_state。basesrc就像是filesrc的基类

osssink的parent_class是audiosink,从下面可以看出来,
osssink_type = g_type_register_static (GST_TYPE_AUDIO_SINK, "GstOssSink", &osssink_info, 0);

osssink只是做跟底层相关的工作,音频的逻辑层还是在audiosink和它的parent audiobasesink里面,他们再调用osssink的函数指针做具体读写声卡的操作

3.5 元件的parent class
因为change_state会分发到管道中的每个元件,元件的change_state里都会调用它parent_class的change_state,所以不免想看看playbin的parent_class
struct _GstPlayBin {
GstPlayBaseBin parent;

struct _GstPlayBaseBin {
GstPipeline pipeline;

playbin-->playbasebin-->pipeline已经到管道了

5 条评论:

匿名 说...

Thаt's where the Aurawave and its index as a TENS annoyance backup, and can be only as negative to us physically.

Feel free to visit my weblog :: (visit)

匿名 说...

Thе applіcation of thiѕ creаm comes with nο side еffects whatsoever.


Μy page - http://www.prnewswire.com/news-releases/trilastin-review-and-latest-coupon-code-savings-released-at-awesomealldaycom-190256601.html

匿名 说...

In that respect, this item does perform or at the extremely least
does not make untrue claims.

Also visit my blog post :: The Flex Belt Review

匿名 说...

In that respect, this item does perform or at the really least does not make untrue claims.


Also visit my site: the flex belt Review

匿名 说...

off white clothing
kyrie shoes
nike off white
kyrie shoes
ggdb outlet
bapesta shoes
alexander mcqueen
supreme hoodie
fear of god essentials hoodie
kevin durant shoes