Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for Temasys to pc method checks #96

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions rtcpeerconnection.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3631,6 +3631,11 @@ function PeerConnection(config, constraints) {
config = config || {};
config.iceServers = config.iceServers || [];

// includes consideration for ActiveX/NPAPI methods (for Temasys support)
function isCallable(val) {
return typeof val === 'function' || !!(val && val.call);
}

// make sure this only gets enabled in Google Chrome
// EXPERIMENTAL FLAG, might get removed without notice
this.enableChromeNativeSimulcast = false;
Expand Down Expand Up @@ -3726,31 +3731,31 @@ function PeerConnection(config, constraints) {

this.pc = new RTCPeerConnection(config, constraints);

if (typeof this.pc.getLocalStreams === 'function') {
if (isCallable(this.pc.getLocalStreams)) {
this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc);
} else {
this.getLocalStreams = function () {
return [];
};
}

if (typeof this.pc.getSenders === 'function') {
if (isCallable(this.pc.getSenders)) {
this.getSenders = this.pc.getSenders.bind(this.pc);
} else {
this.getSenders = function () {
return [];
};
}

if (typeof this.pc.getRemoteStreams === 'function') {
if (isCallable(this.pc.getRemoteStreams)) {
this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc);
} else {
this.getRemoteStreams = function () {
return [];
};
}

if (typeof this.pc.getReceivers === 'function') {
if (isCallable(this.pc.getReceivers)) {
this.getReceivers = this.pc.getReceivers.bind(this.pc);
} else {
this.getReceivers = function () {
Expand All @@ -3761,16 +3766,16 @@ function PeerConnection(config, constraints) {
this.addStream = this.pc.addStream.bind(this.pc);

this.removeStream = function (stream) {
if (typeof self.pc.removeStream === 'function') {
if (isCallable(self.pc.removeStream)) {
self.pc.removeStream.apply(self.pc, arguments);
} else if (typeof self.pc.removeTrack === 'function') {
} else if (isCallable(self.pc.removeTrack)) {
stream.getTracks().forEach(function (track) {
self.pc.removeTrack(track);
});
}
};

if (typeof this.pc.removeTrack === 'function') {
if (isCallable(this.pc.removeTrack)) {
this.removeTrack = this.pc.removeTrack.bind(this.pc);
}

Expand Down Expand Up @@ -3818,6 +3823,7 @@ function PeerConnection(config, constraints) {
logger.log('PeerConnection event:', arguments);
});
}

this.hadLocalStunCandidate = false;
this.hadRemoteStunCandidate = false;
this.hadLocalRelayCandidate = false;
Expand Down Expand Up @@ -3845,6 +3851,7 @@ Object.defineProperty(PeerConnection.prototype, 'signalingState', {
return this.pc.signalingState;
}
});

Object.defineProperty(PeerConnection.prototype, 'iceConnectionState', {
get: function () {
return this.pc.iceConnectionState;
Expand Down
27 changes: 16 additions & 11 deletions rtcpeerconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function PeerConnection(config, constraints) {
config = config || {};
config.iceServers = config.iceServers || [];

// includes consideration for ActiveX/NPAPI methods (for Temasys support)
function isCallable(val) {
return typeof val === 'function' || !!(val && val.call);
}

// make sure this only gets enabled in Google Chrome
// EXPERIMENTAL FLAG, might get removed without notice
this.enableChromeNativeSimulcast = false;
Expand Down Expand Up @@ -109,31 +114,31 @@ function PeerConnection(config, constraints) {

this.pc = new RTCPeerConnection(config, constraints);

if (typeof this.pc.getLocalStreams === 'function') {
this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc);
if (isCallable(this.pc.getLocalStreams)) {
this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc);
} else {
this.getLocalStreams = function () {
return [];
};
}

if (typeof this.pc.getSenders === 'function') {
if (isCallable(this.pc.getSenders)) {
this.getSenders = this.pc.getSenders.bind(this.pc);
} else {
this.getSenders = function () {
return [];
};
}

if (typeof this.pc.getRemoteStreams === 'function') {
this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc);
if (isCallable(this.pc.getRemoteStreams)) {
this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc);
} else {
this.getRemoteStreams = function () {
return [];
};
}

if (typeof this.pc.getReceivers === 'function') {
if (isCallable(this.pc.getReceivers)) {
this.getReceivers = this.pc.getReceivers.bind(this.pc);
} else {
this.getReceivers = function () {
Expand All @@ -144,16 +149,16 @@ function PeerConnection(config, constraints) {
this.addStream = this.pc.addStream.bind(this.pc);

this.removeStream = function (stream) {
if (typeof self.pc.removeStream === 'function') {
if (isCallable(self.pc.removeStream)) {
self.pc.removeStream.apply(self.pc, arguments);
} else if (typeof self.pc.removeTrack === 'function') {
} else if (isCallable(self.pc.removeTrack)) {
stream.getTracks().forEach(function (track) {
self.pc.removeTrack(track);
});
}
};

if (typeof this.pc.removeTrack === 'function') {
if (isCallable(this.pc.removeTrack)) {
this.removeTrack = this.pc.removeTrack.bind(this.pc);
}

Expand Down Expand Up @@ -201,6 +206,7 @@ function PeerConnection(config, constraints) {
logger.log('PeerConnection event:', arguments);
});
}

this.hadLocalStunCandidate = false;
this.hadRemoteStunCandidate = false;
this.hadLocalRelayCandidate = false;
Expand Down Expand Up @@ -228,6 +234,7 @@ Object.defineProperty(PeerConnection.prototype, 'signalingState', {
return this.pc.signalingState;
}
});

Object.defineProperty(PeerConnection.prototype, 'iceConnectionState', {
get: function () {
return this.pc.iceConnectionState;
Expand Down Expand Up @@ -272,7 +279,6 @@ PeerConnection.prototype._checkRemoteCandidate = function (candidate) {
}
};


// Init and add ice candidate object with correct constructor
PeerConnection.prototype.processIce = function (update, cb) {
cb = cb || function () {};
Expand Down Expand Up @@ -449,7 +455,6 @@ PeerConnection.prototype.offer = function (constraints, cb) {
);
};


// Process an incoming offer so that ICE may proceed before deciding
// to answer the request.
PeerConnection.prototype.handleOffer = function (offer, cb) {
Expand Down