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
Next Next commit
Changes to allow temsys objects to work
jmartine committed Nov 9, 2017
commit c93b5a63e3e995493fa233837f806cea61ce5a32
19 changes: 12 additions & 7 deletions rtcpeerconnection.js
Original file line number Diff line number Diff line change
@@ -109,16 +109,18 @@ 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 (typeof this.pc.getLocalStreams === 'function' ||
(this.pc.getLocalStreams && this.pc.getLocalStreams.call)) {
this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc);
} else {
this.getLocalStreams = function () {
return [];
};
}

if (typeof this.pc.getRemoteStreams === 'function') {
this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc);
if (typeof this.pc.getRemoteStreams === 'function' ||
(this.pc.getRemoteStreams && this.pc.getRemoteStreams.call)) {
this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc);
} else {
this.getRemoteStreams = function () {
return [];
@@ -128,16 +130,19 @@ function PeerConnection(config, constraints) {
this.addStream = this.pc.addStream.bind(this.pc);

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

if (typeof this.pc.removeTrack === 'function') {
if (typeof this.pc.removeTrack === 'function' ||
(this.pc.removeTrack && this.pc.removeTrack.call)) {
this.removeTrack = this.pc.removeTrack.bind(this.pc);
}