Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 10 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 35 additions and 36 deletions.
  1. +33 −33 index.js
  2. +2 −3 package.json
View
66 index.js
@@ -2,12 +2,12 @@ module.exports = (function(){
var RTCSessionDescription = require('rtc-session-description');
var SDP = require('sdp');
- var uuid = require('uuid');
var RTCPeerConnection = function(configuration,constraints) {
this.configuration = configuration;
this.constraints = constraints;
+ this.id = (new Date()).valueOf();
this.localDescription = null; // a RTCSessionDescription
this.remoteDescription = null; // a RTCSessionDescription
@@ -64,15 +64,13 @@ module.exports = (function(){
createOffer: function(success,failure,constraints) {
// generate SDP: complete set (since this is an offer)
- this.id = new uuid();
var session = this.localSDPSession();
var sdp = new RTCSessionDescription({type:'offer',sdp:session.toSDP()});
success(sdp);
},
createAnswer: function(success,failure,constraints) {
// generate SDP: restricted set (since this is an answer)
- this.id = new uuid();
var session = this.localSDPSession();
// See http://datatracker.ietf.org/doc/draft-ietf-rtcweb-jsep/ for 'answer' vs 'pranswer'
var sdp = new RTCSessionDescription({type:'answer',sdp:session.toSDP()});
@@ -92,6 +90,7 @@ module.exports = (function(){
},
setLocalDescription: function(description,success,failure) {
+ var self = this;
// If this RTCPeerConnection object's signaling state is closed, the user agent MUST throw an InvalidStateError exception and abort this operation.
if(this.signalingState === 'closed') {
throw new InvalidStateError();
@@ -111,73 +110,74 @@ module.exports = (function(){
session,
function() {
// If connection's signaling state is closed, then abort these steps.
- if(this.signalingState === 'closed') {
+ if(self.signalingState === 'closed') {
return
}
// Set connection's description attribute (localDescription or remoteDescription depending on the setting operation) to the RTCSessionDescription argument.
- this.localDescription = description;
- this._localSession = session;
+ self.localDescription = description;
+ self._localSession = session;
// If the local description was set, connection's ice gathering state is new, and the local description contains media, then set connection's ice gathering state to gathering.
// If the local description was set with content that caused an ICE restart, then set connection's ice gathering state to gathering.
- if(this.iceGatheringState === 'new') {
- this.iceGatheringState = 'gathering';
+ if(self.iceGatheringState === 'new') {
+ self.iceGatheringState = 'gathering';
}
// Set connection's signalingState accordingly.
- switch(this.signalingState + '.' + description.type) {
+ switch(self.signalingState + '.' + description.type) {
case 'stable.answer':
- this.signalingState = 'have-local-offer';
+ self.signalingState = 'have-local-offer';
break;
case 'have-local-offer.offer':
// same state
break;
case 'have-remote-offer.answer':
- this.signalingState = 'stable';
+ self.signalingState = 'stable';
break;
case 'have-remote-offer.pranswer':
- this.signalingState = 'have-local-pranswer';
+ self.signalingState = 'have-local-pranswer';
break;
case 'have-local-pranswer.pranswer':
// same state
break;
case 'have-local-pranswer.answer':
- this.signalingState = 'stable';
+ self.signalingState = 'stable';
break;
// other state transitions are invalid, actually
}
// Fire a simple event named signalingstatechange at connection.
- if(this.onsignalingstatechange) {
- this.onsignalingstatechange({}); // FIXME: Event
+ if(self.onsignalingstatechange) {
+ self.onsignalingstatechange({}); // FIXME: Event
}
// Queue a new task that, if connection's signalingState is not closed, invokes the successCallback.
- if(this.signalingState !== 'closed') {
+ if(self.signalingState !== 'closed') {
success();
}
// EXTRA: Simulate ICE gathering process is done:
- this.iceGatheringState = 'completed';
- if(this.onicecandidate) {
- this.onicecandidate(null);
+ self.iceGatheringState = 'completed';
+ if(self.onicecandidate) {
+ self.onicecandidate({ candidate: null }); // FIXME candidate
}
},
function() {
- if(this.signalingState !== 'closed') {
+ if(self.signalingState !== 'closed') {
failure({name:' IncompatibleSessionDescriptionError'});
}
}
);
},
setRemoteDescription: function(description,success,failure) {
+ var self = this;
// If this RTCPeerConnection object's signaling state is closed, the user agent MUST throw an InvalidStateError exception and abort this operation.
if(this.signalingState === 'closed') {
throw new InvalidStateError();
}
// FIXME: should we accumulate like this?
- var session = SDP.parse(description,this._remoteSession);
+ var session = SDP.parse(description.sdp,this._remoteSession);
if(!session) {
if(this.signalingState !== 'closed') {
@@ -189,47 +189,47 @@ module.exports = (function(){
session,
function() {
// If connection's signaling state is closed, then abort these steps.
- if(this.signalingState === 'closed') {
+ if(self.signalingState === 'closed') {
return
}
// Set connection's description attribute (localDescription or remoteDescription depending on the setting operation) to the RTCSessionDescription argument.
- this.remoteDescription = description;
- this._remoteSession = session;
+ self.remoteDescription = description;
+ self._remoteSession = session;
// Set connection's signalingState accordingly.
- switch(this.signalingState + '.' + description.type) {
+ switch(self.signalingState + '.' + description.type) {
case 'stable.offer':
- this.signalingState = 'have-remote-offer';
+ self.signalingState = 'have-remote-offer';
break;
case 'have-remote-offer.offer':
// same state
break;
case 'have-local-offer.answer':
- this.signalingState = 'stable';
+ self.signalingState = 'stable';
break;
case 'have-local-offer.pranswer':
- this.signalingState = 'have-remote-pranswer';
+ self.signalingState = 'have-remote-pranswer';
break;
case 'have-remote-pranswer.pranswer':
// same state
break;
case 'have-remote-pranswer.answer':
- this.signalingState = 'stable';
+ self.signalingState = 'stable';
break;
// other state transitions are invalid, actually
}
// Fire a simple event named signalingstatechange at connection.
- if(this.onsignalingstatechange) {
- this.onsignalingstatechange({}); // FIXME: Event
+ if(self.onsignalingstatechange) {
+ self.onsignalingstatechange({}); // FIXME: Event
}
// Queue a new task that, if connection's signalingState is not closed, invokes the successCallback.
- if(this.signalingState !== 'closed') {
+ if(self.signalingState !== 'closed') {
success();
}
},
function() {
- if(this.signalingState !== 'closed') {
+ if(self.signalingState !== 'closed') {
failure({name:' IncompatibleSessionDescriptionError'});
}
}
View
5 package.json
@@ -1,6 +1,6 @@
{
"name": "rtc-peer-connection",
- "version": "0.1.11",
+ "version": "0.1.16",
"description": "RTCPeerConnection for Node.js",
"main": "index.js",
"scripts": {
@@ -18,7 +18,6 @@
"homepage": "https://github.com/shimaore/node-rtc-peer-connection",
"dependencies": {
"sdp": "~0.3.1",
- "rtc-session-description": "0.0.1",
- "uuid": "~1.4.1"
+ "rtc-session-description": "0.0.1"
}
}

No commit comments for this range

Something went wrong with that request. Please try again.