Permalink
Browse files

fix a bunch of problems

  • Loading branch information...
contra committed Dec 15, 2015
1 parent 96b803e commit c8849c32b5708b7cb6f8524ce2a5cd400b1e1832
View
@@ -18,6 +18,7 @@
"browser": true,
"mocha": true,
"globals": {
- "cordova": true
+ "cordova": true,
+ "ActiveXObject": true
}
}
View
@@ -36,6 +36,7 @@ var RTCPeerConnectionMock = mock({
]
});
+/*
var RTCSessionDescriptionMock = mock({
properties: [
'type',
@@ -50,6 +51,7 @@ var RTCIceCandidateMock = mock({
'sdpMLineIndex'
]
});
+*/
if (!isInstalled()) {
module.exports = {};
@@ -68,7 +70,7 @@ if (!isInstalled()) {
ctor = rtc.RTCSessionDescription;
});
if (!ctor) {
- throw new Error('Tried to use RTCSessionDescription before plugin loaded!');
+ throw new Error('Tried RTCSessionDescription before RTCPeerConnection');
}
return nu.apply(ctor, arguments);
},
@@ -78,7 +80,7 @@ if (!isInstalled()) {
ctor = rtc.RTCIceCandidate;
});
if (!ctor) {
- throw new Error('Tried to use RTCIceCandidate before plugin loaded!');
+ throw new Error('Tried RTCIceCandidate before RTCPeerConnection');
}
return nu.apply(ctor, arguments);
}
View
@@ -1,10 +1,8 @@
'use strict';
module.exports = function() {
- if (typeof navigator === 'undefined') return;
var getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia;
- if (typeof getUserMedia === 'undefined') return;
return function(constraints, cb) {
// make constraints optional
@@ -1,6 +1,6 @@
'use strict';
module.exports = function(){
- return typeof window!== 'undefined' &&
+ return typeof window !== 'undefined' &&
typeof window.chrome !== 'undefined';
};
View
@@ -1,7 +1,6 @@
'use strict';
module.exports = function() {
- if (typeof window === 'undefined') return;
return {
RTCPeerConnection: window.RTCPeerConnection ||
window.webkitRTCPeerConnection,
@@ -1,12 +1,16 @@
'use strict';
+function needPlatform(){
+ throw new Error('Missing iosrtc plugin for attachStream');
+}
+
module.exports = function(){
var URL = window.URL || window.webkitURL;
return function(el, stream) {
- if (typeof cordova === 'undefined') return;
- if (typeof cordova.plugins === 'undefined') return;
- if (typeof cordova.plugins.iosrtc === 'undefined') return;
+ if (typeof cordova === 'undefined') return needPlatform();
+ if (typeof cordova.plugins === 'undefined') return needPlatform();
+ if (typeof cordova.plugins.iosrtc === 'undefined') return needPlatform();
el.src = URL.createObjectURL(stream);
el.setAttribute('webkit-playsinline', 'true');
@@ -1,10 +1,14 @@
'use strict';
+function needPlatform(){
+ throw new Error('Missing iosrtc plugin for getUserMedia');
+}
+
module.exports = function() {
return function(constraints, cb) {
- if (typeof cordova === 'undefined') return;
- if (typeof cordova.plugins === 'undefined') return;
- if (typeof cordova.plugins.iosrtc === 'undefined') return;
+ if (typeof cordova === 'undefined') return needPlatform();
+ if (typeof cordova.plugins === 'undefined') return needPlatform();
+ if (typeof cordova.plugins.iosrtc === 'undefined') return needPlatform();
// make constraints optional
if (arguments.length !== 2) {
@@ -1,9 +1,13 @@
'use strict';
+function needPlatform(){
+ throw new Error('Missing iosrtc plugin for RTCPeerConnection');
+}
+
module.exports = function() {
- if (typeof cordova === 'undefined') return;
- if (typeof cordova.plugins === 'undefined') return;
- if (typeof cordova.plugins.iosrtc === 'undefined') return;
+ if (typeof cordova === 'undefined') return needPlatform();
+ if (typeof cordova.plugins === 'undefined') return needPlatform();
+ if (typeof cordova.plugins.iosrtc === 'undefined') return needPlatform();
return {
RTCPeerConnection: cordova.plugins.iosrtc.RTCPeerConnection,
View
@@ -1,10 +1,8 @@
'use strict';
module.exports = function() {
- if (typeof navigator === 'undefined') return;
var getUserMedia = navigator.getUserMedia ||
navigator.msGetUserMedia;
- if (typeof getUserMedia === 'undefined') return;
return function(constraints, cb) {
// make constraints optional
View
@@ -1,7 +1,6 @@
'use strict';
-var browser = require('detect-browser');
-
module.exports = function(){
+ var browser = require('detect-browser');
return browser.name === 'edge';
};
View
@@ -1,10 +1,8 @@
'use strict';
module.exports = function() {
- if (typeof navigator === 'undefined') return;
var getUserMedia = navigator.getUserMedia ||
navigator.mozGetUserMedia;
- if (typeof getUserMedia === 'undefined') return;
return function(constraints, cb) {
// make constraints optional
View
@@ -1,7 +1,6 @@
'use strict';
module.exports = function() {
- if (typeof window === 'undefined') return;
return {
RTCPeerConnection: window.RTCPeerConnection ||
window.mozRTCPeerConnection,
@@ -1,6 +1,6 @@
'use strict';
-module.exports = module.exports = function(){
+module.exports = function(){
return function(el, stream) {
// TODO
};
View
@@ -1,7 +1,6 @@
'use strict';
-var browser = require('detect-browser');
-
module.exports = function(){
+ var browser = require('detect-browser');
return browser.name === 'ie';
};
@@ -2,7 +2,6 @@
module.exports = function() {
var rtc;
- if (typeof navigator === 'undefined') return;
try {
rtc = require('react-native-webrtc');
} catch (err) {
@@ -1,7 +1,12 @@
'use strict';
module.exports = function() {
- var rtc = require('react-native-webrtc');
+ var rtc;
+ try {
+ rtc = require('react-native-webrtc');
+ } catch (err) {
+ return;
+ }
return {
RTCPeerConnection: rtc.RTCPeerConnection,
RTCSessionDescription: rtc.RTCSessionDescription,
@@ -2,6 +2,6 @@
module.exports = function(){
return function(el, stream) {
- // TODO
+ // TODO
};
};
View
@@ -24,7 +24,8 @@ describe('rtc()', function(){
'getUserMedia',
'RTCPeerConnection',
'RTCSessionDescription',
- 'RTCIceCandidate'
+ 'RTCIceCandidate',
+ 'attachStream'
]);
done();
});

0 comments on commit c8849c3

Please sign in to comment.