Chapter 18. Autoplugging-GStreamer Application Development Manual (1.0.6)

Chapter 18. Autoplugging

原文在http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-autoplugging.html

In Chapter 10, you've learned to build a simple media player for Ogg/Vorbis files. By using alternative elements, you are able to build media players for other media types, such as Ogg/Speex, MP3 or even video formats. However, you would rather want to build an application that can automatically detect the media type of a stream and automatically generate the best possible pipeline by looking at all available elements in a system. This process is called autoplugging, andGStreamer contains high-quality autopluggers. If you're looking for an autoplugger, don't read any further and go toChapter 20. This chapter will explain the concept of autoplugging and typefinding. It will explain what systemsGStreamer includes to dynamically detect the type of a media stream, and how to generate a pipeline of decoder elements to playback this media. The same principles can also be used for transcoding. Because of the full dynamicity of this concept, GStreamer can be automatically extended to support new media types without needing any adaptations to its autopluggers.

We will first introduce the concept of Media types as a dynamic and extendible way of identifying media streams. After that, we will introduce the concept of typefinding to find the type of a media stream. Lastly, we will explain how autoplugging and theGStreamer registry can be used to setup a pipeline that will convert media from one mediatype to another, for example for media decoding.

事先知道文件格式,或者是使用playbin2的pipeline来decodec也是可以的。但是有些时候就是无法正确播放一些文件

本文目的是为了study:如何使用gstreamer的功能来实现检测媒体流的相关信息,然后建立对于的管道来解析媒体流,达到高质量播放音视频!非常具有意义。下面开始翻译:

然而我们更需要实现一个应用,这个应用可以自动地检测媒体流类型、可以自动地找到一个在系统查找到的最好的管道。这样的应用处理叫做autoplugger。靠,这里指的就是playbin之类的吗?


首先介绍MIME的概念,它通过一种动态可扩展的方式来识别媒体流。然后介绍类型检测(typefinding)的概念,它可以找到媒体流的类型。最后,介绍如何实现自动加载以及如何使用GStreamer注册中心(registry)建立一条可以将媒体从一种mime类型转换到另一种类型的管道。以下两个网页是介绍MIME的。多用途互联网邮件扩展是描述消息内容类型的因特网标准

http://www.w3school.com.cn/media/media_mimeref.asp

http://zh.wikipedia.org/wiki/MIME

一个加载进系统的元件必须提供其源衬垫和接收衬垫支持的MIME类型。GStreamer通过其注册中心可以知道目前注册的不同的元件,以及他们所期望得到的与他们能够产生的媒体类型。这允许我们创建非常具有扩展性的动态元件。

我们学习过构建一个播放Ogg/Vorbis文件的音乐播放器。让我们了解下管道中各个衬垫所关联(associated)的MIME类型。 下图显示了管道中每个衬垫所处理的MIME类型。

图使用MIME类型的Helloworld管道

现在我们了解了GStreamer如何识别已知的媒体流,接下来我们可以了解到GStreamer 建立管道以及检测媒体类型的方法。

媒体流类型检测

通常当加载一个新的媒体流时,媒体的类型并不明了。这意味着当我们选择一条管道来对媒体流进行解码之前,我们首先需要检测媒体流的类型。GStreamer使用了类型检测(typefinding)来达到此目的。类型检测是构建管道所必经的步骤。首先它会一直读取数据流,在此期间,它会把数据提供给所有的实现了类型检测器(typefinder)的插件。当其中任何一个类型检测器识别出数据流,这个类型检测器元件将会发送一个信号,并开始像一个关卡(passthrough)模块一样工作。如果数据流的类型没有被任何类型检测器识别出来,管道会发送一个错误信息,并终止所有正在处理该数据流的动作。 

一旦类型检测元件找到一个类型,应用程序将会使用该元件作为管道的一部分来解码媒体流。这在下部分将有详细讨论。

如前面提到的那样,GStreamer中的插件实现了类型检测的功能。一个实现了这样功能的插件将会提交一个mime类型,该媒体类型将用到的可选的文件扩展,以及一个类型检测函数。一旦插件中的类型检测函数被调用,插件将检查媒体流中的数据是否匹配特定的模式。这些模式标记了mime类型中所识别的媒体类型。如果类型检测函数被调用,它会返回给类型检测元件,告知哪种媒体类型可以被识别,以及数据流与检测结果的吻合程度。一旦所有内置类型检测函数的插件都执行完类型检测函数,类型检测元件将会告诉应用程序它对数据流格式的判断。

下面的代码解释了如何使用类型检测元件。它将打印出检测到的媒体类型,或者给出不能匹配的媒体类型的信息。下一节将介绍更有用的行为,像插件结合(plugging together)成一条解码管道。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值