您的位置:首页 > 其它

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对象即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: