博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WebKit之MediaPlayer之底层调度的源码分析
阅读量:4025 次
发布时间:2019-05-24

本文共 3157 字,大约阅读时间需要 10 分钟。

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对象即可

转载地址:http://ccvbi.baihongyu.com/

你可能感兴趣的文章
Spring事务的七种传播行为
查看>>
ES写入找不到主节点问题排查
查看>>
Java8 HashMap集合解析
查看>>
ArrayList集合解析
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Android计算器实现源码分析
查看>>
Android系统构架
查看>>
Android 跨应用程序访问窗口知识点总结
查看>>
各种排序算法的分析及java实现
查看>>
SSH框架总结(框架分析+环境搭建+实例源码下载)
查看>>
js弹窗插件
查看>>
自定义 select 下拉框 多选插件
查看>>
js判断数组内是否有重复值
查看>>
js获取url链接携带的参数值
查看>>
gdb 调试core dump
查看>>
gdb debug tips
查看>>
arm linux 生成火焰图
查看>>
jtag dump内存数据
查看>>
linux和windows内存布局验证
查看>>
linux config
查看>>