gstreamer 插件编写【一】基础知识

一、Buffer and Event,

    当我们需要push数据到硬件sink插件时,可以使用以下方法直接操作硬件memory。来自:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-basics-data.html

Many sink elements have accelerated methods for copying data to hardware, or have direct access to hardware.  It is common        for these elements to be able to create a GstBufferPool or         GstAllocator for their upstream peers.  One such example is ximagesink.  It creates buffers that contain XImages.  Thus, when an upstream peer copies data into the buffer, it is copying directly into the XImage, enabling ximagesink to draw the image directly to the screen instead of having to copy data into an XImage first.

 

二、Gstreamer 媒体类型定义:

   完整的定义在:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-types-definitions.html

Table 16.1. Table of Audio Types

Media Type Description Property Property Type Property Values Property Description
All audio types.            
audio/* All audio types             rate integer greater than 0               The sample rate of the data, in samples (per channel) per second.            
channels integer greater than 0               The number of channels of audio data.            
All raw audio types.            
audio/x-raw               Unstructured and uncompressed raw audio data.             format string               S8 U8 S16LE S16BE U16LE U16BE S24_32LE S24_32BE U24_32LE U24_32BE S32LE S32BE U32LE U32BE              S24LE S24BE U24LE U24BE S20LE S20BE U20LE U20BE S18LE S18BE U18LE U18BE F32LE F32BE F64LE F64BE                           The format of the sample data.

 

三、The chain function(处理来自sink pad的数据)

   参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-chainfn.html

The chain function is the function in which all data processing takes    place. In the case of a simple filter,_chain ()    functions are mostly linear functions - so for each incoming buffer。

 

四、The event function

The event function notifies you of special events that happen in    the datastream (such as caps, end-of-stream, newsegment, tags, etc.).    Events can travel both upstream and downstream, so you can receive them    on sink pads as well as source pads.

  参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-eventfn.html

 

五、The query function

Through the query function, your element will receive queries that it    has to reply to. These are queries like position, duration but also    about the supported formats and scheduling modes your element supports.    Queries can travel both upstream and downstream, so you can receive them    on sink pads as well as source pads.

参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-queryfn.html

 

六、Element 状态:

A state describes whether the element instance is initialized, whether it    is ready to transfer data and whether it is currently handling data. There    are four states defined inGStreamer:  

  • GST_STATE_NULL      

  • GST_STATE_READY      

  • GST_STATE_PAUSED      

  • GST_STATE_PLAYING

 

参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-statemanage-states.html 

 

七、Adding Properties:

The primary and most important way of controlling how an element behaves,    is through GObject properties. GObject properties are defined in the    _class_init () function. The element optionally    implements a_get_property () and a     _set_property () function. These functions will be    notified if an application changes or requests the value of a property,    and can then fill in the value or take action required for that property    to change value internally.

参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-args.html

七、Building a Test Application:构建测试程序测试新建的plugin。

参考:http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-testapp.html

你可能感兴趣的:(多媒体编程)