From bf26ed5520f1103dd486fbecce2cbd88f6795640 Mon Sep 17 00:00:00 2001 From: Wang Zhuochun Date: Fri, 20 Sep 2013 19:21:45 +0800 Subject: [PATCH] update to version 0.0.4 --- dist/RecordRTC-together.js | 19 +++++++++++++++++-- dist/RecordRTC-together.min.js | 4 ++-- package.json | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dist/RecordRTC-together.js b/dist/RecordRTC-together.js index 7b225c1..312e802 100644 --- a/dist/RecordRTC-together.js +++ b/dist/RecordRTC-together.js @@ -614,8 +614,7 @@ function StereoAudioRecorder(mediaStream, root) { requestAnimationFrame = win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame, cancelAnimationFrame = win.webkitCancelAnimationFrame || win.mozCancelAnimationFrame, URL = win.URL || win.webkitURL, - MediaStream = win.webkitMediaStream, - AudioContext = win.webkitAudioContext || window.mozAudioContext, + AudioContext = win.AudioContext || win.webkitAudioContext; // defaults defaults = { @@ -652,6 +651,12 @@ function StereoAudioRecorder(mediaStream, root) { this.audioStarted = false; } + // get support information + RecordRTC.support = { + "video": !!navigator.getUserMedia, + "audio": !!AudioContext + }; + RecordRTC.prototype = { constructor: RecordRTC, // get user media @@ -713,6 +718,11 @@ function StereoAudioRecorder(mediaStream, root) { }, // start video record startVideo: function() { + if (!RecordRTC.support.video) { + console.log('record video is not supported'); + return ; + } + console.log('start recording video frames'); // reset video blob @@ -756,6 +766,11 @@ function StereoAudioRecorder(mediaStream, root) { }, // start audio record startAudio: function() { + if (!RecordRTC.support.audio) { + console.log('record audio is not supported'); + return ; + } + console.log('start recording audio frames'); // reset audio blob diff --git a/dist/RecordRTC-together.min.js b/dist/RecordRTC-together.min.js index d7b4a53..6695107 100644 --- a/dist/RecordRTC-together.min.js +++ b/dist/RecordRTC-together.min.js @@ -1,2 +1,2 @@ -/*! RecordRTC-together 22-08-2013 */ -function StereoAudioRecorder(a,b){function c(a,b){for(var c=a.length+b.length,d=new Float32Array(c),e=0,f=0;c>f;)d[f++]=a[e],d[f++]=b[e],e++;return d}function d(a,b){for(var c=new Float32Array(b),d=0,e=a.length,f=0;e>f;f++){var g=a[f];c.set(g,d),d+=g.length}return c}function e(a,b,c){for(var d=c.length,e=0;d>e;e++)a.setUint8(b+e,c.charCodeAt(e))}var f,g,h,i,j,k=[],l=[],m=!1,n=0,o=44100;this.record=function(){m=!0,k.length=l.length=0,n=0},this.stop=function(){m=!1;var a=d(k,n),f=d(l,n),g=c(a,f),h=new ArrayBuffer(44+2*g.length),i=new DataView(h);e(i,0,"RIFF"),i.setUint32(4,44+2*g.length,!0),e(i,8,"WAVE"),e(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,2,!0),i.setUint32(24,o,!0),i.setUint32(28,4*o,!0),i.setUint16(32,4,!0),i.setUint16(34,16,!0),e(i,36,"data"),i.setUint32(40,2*g.length,!0);for(var j=g.length,p=44,q=1,r=0;j>r;r++)i.setInt16(p,g[r]*32767*q,!0),p+=2;var s=new Blob([i],{type:"audio/wav"});b.ondataavailable(s)},i=window.AudioContext||window.webkitAudioContext,j=new i,g=j.createGain(),h=j.createMediaStreamSource(a),h.connect(g);var p=2048;f=j.createJavaScriptNode(p,2,2),f.onaudioprocess=function(a){if(m){var b=a.inputBuffer.getChannelData(0),c=a.inputBuffer.getChannelData(1);k.push(new Float32Array(b)),l.push(new Float32Array(c)),n+=p}},g.connect(f),f.connect(j.destination)}window.Whammy=function(){function a(a,c){for(var d=b(a),e=3e4,g=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:k(d.duration),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:25541},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:d.width,id:176},{data:d.height,id:186}]}]}]}]}],i=0,j=0;im);var n=0,o={id:524531317,data:[{data:j,id:231}].concat(l.map(function(a){var b=h({discardable:0,frame:a.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(n)});return n+=a.duration,{data:b,id:163}}))};g[1].data.push(o),j+=m}return f(g,c)}function b(a){for(var b=a[0].width,c=a[0].height,d=a[0].duration,e=1;e32767)throw"Frame "+(e+1)+" has a weird duration (must be between 0 and 32767)";d+=a[e].duration}return{duration:d,width:b,height:c}}function c(a){for(var b=[];a>0;)b.push(255&a),a>>=8;return new Uint8Array(b.reverse())}function d(a){for(var b=new Uint8Array(a.length),c=0;c127)throw"TrackNumber > 127 not supported";var c=[128|a.trackNum,a.timecode>>8,255&a.timecode,b].map(function(a){return String.fromCharCode(a)}).join("")+a.frame;return c}function i(a){for(var b=a.RIFF[0].WEBP[0],c=b.indexOf("*"),d=0,e=[];4>d;d++)e[d]=b.charCodeAt(c+3+d);var f,g,h,i,j;return j=e[1]<<8|e[0],f=16383&j,g=j>>14,j=e[3]<<8|e[2],h=16383&j,i=j>>14,{width:f,height:h,data:b,riff:a}}function j(a){for(var b=0,c={};bf;)d[f++]=a[e],d[f++]=b[e],e++;return d}function d(a,b){for(var c=new Float32Array(b),d=0,e=a.length,f=0;e>f;f++){var g=a[f];c.set(g,d),d+=g.length}return c}function e(a,b,c){for(var d=c.length,e=0;d>e;e++)a.setUint8(b+e,c.charCodeAt(e))}var f,g,h,i,j,k=[],l=[],m=!1,n=0,o=44100;this.record=function(){m=!0,k.length=l.length=0,n=0},this.stop=function(){m=!1;var a=d(k,n),f=d(l,n),g=c(a,f),h=new ArrayBuffer(44+2*g.length),i=new DataView(h);e(i,0,"RIFF"),i.setUint32(4,44+2*g.length,!0),e(i,8,"WAVE"),e(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,2,!0),i.setUint32(24,o,!0),i.setUint32(28,4*o,!0),i.setUint16(32,4,!0),i.setUint16(34,16,!0),e(i,36,"data"),i.setUint32(40,2*g.length,!0);for(var j=g.length,p=44,q=1,r=0;j>r;r++)i.setInt16(p,g[r]*32767*q,!0),p+=2;var s=new Blob([i],{type:"audio/wav"});b.ondataavailable(s)},i=window.AudioContext||window.webkitAudioContext,j=new i,g=j.createGain(),h=j.createMediaStreamSource(a),h.connect(g);var p=2048;f=j.createJavaScriptNode(p,2,2),f.onaudioprocess=function(a){if(m){var b=a.inputBuffer.getChannelData(0),c=a.inputBuffer.getChannelData(1);k.push(new Float32Array(b)),l.push(new Float32Array(c)),n+=p}},g.connect(f),f.connect(j.destination)}window.Whammy=function(){function a(a,c){for(var d=b(a),e=3e4,g=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:k(d.duration),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:25541},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:d.width,id:176},{data:d.height,id:186}]}]}]}]}],i=0,j=0;im);var n=0,o={id:524531317,data:[{data:j,id:231}].concat(l.map(function(a){var b=h({discardable:0,frame:a.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(n)});return n+=a.duration,{data:b,id:163}}))};g[1].data.push(o),j+=m}return f(g,c)}function b(a){for(var b=a[0].width,c=a[0].height,d=a[0].duration,e=1;e32767)throw"Frame "+(e+1)+" has a weird duration (must be between 0 and 32767)";d+=a[e].duration}return{duration:d,width:b,height:c}}function c(a){for(var b=[];a>0;)b.push(255&a),a>>=8;return new Uint8Array(b.reverse())}function d(a){for(var b=new Uint8Array(a.length),c=0;c127)throw"TrackNumber > 127 not supported";var c=[128|a.trackNum,a.timecode>>8,255&a.timecode,b].map(function(a){return String.fromCharCode(a)}).join("")+a.frame;return c}function i(a){for(var b=a.RIFF[0].WEBP[0],c=b.indexOf("*"),d=0,e=[];4>d;d++)e[d]=b.charCodeAt(c+3+d);var f,g,h,i,j;return j=e[1]<<8|e[0],f=16383&j,g=j>>14,j=e[3]<<8|e[2],h=16383&j,i=j>>14,{width:f,height:h,data:b,riff:a}}function j(a){for(var b=0,c={};b