本例子工程代码下载地址:http://download.csdn.net/detail/y601500359/9862413
javascript
例子源码在你nacl_sdk安装目录下,好比个人是:E:\SDK\nacl_sdk\pepper_49\examples\api\media_stream_videohtml
一、新建一个名为media_stream_video的Win32项目,类型选DLL;java
二、去掉预编译头文件stdafx.h和stdafx.cpp,去掉dllmain.cpp文件;web
三、在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。chrome
四、删除自动生成的media_stream_video.cpp。api
五、在“配置属性–>C/C++–>代码生成–>运行库”中设置为MT六、将例子下的media_stream_video.cc,复制到刚刚建立的工程目录;app
七、添加media_stream_video.cc到工程ide
八、设置包含的nacl_sdk头文件目录;post
九、将nacl_sdk安装目录下的lib文件copy到咱们的工程:我是在工程目录建了一个lib文件夹
this个人目录是:E:\SDK\nacl_sdk\pepper_49\lib\win_x86_32_host,注意debug文件夹下的对应咱们的debug工程,release对应release,
将lib添加进工程
设置lib路径
十、编译:平台选择x86 或者 PPAPI都行
一、在工程目录新建一个名为:media_stream_video.html的脚本,js脚本以下:
<!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>
二、运行命令:
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设置有问题,由于咱们须要渲染,设置如图:
而后显示结果如图: