Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rtcpeerconnection

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtcpeerconnection - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

4

package.json
{
"name": "rtcpeerconnection",
"version": "0.3.0",
"version": "0.3.1",
"description": "A tiny browser module that gives normalizes and simplifies the API for WebRTC peer connections.",

@@ -19,3 +19,3 @@ "main": "rtcpeerconnection.js",

"wildemitter": "0.0.5",
"webrtcsupport": "0.3.2"
"webrtcsupport": "0.4.1"
},

@@ -22,0 +22,0 @@ "devDependencies": {

(function(e){if("function"==typeof bootstrap)bootstrap("peerconnection",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makePeerConnection=e}else"undefined"!=typeof window?window.PeerConnection=e():global.PeerConnection=e()})(function(){var define,ses,bootstrap,module,exports;
return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
var WildEmitter = require('wildemitter');
var webrtc = require('webrtcsupport');
function PeerConnection(config, constraints) {
this.pc = new webrtc.PeerConnection(config, constraints);
WildEmitter.call(this);
this.pc.onicecandidate = this._onIce.bind(this);
this.pc.onaddstream = this._onAddStream.bind(this);
this.pc.onremovestream = this._onRemoveStream.bind(this);
if (config.debug) {
this.on('*', function (eventName, event) {
console.log('PeerConnection event:', eventName, event);
});
}
}
PeerConnection.prototype = Object.create(WildEmitter.prototype, {
constructor: {
value: PeerConnection
}
});
PeerConnection.prototype.addStream = function (stream) {
this.localStream = stream;
this.pc.addStream(stream);
};
PeerConnection.prototype._onIce = function (event) {
if (event.candidate) {
this.emit('ice', event.candidate);
} else {
this.emit('endOfCandidates');
}
};
PeerConnection.prototype._onAddStream = function (event) {
this.emit('addStream', event);
};
PeerConnection.prototype._onRemoveStream = function (event) {
this.emit('removeStream', event);
};
PeerConnection.prototype.processIce = function (candidate) {
this.pc.addIceCandidate(new webrtc.IceCandidate(candidate));
};
PeerConnection.prototype.offer = function (constraints, cb) {
var self = this;
var hasConstraints = arguments.length === 2;
var mediaConstraints = hasConstraints ? constraints : {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
}
};
var callback = hasConstraints ? cb : constraints;
this.pc.createOffer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('offer', sessionDescription);
if (callback) callback(null, sessionDescription);
},
function (err) {
self.emit('error', err);
if (callback) callback(err);
},
mediaConstraints
);
};
PeerConnection.prototype.answerAudioOnly = function (offer, cb) {
var mediaConstraints = {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: false
}
};
this._answer(offer, mediaConstraints, cb);
};
PeerConnection.prototype.answerBroadcastOnly = function (offer, cb) {
var mediaConstraints = {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: false
}
};
this._answer(offer, mediaConstraints, cb);
};
PeerConnection.prototype._answer = function (offer, constraints, cb) {
var self = this;
this.pc.setRemoteDescription(new webrtc.SessionDescription(offer));
this.pc.createAnswer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('answer', sessionDescription);
if (cb) cb(null, sessionDescription);
}, function (err) {
self.emit('error', err);
if (cb) cb(err);
},
constraints
);
};
PeerConnection.prototype.answer = function (offer, constraints, cb) {
var self = this;
var hasConstraints = arguments.length === 3;
var callback = hasConstraints ? cb : constraints;
var mediaConstraints = hasConstraints ? constraints : {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
}
};
this._answer(offer, mediaConstraints, callback);
};
PeerConnection.prototype.handleAnswer = function (answer) {
this.pc.setRemoteDescription(new webrtc.SessionDescription(answer));
};
PeerConnection.prototype.close = function () {
this.pc.close();
this.emit('close');
};
module.exports = PeerConnection;
},{"webrtcsupport":2,"wildemitter":3}],2:[function(require,module,exports){
// created by @HenrikJoreteg

@@ -153,3 +15,3 @@ var PC = window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.RTCPeerConnection;

var screenSharing = navigator.userAgent.match('Chrome') && parseInt(navigator.userAgent.match(/Chrome\/(.*) /)[1], 10) >= 26;
var webAudio = !!window.webkitAudioContext;
var AudioContext = window.webkitAudioContext || window.AudioContext;

@@ -161,4 +23,5 @@ // export support flags and constructors.prototype && PC

prefix: prefix,
webAudio: webAudio,
webAudio: !!(AudioContext && AudioContext.prototype.createMediaStreamSource),
screenSharing: screenSharing,
AudioContext: AudioContext,
PeerConnection: PC,

@@ -169,3 +32,3 @@ SessionDescription: SessionDescription,

},{}],3:[function(require,module,exports){
},{}],2:[function(require,module,exports){
/*

@@ -307,4 +170,142 @@ WildEmitter.js is a slim little event emitter by @henrikjoreteg largely based

},{}]},{},[1])(1)
},{}],3:[function(require,module,exports){
var WildEmitter = require('wildemitter');
var webrtc = require('webrtcsupport');
function PeerConnection(config, constraints) {
this.pc = new webrtc.PeerConnection(config, constraints);
WildEmitter.call(this);
this.pc.onicecandidate = this._onIce.bind(this);
this.pc.onaddstream = this._onAddStream.bind(this);
this.pc.onremovestream = this._onRemoveStream.bind(this);
if (config.debug) {
this.on('*', function (eventName, event) {
console.log('PeerConnection event:', eventName, event);
});
}
}
PeerConnection.prototype = Object.create(WildEmitter.prototype, {
constructor: {
value: PeerConnection
}
});
PeerConnection.prototype.addStream = function (stream) {
this.localStream = stream;
this.pc.addStream(stream);
};
PeerConnection.prototype._onIce = function (event) {
if (event.candidate) {
this.emit('ice', event.candidate);
} else {
this.emit('endOfCandidates');
}
};
PeerConnection.prototype._onAddStream = function (event) {
this.emit('addStream', event);
};
PeerConnection.prototype._onRemoveStream = function (event) {
this.emit('removeStream', event);
};
PeerConnection.prototype.processIce = function (candidate) {
this.pc.addIceCandidate(new webrtc.IceCandidate(candidate));
};
PeerConnection.prototype.offer = function (constraints, cb) {
var self = this;
var hasConstraints = arguments.length === 2;
var mediaConstraints = hasConstraints ? constraints : {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
}
};
var callback = hasConstraints ? cb : constraints;
this.pc.createOffer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('offer', sessionDescription);
if (callback) callback(null, sessionDescription);
},
function (err) {
self.emit('error', err);
if (callback) callback(err);
},
mediaConstraints
);
};
PeerConnection.prototype.answerAudioOnly = function (offer, cb) {
var mediaConstraints = {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: false
}
};
this._answer(offer, mediaConstraints, cb);
};
PeerConnection.prototype.answerBroadcastOnly = function (offer, cb) {
var mediaConstraints = {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: false
}
};
this._answer(offer, mediaConstraints, cb);
};
PeerConnection.prototype._answer = function (offer, constraints, cb) {
var self = this;
this.pc.setRemoteDescription(new webrtc.SessionDescription(offer));
this.pc.createAnswer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('answer', sessionDescription);
if (cb) cb(null, sessionDescription);
}, function (err) {
self.emit('error', err);
if (cb) cb(err);
},
constraints
);
};
PeerConnection.prototype.answer = function (offer, constraints, cb) {
var self = this;
var hasConstraints = arguments.length === 3;
var callback = hasConstraints ? cb : constraints;
var mediaConstraints = hasConstraints ? constraints : {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
}
};
this._answer(offer, mediaConstraints, callback);
};
PeerConnection.prototype.handleAnswer = function (answer) {
this.pc.setRemoteDescription(new webrtc.SessionDescription(answer));
};
PeerConnection.prototype.close = function () {
this.pc.close();
this.emit('close');
};
module.exports = PeerConnection;
},{"webrtcsupport":1,"wildemitter":2}]},{},[3])(3)
});
;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc