gstreamer应用开发(播放器)之旅
GStreamer开发,主要分为两块:应用开发、插件开发。
插件开发人员,通常是编解码库的作者(做出了编解码库后,希望gstreamer能用起来这个库,因此增加这个适配层)、芯片原厂人员(将自家的hw适配到gstreamer框架下)、其他(对muxer/demux软件库较熟悉的)。
应用开发人员,调通用的标准接口,进行多媒体处理。
本篇是针对app开发者来介绍的。
需求:命令行的管道方式可以播放一个文件,但如果在应用程序中播放,如何做呢?
这个一个基本流程:
0. pipeline生成:gst_pipeline_new(const gchar * name)
是对下条接口的封装:gst_element_factory_make("pipeline", name);
其实,pipeline就是一个element,其直接父类为GstBin,爷爷类为GstElement,太爷类为GstObject,再上面一层是GInitiallyUnowned,再再上面一层为GInitiallyUnowned
1. element生成:gst_element_factory_make(const gchar * factoryname, const gchar * name)
某个element生成流程:先找到某个elemnent factory,再用该工厂生产出某个具体element
step1: factory = gst_element_factory_find(factoryname)
step2: element = gst_element_factory_create(factory, name)
注意:factoryname必须准确,否则找不到工厂,但某个element的名字name可以随意变化(即使为NULL也行),但最好命名符合意义。
pipeline的生成也是直接调这个接口的。
2. 某个factory的寻找:gst_element_factory_find(const gchar* name)
先从注册的插件系统中寻找该feature,再引用该feature
step1: GstPluginFeature *feature = gst_registry_find_feature(gst_registry_get(), name, GST_TYPE_ELEMENT_FACTORY);
step2: GST_ELEMENT_FACTORY(feature); //把GstPluginFeature *转换为GstElementFactory *
3. 拿到pipeline的消息总线(GstBus*):gst_pipeline_get_bus(GST_PIPELINE(pipeline))
gst_pipeline_xx的参数只能针对GstPipeline类型的
先转换为element,再拿element的bus(只有element才有bus)
step1: gst_element_get_bus(GST_ELEMENT_CAST(pipeline));
step2: gst_element_get_bus(GstElement * element); //拿Bus时要对element加锁
4. 注册总线观察者:gst_bus_add_watch(bus, bus_call, loop);
gst_bus_add_watch_full (bus, G_PRIORITY_DEFAULT, func, user_data, NULL);
gst_bus_add_watch_full_unlocked()
step1: GSource *source = get_bus_create_watch(bus)
step2: g_source_set_callback(source, (GSourceFunc)func, user_data, notify);
step3: GMainContext *ctx = g_main_context_get_thread_default();
step4: guint id = g_source_attach(source, ctx);
step5: g_source_unref(source);
5. bin中添加element:gst_bin_add_many(GST_BIN(pipeline), src, decoder, sink, NULL);
依次将各element添加到bin中:
while (element1) {
gst_bin_add(bin, element1);
element_1 = va_arg(args, GstElement*);
}
6. 串联各element:gst_element_link_many(src, decoder, sink, NULL);
与上条类似,依次将各element串联起来(gst_element_link(element_1, element_2))
7. 设置pipeline状态:gst_element_set_state(pipeline, GST_STATE_PLAYING);
先拿到GstElementClass类,再对其进行状态设置
step1: GstElementClass *oclass = GST_ELEMENT_GET_CLASS(element);
step2: oclass->set_state(element, state);
gstreamer应用开发(播放器)之旅的更多相关文章
- Directshow开发播放器相关介绍
原文地址:http://www.cnblogs.com/qiufa/archive/2006/12/19/596949.html DirectShow技术是DirectX推出的建立在DirectDra ...
- 基于GStreamer编写Mp3播放器
一.简介 作者系统为CentOS6,本文在此基础上对Mp3播放器进行开发,需要使用mp3解码库libmad和gstreamer0.10-plugins-ugly,详细步骤如下. 二.操作步骤 1) ...
- phongap开发中安卓平台上如何调用第三方播放器来播放HLS视频
前文曾经讲了关于在安卓平台上利用phonegap开发播放HLS的解决方案,其实最好的方案就是自己针对HLS视频开发自己的播放器,但是开发播放器是一个浩大的工程,必须对原生安卓开发非常熟悉,并且对视频播 ...
- PLDroidPlayer 是七牛推出的一款免费的适用于 Android 平台的播放器 SDK,采用全自研的跨平台播放内核,拥有丰富的功能和优异的性能,可高度定制化和二次开发。 https://developer.qiniu.com/pili/sdk/…
PLDroidPlayer PLDroidPlayer 是一个适用于 Android 平台的音视频播放器 SDK,可高度定制化和二次开发,为 Android 开发者提供了简单.快捷的接口,帮助开发者在 ...
- c#中用DirectShow实现媒体播放器的核心(1) DirectShow简介
用.net做多媒体开发的似乎不多,所以网上资源也少,看的人更少.不过我的博客上居然还有几位在等新文章的人,有点出乎我的意料了.目前我已不再从事多媒体相关的工作,加入新公司至今都忙到吐血,再加上害怕水平 ...
- 仿迅雷播放器教程 -- 基于VLC的C++播放器 (4)
经过前面的介绍,想必大家对VLC和ffmpeg都有一定印象了,还记得学习ffmpeg多么蛋疼吗?那么VLC会不会也这么蛋疼呢? 那么我们来看一段官方的Demo,Alberl精简了Demo,只留 ...
- c#中用DirectShow实现媒体播放器
原文地址:https://www.cnblogs.com/aiqingqing/p/4338448.html 用.net做多媒体开发的似乎不多,所以网上资源也少,看的人更少.不过我的博客上居然还有几位 ...
- github上十二款最著名的Android播放器开源项目
1.ijkplayer 项目地址: https://github.com/Bilibili/ijkplayer 介绍:Ijkplayer 是Bilibili发布的基于 FFplay 的轻量级 Andr ...
- GitHub上最著名的Android播放器开源项目大全
GitHub上最著名的Android播放器开源项目大全 ...
- 基于MFC的Media Player播放器的制作介绍
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 因为这次多媒体课程设计做一个基于MFC的播放器,因为本人实力太菜,需要播放音乐或视频文件时候,自己写不出解码 函数,所以准备使用第三方多媒 ...
随机推荐
- Pycharm无法import caffe
这里是首先建立在读者可以在终端导入而无法在Pycharm中导入的情况下的: 参考链接(问题的最后一个回答) 选用了虚拟环境的python作为解释器, 但由于caffe的特殊性, 依然没有导入, 原因就 ...
- Linux bash script regex auto replace
Linux bash script regex auto replace 自动替换 /assets/css/0.styles.96df394b.css => ./assets/css/0.sty ...
- SVG animation(text, background)
SVG animation(text, background) demo https://www.happyelements.com/ LICEcap bug Giphy 低帧率 gif https: ...
- Win/Mac 键位映射 & 在 Mac 上更改“键盘”偏好设置
Win/Mac 键位映射 & 在 Mac 上更改"键盘"偏好设置 PC键盘 在Mac下Command/Option键切换 https://support.apple.com ...
- CSS Layout All In One
CSS Layout All In One CSS2 position float % px , rem, em CSS3 flex grid multi column vw / vh 常见布局模式 ...
- Typescript All In One
Typescript All In One TypeScript 3.5 is now available. https://www.typescriptlang.org/#download-link ...
- Taro 开发踩坑指南 (小程序,H5, RN)
Taro 开发踩坑指南 (小程序,H5, RN) css taro 如何展示多行文本省略号 https://www.cnblogs.com/xgqfrms/p/12569057.html UI 设计稿 ...
- free Google translator for the personal website
free Google translator for the personal website https://html5.xgqfrms.xyz/
- qt QTimer 计时器
#include <QtCore> #include <QTimer> QTimer *timer; timer = new QTimer(this); connect(tim ...
- 「NGK每日快讯」12.3日NGK公链第30期官方快讯!