chromium media onFrameInfoUpdate
2018-03-08 本文已影响43人
imesong
onFrameInfoUpdated 新增JNI接口,主要处理网页滑动时,VideoView 位置和坐标更新,重新刷新应用层Video位置
media_player_bridge.cc
void MediaPlayerBridge::OnFrameInfoUpdated() {
if (!j_media_player_bridge_.is_null()){
JNIEnv* env = base::android::AttachCurrentThread();
CHECK(env);
Java_MediaPlayerBridge_onFrameInfoUpdated(
env, j_media_player_bridge_.obj());
}
}
browser_media_player_manager.cc
browser_mediao_player_manager.cc 中调用 MediaPlayerBridge
void BrowserMediaPlayerManager::UpdateFrameInfo() {
MediaPlayerAndroid* lastPlayer = GetPlayer(last_player_id_);
if(lastPlayer){
MediaPlayerBridge* lastBridge = static_cast<MediaPlayerBridge*>(lastPlayer);
//invoke java to remove previous videoview
if(lastBridge){
lastBridge->OnFrameInfoUpdated();
}
}
}
UpdateFrameInfo() 自己封装,被OnFrameInfoUpdated()调用
void BrowserMediaPlayerManager::OnFrameInfoUpdated() {
//zhangls add copy
UpdateFrameInfo();
//end
if (external_video_surface_container_)
external_video_surface_container_->OnFrameInfoUpdated();
}
external_video_surface_container_ 是一个智能指针,等下分析
media_web_content_observer.cc
BrowserMediaPlayerMamanger.onFrameInfoUpdated()在这里被调用
#if defined(VIDEO_HOLE)
void MediaWebContentsObserver::OnFrameInfoUpdated() {
for (MediaPlayerManagerMap::iterator iter = media_player_managers_.begin();
iter != media_player_managers_.end(); ++iter) {
BrowserMediaPlayerManager* manager = iter->second;
manager->OnFrameInfoUpdated();
}
}
#endif // defined(VIDEO_HOLE)
render_widget_host_view_android.cc
这里有一个很长很重要的方法 OnFrameMetadataUpdated
void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
const cc::CompositorFrameMetadata& frame_metadata) {
//...略去若干
if (overscroll_controller_)
overscroll_controller_->OnFrameMetadataUpdated(frame_metadata);
//...略去若干
/ All offsets and sizes are in CSS pixels.
content_view_core_->UpdateFrameInfo(
frame_metadata.root_scroll_offset,
frame_metadata.page_scale_factor,
gfx::Vector2dF(frame_metadata.min_page_scale_factor,
frame_metadata.max_page_scale_factor),
frame_metadata.root_layer_size,
frame_metadata.scrollable_viewport_size,
frame_metadata.location_bar_offset,
frame_metadata.location_bar_content_translation);
#if defined(VIDEO_HOLE)
if (host_ && host_->IsRenderView()) {
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
RenderViewHost::From(host_));
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(rvhi));
if (web_contents_impl)
web_contents_impl->media_web_contents_observer()->OnFrameInfoUpdated();
}
#endif // defined(VIDEO_HOLE)
}
方法中用到的 overscroll_controller 是一个智能指针,主要实现在overscroll_controller_android.cc中
在方法 InternalSwapCompositorFrame(xxxxx),SynchronousFrameMetadata(xxx),中调用OnFrameMetadataUpdated。至于这两个方法在哪里调用,这个点上就不再跟踪。