Skip to content

Commit

Permalink
Add options to erizo build process (lynckia#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun authored Sep 15, 2017
1 parent 630a49e commit c9168ea
Show file tree
Hide file tree
Showing 20 changed files with 185 additions and 62 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ jobs:
- run:
name: Lint Erizo
command: |
docker run --rm -ti -w /opt/licode/erizo/build/ --entrypoint /bin/bash lynckia/licode:develop -c "make lint"
docker run --rm -ti -w /opt/licode/erizo/build/release --entrypoint /bin/bash lynckia/licode:develop -c "make lint"
- run:
name: Unit Tests Erizo
command: |
docker run --rm -ti -w /opt/licode/erizo/build/ --entrypoint /bin/bash lynckia/licode:develop -c "ctest --verbose"
docker run --rm -ti -w /opt/licode/erizo/build/debug --entrypoint /bin/bash lynckia/licode:develop -c "ctest --verbose"
docker run --rm -ti -w /opt/licode/erizo/build/release --entrypoint /bin/bash lynckia/licode:develop -c "ctest --verbose"
- run:
name: Lint Javascript
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir /opt/licode/.git
# Clone and install licode
WORKDIR /opt/licode/scripts

RUN ./installErizo.sh -feacs && \
RUN ./installErizo.sh -dfeacs && \
./../nuve/installNuve.sh && \
./installBasicExample.sh

Expand Down
26 changes: 20 additions & 6 deletions erizo/buildProject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@
set -e

BIN_DIR="build"
if [ -d $BIN_DIR ]; then
cd $BIN_DIR
make $*
else
echo "Error, build directory does not exist, run generateProject.sh first"
fi
OBJ_DIR="CMakeFiles"

buildAll() {
if [ -d $BIN_DIR ]; then
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 $*
32 changes: 32 additions & 0 deletions erizo/cleanObjectFiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

BIN_DIR="build"
OBJ_DIR="CMakeFiles"

maybeRemoveObjDir() {
if [ -d $OBJ_DIR ]; then
rm -rf $OBJ_DIR
fi
}

cleanAll() {
if [ -d $BIN_DIR ]; then
cd $BIN_DIR
for RELEASE_DIR in */ ; do
echo "cleaning $RELEASE_DIR"
cd $RELEASE_DIR
maybeRemoveObjDir
for INTERNAL_DIR in */ ; do
cd $INTERNAL_DIR
maybeRemoveObjDir
cd ..
done
cd ..
done
cd ..
fi
}

cleanAll
34 changes: 21 additions & 13 deletions erizo/generateProject.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#!/usr/bin/env bash

set -e

runcmake() {
cmake ../src
echo "Done"
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"
cd $PATHNAME
}
BIN_DIR="build"
if [ -d $BIN_DIR ]; then
cd $BIN_DIR
runcmake
else
mkdir $BIN_DIR
cd $BIN_DIR
runcmake
fi


generateVersion release
generateVersion debug
11 changes: 9 additions & 2 deletions erizo/src/erizo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8)

project (ERIZO)

set(ERIZO_VERSION_MAJOR 0)
set(ERIZO_VERSION_MINOR 1)
set(CMAKE_CXX_FLAGS "-g -Wall -std=c++11 ${ERIZO_CMAKE_CXX_FLAGS}")
if(${ERIZO_BUILD_TYPE} STREQUAL "debug")
message("Generating DEBUG project")
set(CMAKE_CXX_FLAGS "-g -Wall -std=c++11 ${ERIZO_CMAKE_CXX_FLAGS}")
else()
message("Generating RELEASE project")
set(CMAKE_CXX_FLAGS "-g -Wall -O3 -std=c++11 ${ERIZO_CMAKE_CXX_FLAGS}")
endif()


include_directories("${ERIZO_SOURCE_DIR}" "${THIRD_PARTY_INCLUDE}" "${NICER_INCLUDE}")

Expand Down
3 changes: 1 addition & 2 deletions erizo/src/erizo/SrtpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ std::string octet_string_hex_string(const void *s, int length) {
}

const uint8_t *str = (const uint8_t*)s;
int i;
int i = 0;

char bit_string[kKeyStringLength * 2];

for (i = 0; i < kKeyStringLength * 2; i += 2) {
bit_string[i] = nibble_to_hex_char(*str >> 4);
bit_string[i + 1] = nibble_to_hex_char(*str++ & 0xF);
}
bit_string[i] = 0; /* null terminate string */
return std::string(bit_string);
}

Expand Down
25 changes: 14 additions & 11 deletions erizo/src/erizo/media/ExternalInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ int ExternalInput::init() {

// VideoCodecInfo info;
MediaInfo om;
AVStream *st, *audio_st;
AVStream *st = nullptr;
AVStream *audio_st = nullptr;

int streamNo = av_find_best_stream(context_, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
if (streamNo < 0) {
Expand Down Expand Up @@ -108,16 +109,18 @@ int ExternalInput::init() {
decodedBuffer_.reset((unsigned char*) malloc(100000));
MediaInfo om;
om.processorType = PACKAGE_ONLY;
if (audio_st->codec->codec_id == AV_CODEC_ID_PCM_MULAW) {
ELOG_DEBUG("PCM U8");
om.audioCodec.sampleRate = 8000;
om.audioCodec.codec = AUDIO_CODEC_PCM_U8;
om.rtpAudioInfo.PT = PCMU_8000_PT;
} else if (audio_st->codec->codec_id == AV_CODEC_ID_OPUS) {
ELOG_DEBUG("OPUS");
om.audioCodec.sampleRate = 48000;
om.audioCodec.codec = AUDIO_CODEC_OPUS;
om.rtpAudioInfo.PT = OPUS_48000_PT;
if (audio_st) {
if (audio_st->codec->codec_id == AV_CODEC_ID_PCM_MULAW) {
ELOG_DEBUG("PCM U8");
om.audioCodec.sampleRate = 8000;
om.audioCodec.codec = AUDIO_CODEC_PCM_U8;
om.rtpAudioInfo.PT = PCMU_8000_PT;
} else if (audio_st->codec->codec_id == AV_CODEC_ID_OPUS) {
ELOG_DEBUG("OPUS");
om.audioCodec.sampleRate = 48000;
om.audioCodec.codec = AUDIO_CODEC_OPUS;
om.rtpAudioInfo.PT = OPUS_48000_PT;
}
}
op_.reset(new OutputProcessor());
op_->init(om, this);
Expand Down
2 changes: 1 addition & 1 deletion erizo/src/erizo/media/MediaProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int InputProcessor::decodeAudio(unsigned char* inBuff, int inBuffLen, unsigned c
}

AVPacket avpkt;
int outSize;
int outSize = 0;
int decSize = 0;
int len = -1;
uint8_t *decBuff = reinterpret_cast<uint8_t*>(malloc(16000));
Expand Down
2 changes: 1 addition & 1 deletion erizo/src/erizo/media/codecs/AudioCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int AudioDecoder::initDecoder(AVCodecContext* context) {
int AudioDecoder::decodeAudio(unsigned char* inBuff, int inBuffLen,
unsigned char* outBuff, int outBuffLen, int* gotFrame) {
AVPacket avpkt;
int outSize;
int outSize = 0;
int decSize = 0;
int len = -1;
uint8_t *decBuff = reinterpret_cast<uint8_t*>(malloc(16000));
Expand Down
5 changes: 4 additions & 1 deletion erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void BandwidthEstimationHandler::updateExtensionMaps(std::array<RTPExtensions, 1
}

void BandwidthEstimationHandler::updateExtensionMap(bool is_video, std::array<RTPExtensions, 10> map) {
webrtc::RTPExtensionType type;
webrtc::RTPExtensionType type = webrtc::kRtpExtensionNone;
for (uint8_t id = 0; id < 10; id++) {
RTPExtensions extension = map[id];
switch (extension) {
Expand All @@ -131,6 +131,9 @@ void BandwidthEstimationHandler::updateExtensionMap(bool is_video, std::array<RT
type = webrtc::kRtpExtensionPlayoutDelay;
break;
}
if (type == webrtc::kRtpExtensionNone) {
continue;
}
if (is_video) {
ext_map_video_.RegisterByType(id, type);
} else {
Expand Down
3 changes: 2 additions & 1 deletion erizo/src/erizo/rtp/RtcpAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ int RtcpAggregator::analyzeFeedback(char *buf, int len) {
uint16_t currentNackPos = 0;
uint16_t blp = 0;
uint32_t lostPacketSeq = 0;
uint32_t calculatedlsr, delay, calculateLastSr, extendedSeqNo;
uint32_t delay = 0;
uint32_t calculatedlsr, calculateLastSr, extendedSeqNo;

do {
movingBuf += rtcpLength;
Expand Down
34 changes: 31 additions & 3 deletions erizoAPI/binding.gyp
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
{
'variables' : {
'common_sources': [ 'addon.cc', 'IOThreadPool.cc', 'ThreadPool.cc', 'WebRtcConnection.cc', 'OneToManyProcessor.cc', 'ExternalInput.cc', 'ExternalOutput.cc', 'SyntheticInput.cc'],
'common_include_dirs' : ["<!(node -e \"require('nan')\")", '$(ERIZO_HOME)/src/erizo', '$(ERIZO_HOME)/../build/libdeps/build/include', '$(ERIZO_HOME)/src/third_party/webrtc/src']
},
'targets': [
{
'target_name': 'addon',
'sources': [ 'addon.cc', 'IOThreadPool.cc', 'ThreadPool.cc', 'WebRtcConnection.cc', 'OneToManyProcessor.cc', 'ExternalInput.cc', 'ExternalOutput.cc', 'SyntheticInput.cc'],
'include_dirs' : ["<!(node -e \"require('nan')\")", '$(ERIZO_HOME)/src/erizo', '$(ERIZO_HOME)/../build/libdeps/build/include', '$(ERIZO_HOME)/src/third_party/webrtc/src'],
'libraries': ['-L$(ERIZO_HOME)/build/erizo', '-lerizo'],
'sources': ['<@(common_sources)'],
'include_dirs' : ['<@(common_include_dirs)'],
'libraries': ['-L$(ERIZO_HOME)/build/release/erizo -lerizo -Wl,-rpath,./../../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',
]
},
}, { # OS!="mac"
'cflags!' : ['-fno-exceptions'],
'cflags' : ['-D__STDC_CONSTANT_MACROS'],
'cflags_cc' : ['-Wall', '-O3', '-g' , '-std=c++11', '-fexceptions'],
'cflags_cc!' : ['-fno-exceptions'],
'cflags_cc!' : ['-fno-rtti']
}],
]
},
{
'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'],
'conditions': [
[ 'OS=="mac"', {
'xcode_settings': {
Expand Down
19 changes: 14 additions & 5 deletions erizo_controller/erizoAgent/erizoAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GLOBAL.config.erizoAgent.useIndividualLogFiles =
GLOBAL.config.erizoAgent.useIndividualLogFiles|| false;

var BINDED_INTERFACE_NAME = GLOBAL.config.erizoAgent.networkInterface;
const LAUNCH_SCRIPT = './launch.sh';

// Parse command line arguments
var getopt = new Getopt([
Expand All @@ -30,6 +31,7 @@ var getopt = new Getopt([
['P' , 'prerun-processes=ARG' , 'Default video Bandwidth'],
['I' , 'individual-logs' , 'Use individual log files for ErizoJS processes'],
['m' , 'metadata=ARG' , 'JSON metadata'],
['d' , 'debug' , 'Run erizoJS with debug library'],
['h' , 'help' , 'display this help']
]);

Expand All @@ -39,7 +41,8 @@ var interfaces = require('os').networkInterfaces(),
k2,
address,
privateIP,
publicIP;
publicIP,
launchDebugErizoJS;

var opt = getopt.parse(process.argv.slice(2));

Expand Down Expand Up @@ -76,11 +79,13 @@ for (var prop in opt.options) {
case 'individual-logs':
GLOBAL.config.erizoAgent = GLOBAL.config.erizoAgent || {};
GLOBAL.config.erizoAgent.useIndividualLogFiles = true;

break;
case 'metadata':
metadata = JSON.parse(value);
break;
case 'debug':
launchDebugErizoJS = true;
break;
default:
GLOBAL.config.erizoAgent[prop] = value;
break;
Expand Down Expand Up @@ -114,7 +119,6 @@ var guid = (function() {
})();

var myErizoAgentId = guid();

var launchErizoJS;

var fillErizos = function () {
Expand All @@ -131,13 +135,18 @@ launchErizoJS = function() {
log.debug('message: launching ErizoJS, erizoId: ' + id);
var fs = require('fs');
var erizoProcess, out, err;
const erizoLaunchOptions = ['./../erizoJS/erizoJS.js', id, privateIP, publicIP];
if (launchDebugErizoJS) {
erizoLaunchOptions.push('-d');
}

if (GLOBAL.config.erizoAgent.useIndividualLogFiles){
out = fs.openSync(GLOBAL.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a');
err = fs.openSync(GLOBAL.config.erizoAgent.instanceLogDir + '/erizo-' + id + '.log', 'a');
erizoProcess = spawn('./launch.sh', ['./../erizoJS/erizoJS.js', id, privateIP, publicIP],
erizoProcess = spawn(LAUNCH_SCRIPT, erizoLaunchOptions,
{ detached: true, stdio: [ 'ignore', out, err ] });
}else{
erizoProcess = spawn('./launch.sh', ['./../erizoJS/erizoJS.js', id, privateIP, publicIP],
erizoProcess = spawn(LAUNCH_SCRIPT, erizoLaunchOptions,
{ detached: true, stdio: [ 'ignore', 'pipe', 'pipe' ] });
erizoProcess.stdout.setEncoding('utf8');
erizoProcess.stdout.on('data', function (message) {
Expand Down
2 changes: 0 additions & 2 deletions erizo_controller/erizoAgent/launch.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/../../erizo/build/erizo
ulimit -c unlimited

exec node $ERIZOJS_NODE_OPTIONS $*
5 changes: 5 additions & 0 deletions erizo_controller/erizoJS/erizoJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var getopt = new Getopt([
['T' , 'turnport=ARG' , 'TURN server PORT'],
['c' , 'turnusername=ARG' , 'TURN username'],
['C' , 'turnpass=ARG' , 'TURN password'],
['d', 'debug' , 'Run Debug erizoAPI addon'],
['h' , 'help' , 'display this help']
]);

Expand Down Expand Up @@ -63,6 +64,10 @@ for (var prop in opt.options) {
GLOBAL.config.logger = GLOBAL.config.logger || {};
GLOBAL.config.logger.configFile = value;
break;
case 'debug':
console.log('Loading debug version');
addon = require('./../../erizoAPI/build/Release/addonDebug');
break;
default:
GLOBAL.config.erizo[prop] = value;
break;
Expand Down
2 changes: 1 addition & 1 deletion erizo_controller/initErizo_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ NVM_CHECK="$LICODE_ROOT"/scripts/checkNvm.sh

cd $ROOT/erizoAgent
nvm use
node erizoAgent.js &
node erizoAgent.js $* &

cd $CURRENT_DIR
Loading

0 comments on commit c9168ea

Please sign in to comment.