Skip to content

Commit

Permalink
"getLength", "isEmpty" and "connection.waitUntilRemoteStreamStartsFlo…
Browse files Browse the repository at this point in the history
…wing" fixed.

dev/globals.js --- getLength
dev/globals.js --- isEmpty
dev/RTCMultiSession.js --- connection.waitUntilRemoteStreamStartsFlowing
  • Loading branch information
muaz-khan committed Nov 18, 2014
1 parent c66aac3 commit e2850f0
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 53 deletions.
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<a href="https://github.com/muaz-khan/RTCMultiConnection"><img src="http://www.rtcmulticonnection.org/images/logo.png" /></a> / <a href="https://github.com/muaz-khan/RTCMultiConnection/wiki">Wiki Pages</a> / <a href="http://www.rtcmulticonnection.org/docs/">Documentation</a> / <a href="http://www.rtcmulticonnection.org/FAQ/">FAQ</a> / <a href="https://www.webrtc-experiment.com/RTCMultiConnection/">Demos</a> / <a href="http://www.rtcmulticonnection.org/changes-log/">Changes Log</a>
<a href="https://github.com/muaz-khan/RTCMultiConnection"><img src="https://i.imgur.com/MFfRBSM.png" /></a> / <a href="https://github.com/muaz-khan/RTCMultiConnection/wiki">Wiki Pages</a> / <a href="http://www.rtcmulticonnection.org/docs/">Documentation</a> / <a href="http://www.rtcmulticonnection.org/FAQ/">FAQ</a> / <a href="https://www.webrtc-experiment.com/RTCMultiConnection/">Demos</a> / <a href="http://www.rtcmulticonnection.org/changes-log/">Changes Log</a>

[![npm](https://img.shields.io/npm/v/rtcmulticonnection.svg)](https://npmjs.org/package/rtcmulticonnection) [![downloads](https://img.shields.io/npm/dm/rtcmulticonnection.svg)](https://npmjs.org/package/rtcmulticonnection) [![Build Status: Linux](https://travis-ci.org/muaz-khan/RTCMultiConnection.png?branch=master)](https://travis-ci.org/muaz-khan/RTCMultiConnection)

# Contributors

1. [Muaz Khan](https://github.com/muaz-khan)
2. [Yuri](https://github.com/Yuripetusko)
3. [Alexey Kucherenko](https://github.com/killmenot)
4. +Your Name
2. [Alexey Kucherenko](https://github.com/killmenot)
3. [Yuri](https://github.com/Yuripetusko)
4. [Dmitry](https://github.com/Reptoh)
5. +Your Name

# Rules to Contribute

Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = function(grunt) {
}
},
jsbeautifier: {
files: ['RTCMultiConnection.js', 'demos/*.html', 'Gruntfile.js'],
files: ['RTCMultiConnection.js', 'demos/*.html', 'dev/*.js', 'Gruntfile.js'],
options: {
js: {
braceStyle: "collapse",
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="https://github.com/muaz-khan/RTCMultiConnection"><img src="http://www.rtcmulticonnection.org/images/logo.png" /></a> / <a href="https://github.com/muaz-khan/RTCMultiConnection/wiki">Wiki Pages</a> / <a href="http://www.rtcmulticonnection.org/docs/">Documentation</a> / <a href="http://www.rtcmulticonnection.org/FAQ/">FAQ</a> / <a href="https://www.webrtc-experiment.com/RTCMultiConnection/">Demos</a> / <a href="http://www.rtcmulticonnection.org/changes-log/">Changes Log</a>
<a href="https://github.com/muaz-khan/RTCMultiConnection"><img src="https://i.imgur.com/MFfRBSM.png" /></a> / <a href="https://github.com/muaz-khan/RTCMultiConnection/wiki">Wiki Pages</a> / <a href="http://www.rtcmulticonnection.org/docs/">Documentation</a> / <a href="http://www.rtcmulticonnection.org/FAQ/">FAQ</a> / <a href="https://www.webrtc-experiment.com/RTCMultiConnection/">Demos</a> / <a href="http://www.rtcmulticonnection.org/changes-log/">Changes Log</a>

## WebRTC Library [![npm](https://img.shields.io/npm/v/rtcmulticonnection.svg)](https://npmjs.org/package/rtcmulticonnection) [![downloads](https://img.shields.io/npm/dm/rtcmulticonnection.svg)](https://npmjs.org/package/rtcmulticonnection) [![Build Status: Linux](https://travis-ci.org/muaz-khan/RTCMultiConnection.png?branch=master)](https://travis-ci.org/muaz-khan/RTCMultiConnection)

Expand All @@ -11,35 +11,35 @@ Quick-Demos for newbies:
<tr>
<td>
<a href="https://www.webrtc-experiment.com/RTCMultiConnection/" target="_blank">
<img src="http://www.rtcmulticonnection.org/img/demo.png" style="display:block; width:99px; height99px;" alt="Demos">
<img src="https://i.imgur.com/Fz1Pff6.png" style="display:block; width:99px; height99px;" alt="Demos">
Demos
</a>
</td>
<td>
<a href="http://www.rtcmulticonnection.org/docs/getting-started/" target="_blank">
<img src="http://www.rtcmulticonnection.org/img/getting-started.png" style="display:block; width:99px; height99px;" alt="Getting-Started">
<img src="https://i.imgur.com/v3YdSC6.png" style="display:block; width:99px; height99px;" alt="Getting-Started">
Getting Started
</a>
</td>
<td>
<a href="http://www.rtcmulticonnection.org/docs/" target="_blank">
<img src="http://www.rtcmulticonnection.org/img/documentation.png" style="display:block; width:99px; height99px;" alt="Documentation">
<img src="https://i.imgur.com/mtu6091.png" style="display:block; width:99px; height99px;" alt="Documentation">
Documentation
</a>
</td>
<td>
<a href="http://www.rtcmulticonnection.org/changes-log/" target="_blank">
<img src="http://www.rtcmulticonnection.org/img/whats-new.png" style="display:block; width:99px; height99px;" alt="Changes Log">
<img src="https://i.imgur.com/zHngv8r.png" style="display:block; width:99px; height99px;" alt="Changes Log">
Changes Log
</a>
</td>
<td>
<a href="http://www.rtcmulticonnection.org/FAQ/" target="_blank">
<img src="http://www.rtcmulticonnection.org/img/FAQ.png" style="display:block; width:99px; height99px;" alt="FAQ">
<img src="https://i.imgur.com/Zeqlfv2.png" style="display:block; width:99px; height99px;" alt="FAQ">
FAQ
</a>
</td>
Expand Down
46 changes: 26 additions & 20 deletions RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated at Nov 17, 2014, 08:32:23
// Last time updated at Nov 18, 2014, 08:32:23

// Quick-Demo for newbies: http://jsfiddle.net/c46de0L8/
// Another simple demo: http://jsfiddle.net/zar6fg60/
Expand Down Expand Up @@ -887,7 +887,7 @@

var screenConstraints = {
video: {
chromeMediaSource: 'fake'
chromeMediaSource: 'external-stream'
}
};
var forcedConstraints = isScreen ? screenConstraints : constraints;
Expand Down Expand Up @@ -1551,7 +1551,7 @@

function waitUntilRemoteStreamStartsFlowing(args) {
// chrome for android may have some features missing
if (isMobileDevice || isPluginRTC || (isNull(connection.waitUntilRemoteStreamStartsFlowing) || !connection.waitUntilRemoteStreamStartsFlowing)) {
if (isMobileDevice || isPluginRTC || (!isNull(connection.waitUntilRemoteStreamStartsFlowing) && connection.waitUntilRemoteStreamStartsFlowing === false)) {
return afterRemoteStreamStartedFlowing(args);
}

Expand Down Expand Up @@ -2543,11 +2543,11 @@
delete participants[userid];
}

for (var stream in connection.streams) {
stream = connection.streams[stream];
for (var streamid in connection.streams) {
var stream = connection.streams[streamid];
if (stream.userid === userid) {
onStreamEndedHandler(stream, connection);
delete connection.streams[stream];
delete connection.streams[streamid];
}
}

Expand Down Expand Up @@ -3793,7 +3793,7 @@
},
init: function() {
this.setConstraints();
this.connection = new RTCPeerConnection(this.iceServers, this.optionalArgument);
this.connection = new RTCPeerConnection(this.rtcConfiguration, this.optionalArgument);

if (this.session.data) {
log('invoked: createDataChannel');
Expand Down Expand Up @@ -3920,13 +3920,7 @@
}
};

if (this.constraints.mandatory) {
log('sdp-mandatory-constraints', toStr(this.constraints.mandatory));
}

if (this.constraints.optional) {
log('sdp-optional-constraints', toStr(this.constraints.optional));
}
log('sdp-constraints', toStr(this.constraints));

this.optionalArgument = {
optional: this.optionalArgument.optional || [],
Expand All @@ -3941,7 +3935,7 @@

log('optional-argument', toStr(this.optionalArgument));

if (!isNull(this.iceServers)) {
if (!isNull(this.rtcConfiguration) && !isNull(this.iceServers)) {
var iceCandidates = this.rtcMultiConnection.candidates;

var stun = iceCandidates.stun;
Expand All @@ -3961,15 +3955,15 @@
this.rtcConfiguration.iceTransports = 'none';
}

this.iceServers = {
this.rtcConfiguration = {
iceServers: this.iceServers,
iceTransports: this.rtcConfiguration.iceTransports
};
} else {
this.iceServers = null;
this.rtcConfiguration = null;
}

log('rtc-configuration', toStr(this.iceServers));
log('rtc-configuration', toStr(this.rtcConfiguration));
},
onSdpError: function(e) {
var message = toStr(e);
Expand Down Expand Up @@ -4425,7 +4419,11 @@
}

function isEmpty(session) {
return (session && !JSON.stringify(session).split(',').length) || !session;
var stringified = JSON.stringify(session);
if (stringified === '{}' || !stringified.split(',').length) {
return true;
}
return false;
}

// this method converts array-buffer into string
Expand Down Expand Up @@ -4505,7 +4503,15 @@
}

function getLength(obj) {
return obj ? JSON.stringify(obj).split(',').length : 0;
if (typeof obj !== 'object') {
throw 'Invalid data-type: ' + (typeof obj) + '; expected: object';
}

var stringified = JSON.stringify(obj);
if (stringified === '{}' || !stringified.split(',').length) {
return 0;
}
return stringified.split(',').length;
}

// Get HTMLAudioElement/HTMLVideoElement accordingly
Expand Down
8 changes: 4 additions & 4 deletions RTCMultiConnection.min.js

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions dev/PeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function PeerConnection() {
},
init: function() {
this.setConstraints();
this.connection = new RTCPeerConnection(this.iceServers, this.optionalArgument);
this.connection = new RTCPeerConnection(this.rtcConfiguration, this.optionalArgument);

if (this.session.data) {
log('invoked: createDataChannel');
Expand Down Expand Up @@ -286,13 +286,7 @@ function PeerConnection() {
}
};

if (this.constraints.mandatory) {
log('sdp-mandatory-constraints', toStr(this.constraints.mandatory));
}

if (this.constraints.optional) {
log('sdp-optional-constraints', toStr(this.constraints.optional));
}
log('sdp-constraints', toStr(this.constraints));

this.optionalArgument = {
optional: this.optionalArgument.optional || [],
Expand All @@ -307,7 +301,7 @@ function PeerConnection() {

log('optional-argument', toStr(this.optionalArgument));

if (!isNull(this.iceServers)) {
if (!isNull(this.rtcConfiguration) && !isNull(this.iceServers)) {
var iceCandidates = this.rtcMultiConnection.candidates;

var stun = iceCandidates.stun;
Expand All @@ -327,15 +321,15 @@ function PeerConnection() {
this.rtcConfiguration.iceTransports = 'none';
}

this.iceServers = {
this.rtcConfiguration = {
iceServers: this.iceServers,
iceTransports: this.rtcConfiguration.iceTransports
};
} else {
this.iceServers = null;
this.rtcConfiguration = null;
}

log('rtc-configuration', toStr(this.iceServers));
log('rtc-configuration', toStr(this.rtcConfiguration));
},
onSdpError: function(e) {
var message = toStr(e);
Expand Down
2 changes: 1 addition & 1 deletion dev/RTCMultiConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ window.RTCMultiConnection = function(channel) {

var screenConstraints = {
video: {
chromeMediaSource: 'fake'
chromeMediaSource: 'external-stream'
}
};
var forcedConstraints = isScreen ? screenConstraints : constraints;
Expand Down
2 changes: 1 addition & 1 deletion dev/RTCMultiSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function RTCMultiSession(connection, callbackForSignalingReady) {

function waitUntilRemoteStreamStartsFlowing(args) {
// chrome for android may have some features missing
if (isMobileDevice || isPluginRTC || (isNull(connection.waitUntilRemoteStreamStartsFlowing) || !connection.waitUntilRemoteStreamStartsFlowing)) {
if (isMobileDevice || isPluginRTC || (!isNull(connection.waitUntilRemoteStreamStartsFlowing) && connection.waitUntilRemoteStreamStartsFlowing === false)) {
return afterRemoteStreamStartedFlowing(args);
}

Expand Down
18 changes: 15 additions & 3 deletions dev/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ function isString(obj) {
}

function isEmpty(session) {
return (session && !JSON.stringify(session).split(',').length) || !session;
var stringified = JSON.stringify(session);
if (stringified === '{}' || !stringified.split(',').length) {
return true;
}
return false;
}

// this method converts array-buffer into string
Expand Down Expand Up @@ -155,7 +159,15 @@ function toStr(obj) {
}

function getLength(obj) {
return obj ? JSON.stringify(obj).split(',').length : 0;
if (typeof obj !== 'object') {
throw 'Invalid data-type: ' + (typeof obj) + '; expected: object';
}

var stringified = JSON.stringify(obj);
if (stringified === '{}' || !stringified.split(',').length) {
return 0;
}
return stringified.split(',').length;
}

// Get HTMLAudioElement/HTMLVideoElement accordingly
Expand Down Expand Up @@ -359,7 +371,7 @@ function loadScreenFrame(skip) {
if (loadedScreenFrame) {
return;
}

if (!skip) {
return loadScreenFrame(true);
}
Expand Down
2 changes: 1 addition & 1 deletion dev/head.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated at Nov 17, 2014, 08:32:23
// Last time updated at Nov 18, 2014, 08:32:23

// Quick-Demo for newbies: http://jsfiddle.net/c46de0L8/
// Another simple demo: http://jsfiddle.net/zar6fg60/
Expand Down

0 comments on commit e2850f0

Please sign in to comment.