WebKit之MediaPlayer之底层调度的源码分析
2015-12-07 22:35
267 查看
bool MediaPlayer::load(const KURL& url, const ContentType& contentType, const String& keySystem);
#url=>lastPath=>extension=>
#String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
#loadWithNextMediaEngine(0); //采用Media引擎加载URL(播放器->引擎)
void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
# 根据内容/编码选择合适引擎 -> 引擎负责创建具体的平台播放器
# 工厂模式负责一个中间管理站的效果
# MediaPlayerFactory * engine = bestMediaEngineForTypeAndCodecs(m_contentMIMEType, m_contentTypeCodecs, m_keySystem, m_url, current);
engine = nextMediaEngine(current); //遍历媒体引擎
# OwnPtr<MediaPlayerPrivateInterface> m_private = engine->constructor(this); //构建一个播放的私有对象
# m_mediaPlayerClient->mediaPlayerEngineUpdated(this);//内核通知客户端事件(MediaPlayerClient* m_mediaPlayerClient;)
# m_private->load(m_url.string());//引擎构建出的对象进行具体的加载动作
## 具体的平台来负责实现统一的接口
class MediaPlayerPrivate : public MediaPlayerPrivateInterface {}
class MediaPlayerPrivateQt : public QAbstractVideoSurface, public MediaPlayerPrivateInterface{}
class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public AuthenticationChallengeClient, public BlackBerry::Platform::IPlatformPlayerListener {}
class MediaPlayerPrivateQuickTimeVisualContext : public MediaPlayerPrivateInterface {}
class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface{}
class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface, public AVFInbandTrackParent{}
struct MediaPlayerFactory {
x1;
x2;
x3;
}
static void addMediaEngine(x1,x2,x3)
{}
由具体的平台和实现层来添加元素,然后具体的使用的时候,也是从工厂内进行使用
上层传递个性化的参数 => 选择一个比较好的底层的实现商进行满足功能
==============工厂==================(明确规定组成、实现的指标)
A厂商投标:负责实现该套标准(根据各自的资源和特色)
B厂商投标:负责实现该套标准(根据自己的环境)
...
...
struct MediaPlayerFactory {
WTF_MAKE_NONCOPYABLE(MediaPlayerFactory); WTF_MAKE_FAST_ALLOCATED;
public:
MediaPlayerFactory(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsTypeAndCodecs,
MediaEngineGetSitesInMediaCache getSitesInMediaCache, MediaEngineClearMediaCache clearMediaCache, MediaEngineClearMediaCacheForSite clearMediaCacheForSite)
: constructor(constructor)
, getSupportedTypes(getSupportedTypes)
, supportsTypeAndCodecs(supportsTypeAndCodecs)
, getSitesInMediaCache(getSitesInMediaCache)
, clearMediaCache(clearMediaCache)
, clearMediaCacheForSite(clearMediaCacheForSite)
{
}
CreateMediaEnginePlayer constructor;
MediaEngineSupportedTypes getSupportedTypes;
MediaEngineSupportsType supportsTypeAndCodecs;
MediaEngineGetSitesInMediaCache getSitesInMediaCache;
MediaEngineClearMediaCache clearMediaCache;
MediaEngineClearMediaCacheForSite clearMediaCacheForSite;
};
//typedef PassOwnPtr<MediaPlayerPrivateInterface> (*CreateMediaEnginePlayer)(MediaPlayer*);
//typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs, const String& keySystem, const KURL& url);
typedef void (*MediaEngineRegistrar)(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType,
MediaEngineGetSitesInMediaCache, MediaEngineClearMediaCache, MediaEngineClearMediaCacheForSite);
>>一层层封装函数指针的效果
>>本来是回调函数,却被使用为注册去啦
CreateMediaEnginePlayer:create()方法 => 直接new对象即可
#url=>lastPath=>extension=>
#String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
#loadWithNextMediaEngine(0); //采用Media引擎加载URL(播放器->引擎)
void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
# 根据内容/编码选择合适引擎 -> 引擎负责创建具体的平台播放器
# 工厂模式负责一个中间管理站的效果
# MediaPlayerFactory * engine = bestMediaEngineForTypeAndCodecs(m_contentMIMEType, m_contentTypeCodecs, m_keySystem, m_url, current);
engine = nextMediaEngine(current); //遍历媒体引擎
# OwnPtr<MediaPlayerPrivateInterface> m_private = engine->constructor(this); //构建一个播放的私有对象
# m_mediaPlayerClient->mediaPlayerEngineUpdated(this);//内核通知客户端事件(MediaPlayerClient* m_mediaPlayerClient;)
# m_private->load(m_url.string());//引擎构建出的对象进行具体的加载动作
## 具体的平台来负责实现统一的接口
class MediaPlayerPrivate : public MediaPlayerPrivateInterface {}
class MediaPlayerPrivateQt : public QAbstractVideoSurface, public MediaPlayerPrivateInterface{}
class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public AuthenticationChallengeClient, public BlackBerry::Platform::IPlatformPlayerListener {}
class MediaPlayerPrivateQuickTimeVisualContext : public MediaPlayerPrivateInterface {}
class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface{}
class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface, public AVFInbandTrackParent{}
struct MediaPlayerFactory {
x1;
x2;
x3;
}
static void addMediaEngine(x1,x2,x3)
{}
由具体的平台和实现层来添加元素,然后具体的使用的时候,也是从工厂内进行使用
上层传递个性化的参数 => 选择一个比较好的底层的实现商进行满足功能
==============工厂==================(明确规定组成、实现的指标)
A厂商投标:负责实现该套标准(根据各自的资源和特色)
B厂商投标:负责实现该套标准(根据自己的环境)
...
...
struct MediaPlayerFactory {
WTF_MAKE_NONCOPYABLE(MediaPlayerFactory); WTF_MAKE_FAST_ALLOCATED;
public:
MediaPlayerFactory(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsTypeAndCodecs,
MediaEngineGetSitesInMediaCache getSitesInMediaCache, MediaEngineClearMediaCache clearMediaCache, MediaEngineClearMediaCacheForSite clearMediaCacheForSite)
: constructor(constructor)
, getSupportedTypes(getSupportedTypes)
, supportsTypeAndCodecs(supportsTypeAndCodecs)
, getSitesInMediaCache(getSitesInMediaCache)
, clearMediaCache(clearMediaCache)
, clearMediaCacheForSite(clearMediaCacheForSite)
{
}
CreateMediaEnginePlayer constructor;
MediaEngineSupportedTypes getSupportedTypes;
MediaEngineSupportsType supportsTypeAndCodecs;
MediaEngineGetSitesInMediaCache getSitesInMediaCache;
MediaEngineClearMediaCache clearMediaCache;
MediaEngineClearMediaCacheForSite clearMediaCacheForSite;
};
//typedef PassOwnPtr<MediaPlayerPrivateInterface> (*CreateMediaEnginePlayer)(MediaPlayer*);
//typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs, const String& keySystem, const KURL& url);
typedef void (*MediaEngineRegistrar)(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType,
MediaEngineGetSitesInMediaCache, MediaEngineClearMediaCache, MediaEngineClearMediaCacheForSite);
>>一层层封装函数指针的效果
>>本来是回调函数,却被使用为注册去啦
CreateMediaEnginePlayer:create()方法 => 直接new对象即可
相关文章推荐
- Oracle Demo库默认用户/密码为什么叫Scott/Tigger?
- 用python 10min手写一个简易的实时内存监控系统
- 计算机视觉和模式识别的code
- Oracle Data Security - Data Masking(数据屏蔽)
- 删除(注意,删除后,后面顶上去,所以id会一直变,所以我们用class来定义,因为id是唯一的)
- 【学神-RHEL7】1-11-重定向和文件查找
- UVaoj The Cat in the Hat 107 (数论&&精度)
- Linux Shell 命令学习二-----------apt-get指令的使用
- 有趣的EditView为空时的抖动效果(用户名和密码)--第三方开源--ClearEditText
- 阿里组织架构调整
- 原生js实现节点拖拽
- Java类加载器
- 对关系数据库的设计理论的简单认识
- is-a、has-a和like-a、组合、聚合和继承 两组概念的区别
- sphinx实时搜索代码
- JavaScript 事件入门知识
- LeetCode147 Insertion Sort List
- LeetCode 171:Excel Sheet Column Number
- 3117 高精度练习之乘法
- 信息安全系统设计基础实验五—20135222胡御风20135215黄伟业