Skip to content

Commit

Permalink
MultiStreamsMixer, DetectRTC, RecordRTC, RTCMultiConnection updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jul 8, 2019
1 parent fcbda5f commit 2aefed4
Show file tree
Hide file tree
Showing 193 changed files with 3,843 additions and 20,610 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
RecordRTC/RecordRTC-to-Nodejs/uploads/
*.DS_Store
ffmpeg/ffmpeg_asm.js
node_modules
RecordRTC/node_modules
DetectRTC/node_modules
RTCMultiConnection/node_modules
8 changes: 7 additions & 1 deletion DetectRTC/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
language: node_js
node_js:
- "0.11"
- "8"
- "10"
git:
depth: 5
cache:
directories:
node_modules
install: npm install
before_script:
- npm install [email protected] -g
Expand Down
6 changes: 0 additions & 6 deletions DetectRTC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ grunt

**Check tests here:** https://travis-ci.org/muaz-khan/DetectRTC

# Disclaimer

There is no warranty, expressed or implied, associated with this product. Use at your own risk.

* https://www.webrtc-experiment.com/disclaimer/

# License

[DetectRTC.js](https://github.com/muaz-khan/DetectRTC) is released under [MIT licence](https://www.webrtc-experiment.com/licence/) . Copyright (c) [Muaz Khan](http://www.MuazKhan.com/).
2 changes: 1 addition & 1 deletion DetectRTC/test/html-test-files/CheckDeviceSupport.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
audioOutputDevices: <span id="audioOutputDevices"></span><hr>
videoInputDevices: <span id="videoInputDevices"></span>

<script src="https://cdn.webrtc-experiment.com/DetectRTC/dev/CheckDeviceSupport.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC/dev/CheckDeviceSupport.js"> </script>
<script type="text/javascript">
checkDeviceSupport(function() {
document.getElementById('audioInputDevices').innerHTML = audioInputDevices.length;
Expand Down
2 changes: 1 addition & 1 deletion DetectRTC/test/html-test-files/DetectRTC.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script src="https://cdn.webrtc-experiment.com/DetectRTC.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC.js"> </script>
<script type="text/javascript">
['hasWebcam', 'hasMicrophone', 'hasSpeakers', 'isApplyConstraintsSupported',
'isAudioContextSupported', 'isCanvasSupportsStreamCapturing',
Expand Down
4 changes: 2 additions & 2 deletions DetectRTC/test/html-test-files/detectOSName.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
osName: <span id="osName"></span><hr>
osVersion: <span id="osVersion"></span>

<script src="https://cdn.webrtc-experiment.com/DetectRTC/dev/detectDesktopOS.js"> </script>
<script src="https://cdn.webrtc-experiment.com/DetectRTC/dev/detectOSName.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC/dev/detectDesktopOS.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC/dev/detectOSName.js"> </script>
<script type="text/javascript">
document.getElementById('osName').innerHTML = osName;
document.getElementById('osVersion').innerHTML = osVersion;
Expand Down
4 changes: 2 additions & 2 deletions DetectRTC/test/html-test-files/getBrowserInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
browserFullVersion: <span id="browserFullVersion"></span><hr>
isPrivateBrowsing: <span id="isPrivateBrowsing"></span>

<script src="https://cdn.webrtc-experiment.com/DetectRTC/dev/getBrowserInfo.js"> </script>
<script src="https://cdn.webrtc-experiment.com/DetectRTC/dev/detectPrivateBrowsing.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC/dev/getBrowserInfo.js"> </script>
<script src="https://www.webrtc-experiment.com/DetectRTC/dev/detectPrivateBrowsing.js"> </script>
<script type="text/javascript">
var browser = getBrowserInfo();

Expand Down
3 changes: 2 additions & 1 deletion MultiStreamsMixer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
bower_components

npm-debug.log
.DS_Store
.DS_Store
package-lock.json
8 changes: 7 additions & 1 deletion MultiStreamsMixer/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
language: node_js
node_js:
- "0.11"
- "8"
- "10"
git:
depth: 5
cache:
directories:
node_modules
install: npm install
before_script:
- npm install [email protected] -g
Expand Down
1 change: 1 addition & 0 deletions MultiStreamsMixer/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = function(grunt) {
dist: {
src: [
'dev/head.js',
'dev/amd.js',
'dev/init.js',
'dev/cross-browser-declarations.js',
'dev/start-drawing-frames.js',
Expand Down
152 changes: 140 additions & 12 deletions MultiStreamsMixer/MultiStreamsMixer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Last time updated: 2019-01-12 7:02:57 AM UTC
// Last time updated: 2019-06-24 6:39:09 PM UTC

// ________________________
// MultiStreamsMixer v1.0.7
// MultiStreamsMixer v1.2.3

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

Expand All @@ -10,16 +10,119 @@
// MIT License - www.WebRTC-Experiment.com/licence
// --------------------------------------------------

function MultiStreamsMixer(arrayOfMediaStreams) {
function MultiStreamsMixer(arrayOfMediaStreams, elementClass) {

var browserFakeUserAgent = 'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45';

(function(that) {
if (typeof RecordRTC !== 'undefined') {
return;
}

if (!that) {
return;
}

if (typeof window !== 'undefined') {
return;
}

if (typeof global === 'undefined') {
return;
}

global.navigator = {
userAgent: browserFakeUserAgent,
getUserMedia: function() {}
};

if (!global.console) {
global.console = {};
}

if (typeof global.console.log === 'undefined' || typeof global.console.error === 'undefined') {
global.console.error = global.console.log = global.console.log || function() {
console.log(arguments);
};
}

if (typeof document === 'undefined') {
/*global document:true */
that.document = {
documentElement: {
appendChild: function() {
return '';
}
}
};

document.createElement = document.captureStream = document.mozCaptureStream = function() {
var obj = {
getContext: function() {
return obj;
},
play: function() {},
pause: function() {},
drawImage: function() {},
toDataURL: function() {
return '';
},
style: {}
};
return obj;
};

that.HTMLVideoElement = function() {};
}

if (typeof location === 'undefined') {
/*global location:true */
that.location = {
protocol: 'file:',
href: '',
hash: ''
};
}

if (typeof screen === 'undefined') {
/*global screen:true */
that.screen = {
width: 0,
height: 0
};
}

if (typeof URL === 'undefined') {
/*global screen:true */
that.URL = {
createObjectURL: function() {
return '';
},
revokeObjectURL: function() {
return '';
}
};
}

/*global window:true */
that.window = global;
})(typeof global !== 'undefined' ? global : null);

// requires: chrome://flags/#enable-experimental-web-platform-features

elementClass = elementClass || 'multi-streams-mixer';

var videos = [];
var isStopDrawingFrames = false;

var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
canvas.style = 'opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000; margin-top:-1000000000;margin-left:-1000000000;';
canvas.style.opacity = 0;
canvas.style.position = 'absolute';
canvas.style.zIndex = -1;
canvas.style.top = '-1000em';
canvas.style.left = '-1000em';
canvas.className = elementClass;
(document.body || document.documentElement).appendChild(canvas);

this.disableLogs = false;
Expand Down Expand Up @@ -126,6 +229,7 @@ function MultiStreamsMixer(arrayOfMediaStreams) {
if (video.stream.fullcanvas) {
fullcanvas = video;
} else {
// todo: video.stream.active or video.stream.live to fix blank frames issues?
remaining.push(video);
}
});
Expand Down Expand Up @@ -250,6 +354,10 @@ function MultiStreamsMixer(arrayOfMediaStreams) {
}
});

// mixedVideoStream.prototype.appendStreams = appendStreams;
// mixedVideoStream.prototype.resetVideoStreams = resetVideoStreams;
// mixedVideoStream.prototype.clearRecordedData = clearRecordedData;

return mixedVideoStream;
}

Expand Down Expand Up @@ -314,10 +422,6 @@ function MultiStreamsMixer(arrayOfMediaStreams) {
self.audioSources.push(audioSource);
});

if (!audioTracksLength) {
return;
}

self.audioDestination = self.audioContext.createMediaStreamDestination();
self.audioSources.forEach(function(audioSource) {
audioSource.connect(self.audioDestination);
Expand All @@ -330,6 +434,8 @@ function MultiStreamsMixer(arrayOfMediaStreams) {

setSrcObject(stream, video);

video.className = elementClass;

video.muted = true;
video.volume = 0;

Expand All @@ -350,23 +456,33 @@ function MultiStreamsMixer(arrayOfMediaStreams) {
streams = [streams];
}

arrayOfMediaStreams.concat(streams);

streams.forEach(function(stream) {
arrayOfMediaStreams.push(stream);

var newStream = new MediaStream();

if (stream.getTracks().filter(function(t) {
return t.kind === 'video';
}).length) {
var video = getVideo(stream);
video.stream = stream;
videos.push(video);

newStream.addTrack(stream.getTracks().filter(function(t) {
return t.kind === 'video';
})[0]);
}

if (stream.getTracks().filter(function(t) {
return t.kind === 'audio';
}).length && self.audioContext) {
}).length) {
var audioSource = self.audioContext.createMediaStreamSource(stream);
// self.audioDestination = self.audioContext.createMediaStreamDestination();
audioSource.connect(self.audioDestination);
self.audioSources.push(audioSource);

newStream.addTrack(self.audioDestination.stream.getTracks().filter(function(t) {
return t.kind === 'audio';
})[0]);
}
});
};
Expand Down Expand Up @@ -441,3 +557,15 @@ function MultiStreamsMixer(arrayOfMediaStreams) {
this.getMixedStream = getMixedStream;

}

if (typeof RecordRTC === 'undefined') {
if (typeof module !== 'undefined' /* && !!module.exports*/ ) {
module.exports = MultiStreamsMixer;
}

if (typeof define === 'function' && define.amd) {
define('MultiStreamsMixer', [], function() {
return MultiStreamsMixer;
});
}
}
6 changes: 3 additions & 3 deletions MultiStreamsMixer/MultiStreamsMixer.min.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions MultiStreamsMixer/MultiStreamsMixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ export class MultiStreamsMixer {
height: number;
useGainNode : boolean;
arrayOfMediaStreams: Array<MediaStream>;
elementClass: string;
/********************************************/
audioContext : any;
audioDestination : any;
audioSources : Array<any>;
gainNode : GainNode;


constructor (_arrayOfMediaStreams) {
constructor (_arrayOfMediaStreams, elementClass = 'multi-streams-mixer') {
// requires: chrome://flags/#enable-experimental-web-platform-features
this.arrayOfMediaStreams = _arrayOfMediaStreams;
this.elementClass = elementClass;
this.videos = new Array<any>();
this.isStopDrawingFrames = false;
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
// this.canvas.style = 'opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000; margin-top:-1000000000;margin-left:-1000000000;';
// (document.body || document.documentElement).appendChild(canvas);
this.canvas.style = 'opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000; margin-top:-1000000000;margin-left:-1000000000;';
this.canvas.className = this.elementClass;
(document.body || document.documentElement).appendChild(canvas);
this.disableLogs = false;
this.frameInterval = 10;
this.width = 360;
Expand Down Expand Up @@ -259,6 +262,7 @@ export class MultiStreamsMixer {
private getVideo(stream) {
var video = document.createElement('video');
this.setSrcObject(stream, video);
video.className = this.elementClass;
video.muted = true;
video.volume = 0;
video.width = stream.width || this.width || 360;
Expand Down
Loading

0 comments on commit 2aefed4

Please sign in to comment.