Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: ppapi/examples/video_encode/video_encode.html

Issue 859313002: Pepper: Define PPB_VideoEncoder API + Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/examples/video_encode/video_encode.html
diff --git a/ppapi/examples/video_encode/video_encode.html b/ppapi/examples/video_encode/video_encode.html
new file mode 100644
index 0000000000000000000000000000000000000000..8b01ca5992d457476a29aeec260e02944cfa6e57
--- /dev/null
+++ b/ppapi/examples/video_encode/video_encode.html
@@ -0,0 +1,117 @@
+<!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>Video Encoder Example</title>
+ <style type="text/css">
+ #video {
+ position: fixed;
+ }
+ #plugin {
+ position: fixed;
+ }
+ </style>
+ <script type="text/javascript">
+ var plugin;
+ var stream;
+ var video;
+
+ function success(s) {
+ console.log(stream);
+ stream = s;
+ video.src = URL.createObjectURL(stream);
+ video.play();
+
+ plugin.postMessage({
+ command: 'start',
+ track: stream.getVideoTracks()[0]
+ });
+ }
+
+ function failure(e) {
+ console.log("Error: ", e);
+ }
+
+ function startRecord() {
+ console.log("starting record");
+ navigator.webkitGetUserMedia({audio: false, video: true}, success, failure);
+ }
+
+ function stopRecord() {
+ plugin.postMessage({
+ command: "stop"
+ });
+ var video = document.getElementById('video');
+ video.pause();
+ }
+
+ function saveBlob(blob) {
+ var blobUrl = URL.createObjectURL(blob);
+ window.location = blobUrl;
+ }
+
+ function handleMessage(msg) {
+ if (msg.data.name == 'started') {
+ console.log('recording!');
+ } else if (msg.data.name == 'data') {
+ appendData(msg.data.data);
+ } else if (msg.data.name == 'stopped') {
+ console.log('done recording! bytes: ' + dataArray.byteLength);
+ saveBlob(new Blob([dataArray], { type: "application/octet-stream" }));
+ resetData();
+ }
+ }
+
+ function resetData() {
+ window.dataArray = new ArrayBuffer(0);
+ }
+
+ function appendData(data) {
+ var tmp = new Uint8Array(dataArray.byteLength + data.byteLength);
+ tmp.set(new Uint8Array(dataArray), 0 );
+ tmp.set(new Uint8Array(data), dataArray.byteLength);
+ dataArray = tmp.buffer;
+ }
+
+ function initialize() {
+ plugin = document.getElementById('plugin');
+ plugin.addEventListener('message', handleMessage, false);
+
+ video = document.getElementById('video');
+
+ var selectEl = document.getElementById('start');
+ selectEl.addEventListener('click', function (e) {
+ console.log("start clicked");
+ resetData();
+ startRecord();
+ });
+ selectEl = document.getElementById('stop');
+ selectEl.addEventListener('click', function (e) {
+ console.log("stop clicked");
+ stopRecord();
+ });
+ }
+
+ document.addEventListener('DOMContentLoaded', initialize, false);
+ </script>
+</head>
+
+<body>
+ <h1>Video Encoder API Example</h1><br>
+ This example demonstrates receiving frames from a video MediaStreamTrack and
+ encoding them in a plugin.
+ <br>
+ <input type="button" id="start" value="Start Recording"/>
+ <input type="button" id="stop" value="Stop Recording"/>
+ <br>
+ <div>
+ <embed id="plugin" type="application/x-ppapi-example-video-encode"
+ width="640" height="480"/>
+ <video id="video" width="640" height="480"/>
+ </div>
+</body>
+</html>
« no previous file with comments | « ppapi/examples/video_encode/video_encode.cc ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698