WPEWebkit调试MSE播放
下载mse-demo
git clone https://github.com/bitmovin/mse-demo
cog启动
cog运行,每次都要配置编译时用的环境变量
export PATH=$PATH:/home/hui/disk4t/codes/wpe/source/inst/binexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib:/home/hui/disk4t/codes/wpe/source/inst/lib/x86_64-linux-gnuexport PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib/pkgconfig:/home/hui/disk4t/codes/wpe/source/inst/lib/x86_64-linux-gnu/pkgconfig
cog --platform=x11 file:///home/hui/webkit-debug/mse-demo/index.html
在Tools/TestWebKitAPI/Tests/WebKit/file-with-mse.html
文件中,也是mse的测试代码,可以参考修改下上面的这个html,增加一个button以方便attach到WPEWebprocess进程进行调试。
diff --git a/index.html b/index.html
index 58aa0e5..b22f048 100644
--- a/index.html
+++ b/index.html
@@ -6,12 +6,12 @@</head><body><h1>MSE Demo</h1>
- <div>
- <video controls width="80%"></video>
- </div>
-
+ <div>
+ <video id="player" controls width="80%" ></video>
+ </div>
+ <button οnclick="playVideo()">play video</button><script type="text/javascript">
- (function() {
+ function playVideo() {var baseUrl = 'https://bitdash-a.akamaihd.net/content/MI201109210084_1/video/720_2400000/dash/';var initUrl = baseUrl + 'init.mp4';var templateUrl = baseUrl + 'segment_$Number$.m4s';
@@ -68,7 +68,7 @@xhr.send();}
- })();
+ };</script></body>
-</html>
+</html>
<script>var v = document.getElementById("player");v.onclick = function() {if (v.playing) {v.play();} else {v.pause();}};</script>
通过增加js代码,直接利用video标签的play按钮的代码不起作用,还需要研究下。
获取journal输出
journalctl -ef | grep -E "WPEWebProcess|WPENetworkProcess"
security origin
运行cog时,发现cog起来后页面加载不出来,chrome播放正常,log中有:
was rejected by SecurityOrigin
是被SecurityOrigin这个地方直接return了,为了测试,直接修改这个地方,返回true,编译运行就可以了。
RefPtr<Frame> frame = document().frame();if (!frame || !document().securityOrigin().canDisplay(url)) {if (actionIfInvalid == Complain) {FrameLoader::reportLocalLoadFailed(frame.get(), url.stringCenterEllipsizedToLength());ERROR_LOG(LOGIDENTIFIER, url , " was rejected by SecurityOrigin");}
- return false;
+ return true;}
在做完这些之后,通过qtcreator断点调试就可以了,可以方便的看到mediasource和sourcebuffer的调用栈。
mediasource的创建
MediaSource是在js中通过代码调用才能创建,并不是所有的html5 video都是MSE,所以刚开始接触的时候,用https://www.w3.org/2010/05/video/mediaevents.html
的测试页面,就没有这个过程,很怀疑是不是代码思路看错了。
1 WebCore::MediaSource::MediaSource
2 WebCore::MediaSource::create
3 WebCore::JSDOMConstructor<WebCore::JSMediaSource>::construct
addSourceBuffer
同样,sourcebuffer的创建也是通过js代码的调用才走到底层C++代码的,addSourceBuffer
1 WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer
2 WebCore::SourceBufferPrivateGStreamer::create
3 WebCore::MediaSourcePrivateGStreamer::addSourceBuffer
4 WebCore::MediaSource::createSourceBufferPrivate
5 WebCore::MediaSource::addSourceBuffer
6 WebCore::jsMediaSourcePrototypeFunction_addSourceBufferBody
8 WebCore::jsMediaSourcePrototypeFunction_addSourceBuffer
通过断点设置,可以快速的看到AppendPipeline的创建所做的工作:
1 WebCore::HTMLMediaElement::prepareToPlay
2 WebCore::HTMLMediaElement::updatePlayState
3 WebCore::HTMLMediaElement::setReadyState
4 WebCore::HTMLMediaElement::mediaPlayerReadyStateChanged
5 WebCore::MediaPlayer::readyStateChanged
6 WebCore::MediaPlayerPrivateGStreamerMSE::setReadyState
7 WebCore::MediaSourcePrivateGStreamer::setReadyState
8 WebCore::SourceBufferPrivateGStreamer::setReadyState
9 WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment
10 WebCore::SourceBufferPrivate::didReceiveInitializationSegment
11 WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment
12 WebCore::AppendPipeline::didReceiveInitializationSegment
14 WTF::Detail::CallableWrapper<WebCore::AppendPipeline::AppendPipeline
AppendPipeline在构造函数里面,no-more-pads信号连接的地方,直接通过lambda表达式调用了didReceiveInitializationSegment:
html MSE的全部代码
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>MSE Demo</title>
</head>
<body><h1>MSE Demo</h1><div><video id="player" controls width="80%" ></video></div><button onclick="playVideo()" >play video</button><script type="text/javascript"> function playVideo() {var baseUrl = 'https://bitdash-a.akamaihd.net/content/MI201109210084_1/video/720_2400000/dash/';var initUrl = baseUrl + 'init.mp4';var templateUrl = baseUrl + 'segment_$Number$.m4s';var sourceBuffer;var index = 0;var numberOfChunks = 52;var video = document.querySelector('video');if (!window.MediaSource) {console.error('No Media Source API available');return;}var ms = new MediaSource();video.src = window.URL.createObjectURL(ms);ms.addEventListener('sourceopen', onMediaSourceOpen);function onMediaSourceOpen() {sourceBuffer = ms.addSourceBuffer('video/mp4; codecs="avc1.4d401f"');sourceBuffer.addEventListener('updateend', nextSegment);GET(initUrl, appendToBuffer);video.play();}function nextSegment() {var url = templateUrl.replace('$Number$', index);GET(url, appendToBuffer);index++;if (index > numberOfChunks) {sourceBuffer.removeEventListener('updateend', nextSegment);}}function appendToBuffer(videoChunk) {if (videoChunk) {sourceBuffer.appendBuffer(new Uint8Array(videoChunk));}}function GET(url, callback) {var xhr = new XMLHttpRequest();xhr.open('GET', url);xhr.responseType = 'arraybuffer';xhr.onload = function(e) {if (xhr.status != 200) {console.warn('Unexpected status code ' + xhr.status + ' for ' + url);return false;}callback(xhr.response);};xhr.send();}};</script>
</body>
</html>
WPEWebkit调试MSE播放相关推荐
- 本地MSE播放fragment mp4服务
为了测试浏览器MSE的多媒体框架,搭建一个MSE服务会方便不少,这里记录下fragment mp4服务的搭建过程. 生成fragment mp4 为了方便,使用fragment mp4测试会更方便,所 ...
- Hls.js播放m3u8视频 DPlayer视频播放器(easypan) MSE简介
文章目录 学习链接 hls.js播放m3u8视频 效果 代码 前端代码 安装hls.js App.vue 后台代码 准备文件 mp4文件切片java实现 TsController TsService ...
- ffmpeg提取音频播放器总结
ffmpeg提取音频播放器总结: 一:简介 从编写音频播放器代码到完成播放器编写,测试,整整5天的时间,这时间还不算之前对 ffmpeg熟悉的时间,可以说是历经千辛万苦,终于搞出来了,虽然最终效果 ...
- mplayer - Linux下的电影播放器
概要 mplayer [选项] [ 文件 | URL | 播放列表 | - ] mplayer [全局选项] 文件1 [特定选项] [文件2] [特定选项] mplayer [全局选项] {一组文件和 ...
- MSE H265 支持调查
MSE api 经常用于浏览器视频播放中,一般用来将H264 等编码的视频打包成fmp4,然后喂给video 标签实现流媒体播放.于是猜想既然video 标签能直接支持播放的,MSE 理论上也能进行流 ...
- chrom调试技巧大全,史上最全
Chrome的隐身模式 先来说说隐身模式的启用方法吧 1.键盘快捷:Ctrl + Shift + N. 2.在Windows7下的任务栏处,右击"Chrome"图标,会出一个下拉菜 ...
- HaaS100 云端钉一体智能语音播放器设计
1.方案介绍 本文主要介绍如何基于HaaS100硬件平台搭建"云端钉一体"(阿里云IoT平台 + HaaS100 + 钉钉小程序)的智能语音播放器(以下简称智能语音播放器).该智能 ...
- 大华海康摄像头人家自己是怎么在web上播放视频的
最近处理安防视频,怎么把摄像头视频在web上展示费了很大功夫,当然这一篇不是讲解我是怎么显示的,而是回答当时领导问我的一个问题,人家大华自己是怎么显示的? 我们知道大华海康大部分摄像头只对外提供rts ...
- windows应用程序-音乐播放器【一】
源代码到girhub下载https://github.com/viafcccy/DoublePigMusicPlayer 消息分流器 HANDLE_MSG宏,需要引用<windowsx.h> ...
最新文章
- WCF自我学习之(一)
- 前端学习(592):使用snippets辅助debugging
- 原生Js 两种方法实现页面关键字高亮显示
- IAM(身份验证以及访问控制)
- python解题软件哪个好用_几个好用的Python数据分析工具
- linux多线程加解锁
- 打印机如何共享多台电脑_多台电脑打印机共享的方法
- 《21天学通Java(第7版)》——VC程序员的学习笔记1
- (附源码)springboot电子阅览室app 毕业设计 016514
- 用火箭送快递?淘宝宣布联合蓝箭航天起启动“宝箭”计划
- python递归输出斐波那契数列_艾艾精工涨停
- < span >标签的使用
- 关于平面战机射击游戏的一点小结
- 解决Windows环境下PHP连接MySQL很慢的问题
- 性能优化专题 - JVM 性能优化 - 04 - GC算法与调优
- Direct3D 10系统(二)
- Linux命令之mkdir命令
- 零基础入门推荐系统(新闻推荐)
- 新房装修甲醛超标的危害 专业去除室内甲醛的方法
- 神经网络滤镜安装教程图,ps神经网络滤镜安装包
热门文章
- 教你将文件名称中文转英文
- 滴答顺风车怎么抢90%以上的订单_网约车司机都是什么人?想加入网约车不妨看看过来人怎么说...
- ArcGIS 要素融合工具(dissolve)使用方法
- 企业邮箱如何登录手机邮箱?
- 新型智慧城市整体建设方案(图文)
- extcon学习记录
- 【零基础入门SpringBoot2】—— 核心功能_配置文件与Web开发
- Reprint:C/C++ Volatile关键词深度剖析;
- 解读VO、DTO、BO、PO、DO、DTO
- EXT4文件系统学习(二)dumpe2fs查看ext4文件系统超级块信息数据