惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - fishert

nasm学习ing 嵌入式汇编入门 vs2005下编译asm文件 控制台清屏 - fishert - 博客园 C/C++从文件中读取文件 Fedora 5下安装VMware Tool[转] uCOS-II在ARM上的移植[转] 2008/6/3 ARM7板子的驱动 排序算法比较 调试LINUX驱动的方法 pads 2007的概述 2008/5/20 C++ 调用DLL方法 - fishert - 博客园 2008/5/19 2008/5/17 - fishert 2008/5/16 一些电路上的概念 Cadence orCAD 15.7 使用心得 - fishert
gstreamer 0.10学习笔记
fishert · 2008-07-24 · via 博客园 - fishert

最近要用gstreamer,所以作些笔记.

  GStreamer is an extremely powerful and versatile framework for creating streaming media applications.

///////

  it use GObject,glib,etc.

  • GObject instentiation
  • GObject properties (set/get)
  • GObject casting
  • GObject referecing/dereferencing
  • glib memory management
  • glib signals and callbacks
  • glib main loop

////////////

It's feature contain: plugin. pipeline, source , filter, sink,codec,format,protocal

//////////////

An element is the most important class of objects in GStreamer.

Pads are element’s input and output, where you can connect other elements.

A bin is a container for a collection of elements.

A pipeline is a special subtype of a bin that allows execution of all of its contained child elements.

//////////////

初始化:

gst_init (&argc, &argv);

gst_version (&major, &minor, &micro, &nano);

or 使用GOption初始化

创建Element:

gst_element_factory_make   相当于gst_element_factory_find + gst_element_factory_create

释放Element:

gst_object_unref(GST_OBJECT (element));

获取/设置GstElement/GObject属性

GstElement 继承了GObject,所以可以设置属性

g_object_get (G_OBJECT (element), "name", &name, NULL);

////////////////////////

Element factories are the basic types retrieved from the GStreamer registry, they describe all plugins
and elements that GStreamer can create.

for creating lists of available elements, such as what pipeline editing applications  do.

从Element Factory 中获取信息:

gst_plugin_feature_get_name

gst_element_factory_get_klass  \\所属类别

gst_element_factory_get_description\\详细信息

gst_registry_pool_feature_list\\全部feature list

/////////////////////////

gst_bin_add_many (GST_BIN (pipeline), source, filter, sink, NULL);\\add source ,filter ,sink elements to pipeline first

gst_element_link_many (source, filter, sink, NULL)\\link all

gst_element_link () ,gst_element_link_pads () ...will also link elements.

///////////////

elements state:

GST_STATE_NULL

GST_STATE_READY

GST_STATE_PAUSED

GST_STATE_PLAYING

You can change the state of an element using the function gst_element_set_state (). If you set an
element to another state, GStreamer will internally traverse all intermediate states. So if you set an
element from NULL to PLAYING, GStreamer will internally set the element to READY and PAUSED
in between.
When moved to GST_STATE_PLAYING, pipelines will process data automatically. They do not need to
be iterated in any form. Internally, GStreamer will start threads that take this task on to them. GStreamer
will also take care of switching messages from the pipeline’s thread into the application’s own thread, by
using a GstBus

/////////////////////////////

bin:A bin is a container element.

gst_bin_new ()  or gst_pipeline_new ()  \\create a new bin

gst_bin_add () \\ add element to bin

gst_bin_remove  \\  remove element from bin

gst_bin_get_list  \\  get a elements list of bin

////////////////////////////////

bus:A bus is a simple system that takes care of forwarding messages from the pipeline threads to an
application in its own thread context.

There are two different ways to use a bus:
• Run a GLib/Gtk+ main loop (or iterate the defauly GLib main context yourself regularly) and attach
some kind of watch to the bus. This way the GLib main loop will check the bus for new messages and
notify you whenever there are messages.
Typically you would use gst_bus_add_watch () or gst_bus_add_signal_watch () in this
case.
To use a bus, attach a message handler to the bus of a pipeline using gst_bus_add_watch (). This
handler will be called whenever the pipeline emits a message to the bus. In this handler, check the
signal type (see next section) and do something accordingly. The return value of the handler should be
TRUE to remove the message from the bus.
• Check for messages on the bus yourself. This can be done using gst_bus_peek () and/or
gst_bus_poll ().

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::error", G_CALLBACK (cb_message_error), NULL);
g_signal_connect (bus, "message::eos", G_CALLBACK (cb_message_eos), NULL);

Message types:

Error

End-of-stream

Tags:emitted when metadata was found in the stream.

State-changes

Buffering:emitted during caching of network-streams.

Element messages: these are special messages that are unique to certain elements and usually represent additional features.

Application-specific messages: any information on those can be extracted by getting the message structure (see above) and reading its fields.

////////////////////////////////////////

pad:A pad type is defined by two properties: its direction and its availability.

A pad can have any of three availabilities:always, sometimes and on request.

gst_element_get_request_pad \\  get a request pad

////////////////////

capabilities:

Properties are used to describe extra information for capabilities.

Basic types, this can be pretty much any GType registered with Glib.

Range types are GTypes registered by GStreamer to indicate a range of possible values.

A list value (GST_TYPE_LIST): the property can take any value from a list of basic values given in this list.

An array value (GST_TYPE_ARRAY): the property is an array of values.

Capabilities (short: caps) describe the type of data that is streamed between two pads, or that one pad
(template) supports. This makes them very useful for various purposes:
• Autoplugging: automatically finding elements to link to a pad based on its capabilities. All
autopluggers use this method.
• Compatibility detection: when two pads are linked, GStreamer can verify if the two pads are talking
about the same media type. The process of linking two pads and checking if they are compatible
called “caps negotiation”.
• Metadata: by reading the capabilities from a pad, applications can provide information about the
of media that is being streamed over the pad, which is information about the stream that is currently
being played back.
• Filtering: an application can use capabilities to limit the possible media types that can stream between
two pads to a specific subset of their supported stream types. An application can, for example, use
“filtered caps” to set a specific (fixed or non-fixed) video size that should stream between two pads.
You will see an example of filtered caps later in this manual, in Section 18.2. You can do caps filtering
by inserting a capsfilter element into your pipeline and setting its “caps” property. Caps filters are
placed after converter elements like audioconvert, audioresample, ffmpegcolorspace or videoscale
force those converters to convert data to a specific output format at a certain point in a stream.

gst_caps_get_structure () \\ get a structure of a cap

gst_caps_get_size ()  \\  get number of caps

gst_structure_get_int (str, "width", &width)  \\ get width

gst_structure_get_int (str, "height", &height)  \\ get height

gst_caps_new_simple  \\ create a simple cap

gst_caps_new_full  \\ create more caps

gst_element_link_filtered () it will automatically create a
capsfilter element for you and insert it into your bin or pipeline between the two elements you want
to connect (this is important if you ever want to disconnect those elements).

////////////////////

Ghost pads:A ghost pad is a pad from some element in the bin that can be accessed directly from the bin as well.
Compare it to a symbolic link in UNIX filesystems. Using ghost pads on bins, the bin also has a pad and
can transparently be used as an element in other parts of your code.

/* add ghostpad */
pad = gst_element_get_static_pad (sink, "sink");
gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));

//////////////////////

Buffers:Buffers contain the data that will flow through the pipeline you have created.

A buffer consists, amongst others, of:
• A pointer to a piece of memory.
• The size of the memory.
• A timestamp for the buffer.
• A refcount that indicates how many elements are using this buffer. This refcount will be used to
destroy the buffer when no element has a reference to it.

////////////////////////

Events:Events are control particles that are sent both up- and downstream in a pipeline along with buffers.

GstEvent *event;
event = gst_event_new_seek (GST_SEEK_METHOD_SET |
GST_FORMAT_TIME,
time_ns);
gst_element_send_event (element, event);

//////////////////////