Chinaunix首页 | 论坛 | 博客
  • 博客访问: 501297
  • 博文数量: 174
  • 博客积分: 8001
  • 博客等级: 中将
  • 技术积分: 1840
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-04 19:30
文章分类

全部博文(174)

文章存档

2011年(1)

2010年(24)

2009年(149)

我的朋友

分类: LINUX

2009-05-03 20:05:33

Gstreamer--想不到还有这种东西。据说是写流媒体应用程序的框架。
理解以下的图:



Specifically, GStreamer provides
• an API for multimedia applications
• a plugin architecture
• a pipeline architecture
• a mechanism for media type handling/negotiation
• over 150 plug-ins
• a set of tools

GStreamer provides a clean interface to:
• The application programmer who wants to build a media pipeline. The programmer can use an extensive set of powerful tools to create media pipelines without writing a single line of code. Performing complex media manipulations becomes very easy.
• The plugin programmer. Plugin programmers are provided a clean and simple API to create self-contained plugins. An extensive debugging and tracing mechanism has been integrated. GStreamer also comes with an extensive set of real-life plugins that serve as examples too.

self-contained是指这个插件是不依赖于任何其他插件的?no dependency on...个人理解。

也就是说:
GStreamer提供了这样的接口给:
*创建媒体流水线的应用程序程序员,他们可以使用扩展的强大工具创建媒体流水线而不用写一行代码。复杂的媒体应用也会变得十分简单。
*插件程序员。提供简洁(clean and simple)的API以创建独立的插件。并且有扩展的调试和跟踪机制。
另外还提供了实用的插件可作参考。

下面是使我迷惑的一点:
Object oriented
GStreamer adheres to GObject, the GLib 2.0 object model. A programmer familiar with GLib 2.0 or GTK+ will be comfortable with GStreamer.
GStreamer uses the mechanism of signals and object properties.
All objects can be queried at runtime for their various properties and capabilities.
GStreamer intends to be similar in programming methodology to GTK+. This applies to the object model, ownership of objects, reference counting, etc.
GLib是一个C库,但是它试图成为对象导向的,它定义了一些跨平台的机制,它的GObject部分定义了类似对象的结构特征还有对象之间的消息传递机制,它还像STL一样提供了常用的数据结构。它是GTK+和GNome工程
的基础。
PS:
说起来,Linxu的图形化界面,主流的来说就是:KDE和GNOME,而KDE是基于QT,GNOME是基于GTK+。
QT貌似要流行,尤其是在嵌入式领域。而且是基于C++。如果说GTK+是用C模拟C++的对象导向,但是这样语法是否会晦涩呢?或者说,学习的代价是否太大呢?
所以还是:QT。

Foundations
基础概念
1.Elements:元素
An element is the most important class of objects in GStreamer. You will usually create a chain of elements linked together and let data flow through this chain of elements. An element has one specific
function, which can be the reading of data from a file, decoding of this data or outputting this data to your sound card (or anything else). By chaining together several such elements, you create a pipeline that
can do a specific task, for example media playback or capture. GStreamer ships with a large collection of elements by default, making the development of a large variety of media applications possible. If needed, you can also write new elements. That topic is explained in great deal in the GStreamer Plugin Writer’s Guide.
你经常是创建元素的链以处理数据流,一个元素有特定的功能:输入,解码,输出等。同故宫创建这样的流水线来进行多媒体应用。
2.Pads:焊盘
(就好像电路元件两端的圆形)
Pads are element’s input and output, where you can connect other elements. They used to negotiate links and data flow between elements in GStreamer. A pad can be viewed as a “plug” or “port” on an element
where links may be made with other elements, and through which data can flow to or from those elements. Pads have specific data handling capabilities: A pad can restrict the type of data that flows
through it. Links are only allowed between two pads when the allowed data types of the two pads are compatible. Data types are negotiated between pads using a process called caps negotiation. Data types
are described as a GstCaps.
An analogy may be helpful here. A pad is similar to a plug or jack on a physical device. Consider, for example, a home theater system consisting of an amplifier, a DVD player, and a (silent) video projector.
Linking the DVD player to the amplifier is allowed because both devices have audio jacks, and linking the projector to the DVD player is allowed because both devices have compatible video jacks. Links
between the projector and the amplifier may not be made because the projector and amplifier have different types of jacks. Pads in GStreamer serve the same purpose as the jacks in the home theater system.
Pads就像是元素上的接口,它们约束了可以通过的数据类型。通过caps negotiation机制,pads之间被定义是否兼容。就好像不同的设备的接口,扩音器只能接在音频接口上,而不能接在视频接口。
For the most part, all data in GStreamer flows one way through a link between elements. Data flows out of one element through one or more source pads, and elements accept incoming data through one or
more sink pads. Source and sink elements have only source and sink pads, respectively. Data usually means buffers(described by the GstBuffer
()object) and events (described by the GstEvent()object).
数据经常从SRC pad流出一个元素,而从SINK pad流进一个元素。而SRC 元素只有SRC pad, SINK 元素只有SINK pad。数据总是意味着缓冲区对象或者事件对象。
Bins and pipelines:容器和流水线
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. Since bins are subclasses of elements themselves, you
can mostly control a bin as if it were an element, thereby abstracting away a lot of complexity for your application. You can, for example change state on all elements in a bin by changing the state of that bin
itself. Bins also forward bus messages from their contained children (such as error messages, tag messages or EOS messages).
A pipeline is a top-level bin. As you set it to PAUSED or PLAYING state, data flow will start and media processing will take place. Once started, pipelines will run in a separate thread until you stop them or the
end of the data stream is reached.
容器是元素的集合,流水线是一种特殊的容器,它允许对所有的元素的操作。你可以把容器当作一个元素以降低设计复杂度,并且容器内定义了消息机制。
流水线式最高级的容器,你可以让它暂停和运行以控制数据流。流水线会在一个单独的线程运行。



上图解释了一个ogg格式文件的播放应用。
总结:
在大多数的Gstreamer应用中,你经常是创建一个流水线,这个流水线式定义了某种操作(播放,捕捉等)的容器,它由通过pads连接(SRC->SINK)的元素构成,而每种元素会执行一种操作(解复用,解码等)。
至于插件和工具是如何被应用在创建流水线的过程的?
待续。
阅读(1517) | 评论(0) | 转发(0) |
0

上一篇:编译Busybox

下一篇:Linux下安装文件的机制

给主人留下些什么吧!~~