From 914ff764136817854df063fc2364b2091f0b6f28 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Fri, 11 May 2018 11:26:56 +0200 Subject: [PATCH 01/10] Fix build script and generation of Eclipse CDT --- erizo/buildProject.sh | 14 ++++---------- erizo/generateEclipseProject.sh | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/erizo/buildProject.sh b/erizo/buildProject.sh index cb1d332b74..6ae9ef7b64 100755 --- a/erizo/buildProject.sh +++ b/erizo/buildProject.sh @@ -3,23 +3,17 @@ set -e BIN_DIR="build" -OBJ_DIR="CMakeFiles" buildAll() { if [ -d $BIN_DIR ]; then - cd $BIN_DIR - for d in */ ; do - echo "Building $d - $*" - cd $d - make $* - cd .. + for entry in "$BIN_DIR"/* + do + echo "Building directory: $entry with flags $*" + make -C $entry $* done - cd .. else echo "Error, build directory does not exist, run generateProject.sh first" fi } - - buildAll $* diff --git a/erizo/generateEclipseProject.sh b/erizo/generateEclipseProject.sh index 235d104bec..a060853c5a 100755 --- a/erizo/generateEclipseProject.sh +++ b/erizo/generateEclipseProject.sh @@ -6,7 +6,7 @@ BIN_DIR="build" if [ -d $BIN_DIR ]; then cd $BIN_DIR # Set to Debug to be able to debug in Eclipse - cmake -G"Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=debug ../src + cmake -G "Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=debug ../build/debug echo "Done" cd .. else From 8ce3034b00175b6621730aaaa4a650691d903e6d Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Fri, 11 May 2018 11:57:06 +0200 Subject: [PATCH 02/10] add release --- erizo/generateEclipseProject.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/erizo/generateEclipseProject.sh b/erizo/generateEclipseProject.sh index a060853c5a..20bb0c0015 100755 --- a/erizo/generateEclipseProject.sh +++ b/erizo/generateEclipseProject.sh @@ -7,6 +7,7 @@ if [ -d $BIN_DIR ]; then cd $BIN_DIR # Set to Debug to be able to debug in Eclipse cmake -G "Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=debug ../build/debug + cmake -G "Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=release ../build/release echo "Done" cd .. else From c9dc44414ed1e8655c7e516998be7306585a870c Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Fri, 11 May 2018 12:10:32 +0200 Subject: [PATCH 03/10] modify generateEclipseProject --- erizo/generateEclipseProject.sh | 34 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/erizo/generateEclipseProject.sh b/erizo/generateEclipseProject.sh index 20bb0c0015..4f853bcdae 100755 --- a/erizo/generateEclipseProject.sh +++ b/erizo/generateEclipseProject.sh @@ -1,15 +1,25 @@ #!/usr/bin/env bash - set -e -BIN_DIR="build" -if [ -d $BIN_DIR ]; then - cd $BIN_DIR - # Set to Debug to be able to debug in Eclipse - cmake -G "Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=debug ../build/debug - cmake -G "Eclipse CDT4 - Unix Makefiles" -D ERIZO_BUILD_TYPE=release ../build/release - echo "Done" - cd .. -else - echo "Error, build directory does not exist, run generateProject.sh first" -fi +SCRIPT=`pwd`/$0 +FILENAME=`basename $SCRIPT` +PATHNAME=`dirname $SCRIPT` +BASE_BIN_DIR="build" + + +generateVersion() { + echo "generating $1" + BIN_DIR="$BASE_BIN_DIR/$1" + if [ -d $BIN_DIR ]; then + cd $BIN_DIR + else + mkdir -p $BIN_DIR + cd $BIN_DIR + fi + cmake ../../src "-DERIZO_BUILD_TYPE=$1" -G"Eclipse CDT4 - Unix Makefiles" + cd $PATHNAME +} + + +generateVersion debug +generateVersion release From de3d7a465f939bdce44ae65e5aea2d8f2ca804e4 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Fri, 11 May 2018 12:11:29 +0200 Subject: [PATCH 04/10] revert buildProject --- erizo/buildProject.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/erizo/buildProject.sh b/erizo/buildProject.sh index 6ae9ef7b64..cb1d332b74 100755 --- a/erizo/buildProject.sh +++ b/erizo/buildProject.sh @@ -3,17 +3,23 @@ set -e BIN_DIR="build" +OBJ_DIR="CMakeFiles" buildAll() { if [ -d $BIN_DIR ]; then - for entry in "$BIN_DIR"/* - do - echo "Building directory: $entry with flags $*" - make -C $entry $* + cd $BIN_DIR + for d in */ ; do + echo "Building $d - $*" + cd $d + make $* + cd .. done + cd .. else echo "Error, build directory does not exist, run generateProject.sh first" fi } + + buildAll $* From 013e8a5b6eac505e3c6d1c7df54e939f4bb678f2 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Wed, 16 May 2018 12:21:41 +0200 Subject: [PATCH 05/10] force codec clientside --- doc/client_api.md | 10 ++++-- erizo_controller/erizoClient/src/Room.js | 10 ++++-- .../erizoClient/src/utils/SdpHelpers.js | 20 +++++++++++ .../src/webrtc-stacks/BaseStack.js | 34 +++++++++++++++++++ nuve/nuveAPI/resource/tokensResource.js | 3 +- 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/doc/client_api.md b/doc/client_api.md index 09f3b46b86..424370dbde 100644 --- a/doc/client_api.md +++ b/doc/client_api.md @@ -321,6 +321,12 @@ Typical Room initialization would be: var room = Erizo.Room({token:'213h8012hwduahd-321ueiwqewq'}); ``` +You can also pass an optional parameter which will force the codecs specified in createroom also in p2p (default is false) + +``` +var room = Erizo.Room({token:'213h8012hwduahd-321ueiwqewq', forceCodecs: true}); +``` + It will create the room object by passing the token this users have previously received from your service. This token is has to be retreived using the [Server API](/server_api), because it is a user access token. But you need to call to the connect function we will see later in order to connect to the room. You can access some variables like: @@ -396,8 +402,8 @@ room.publish(localStream, {forceTurn: true}); ``` There are two options that allow advance control of video bitrate in Chrome: -- `startVideoBW`: Configures Chrome to start sending video at the specified bitrate instead of the default one. -- `hardMinVideoBW`: Configures a hard limit for the minimum video bitrate. +- `startVideoBW`: Configures Chrome to start sending video at the specified bitrate instead of the default one. +- `hardMinVideoBW`: Configures a hard limit for the minimum video bitrate. ``` room.publish(localStream, {startVideoBW: 1000, hardMinVideoBW:500}); diff --git a/erizo_controller/erizoClient/src/Room.js b/erizo_controller/erizoClient/src/Room.js index 7fb227fa13..3d7862cd0c 100644 --- a/erizo_controller/erizoClient/src/Room.js +++ b/erizo_controller/erizoClient/src/Room.js @@ -31,6 +31,7 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { that.roomID = ''; that.state = DISCONNECTED; that.p2p = false; + that.forceCodecs = spec.forceCodecs || false; that.ConnectionHelpers = altConnectionHelpers === undefined ? ConnectionHelpers : altConnectionHelpers; @@ -114,6 +115,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { limitMaxAudioBW: spec.maxAudioBW, limitMaxVideoBW: spec.maxVideoBW, forceTurn: stream.forceTurn, + mediaConfiguration: that.mediaConfiguration, + forceCodecs: that.forceCodecs, p2p: true, }; return options; @@ -177,6 +180,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { label: stream.getLabel(), iceServers: that.iceServers, forceTurn: stream.forceTurn, + mediaConfiguration: that.mediaConfiguration, + forceCodecs: that.forceCodecs, p2p: false, }; if (!isRemote) { @@ -573,7 +578,7 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { // It stablishes a connection to the room. // Once it is done it throws a RoomEvent("room-connected") that.connect = (options = {}) => { - const token = Base64.decodeBase64(spec.token); + const token = JSON.parse(Base64.decodeBase64(spec.token)); if (that.state !== DISCONNECTED) { Logger.warning('Room already connected'); @@ -581,7 +586,7 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { // 1- Connect to Erizo-Controller that.state = CONNECTING; - socket.connect(JSON.parse(token), options, (response) => { + socket.connect(token, options, (response) => { let stream; const streamList = []; const streams = response.streams || []; @@ -590,6 +595,7 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => { that.p2p = response.p2p; that.iceServers = response.iceServers; that.state = CONNECTED; + that.mediaConfiguration = token.mediaConfiguration; spec.singlePC = response.singlePC; spec.defaultVideoBW = response.defaultVideoBW; spec.maxVideoBW = response.maxVideoBW; diff --git a/erizo_controller/erizoClient/src/utils/SdpHelpers.js b/erizo_controller/erizoClient/src/utils/SdpHelpers.js index 68f83e76e3..de077c7546 100644 --- a/erizo_controller/erizoClient/src/utils/SdpHelpers.js +++ b/erizo_controller/erizoClient/src/utils/SdpHelpers.js @@ -62,4 +62,24 @@ SdpHelpers.setParamForCodecs = (sdpInfo, mediaType, paramName, value) => { }); }; +SdpHelpers.forceCodecs = (sdp, codecs) => { + const video = sdp.getMedia('video'); + const audio = sdp.getMedia('audio'); + if (video) { + video.getCodecs().forEach((codec, index) => { + if (codec.codec.toLowerCase() !== codecs.video.toLowerCase()) { + sdp.getMedia('video').getCodecs().delete(index); + } + }); + } + if (audio) { + audio.getCodecs().forEach((codec, index) => { + if (codec.codec.toLowerCase() !== codecs.audio.toLowerCase()) { + sdp.getMedia('audio').getCodecs().delete(index); + } + }); + } +}; + + export default SdpHelpers; diff --git a/erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js b/erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js index fe31d4dc7d..090f2dc4f7 100644 --- a/erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js +++ b/erizo_controller/erizoClient/src/webrtc-stacks/BaseStack.js @@ -16,6 +16,22 @@ const BaseStack = (specInput) => { let isNegotiating = false; let latestSessionVersion = -1; + const parseMediaConfiguration = () => { + const codecs = { audio: null, video: null }; + switch (specBase.mediaConfiguration) { + case 'default': + codecs.video = 'VP8'; + codecs.audio = 'OPUS'; + break; + default: + codecs.video = specBase.mediaConfiguration.split('_AND_')[0]; + codecs.audio = specBase.mediaConfiguration.split('_AND_')[1]; + } + return codecs; + }; + + const codecs = parseMediaConfiguration(); + Logger.info('Starting Base stack', specBase); that.pcConfig = { @@ -96,6 +112,9 @@ const BaseStack = (specInput) => { localDesc.sdp = that.enableSimulcast(localDesc.sdp); } localSdp = SemanticSdp.SDPInfo.processString(localDesc.sdp); + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(localSdp, codecs); + } SdpHelpers.setMaxBW(localSdp, specBase); localDesc.sdp = localSdp.toString(); that.localSdp = localSdp; @@ -110,6 +129,9 @@ const BaseStack = (specInput) => { const setLocalDescForAnswerp2p = (sessionDescription) => { localDesc = sessionDescription; localSdp = SemanticSdp.SDPInfo.processString(localDesc.sdp); + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(localSdp, codecs); + } SdpHelpers.setMaxBW(localSdp, specBase); localDesc.sdp = localSdp.toString(); that.localSdp = localSdp; @@ -126,6 +148,9 @@ const BaseStack = (specInput) => { // Its an offer, we assume its p2p const msg = message; remoteSdp = SemanticSdp.SDPInfo.processString(msg.sdp); + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(remoteSdp, codecs); + } SdpHelpers.setMaxBW(remoteSdp, specBase); msg.sdp = remoteSdp.toString(); that.remoteSdp = remoteSdp; @@ -147,6 +172,9 @@ const BaseStack = (specInput) => { Logger.info('Set remote and local description'); latestSessionVersion = sessionVersion; + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(remoteSdp, codecs); + } SdpHelpers.setMaxBW(remoteSdp, specBase); that.setStartVideoBW(remoteSdp); that.setHardMinVideoBW(remoteSdp); @@ -265,6 +293,9 @@ const BaseStack = (specInput) => { } localSdp = SemanticSdp.SDPInfo.processString(localDesc.sdp); + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(localSdp, codecs); + } SdpHelpers.setMaxBW(localSdp, specBase); localDesc.sdp = localSdp.toString(); that.localSdp = localSdp; @@ -274,6 +305,9 @@ const BaseStack = (specInput) => { that.peerConnection.setLocalDescription(localDesc) .then(() => { remoteSdp = SemanticSdp.SDPInfo.processString(remoteDesc.sdp); + if (specBase.forceCodecs) { + SdpHelpers.forceCodecs(remoteSdp, codecs); + } SdpHelpers.setMaxBW(remoteSdp, specBase); remoteDesc.sdp = remoteSdp.toString(); that.remoteSdp = remoteSdp; diff --git a/nuve/nuveAPI/resource/tokensResource.js b/nuve/nuveAPI/resource/tokensResource.js index 909d4ced90..f63dba1c78 100644 --- a/nuve/nuveAPI/resource/tokensResource.js +++ b/nuve/nuveAPI/resource/tokensResource.js @@ -31,7 +31,8 @@ var getTokenString = function (id, token) { tokenId: id, host: token.host, secure: token.secure, - signature: signed + signature: signed, + mediaConfiguration: token.mediaConfiguration }, tokenS = (new Buffer(JSON.stringify(tokenJ))).toString('base64'); From 35979a6edccf7f41938bd552d4951f9140c5a91c Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Wed, 16 May 2018 12:48:43 +0200 Subject: [PATCH 06/10] Added option in basicexample --- extras/basic_example/public/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/basic_example/public/script.js b/extras/basic_example/public/script.js index 3d493f74f1..4c55a5c40a 100644 --- a/extras/basic_example/public/script.js +++ b/extras/basic_example/public/script.js @@ -54,6 +54,7 @@ window.onload = function () { var mediaConfiguration = getParameterByName('mediaConfiguration') || 'default'; var onlySubscribe = getParameterByName('onlySubscribe'); var onlyPublish = getParameterByName('onlyPublish'); + var forceCodecs = getParameterByName('forceCodecs') || false; console.log('Selected Room', roomName, 'of type', roomType); var config = {audio: true, video: true, @@ -93,7 +94,7 @@ window.onload = function () { createToken(roomData, function (response) { var token = response; console.log(token); - room = Erizo.Room({token: token}); + room = Erizo.Room({token: token, forceCodecs: forceCodecs}); var subscribeToStreams = function (streams) { if (onlyPublish) { From 13fe8a75d7bdf0f36e67f1d4218344c2bc25bfd7 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Wed, 16 May 2018 13:18:27 +0200 Subject: [PATCH 07/10] fix unit test --- nuve/nuveAPI/test/resource/tokensResource.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nuve/nuveAPI/test/resource/tokensResource.js b/nuve/nuveAPI/test/resource/tokensResource.js index 58e24b6bfe..0dfb0661aa 100644 --- a/nuve/nuveAPI/test/resource/tokensResource.js +++ b/nuve/nuveAPI/test/resource/tokensResource.js @@ -108,9 +108,9 @@ describe('Tokens Resource', function() { setUserStub.returns('username'); serviceRegistryMock.getRoomForService.callsArgWith(2, kArbitraryRoom); cloudHandlerMock.getErizoControllerForRoom.callsArgWith(1, kArbitraryErizoController); - var token = 'eyJ0b2tlbklkIjoic3RyaW5nIiwiaG9zdCI6Imhvc3RuYW1lOjMwMDAiLCJzZWN1cmUiOnRyd' + - 'WUsInNpZ25hdHVyZSI6Ik5UYzBORGRpTWpneE5ERXhZek5oTkRVMlkyRXpZVFF3TVRGbE1HVT' + - 'FZelJoWVRoaE1UQXlaUT09In0='; + var token = 'eyJ0b2tlbklkIjoic3RyaW5nIiwiaG9zdCI6Imhvc3RuYW1lOjMwMDAiLCJzZWN1cm' + + 'UiOnRydWUsInNpZ25hdHVyZSI6Ik5UYzBORGRpTWpneE5ERXhZek5oTkRVMlkyRXpZ' + + 'VFF3TVRGbE1HVTFZelJoWVRoaE1UQXlaUT09IiwibWVkaWFDb25maWd1cmF0aW9uIjoiZGVmYXVsdCJ9'; tokenRegistryMock.addToken.callsArgWith(1, 'string'); request(app) .post('/rooms/1/tokens') From 92749f6c3d462c62de56ac38024f0a0ac3f2eaf5 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Wed, 16 May 2018 14:07:46 +0200 Subject: [PATCH 08/10] lint --- nuve/nuveAPI/test/resource/tokensResource.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nuve/nuveAPI/test/resource/tokensResource.js b/nuve/nuveAPI/test/resource/tokensResource.js index 0dfb0661aa..fd4134f283 100644 --- a/nuve/nuveAPI/test/resource/tokensResource.js +++ b/nuve/nuveAPI/test/resource/tokensResource.js @@ -108,9 +108,9 @@ describe('Tokens Resource', function() { setUserStub.returns('username'); serviceRegistryMock.getRoomForService.callsArgWith(2, kArbitraryRoom); cloudHandlerMock.getErizoControllerForRoom.callsArgWith(1, kArbitraryErizoController); - var token = 'eyJ0b2tlbklkIjoic3RyaW5nIiwiaG9zdCI6Imhvc3RuYW1lOjMwMDAiLCJzZWN1cm' + - 'UiOnRydWUsInNpZ25hdHVyZSI6Ik5UYzBORGRpTWpneE5ERXhZek5oTkRVMlkyRXpZ' + - 'VFF3TVRGbE1HVTFZelJoWVRoaE1UQXlaUT09IiwibWVkaWFDb25maWd1cmF0aW9uIjoiZGVmYXVsdCJ9'; + var token = 'eyJ0b2tlbklkIjoic3RyaW5nIiwiaG9zdCI6Imhvc3RuYW1lOjMwMDAiLCJzZWN1cmUiOnR' + + 'ydWUsInNpZ25hdHVyZSI6Ik5UYzBORGRpTWpneE5ERXhZek5oTkRVMlkyRXpZVFF3TVRGbE' + + '1HVTFZelJoWVRoaE1UQXlaUT09IiwibWVkaWFDb25maWd1cmF0aW9uIjoiZGVmYXVsdCJ9'; tokenRegistryMock.addToken.callsArgWith(1, 'string'); request(app) .post('/rooms/1/tokens') From 87d765aa6c2cb0c9a4f05ac8a0703990578b1516 Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Thu, 31 May 2018 16:12:56 +0200 Subject: [PATCH 09/10] Added automatic thread detection --- scripts/installErizo.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/installErizo.sh b/scripts/installErizo.sh index 76c3d33a8a..07c581044d 100755 --- a/scripts/installErizo.sh +++ b/scripts/installErizo.sh @@ -13,6 +13,12 @@ PREFIX_DIR=$LIB_DIR/build/ NVM_CHECK="$PATHNAME"/checkNvm.sh FAST_MAKE='' +NUM_CORES=1; +if [ "$(uname)" == "Darwin" ]; then + NUM_CORES=$(sysctl -n hw.ncpu); +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + NUM_CORES=$(grep -c ^processor /proc/cpuinfo); +fi export ERIZO_HOME=$ROOT/erizo @@ -128,8 +134,9 @@ else execute_tests ;; f) - FAST_MAKE='-j4' - FAST_BUILD='env JOBS=4' + FAST_MAKE="-j$NUM_CORES" + FAST_BUILD="env JOBS=$NUM_CORES" + echo "Compiling using $NUM_CORES threads" ;; d) DELETE_OBJECT_FILES='true' From 91940cce12c9f56396996cfe84b418ed4eef411f Mon Sep 17 00:00:00 2001 From: Francesco Durighetto Date: Mon, 4 Jun 2018 10:24:49 +0200 Subject: [PATCH 10/10] revert to run cmake every time --- erizo/generateProject.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erizo/generateProject.sh b/erizo/generateProject.sh index c58e4286a9..58abdf62fe 100755 --- a/erizo/generateProject.sh +++ b/erizo/generateProject.sh @@ -10,11 +10,13 @@ BASE_BIN_DIR="build" generateVersion() { echo "generating $1" BIN_DIR="$BASE_BIN_DIR/$1" - if [ ! -d $BIN_DIR ]; then + if [ -d $BIN_DIR ]; then + cd $BIN_DIR + else mkdir -p $BIN_DIR cd $BIN_DIR - cmake ../../src "-DERIZO_BUILD_TYPE=$1" fi + cmake ../../src "-DERIZO_BUILD_TYPE=$1" cd $PATHNAME }