Skip to content

Commit

Permalink
Added recordrtc@5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Feb 13, 2017
1 parent 886e775 commit 0be5b89
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 96 deletions.
14 changes: 11 additions & 3 deletions .npmignore
@@ -1,3 +1,11 @@
node_modules
lib-cov
npm-debug.log
# ignore everything
*

# but not these files...
!RecordRTC.js
!RecordRTC.min.js
!index.html
!package.json
!bower.json
!npm-test.js
!README.md
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -163,8 +163,8 @@ bower install recordrtc
You can even link specific [releases](https://github.com/muaz-khan/RecordRTC/releases):

```html
<!-- use 5.4.0 or any other version -->
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.4.0/RecordRTC.js"></script>
<!-- use 5.4.1 or any other version -->
<script src="https://github.com/muaz-khan/RecordRTC/releases/download/5.4.1/RecordRTC.js"></script>
```

## How to capture stream?
Expand Down Expand Up @@ -574,6 +574,8 @@ var recordVideo = RecordRTC(MediaStream, options);

## `pauseRecording`

> Note: Firefox seems has a bug. It is unable to pause the recording. Seems internal bug because they correctly changes `mediaRecorder.state` from `recording` to `paused` but they are unable to pause internal recorders.
RecordRTC pauses recording buffers/frames.

```javascript
Expand Down
64 changes: 25 additions & 39 deletions RecordRTC.js
@@ -1,7 +1,7 @@
// Last time updated: 2017-02-10 4:43:51 AM UTC
// Last time updated: 2017-02-13 9:58:18 AM UTC

// ________________
// RecordRTC v5.4.0
// RecordRTC v5.4.1

// Open-Sourced: https://github.com/muaz-khan/RecordRTC

Expand Down Expand Up @@ -1743,6 +1743,14 @@ function MediaStreamRecorder(mediaStream, config) {
}

if (!e.data || !e.data.size || e.data.size < 100 || self.blob) {
// make sure that stopRecording always getting fired
// even if there is invalid data
if (self.recordingCallback) {
self.recordingCallback(new Blob([], {
type: recorderHints.mimeType || 'video/webm'
}));
self.recordingCallback = null;
}
return;
}

Expand All @@ -1755,7 +1763,7 @@ function MediaStreamRecorder(mediaStream, config) {
* });
*/
self.blob = config.getNativeBlob ? e.data : new Blob([e.data], {
type: config.mimeType || 'video/webm'
type: recorderHints.mimeType || 'video/webm'
});

if (self.recordingCallback) {
Expand Down Expand Up @@ -4053,10 +4061,6 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {

options = options || {
mimeType: 'video/webm',
canvas: {
width: window.screen.width,
height: window.screen.height
},
video: {
width: 320,
height: 240
Expand All @@ -4067,22 +4071,10 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
options.frameInterval = 10;
}

if (!options.canvas) {
options.canvas = {};
}

if (!options.video) {
options.video = {};
}

if (!options.canvas.width) {
options.canvas.width = window.screen.width;
}

if (!options.canvas.height) {
options.canvas.height = window.screen.height;
}

if (!options.video.width) {
options.video.width = 320;
}
Expand Down Expand Up @@ -4117,6 +4109,9 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
mimeType: 'video/webm'
});

canvas.width = videos.length > 1 ? videos[0].width * 2 : videos[0].width;
canvas.height = videos.length > 2 ? videos[0].height * 2 : videos[0].height;

drawVideosToCanvas();

mediaRecorder.record();
Expand Down Expand Up @@ -4217,62 +4212,56 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
var videosLength = videos.length;
videos.forEach(function(video, idx) {
if (videosLength === 1) {
context.drawImage(video, 0, 0, canvas.width, canvas.height);
context.drawImage(video, 0, 0, video.width, video.height);
return;
}

if (videosLength === 2) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = width;

if (idx === 1) {
x = width;
x = video.width;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}

if (videosLength === 3) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = parseInt(canvas.height / 2);

if (idx === 1) {
x = width;
x = video.width;
}

if (idx === 2) {
y = height;
y = video.height;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}

if (videosLength === 4) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = parseInt(canvas.height / 2);

if (idx === 1) {
x = width;
x = video.width;
}

if (idx === 2) {
y = height;
y = video.height;
}

if (idx === 3) {
x = width;
y = height;
x = video.width;
y = video.height;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}
});
Expand All @@ -4283,9 +4272,6 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');

canvas.width = options.canvas.width;
canvas.height = options.canvas.height;

canvas.style = 'opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000;';

document.body.appendChild(canvas);
Expand Down
8 changes: 4 additions & 4 deletions RecordRTC.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "recordrtc",
"version": "5.4.0",
"version": "5.4.1",
"authors": [
{
"name": "Muaz Khan",
Expand Down
10 changes: 9 additions & 1 deletion dev/MediaStreamRecorder.js
Expand Up @@ -136,6 +136,14 @@ function MediaStreamRecorder(mediaStream, config) {
}

if (!e.data || !e.data.size || e.data.size < 100 || self.blob) {
// make sure that stopRecording always getting fired
// even if there is invalid data
if (self.recordingCallback) {
self.recordingCallback(new Blob([], {
type: recorderHints.mimeType || 'video/webm'
}));
self.recordingCallback = null;
}
return;
}

Expand All @@ -148,7 +156,7 @@ function MediaStreamRecorder(mediaStream, config) {
* });
*/
self.blob = config.getNativeBlob ? e.data : new Blob([e.data], {
type: config.mimeType || 'video/webm'
type: recorderHints.mimeType || 'video/webm'
});

if (self.recordingCallback) {
Expand Down
50 changes: 14 additions & 36 deletions dev/MultiStreamRecorder.js
Expand Up @@ -34,10 +34,6 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {

options = options || {
mimeType: 'video/webm',
canvas: {
width: window.screen.width,
height: window.screen.height
},
video: {
width: 320,
height: 240
Expand All @@ -48,22 +44,10 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
options.frameInterval = 10;
}

if (!options.canvas) {
options.canvas = {};
}

if (!options.video) {
options.video = {};
}

if (!options.canvas.width) {
options.canvas.width = window.screen.width;
}

if (!options.canvas.height) {
options.canvas.height = window.screen.height;
}

if (!options.video.width) {
options.video.width = 320;
}
Expand Down Expand Up @@ -98,6 +82,9 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
mimeType: 'video/webm'
});

canvas.width = videos.length > 1 ? videos[0].width * 2 : videos[0].width;
canvas.height = videos.length > 2 ? videos[0].height * 2 : videos[0].height;

drawVideosToCanvas();

mediaRecorder.record();
Expand Down Expand Up @@ -198,62 +185,56 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
var videosLength = videos.length;
videos.forEach(function(video, idx) {
if (videosLength === 1) {
context.drawImage(video, 0, 0, canvas.width, canvas.height);
context.drawImage(video, 0, 0, video.width, video.height);
return;
}

if (videosLength === 2) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = width;

if (idx === 1) {
x = width;
x = video.width;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}

if (videosLength === 3) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = parseInt(canvas.height / 2);

if (idx === 1) {
x = width;
x = video.width;
}

if (idx === 2) {
y = height;
y = video.height;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}

if (videosLength === 4) {
var x = 0;
var y = 0;
var width = parseInt(canvas.width / 2);
var height = parseInt(canvas.height / 2);

if (idx === 1) {
x = width;
x = video.width;
}

if (idx === 2) {
y = height;
y = video.height;
}

if (idx === 3) {
x = width;
y = height;
x = video.width;
y = video.height;
}

context.drawImage(video, x, y, width, height);
context.drawImage(video, x, y, video.width, video.height);
return;
}
});
Expand All @@ -264,9 +245,6 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');

canvas.width = options.canvas.width;
canvas.height = options.canvas.height;

canvas.style = 'opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000;';

document.body.appendChild(canvas);
Expand Down

0 comments on commit 0be5b89

Please sign in to comment.