Skip to content

Commit

Permalink
Send SDP as JSON instead of String between clients and Erizo (lynckia…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Nov 28, 2017
1 parent de02b82 commit ebc66a8
Show file tree
Hide file tree
Showing 31 changed files with 2,300 additions and 190 deletions.
20 changes: 8 additions & 12 deletions erizoAPI/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
'target_name': 'addon',
'sources': ['<@(common_sources)'],
'include_dirs' : ['<@(common_include_dirs)'],
'libraries': ['-L$(ERIZO_HOME)/build/release/erizo -lerizo -Wl,-rpath,./../../erizo/build/release/erizo'],
'libraries': ['-L$(ERIZO_HOME)/build/release/erizo -lerizo -Wl,-rpath,<(module_root_dir)/../erizo/build/release/erizo'],
'conditions': [
[ 'OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', # -fno-exceptions
'GCC_ENABLE_CPP_RTTI': 'YES', # -fno-rtti
'MACOSX_DEPLOYMENT_TARGET' : '10.11', #from MAC OS 10.7
'OTHER_CFLAGS': [
'-g -O3 -stdlib=libc++ -std=c++11',
]
'GCC_ENABLE_CPP_RTTI': 'YES', # -fno-rtti
'MACOSX_DEPLOYMENT_TARGET' : '10.11', #from MAC OS 10.7
'OTHER_CFLAGS': ['-g -O3 -stdlib=libc++ -std=c++11',]
},
}, { # OS!="mac"
'cflags!' : ['-fno-exceptions'],
Expand All @@ -32,16 +30,14 @@
'target_name': 'addonDebug',
'sources': ['<@(common_sources)'],
'include_dirs' : ['<@(common_include_dirs)'],
'libraries': ['-L$(ERIZO_HOME)/build/debug/erizo -lerizo -Wl,-rpath,./../../erizo/build/debug/erizo'],
'libraries': ['-L$(ERIZO_HOME)/build/debug/erizo -lerizo -Wl,-rpath,<(module_root_dir)/../erizo/build/debug/erizo'],
'conditions': [
[ 'OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', # -fno-exceptions
'GCC_ENABLE_CPP_RTTI': 'YES', # -fno-rtti
'MACOSX_DEPLOYMENT_TARGET' : '10.11', #from MAC OS 10.7
'OTHER_CFLAGS': [
'-g -O3 -stdlib=libc++ -std=c++11',
]
'GCC_ENABLE_CPP_RTTI': 'YES', # -fno-rtti
'MACOSX_DEPLOYMENT_TARGET' : '10.11', #from MAC OS 10.7
'OTHER_CFLAGS': ['-g -O3 -stdlib=libc++ -std=c++11',]
},
}, { # OS!="mac"
'cflags!' : ['-fno-exceptions'],
Expand Down
79 changes: 79 additions & 0 deletions erizo_controller/common/semanticSdp/CandidateInfo.js
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;
97 changes: 97 additions & 0 deletions erizo_controller/common/semanticSdp/CodecInfo.js
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;
39 changes: 39 additions & 0 deletions erizo_controller/common/semanticSdp/DTLSInfo.js
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;
43 changes: 43 additions & 0 deletions erizo_controller/common/semanticSdp/Direction.js
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;
29 changes: 29 additions & 0 deletions erizo_controller/common/semanticSdp/DirectionWay.js
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;
12 changes: 12 additions & 0 deletions erizo_controller/common/semanticSdp/Enum.js
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;
Loading

0 comments on commit ebc66a8

Please sign in to comment.