现在的位置: 首页 > 综合 > 正文

Plugin NPP and MediaPlayer

2014年01月02日 ⁄ 综合 ⁄ 共 2956字 ⁄ 字号 评论关闭
1.NPP是一个结构体,包含两个void的指针
ndata, the pointer of the browser, usually the PluginView, was valued in PluginView::PluginView.
pdata, the pointer of the plugin, was valued by Plugin in NPP_New, maybe a type of "PluginObject" only could be seen in the plugin.
in Browser, we use NPP as a whole.
2. NPP_Window
is the structure holding a void * window, and it's location.
usually save the point in both Browser and Plugin.
3. PluginObject in Plugin
we usually use type "PluginObject" to describe the "Plugin" in Plugin's code.
It should include at least the information below.
NPP
NPP_Window.
NPObject
所以,一个plugin,必不可少的东西包括
"NPNetscapeFuncs" and "PluginObject" mentioned above.
4. m_windowRect = frameView->contentsToWindow(frameRect())
m_pageRect=m_windowRect
5.pluginView.setParent->PluginView.updatePlginWidget
->PluginViewAndroid.setNPWindowIfNeeded
->PluginWidgetAndroid.setWindow
->PluginWidgetAndroid.layoutSurface
6.PluginWidgetAndroid's m_embededView is a java object.

surfaceview绘制方式是在m_embeddedView这个jobject绘制;opengl全屏模式下也是用这个view绘制。

但是opengl绘制方式(非全屏),没有对这个embeddedView赋值,只有一个medialayer那它是怎么绘制的呢?
莫非open每次都能够在最外层绘制?那是如何做的的呢?
7.对于非全屏
pluginView.setParent->PluginView.updatePlginWidget
->PluginViewAndroid.setNPWindowIfNeeded
->PluginWidgetAndroid.setWindow
会调用到sendSizeAndVisibilityEvents
这里面会设置绘制大小,向插件发事件。
8.全屏步骤
a、opengl由于embeddedView默认为null,因此先向插件获取这个View
b、向插件发生一个全屏消息
c、对于非全屏原来有embeddedView,不过要将之前的从webview detach
d、向webcore发送一个消息,SHOW_FULLSCREEN显示全屏。通过PluginFullScreenHolder获取webview的最外层view,将embeddedView给attach上去
9、MediaPlayer
MediaPlay中,唯一重要的类就是MediaTexture
MediaPlayer中方法
a ANativeWindow* MediaLayer::acquireNativeWindowForContent()
b ANativeWindow* MediaLayer::acquireNativeWindowForVideo()
c void MediaLayer::setWindowDimensionsForVideo
d void MediaLayer::releaseNativeWindowForVideo(ANativeWindow* window)
e void MediaLayer::setFramerateCallback
bool MediaLayer::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
最终都是调用了MediaTexture的函数
10、
在MediaTexture中,有如下类
a、TextureWrapper* m_contentTexture;
b、Vector<TextureWrapper*> m_videoTextures;
c Vector<GLuint> m_unusedTextures;
d sp<ANativeWindow> m_newWindow;
e jobject m_weakWebViewRef;就是传入的WebView
传入的WebView jobject有什么用呢?
a 在MediaTexture::initNativeWindowIfNeeded
调用WebView的sendPluginDrawMsg
最后会调入PluginWidgetAndroid的sendSizeAndVisibilityEvents
b在MediaTexture::requestNativeWindowForVideo
调用WebView的postInvalidate
c 传给MediaListener,在其onFrameAvailable中调用
调用WebView的postInvalidate
最后会调用View的invalidate
貌似依然没有解释,绘在哪里的问题。
莫非opengl的绘制,真的每次都是在最顶层,只有给它一个区域就行了?全屏时候,设置embeddedView是避免绘制和WebView绘制冲突,所以用一个view覆盖WebView避免它绘制。然后就完全自己绘制??
11、TextureWrapper
定义里面包含内容如下:
a GLunit
b SurfaceTexture
c ANativeWindow
d MediaListener
其中,的MediaListener最终持有了传入的m_weakWebViewRef。
12、ANativeWindow
定义在system\core\include\system\Window.h中
它在TextureWrapper的默认构造函数中被创建
TextureWrapper* videoTexture = createTexture();
m_newWindow = videoTexture->nativeWindow;
在createTexture中
wrapper->nativeWindow = new android::SurfaceTextureClient(wrapper->surfaceTexture);
这是用一个它的子类对其进行实现和初始化。
除此以外它还有如下初始化方式
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface)
这个函数定义在frameworks\base\native\android的Native_window.cpp中

抱歉!评论已关闭.