forked from lynckia/licode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send SDP as JSON instead of String between clients and Erizo (lynckia…
- Loading branch information
Showing
31 changed files
with
2,300 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
class CandidateInfo { | ||
constructor(foundation, componentId, transport, priority, address, port, | ||
type, generation, relAddr, relPort) { | ||
this.foundation = foundation; | ||
this.componentId = componentId; | ||
this.transport = transport; | ||
this.priority = priority; | ||
this.address = address; | ||
this.port = port; | ||
this.type = type; | ||
this.generation = generation; | ||
this.relAddr = relAddr; | ||
this.relPort = relPort; | ||
} | ||
|
||
clone() { | ||
return new CandidateInfo(this.foundation, this.componentId, this.transport, this.priority, | ||
this.address, this.port, this.type, this.generation, this.relAddr, this.relPort); | ||
} | ||
|
||
plain() { | ||
const plain = { | ||
foundation: this.foundation, | ||
componentId: this.componentId, | ||
transport: this.transport, | ||
priority: this.priority, | ||
address: this.address, | ||
port: this.port, | ||
type: this.type, | ||
generation: this.generation, | ||
}; | ||
if (this.relAddr) plain.relAddr = this.relAddr; | ||
if (this.relPort) plain.relPort = this.relPort; | ||
return plain; | ||
} | ||
|
||
getFoundation() { | ||
return this.foundation; | ||
} | ||
|
||
getComponentId() { | ||
return this.componentId; | ||
} | ||
|
||
getTransport() { | ||
return this.transport; | ||
} | ||
|
||
getPriority() { | ||
return this.priority; | ||
} | ||
|
||
getAddress() { | ||
return this.address; | ||
} | ||
|
||
getPort() { | ||
return this.port; | ||
} | ||
|
||
getType() { | ||
return this.type; | ||
} | ||
|
||
getGeneration() { | ||
return this.generation; | ||
} | ||
|
||
getRelAddr() { | ||
return this.relAddr; | ||
} | ||
|
||
getRelPort() { | ||
return this.relPort; | ||
} | ||
|
||
} | ||
|
||
module.exports = CandidateInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
class CodecInfo { | ||
|
||
constructor(codec, type, rate, encoding, params, feedback) { | ||
this.codec = codec; | ||
this.type = type; | ||
this.rate = rate; | ||
this.encoding = encoding; | ||
this.params = params || {}; | ||
this.feedback = feedback || []; | ||
} | ||
|
||
clone() { | ||
const cloned = new CodecInfo(this.codec, this.type, this.rate, this.encoding, | ||
this.params, this.feedback); | ||
if (this.rtx) { | ||
cloned.setRTX(this.rtx); | ||
} | ||
return cloned; | ||
} | ||
|
||
|
||
plain() { | ||
return { | ||
codec: this.codec, | ||
type: this.type, | ||
rate: this.rate, | ||
encoding: this.encoding, | ||
params: this.params, | ||
feedback: this.feedback, | ||
}; | ||
} | ||
|
||
setRTX(rtx) { | ||
this.rtx = rtx; | ||
} | ||
|
||
getType() { | ||
return this.type; | ||
} | ||
|
||
setType(type) { | ||
this.type = type; | ||
} | ||
|
||
getCodec() { | ||
return this.codec; | ||
} | ||
|
||
getParams() { | ||
return this.params; | ||
} | ||
|
||
hasRTX() { | ||
return this.rtx; | ||
} | ||
|
||
getRTX() { | ||
return this.rtx; | ||
} | ||
|
||
getRate() { | ||
return this.rate; | ||
} | ||
|
||
getEncoding() { | ||
return this.encoding; | ||
} | ||
|
||
getFeedback() { | ||
return this.feedback; | ||
} | ||
} | ||
|
||
CodecInfo.mapFromNames = (names, rtx) => { | ||
const codecs = new Map(); | ||
|
||
let dyn = 96; | ||
names.forEach((nameWithUpperCases) => { | ||
let pt; | ||
const name = nameWithUpperCases.toLowerCase(); | ||
if (name === 'pcmu') pt = 0; | ||
else if (name === 'pcma') pt = 8; | ||
else { | ||
dyn += 1; | ||
pt = dyn; | ||
} | ||
const codec = new CodecInfo(name, pt); | ||
if (rtx && name !== 'ulpfec' && name !== 'flexfec-03' && name !== 'red') { | ||
dyn += 1; | ||
codec.setRTX(dyn); | ||
} | ||
codecs.set(codec.getCodec().toLowerCase(), codec); | ||
}); | ||
return codecs; | ||
}; | ||
|
||
module.exports = CodecInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const Setup = require('./Setup'); | ||
|
||
class DTLSInfo { | ||
constructor(setup, hash, fingerprint) { | ||
this.setup = setup; | ||
this.hash = hash; | ||
this.fingerprint = fingerprint; | ||
} | ||
|
||
clone() { | ||
return new DTLSInfo(this.setup, this.hash, this.fingerprint); | ||
} | ||
|
||
plain() { | ||
return { | ||
setup: Setup.toString(this.setup), | ||
hash: this.hash, | ||
fingerprint: this.fingerprint, | ||
}; | ||
} | ||
|
||
getFingerprint() { | ||
return this.fingerprint; | ||
} | ||
|
||
getHash() { | ||
return this.hash; | ||
} | ||
|
||
getSetup() { | ||
return this.setup; | ||
} | ||
|
||
setSetup(setup) { | ||
this.setup = setup; | ||
} | ||
} | ||
|
||
module.exports = DTLSInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const Enum = require('./Enum'); | ||
|
||
const Direction = Enum('SENDRECV', 'SENDONLY', 'RECVONLY', 'INACTIVE'); | ||
|
||
Direction.byValue = direction => Direction[direction.toUpperCase()]; | ||
|
||
/** | ||
* Get Direction name | ||
* @memberOf Direction | ||
* @param {Direction} direction | ||
* @returns {String} | ||
*/ | ||
Direction.toString = (direction) => { | ||
switch (direction) { | ||
case Direction.SENDRECV: | ||
return 'sendrecv'; | ||
case Direction.SENDONLY: | ||
return 'sendonly'; | ||
case Direction.RECVONLY: | ||
return 'recvonly'; | ||
case Direction.INACTIVE: | ||
return 'inactive'; | ||
default: | ||
return 'unknown'; | ||
} | ||
}; | ||
|
||
Direction.reverse = (direction) => { | ||
switch (direction) { | ||
case Direction.SENDRECV: | ||
return Direction.SENDRECV; | ||
case Direction.SENDONLY: | ||
return Direction.RECVONLY; | ||
case Direction.RECVONLY: | ||
return Direction.SENDONLY; | ||
case Direction.INACTIVE: | ||
return Direction.INACTIVE; | ||
default: | ||
return Direction.SENDRECV; | ||
} | ||
}; | ||
|
||
module.exports = Direction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const Enum = require('./Enum'); | ||
|
||
const DirectionWay = Enum('SEND', 'RECV'); | ||
|
||
DirectionWay.byValue = direction => DirectionWay[direction.toUpperCase()]; | ||
|
||
DirectionWay.toString = (direction) => { | ||
switch (direction) { | ||
case DirectionWay.SEND: | ||
return 'send'; | ||
case DirectionWay.RECV: | ||
return 'recv'; | ||
default: | ||
return 'unknown'; | ||
} | ||
}; | ||
|
||
DirectionWay.reverse = (direction) => { | ||
switch (direction) { | ||
case DirectionWay.SEND: | ||
return DirectionWay.RECV; | ||
case DirectionWay.RECV: | ||
return DirectionWay.SEND; | ||
default: | ||
return DirectionWay.SEND; | ||
} | ||
}; | ||
|
||
module.exports = DirectionWay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
function Enum(...args) { | ||
if (!(this instanceof Enum)) { | ||
return new (Function.prototype.bind.apply(Enum, | ||
[null].concat(Array.prototype.slice.call(args))))(); | ||
} | ||
Array.from(args).forEach((arg) => { | ||
this[arg] = Symbol.for(`LICODE_SEMANTIC_SDP_${arg}`); | ||
}); | ||
} | ||
|
||
module.exports = Enum; |
Oops, something went wrong.