Skip to content

Commit

Permalink
Added: recordrtc@5.2.7 Merged & Fixed #79 also Fixed #78, Fixed #76
Browse files Browse the repository at this point in the history
Now RecordRTC will skip MediaRecorder for Chrome < 49
  • Loading branch information
muaz-khan committed Jan 18, 2016
1 parent 3b6d958 commit 0f6ad76
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Canvas-Recording/canvas-designer.js
Expand Up @@ -83,7 +83,7 @@
var context = getContext('main-canvas'),
tempContext = getContext('temp-canvas');

window.canvasElementToBeRecorded = tempContext.canvas;
window.canvasElementToBeRecorded = context.canvas;

// -------------------------------------------------------------

Expand Down
19 changes: 2 additions & 17 deletions Gruntfile.js
Expand Up @@ -28,6 +28,7 @@ module.exports = function(grunt) {
'dev/MRecordRTC.js',
'dev/Cross-Browser-Declarations.js',
'dev/Storage.js',
'dev/isMediaRecorderCompatible.js',
'dev/MediaStreamRecorder.js',
'dev/StereoAudioRecorder.js',
'dev/CanvasRecorder.js',
Expand All @@ -39,22 +40,6 @@ module.exports = function(grunt) {
dest: 'RecordRTC.js',
},
},
htmlhint: {
html1: {
src: [
'./Canvas-Recording/*.html',
'./MRecordRTC/*.html',
'./PHP-and-FFmpeg/*.html',
'./RecordRTC-over-Socketio/*.html',
'./RecordRTC-to-Nodejs/static/*.html',
'./RecordRTC-to-PHP/*.html',
'./*.html'
],
options: {
'tag-pair': true
}
}
},
jshint: {
options: {
globals: {
Expand Down Expand Up @@ -186,5 +171,5 @@ module.exports = function(grunt) {

// set default tasks to run when grunt is called without parameters
// http://gruntjs.com/api/grunt.task
grunt.registerTask('default', ['concat', 'jsbeautifier', 'htmlhint', 'jshint', 'uglify']);
grunt.registerTask('default', ['concat', 'jsbeautifier', 'jshint', 'uglify']);
};
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -134,7 +134,7 @@ function successCallback(stream) {
videoBitsPerSecond: 128000,
bitsPerSecond: 128000 // if this line is provided, skip above two
};
recordRTC = RecordRTC(MediaStream);
recordRTC = RecordRTC(stream, options);
recordRTC.startRecording();
}

Expand Down
49 changes: 46 additions & 3 deletions RecordRTC.js
@@ -1,4 +1,4 @@
// Last time updated: 2016-01-18 1:39:49 PM UTC
// Last time updated: 2016-01-18 2:47:14 PM UTC

// links:
// Open-Sourced: https://github.com/muaz-khan/RecordRTC
Expand Down Expand Up @@ -807,7 +807,7 @@ function GetRecorderType(mediaStream, config) {
}

// todo: enable below block when MediaRecorder in Chrome gets out of flags; and it also supports audio recording.
if (isChrome && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {
if (isMediaRecorderCompatible() && isChrome && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {
if (mediaStream.getVideoTracks().length) {
recorder = MediaStreamRecorder;
}
Expand Down Expand Up @@ -1347,6 +1347,49 @@ if (typeof AudioContext !== 'undefined') {
Storage.AudioContext = webkitAudioContext;
}

function isMediaRecorderCompatible() {
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isChrome = !!window.chrome && !isOpera;
var isFirefox = typeof window.InstallTrigger !== 'undefined';

if (isFirefox) {
return true;
}

if (!isChrome) {
return false;
}

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var fullVersion = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;

if (isChrome) {
verOffset = nAgt.indexOf('Chrome');
fullVersion = nAgt.substring(verOffset + 7);
}

// trim the fullVersion string at semicolon/space if present
if ((ix = fullVersion.indexOf(';')) !== -1) {
fullVersion = fullVersion.substring(0, ix);
}

if ((ix = fullVersion.indexOf(' ')) !== -1) {
fullVersion = fullVersion.substring(0, ix);
}

majorVersion = parseInt('' + fullVersion, 10);

if (isNaN(majorVersion)) {
fullVersion = '' + parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion, 10);
}

return majorVersion >= 49;
}

// ______________________
// MediaStreamRecorder.js

Expand Down Expand Up @@ -1889,7 +1932,7 @@ function StereoAudioRecorder(mediaStream, config) {
view.setUint32(24, sampleRate, true);

// byte rate (sample rate * block align)
view.setUint32(28, sampleRate * 4, true);
view.setUint32(28, sampleRate * 2, true);

// block align (channel count * bytes per sample)
view.setUint16(32, numberOfAudioChannels * 2, true);
Expand Down
6 changes: 3 additions & 3 deletions RecordRTC.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/GetRecorderType.js
Expand Up @@ -47,7 +47,7 @@ function GetRecorderType(mediaStream, config) {
}

// todo: enable below block when MediaRecorder in Chrome gets out of flags; and it also supports audio recording.
if (isChrome && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {
if (isMediaRecorderCompatible() && isChrome && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== 'undefined' && 'requestData' in MediaRecorder.prototype) {
if (mediaStream.getVideoTracks().length) {
recorder = MediaStreamRecorder;
}
Expand Down
2 changes: 1 addition & 1 deletion dev/StereoAudioRecorder.js
Expand Up @@ -195,7 +195,7 @@ function StereoAudioRecorder(mediaStream, config) {
view.setUint32(24, sampleRate, true);

// byte rate (sample rate * block align)
view.setUint32(28, sampleRate * 4, true);
view.setUint32(28, sampleRate * 2, true);

// block align (channel count * bytes per sample)
view.setUint16(32, numberOfAudioChannels * 2, true);
Expand Down
42 changes: 42 additions & 0 deletions dev/isMediaRecorderCompatible.js
@@ -0,0 +1,42 @@
function isMediaRecorderCompatible() {
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isChrome = !!window.chrome && !isOpera;
var isFirefox = typeof window.InstallTrigger !== 'undefined';

if (isFirefox) {
return true;
}

if (!isChrome) {
return false;
}

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var fullVersion = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;

if (isChrome) {
verOffset = nAgt.indexOf('Chrome');
fullVersion = nAgt.substring(verOffset + 7);
}

// trim the fullVersion string at semicolon/space if present
if ((ix = fullVersion.indexOf(';')) !== -1) {
fullVersion = fullVersion.substring(0, ix);
}

if ((ix = fullVersion.indexOf(' ')) !== -1) {
fullVersion = fullVersion.substring(0, ix);
}

majorVersion = parseInt('' + fullVersion, 10);

if (isNaN(majorVersion)) {
fullVersion = '' + parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion, 10);
}

return majorVersion >= 49;
}
20 changes: 9 additions & 11 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "recordrtc",
"preferGlobal": false,
"version": "5.2.6",
"version": "5.2.7",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down Expand Up @@ -35,15 +35,13 @@
"_id": "recordrtc@",
"_from": "recordrtc@",
"devDependencies": {
"grunt": "latest",
"grunt-cli": "latest",
"load-grunt-tasks": "latest",
"grunt-contrib-concat": "latest",
"grunt-contrib-csslint": "latest",
"grunt-contrib-jshint": "latest",
"grunt-contrib-uglify": "latest",
"grunt-htmlhint": "latest",
"grunt-jsbeautifier": "latest",
"grunt-bump": "latest"
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"load-grunt-tasks": "3.4.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-jshint": "0.11.3",
"grunt-contrib-uglify": "0.11.0",
"grunt-jsbeautifier": "0.2.10",
"grunt-bump": "0.7.0"
}
}

0 comments on commit 0f6ad76

Please sign in to comment.