PPAPI开发之路(二)在VS 2013上编译media_stream_video例子
2018-01-26 10:02
411 查看
本例子工程代码下载地址:http://download.csdn.net/detail/y601500359/9862413
例子源码在你nacl_sdk安装目录下,比如我的是:E:\SDK\nacl_sdk\pepper_49\examples\api\media_stream_video
1、新建一个名为media_stream_video的Win32项目,类型选DLL;
2、去掉预编译头文件stdafx.h和stdafx.cpp,去掉dllmain.cpp文件;
3、在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。
4、删除自动生成的media_stream_video.cpp。
5、在“配置属性–>C/C++–>代码生成–>运行库”中设置为MT
6、将例子下的media_stream_video.cc,复制到刚刚创建的工程目录;
7、添加media_stream_video.cc到工程
8、设置包含的nacl_sdk头文件目录;
9、将nacl_sdk安装目录下的lib文件copy到我们的工程:我是在工程目录建了一个lib文件夹
我的目录是:E:\SDK\nacl_sdk\pepper_49\lib\win_x86_32_host,注意debug文件夹下的对应我们的debug工程,release对应release,
将lib添加进工程
设置lib路径
10、编译:平台选择x86 或者 PPAPI都行
1、在工程目录新建一个名为:media_stream_video.html的脚本,js脚本如下:
[html] view
plain copy
<!DOCTYPE html>
<html>
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>Media Stream Video Example</title>
<script type="text/javascript">
var plugin;
var stream;
function handleMessage(message) {
console.log(message);
}
function success(s) {
stream = s;
plugin.postMessage({command: 'init', track: stream.getVideoTracks()[0]});
}
function failure(e) {
console.log(e);
}
function initialize() {
plugin = document.getElementById('plugin');
plugin.addEventListener('message', handleMessage, false);
var constraints = {
audio: false,
video: {
mandatory: {
minWidth: 640,
minHeight: 320,
minFrameRate: 30
},
optional: []
}
};
navigator.webkitGetUserMedia(constraints, success, failure);
}
function changeFormat(format) {
plugin.postMessage({command:'format', format: format});
}
function changeSize(width, height) {
plugin.postMessage({command:'size', width: width, height: height});
}
document.addEventListener('DOMContentLoaded', initialize, false);
</script>
</head>
<body>
<h1>Pepper MediaStream Video API Example</h1><br>
This example demonstrates receiving frames from a video MediaStreamTrack and
rendering them in a plugin.<br>
Left side shows YUV frames. Right side shows BGRA frames.
<embed id="plugin" type="application/x-ppapi-example-media-stream-video"
width="640" height="240"/>
<h2>Format:</h2><br>
<button onclick="changeFormat('YV12')" >YV12</button>
<button onclick="changeFormat('I420')" >I420</button>
<button onclick="changeFormat('BGRA')" >BGRA</button>
<button onclick="changeFormat('DEFAULT')" >DEFAULT</button>
<h2>Size:</h2><br>
<button onclick="changeSize(72, 72)" >72 x 72</button>
<button onclick="changeSize(640, 360)" >640 x 360</button>
<button onclick="changeSize(1280, 720)" >1280 x 720</button>
<button onclick="changeSize(0, 0)" >DEFAULT</button>
</body>
</html>
2、运行命令:
[html] view
plain copy
[html] view
plain copy
chrome --register-pepper-plugins="E:\\TestPro\media_stream_video\Debug\media_stream_video.dll#ppexample##1.0.0;application/x-ppapi-example-media-stream-video" file:///E:/TestPro/media_stream_video/media_stream_video.html
为什么插件没有被加载呢,原因是我们的chrome设置有问题,因为我们需要渲染,设置如图:
然后显示结果如图:
版权声明:本文为博主原创文章,未经博主允许不得转载。
本文已收录于以下专栏:
Chrome控件之PPAPI开发
一、源码路径
例子源码在你nacl_sdk安装目录下,比如我的是:E:\SDK\nacl_sdk\pepper_49\examples\api\media_stream_video
二、新建vs项目
1、新建一个名为media_stream_video的Win32项目,类型选DLL;2、去掉预编译头文件stdafx.h和stdafx.cpp,去掉dllmain.cpp文件;
3、在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。
4、删除自动生成的media_stream_video.cpp。
5、在“配置属性–>C/C++–>代码生成–>运行库”中设置为MT
6、将例子下的media_stream_video.cc,复制到刚刚创建的工程目录;
7、添加media_stream_video.cc到工程
8、设置包含的nacl_sdk头文件目录;
9、将nacl_sdk安装目录下的lib文件copy到我们的工程:我是在工程目录建了一个lib文件夹
我的目录是:E:\SDK\nacl_sdk\pepper_49\lib\win_x86_32_host,注意debug文件夹下的对应我们的debug工程,release对应release,
将lib添加进工程
设置lib路径
10、编译:平台选择x86 或者 PPAPI都行
三、本地调试PPAPI插件
1、在工程目录新建一个名为:media_stream_video.html的脚本,js脚本如下:[html] view
plain copy
<!DOCTYPE html>
<html>
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>Media Stream Video Example</title>
<script type="text/javascript">
var plugin;
var stream;
function handleMessage(message) {
console.log(message);
}
function success(s) {
stream = s;
plugin.postMessage({command: 'init', track: stream.getVideoTracks()[0]});
}
function failure(e) {
console.log(e);
}
function initialize() {
plugin = document.getElementById('plugin');
plugin.addEventListener('message', handleMessage, false);
var constraints = {
audio: false,
video: {
mandatory: {
minWidth: 640,
minHeight: 320,
minFrameRate: 30
},
optional: []
}
};
navigator.webkitGetUserMedia(constraints, success, failure);
}
function changeFormat(format) {
plugin.postMessage({command:'format', format: format});
}
function changeSize(width, height) {
plugin.postMessage({command:'size', width: width, height: height});
}
document.addEventListener('DOMContentLoaded', initialize, false);
</script>
</head>
<body>
<h1>Pepper MediaStream Video API Example</h1><br>
This example demonstrates receiving frames from a video MediaStreamTrack and
rendering them in a plugin.<br>
Left side shows YUV frames. Right side shows BGRA frames.
<embed id="plugin" type="application/x-ppapi-example-media-stream-video"
width="640" height="240"/>
<h2>Format:</h2><br>
<button onclick="changeFormat('YV12')" >YV12</button>
<button onclick="changeFormat('I420')" >I420</button>
<button onclick="changeFormat('BGRA')" >BGRA</button>
<button onclick="changeFormat('DEFAULT')" >DEFAULT</button>
<h2>Size:</h2><br>
<button onclick="changeSize(72, 72)" >72 x 72</button>
<button onclick="changeSize(640, 360)" >640 x 360</button>
<button onclick="changeSize(1280, 720)" >1280 x 720</button>
<button onclick="changeSize(0, 0)" >DEFAULT</button>
</body>
</html>
2、运行命令:
[html] view
plain copy
[html] view
plain copy
chrome --register-pepper-plugins="E:\\TestPro\media_stream_video\Debug\media_stream_video.dll#ppexample##1.0.0;application/x-ppapi-example-media-stream-video" file:///E:/TestPro/media_stream_video/media_stream_video.html
为什么插件没有被加载呢,原因是我们的chrome设置有问题,因为我们需要渲染,设置如图:
然后显示结果如图:
版权声明:本文为博主原创文章,未经博主允许不得转载。
本文已收录于以下专栏:
Chrome控件之PPAPI开发
相关文章推荐
- PPAPI开发之路(二)在VS 2013上编译media_stream_video例子
- PPAPI开发之路(三)通过本地服务发布例子:media_stream_video的PPAPI
- VS2013下编译osip和exosip的5.0版本静态库及搭建和简单例子的实现
- 编译PPAPI的media_stream_video示例
- PPAPI开发之路(三)通过本地服务发布例子:media_stream_video的PPAPI
- 在VS2013编译FFmpeg遇到的问题
- VS2013编译运行常见错误及解决方法
- VS2013编译Poco X64
- vs2013 v8编译
- vs2013 boost库编译小结
- 【FFMEPG】windows下编译ffmpeg2.5——使用VS2013,ARMLINUX,ANDORID编译ffmpeg
- net-snmp源码VS2013编译添加加密支持(OpenSSL)
- c++操作mongodb Windows 下 mongo-c-driver vs2013编译 附使用实例
- vim7.4官方源码在vs2013的编译方法及问题总结 (2013-11-04 12:06:52)
- VS2013 编译程序时提示 无法查找或打开 PDB 文件
- VS2013 加快编译速度 的方法整理
- vs2013无法编译多字节程序解决
- Win7 VS2013编译cvBlob
- VC++6.0 VS2005 VS2008 VS2010 VS2012 VS2013 编译 连接时候到底调用了那些东东
- vs2013中能编译通过,但是会有红色波浪线错误