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 1.0.0 to 1.0.1

2

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

@@ -5,0 +5,0 @@ "main": "rtcpeerconnection.js",

@@ -12,2 +12,3 @@ # RTCPeerConnection

It also applies the SDP hack for lifting data transfer speed limits imposed by chrome by default. It modifies the "AS" or application specific maximum bandwidth setting from 30 kilobits / sec to 100 Mbps. This is really handy for file transfers, etc. It can be disabled by passing `{sdpHack: false}` as part of your config as passed in the first argument.

@@ -32,4 +33,7 @@ ## Installing

// init it like a normal peer connection object
// passing in ice servers/constraints
var pc = new PeerConnection({servers}, {constraints});
// passing in ice servers/constraints the initial server config
// also takes a couple other options:
// sdpHack: false (to not use the SDP hack as described above)
// debug: true (to log out all emitted events)
var pc = new PeerConnection({config servers as usual}, {constraints as to regular PC});
```

@@ -92,3 +96,3 @@

// assumptions
var pc = new PeerConnection(servers, constraints);
var pc = new PeerConnection(config, constraints);
var connection = new RealTimeConnection(); // could be socket.io or whatever

@@ -95,0 +99,0 @@

@@ -184,2 +184,3 @@ (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;

function PeerConnection(config, constraints) {
var item;
this.pc = new webrtc.PeerConnection(config, constraints);

@@ -199,3 +200,14 @@ WildEmitter.call(this);

if (config.debug) {
// whether to use SDP hack for faster data transfer
this.config = {
debug: false,
sdpHack: true
};
// apply our config
for (item in config) {
this.config[item] = config[item];
}
if (this.config.debug) {
this.on('*', function (eventName, event) {

@@ -240,6 +252,7 @@ var logger = config.logger || console;

this.pc.createOffer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('offer', sessionDescription);
if (callback) callback(null, sessionDescription);
function (offer) {
offer.sdp = self._applySdpHack(offer.sdp);
self.pc.setLocalDescription(offer);
self.emit('offer', offer);
if (callback) callback(null, offer);
},

@@ -307,6 +320,7 @@ function (err) {

this.pc.createAnswer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('answer', sessionDescription);
if (cb) cb(null, sessionDescription);
function (answer) {
answer.sdp = self._applySdpHack(answer.sdp);
self.pc.setLocalDescription(answer);
self.emit('answer', answer);
if (cb) cb(null, answer);
}, function (err) {

@@ -341,2 +355,14 @@ self.emit('error', err);

// SDP hack for increasing AS (application specific) data transfer speed allowed in chrome
PeerConnection.prototype._applySdpHack = function (sdp) {
if (!this.config.sdpHack) return sdp;
var parts = sdp.split('b=AS:30');
if (parts.length === 2) {
// increase max data transfer bandwidth to 100 Mbps
return parts[0] + 'b=AS:102400' + parts[1];
} else {
return sdp;
}
};
module.exports = PeerConnection;

@@ -343,0 +369,0 @@

@@ -6,2 +6,3 @@ var WildEmitter = require('wildemitter');

function PeerConnection(config, constraints) {
var item;
this.pc = new webrtc.PeerConnection(config, constraints);

@@ -21,3 +22,14 @@ WildEmitter.call(this);

if (config.debug) {
// whether to use SDP hack for faster data transfer
this.config = {
debug: false,
sdpHack: true
};
// apply our config
for (item in config) {
this.config[item] = config[item];
}
if (this.config.debug) {
this.on('*', function (eventName, event) {

@@ -62,6 +74,7 @@ var logger = config.logger || console;

this.pc.createOffer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('offer', sessionDescription);
if (callback) callback(null, sessionDescription);
function (offer) {
offer.sdp = self._applySdpHack(offer.sdp);
self.pc.setLocalDescription(offer);
self.emit('offer', offer);
if (callback) callback(null, offer);
},

@@ -129,6 +142,7 @@ function (err) {

this.pc.createAnswer(
function (sessionDescription) {
self.pc.setLocalDescription(sessionDescription);
self.emit('answer', sessionDescription);
if (cb) cb(null, sessionDescription);
function (answer) {
answer.sdp = self._applySdpHack(answer.sdp);
self.pc.setLocalDescription(answer);
self.emit('answer', answer);
if (cb) cb(null, answer);
}, function (err) {

@@ -163,2 +177,14 @@ self.emit('error', err);

// SDP hack for increasing AS (application specific) data transfer speed allowed in chrome
PeerConnection.prototype._applySdpHack = function (sdp) {
if (!this.config.sdpHack) return sdp;
var parts = sdp.split('b=AS:30');
if (parts.length === 2) {
// increase max data transfer bandwidth to 100 Mbps
return parts[0] + 'b=AS:102400' + parts[1];
} else {
return sdp;
}
};
module.exports = PeerConnection;
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