Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2094376
  • 博文数量: 288
  • 博客积分: 10594
  • 博客等级: 上将
  • 技术积分: 3469
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-27 19:27
文章分类

全部博文(288)

文章存档

2012年(4)

2011年(30)

2010年(40)

2009年(32)

2008年(71)

2007年(79)

2006年(32)

分类: LINUX

2010-12-21 18:11:16

parser = gst_element_factory_make ("oggdemux", "ogg-parser");
2007-10-06 18:29

这条语句首先检查 oggdemux factory 是否已经在 registery 中注册,然后进一步检查 ogg factory 中是否有 ogg-parser plugin。如果有,就调用 gst_ogg_parse_init 函数:

static void
gst_ogg_parse_init (GstOggParse * ogg)
{
   /* create the sink and source pads */
   ogg->sinkpad =
       gst_pad_new_from_static_template (&ogg_parse_sink_template_factory,
       "sink");
   ogg->srcpad =
       gst_pad_new_from_static_template (&ogg_parse_src_template_factory, "src");

   /* TODO: Are there any events we must handle? */
   /* gst_pad_set_event_function (ogg->sinkpad, gst_ogg_parse_handle_event); */
   gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_parse_chain);

   gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad);
   gst_element_add_pad (GST_ELEMENT (ogg), ogg->srcpad);

   ogg->oggstreams = NULL;
}

ogg-parser 元件的数据结构如下:

struct _GstOggParse
{
   GstElement element;
   GstPad *sinkpad;               /* Sink pad we're reading data from */
   GstPad *srcpad;                /* Source pad we're writing to */
   GSList *oggstreams;            /* list of GstOggStreams for known streams */
   gint64 offset;                 /* Current stream offset */
   gboolean in_headers;           /* Set if we're reading headers for streams */
   gboolean last_page_not_bos;    /* Set if we've seen a non-BOS page */
   ogg_sync_state sync;           /* Ogg page synchronisation */
   GstCaps *caps;                 /* Our src caps */
};

gst_ogg_parse_init 函数对 GstOggParse 数据结构进行了必要的初始化,并把核心函数 gst_ogg_parse_chain 注册到了 sinkpad 中。

在 helloworld 程序中执行 gst_element_set_state (pipeline, GST_STATE_PLAYING); 这条语句之后,ogg-parser 元件对 filesrc 源元件传递过来的数据进行解析。

(传递的过程应该是由 gst_element_link (source, parser); 这条语句完成的,它可能设置了 GstOggParse 数据结构中的 GstPad *sinkpad;   数据项。)

而解析过程是由核心函数 gst_ogg_parse_chain 完成的。

ogg 插件位于 \gst-plugins-base-0.10.14\ext\ogg 目录下。

阅读(2411) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-04-04 11:18:21

学习了,多谢楼主分享哦!也欢迎广大linux爱好者来我的论坛一起讨论arm哦!www.lt-net.cn