From 27749a4bcca5008cab9e2f00d7b948f55496a185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cervi=C3=B1o?= Date: Wed, 20 Nov 2019 14:40:00 +0100 Subject: [PATCH] Update to Node v12 (#1500) --- .nvmrc | 2 +- erizo/src/erizo/dtls/DtlsClient.cpp | 26 ++++++- erizo/src/erizo/dtls/DtlsSocket.cpp | 20 ++--- erizo/src/erizo/dtls/DtlsSocket.h | 2 + erizo/src/erizo/dtls/bf_dwrap.c | 77 +++++++++---------- erizo/src/erizo/dtls/bf_dwrap.h | 10 +-- erizoAPI/AsyncPromiseWorker.cc | 4 +- erizoAPI/ConnectionDescription.cc | 50 ++++++------ erizoAPI/ExternalInput.cc | 4 +- erizoAPI/ExternalOutput.cc | 6 +- erizoAPI/IOThreadPool.cc | 4 +- erizoAPI/MediaStream.cc | 50 ++++++------ erizoAPI/OneToManyProcessor.cc | 8 +- erizoAPI/SyntheticInput.cc | 8 +- erizoAPI/ThreadPool.cc | 4 +- erizoAPI/WebRtcConnection.cc | 69 +++++++++-------- erizoAPI/package.json | 6 +- .../erizoClient/gulp/erizoTasks.js | 4 +- erizo_controller/erizoClient/gulpfile.js | 30 +++----- erizo_controller/package.json | 1 + package.json | 5 +- 21 files changed, 199 insertions(+), 191 deletions(-) diff --git a/.nvmrc b/.nvmrc index 1f9205dd07..47c0a98a11 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -6.14.4 +12.13.0 diff --git a/erizo/src/erizo/dtls/DtlsClient.cpp b/erizo/src/erizo/dtls/DtlsClient.cpp index ba6c3af4d2..5d7cf979a8 100644 --- a/erizo/src/erizo/dtls/DtlsClient.cpp +++ b/erizo/src/erizo/dtls/DtlsClient.cpp @@ -25,7 +25,6 @@ extern "C" { #include #include "./DtlsSocket.h" -#include "./bf_dwrap.h" using dtls::DtlsSocketContext; using dtls::DtlsSocket; @@ -42,7 +41,7 @@ static std::mutex* array_mutex; DEFINE_LOGGER(DtlsSocketContext, "dtls.DtlsSocketContext"); log4cxx::LoggerPtr sslLogger(log4cxx::Logger::getLogger("dtls.SSL")); - +#if OPENSSL_VERSION_NUMBER < 0x10100000 static void ssl_lock_callback(int mode, int type, const char* file, int line) { if (mode & CRYPTO_LOCK) { array_mutex[type].lock(); @@ -50,22 +49,34 @@ static void ssl_lock_callback(int mode, int type, const char* file, int line) { array_mutex[type].unlock(); } } - -static unsigned long ssl_thread_id() { // NOLINT +#if OPENSSL_VERSION_NUMBER < 0x10000000 +unsigned long ssl_thread_id() { // NOLINT return (unsigned long)std::hash()(std::this_thread::get_id()); // NOLINT } +#else +void ssl_thread_id(CRYPTO_THREADID *id) { // NOLINT + CRYPTO_THREADID_set_numeric(id, (unsigned long)std::hash()(std::this_thread::get_id()); // NOLINT +} +#endif +#endif +#if OPENSSL_VERSION_NUMBER < 0x10100000 static int ssl_thread_setup() { array_mutex = new std::mutex[CRYPTO_num_locks()]; if (!array_mutex) { return 0; } else { +#if OPENSSL_VERSION_NUMBER < 0x10000000 CRYPTO_set_id_callback(ssl_thread_id); +#else + CRYPTO_THREADID_set_callback(ssl_thread_id); +#endif CRYPTO_set_locking_callback(ssl_lock_callback); } return 1; } +#endif static int ssl_thread_cleanup() { if (!array_mutex) { @@ -298,6 +309,7 @@ int createCert(const std::string& pAor, int expireDays, int keyLen, X509*& outCe } void DtlsSocketContext::Init() { +#if OPENSSL_VERSION_NUMBER < 0x10100000 ssl_thread_setup(); if (DtlsSocketContext::mCert == nullptr) { OpenSSL_add_all_algorithms(); @@ -306,6 +318,12 @@ int createCert(const std::string& pAor, int expireDays, int keyLen, X509*& outCe ERR_load_crypto_strings(); createCert("sip:licode@lynckia.com", 365, 1024, DtlsSocketContext::mCert, DtlsSocketContext::privkey); } +#else + if (DtlsSocketContext::mCert == nullptr) { + OPENSSL_init_ssl(0, NULL); + createCert("sip:licode@lynckia.com", 365, 1024, DtlsSocketContext::mCert, DtlsSocketContext::privkey); + } +#endif } void DtlsSocketContext::Destroy() { diff --git a/erizo/src/erizo/dtls/DtlsSocket.cpp b/erizo/src/erizo/dtls/DtlsSocket.cpp index dc1eefae78..2d8ddd6fe8 100644 --- a/erizo/src/erizo/dtls/DtlsSocket.cpp +++ b/erizo/src/erizo/dtls/DtlsSocket.cpp @@ -9,8 +9,6 @@ #include "./config.h" #endif -#include "./bf_dwrap.h" - using dtls::DtlsSocket; using dtls::SrtpSessionKeys; using std::memcpy; @@ -32,8 +30,6 @@ DtlsSocket::DtlsSocket(DtlsSocketContext* socketContext, enum SocketType type): mSsl = SSL_new(mContext); assert(mSsl != 0); SSL_set_mtu(mSsl, DTLS_MTU); - mSsl->ctx = mContext; - mSsl->session_ctx = mContext; switch (type) { case Client: @@ -48,13 +44,16 @@ DtlsSocket::DtlsSocket(DtlsSocketContext* socketContext, enum SocketType type): default: assert(0); } - BIO* memBIO1 = BIO_new(BIO_s_mem()); - mInBio = BIO_new(BIO_f_dwrap()); - BIO_push(mInBio, memBIO1); - BIO* memBIO2 = BIO_new(BIO_s_mem()); - mOutBio = BIO_new(BIO_f_dwrap()); - BIO_push(mOutBio, memBIO2); + dwrap_bio_method = BIO_f_dwrap(); + + BIO* mem_in_BIO = BIO_new(BIO_s_mem()); + mInBio = BIO_new(dwrap_bio_method); + BIO_push(mInBio, mem_in_BIO); + + BIO* mem_out_BIO = BIO_new(BIO_s_mem()); + mOutBio = BIO_new(dwrap_bio_method); + BIO_push(mOutBio, mem_out_BIO); SSL_set_bio(mSsl, mInBio, mOutBio); SSL_accept(mSsl); @@ -71,6 +70,7 @@ void DtlsSocket::close() { ELOG_DEBUG("SSL Shutdown"); SSL_shutdown(mSsl); SSL_free(mSsl); + BIO_f_wrap_destroy(dwrap_bio_method); mSsl = NULL; } } diff --git a/erizo/src/erizo/dtls/DtlsSocket.h b/erizo/src/erizo/dtls/DtlsSocket.h index e99cef8b8f..5645a423f9 100644 --- a/erizo/src/erizo/dtls/DtlsSocket.h +++ b/erizo/src/erizo/dtls/DtlsSocket.h @@ -17,6 +17,7 @@ extern "C" { #include #include +#include "dtls/bf_dwrap.h" #include "../logger.h" const int SRTP_MASTER_KEY_KEY_LEN = 16; @@ -117,6 +118,7 @@ class DtlsSocket { DtlsSocketContext* mSocketContext; // OpenSSL context data + BIO_METHOD *dwrap_bio_method; SSL *mSsl; BIO *mInBio; BIO *mOutBio; diff --git a/erizo/src/erizo/dtls/bf_dwrap.c b/erizo/src/erizo/dtls/bf_dwrap.c index 2fb1b7948b..ac1a733282 100644 --- a/erizo/src/erizo/dtls/bf_dwrap.c +++ b/erizo/src/erizo/dtls/bf_dwrap.c @@ -4,10 +4,10 @@ #include #include -#define BIO_TYPE_DWRAP (50 | 0x0400 | 0x0200) +#define BIO_TYPE_DWRAP (50|0x0400|0x0200) -static int dwrap_new(BIO *bio); -static int dwrap_free(BIO *a); +static int dwrap_create(BIO *bio); +static int dwrap_destroy(BIO *a); static int dwrap_read(BIO *b, char *out, int outl); static int dwrap_write(BIO *b, const char *in, int inl); static int dwrap_puts(BIO *b, const char *in); @@ -15,48 +15,47 @@ static int dwrap_gets(BIO *b, char *buf, int size); static long dwrap_ctrl(BIO *b, int cmd, long num, void *ptr); // NOLINT(runtime/int) static long dwrap_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp); // NOLINT(runtime/int) -static BIO_METHOD methods_dwrap = { - BIO_TYPE_DWRAP, - "dtls_wrapper", - dwrap_write, - dwrap_read, - dwrap_puts, - dwrap_gets, - dwrap_ctrl, - dwrap_new, - dwrap_free, - dwrap_callback_ctrl -}; - typedef struct BIO_F_DWRAP_CTX_ { int dgram_timer_exp; } BIO_F_DWRAP_CTX; BIO_METHOD *BIO_f_dwrap(void) { - return(&methods_dwrap); + BIO_METHOD *method = BIO_meth_new(BIO_TYPE_DWRAP, "dtls_wrapper"); + BIO_meth_set_write(method, dwrap_write); + BIO_meth_set_read(method, dwrap_read); + BIO_meth_set_puts(method, dwrap_puts); + BIO_meth_set_ctrl(method, dwrap_ctrl); + BIO_meth_set_gets(method, dwrap_gets); + BIO_meth_set_create(method, dwrap_create); + BIO_meth_set_destroy(method, dwrap_destroy); + BIO_meth_set_callback_ctrl(method, dwrap_callback_ctrl); + return method; +} + +void BIO_f_wrap_destroy(BIO_METHOD *method) { + BIO_meth_free(method); } -static int dwrap_new(BIO *bi) { - BIO_F_DWRAP_CTX *ctx = OPENSSL_malloc(sizeof(BIO_F_BUFFER_CTX)); +static int dwrap_create(BIO *bi) { + BIO_F_DWRAP_CTX *ctx = OPENSSL_malloc(sizeof(BIO_F_DWRAP_CTX)); if (!ctx) return(0); - memset(ctx, 0, sizeof(BIO_F_BUFFER_CTX)); + memset(ctx, 0, sizeof(BIO_F_DWRAP_CTX)); - bi->init = 1; - bi->ptr = (char *)ctx; // NOLINT - bi->flags = 0; + BIO_set_init(bi, 1); + BIO_set_data(bi, (char *)ctx); // NOLINT + BIO_set_flags(bi, 0); return 1; } -static int dwrap_free(BIO *a) { +static int dwrap_destroy(BIO *a) { if (a == NULL) return 0; - - OPENSSL_free(a->ptr); - a->ptr = NULL; - a->init = 0; - a->flags = 0; + BIO_F_DWRAP_CTX *ctx = (BIO_F_DWRAP_CTX*)BIO_get_data(a); + OPENSSL_free(ctx); + BIO_set_init(a, 0); + BIO_set_flags(a, 0); return 1; } @@ -68,7 +67,8 @@ static int dwrap_read(BIO *b, char *out, int outl) { BIO_clear_retry_flags(b); - ret = BIO_read(b->next_bio, out, outl); + BIO *next = BIO_next(b); + ret = BIO_read(next, out, outl); if (ret <= 0) { BIO_copy_next_retry(b); @@ -82,7 +82,9 @@ static int dwrap_write(BIO *b, const char *in, int inl) { return 0; } - int ret = BIO_write(b->next_bio, in, inl); + BIO *next = BIO_next(b); + + int ret = BIO_write(next, in, inl); return ret; } @@ -102,7 +104,7 @@ static long dwrap_ctrl(BIO *b, int cmd, long num, void *ptr) { // NOLINT(runtim long ret; // NOLINT(runtime/int) BIO_F_DWRAP_CTX *ctx; - ctx = b->ptr; + ctx = (BIO_F_DWRAP_CTX*) BIO_get_data(b); switch (cmd) { case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: @@ -120,7 +122,7 @@ static long dwrap_ctrl(BIO *b, int cmd, long num, void *ptr) { // NOLINT(runtim ret = 1; break; default: - ret = BIO_ctrl(b->next_bio, cmd, num, ptr); + ret = BIO_ctrl(BIO_next(b), cmd, num, ptr); break; } @@ -130,32 +132,26 @@ static long dwrap_ctrl(BIO *b, int cmd, long num, void *ptr) { // NOLINT(runtim static long dwrap_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { // NOLINT(runtime/int) long ret; // NOLINT(runtime/int) - ret = BIO_callback_ctrl(b->next_bio, cmd, fp); + ret = BIO_callback_ctrl(BIO_next(b), cmd, fp); return ret; } /* ==================================================================== - Copyright (c) 2007-2008, Eric Rescorla and Derek MacDonald All rights reserved. - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. None of the contributors names may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -167,5 +163,4 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ==================================================================== */ diff --git a/erizo/src/erizo/dtls/bf_dwrap.h b/erizo/src/erizo/dtls/bf_dwrap.h index 2975e3c8d2..2f065c9c16 100644 --- a/erizo/src/erizo/dtls/bf_dwrap.h +++ b/erizo/src/erizo/dtls/bf_dwrap.h @@ -2,31 +2,26 @@ #define ERIZO_SRC_ERIZO_DTLS_BF_DWRAP_H_ extern "C" { - BIO_METHOD *BIO_f_dwrap(void); + BIO_METHOD *BIO_f_dwrap(void); + void BIO_f_wrap_destroy(BIO_METHOD *method); } #endif // ERIZO_SRC_ERIZO_DTLS_BF_DWRAP_H_ /* ==================================================================== - Copyright (c) 2007-2008, Eric Rescorla and Derek MacDonald All rights reserved. - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. None of the contributors names may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -38,5 +33,4 @@ extern "C" { THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ==================================================================== */ diff --git a/erizoAPI/AsyncPromiseWorker.cc b/erizoAPI/AsyncPromiseWorker.cc index f05a4b3a7d..c57b9e8d31 100644 --- a/erizoAPI/AsyncPromiseWorker.cc +++ b/erizoAPI/AsyncPromiseWorker.cc @@ -14,12 +14,12 @@ void AsyncPromiseWorker::Execute() { void AsyncPromiseWorker::HandleOKCallback() { Nan::HandleScope scope; auto resolver = Nan::New(*_persistent); - resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()); + resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()).IsNothing(); } void AsyncPromiseWorker::HandleErrorCallback() { Nan::HandleScope scope; auto resolver = Nan::New(*_persistent); - resolver->Reject(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()); + resolver->Reject(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()).IsNothing(); } diff --git a/erizoAPI/ConnectionDescription.cc b/erizoAPI/ConnectionDescription.cc index a43724978c..2d9c38701d 100644 --- a/erizoAPI/ConnectionDescription.cc +++ b/erizoAPI/ConnectionDescription.cc @@ -20,7 +20,7 @@ using json = nlohmann::json; std::shared_ptr sdp = obj->me; std::string getString(v8::Local value) { - v8::String::Utf8Value value_str(Nan::To(value).ToLocalChecked()); \ + Nan::Utf8String value_str(Nan::To(value).ToLocalChecked()); \ return std::string(*value_str); } @@ -106,7 +106,7 @@ NAN_MODULE_INIT(ConnectionDescription::Init) { Nan::SetPrototypeMethod(tpl, "postProcessInfo", postProcessInfo); Nan::SetPrototypeMethod(tpl, "copyInfoFromSdp", copyInfoFromSdp); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("ConnectionDescription").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -131,7 +131,7 @@ NAN_METHOD(ConnectionDescription::New) { return; } - v8::String::Utf8Value json_param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String json_param(Nan::To(info[0]).ToLocalChecked()); std::string media_config_string = std::string(*json_param); json media_config = json::parse(media_config_string); @@ -211,7 +211,7 @@ NAN_METHOD(ConnectionDescription::setProfile) { NAN_METHOD(ConnectionDescription::setBundle) { GET_SDP(); - sdp->isBundle = info[0]->BooleanValue(); + sdp->isBundle = Nan::To(info[0]).FromJust(); } NAN_METHOD(ConnectionDescription::addBundleTag) { @@ -223,13 +223,13 @@ NAN_METHOD(ConnectionDescription::addBundleTag) { NAN_METHOD(ConnectionDescription::setRtcpMux) { GET_SDP(); - sdp->isRtcpMux = info[0]->BooleanValue(); + sdp->isRtcpMux = Nan::To(info[0]).FromJust(); } NAN_METHOD(ConnectionDescription::setAudioAndVideo) { GET_SDP(); - sdp->hasAudio = info[0]->BooleanValue(); - sdp->hasVideo = info[1]->BooleanValue(); + sdp->hasAudio = Nan::To(info[0]).FromJust(); + sdp->hasVideo = Nan::To(info[1]).FromJust(); } NAN_METHOD(ConnectionDescription::getProfile) { @@ -285,14 +285,14 @@ NAN_METHOD(ConnectionDescription::hasVideo) { NAN_METHOD(ConnectionDescription::setAudioSsrc) { GET_SDP(); std::string stream_id = getString(info[0]); - sdp->audio_ssrc_map[stream_id] = info[1]->IntegerValue(); + sdp->audio_ssrc_map[stream_id] = Nan::To(info[1]).FromJust(); } NAN_METHOD(ConnectionDescription::getAudioSsrcMap) { GET_SDP(); Local audio_ssrc_map = Nan::New(); for (auto const& audio_ssrcs : sdp->audio_ssrc_map) { - audio_ssrc_map->Set(Nan::New(audio_ssrcs.first.c_str()).ToLocalChecked(), + Nan::Set(audio_ssrc_map, Nan::New(audio_ssrcs.first.c_str()).ToLocalChecked(), Nan::New(audio_ssrcs.second)); } info.GetReturnValue().Set(audio_ssrc_map); @@ -305,8 +305,8 @@ NAN_METHOD(ConnectionDescription::setVideoSsrcList) { std::vector video_ssrc_list; for (unsigned int i = 0; i < video_ssrc_array->Length(); i++) { - v8::Handle val = video_ssrc_array->Get(i); - unsigned int numVal = val->IntegerValue(); + v8::Local val = Nan::Get(video_ssrc_array, i).ToLocalChecked(); + unsigned int numVal = Nan::To(val).FromJust(); video_ssrc_list.push_back(numVal); } @@ -322,7 +322,7 @@ NAN_METHOD(ConnectionDescription::getVideoSsrcMap) { for (uint32_t ssrc : video_ssrcs.second) { Nan::Set(array, index++, Nan::New(ssrc)); } - video_ssrc_map->Set(Nan::New(video_ssrcs.first.c_str()).ToLocalChecked(), array); + Nan::Set(video_ssrc_map, Nan::New(video_ssrcs.first.c_str()).ToLocalChecked(), array); } info.GetReturnValue().Set(video_ssrc_map); } @@ -422,7 +422,7 @@ NAN_METHOD(ConnectionDescription::getDtlsRole) { NAN_METHOD(ConnectionDescription::setVideoBandwidth) { GET_SDP(); - sdp->videoBandwidth = info[0]->IntegerValue(); + sdp->videoBandwidth = Nan::To(info[0]).FromJust(); } NAN_METHOD(ConnectionDescription::getVideoBandwidth) { @@ -446,11 +446,11 @@ NAN_METHOD(ConnectionDescription::addCandidate) { cand.mediaType = getMediaType(getString(info[0])); cand.foundation = getString(info[1]); - cand.componentId = info[2]->IntegerValue(); + cand.componentId = Nan::To(info[2]).FromJust(); cand.netProtocol = getString(info[3]); - cand.priority = info[4]->IntegerValue(); + cand.priority = Nan::To(info[4]).FromJust(); cand.hostAddress = getString(info[5]); - cand.hostPort = info[6]->IntegerValue(); + cand.hostPort = Nan::To(info[6]).FromJust(); // libnice does not support tcp candidates, we ignore them if (cand.netProtocol.compare("UDP") && cand.netProtocol.compare("udp")) { @@ -473,7 +473,7 @@ NAN_METHOD(ConnectionDescription::addCandidate) { if (cand.hostType == erizo::SRFLX || cand.hostType == erizo::RELAY) { cand.rAddress = getString(info[8]); - cand.rPort = info[9]->IntegerValue(); + cand.rPort = Nan::To(info[9]).FromJust(); } cand.sdp = getString(info[10]); @@ -635,7 +635,7 @@ NAN_METHOD(ConnectionDescription::getCodecs) { Local parameters = Nan::New(); std::map ¶ms = pt.format_parameters; for (auto const& param : params) { - parameters->Set(Nan::New(param.first).ToLocalChecked(), Nan::New(param.second).ToLocalChecked()); + Nan::Set(parameters, Nan::New(param.first).ToLocalChecked(), Nan::New(param.second).ToLocalChecked()); } Nan::Set(codec, Nan::New("params").ToLocalChecked(), parameters); @@ -652,7 +652,7 @@ NAN_METHOD(ConnectionDescription::getExtensions) { Local extensions = Nan::New(); for (erizo::ExtMap& extension : media_extensions) { - extensions->Set(Nan::New(extension.value), Nan::New(extension.uri).ToLocalChecked()); + Nan::Set(extensions, Nan::New(extension.value), Nan::New(extension.uri).ToLocalChecked()); } info.GetReturnValue().Set(extensions); } @@ -676,9 +676,9 @@ NAN_METHOD(ConnectionDescription::addRid) { NAN_METHOD(ConnectionDescription::addPt) { GET_SDP(); - unsigned int pt = info[0]->IntegerValue(); + unsigned int pt = Nan::To(info[0]).FromJust(); std::string codec_name = getString(info[1]); - unsigned int parsed_clock = info[2]->IntegerValue(); + unsigned int parsed_clock = Nan::To(info[2]).FromJust(); erizo::MediaType media = getMediaType(getString(info[3])); erizo::RtpMap new_mapping; @@ -691,7 +691,7 @@ NAN_METHOD(ConnectionDescription::addPt) { NAN_METHOD(ConnectionDescription::addExtension) { GET_SDP(); - unsigned int id = info[0]->IntegerValue(); + unsigned int id = Nan::To(info[0]).FromJust(); std::string uri = getString(info[1]); erizo::MediaType media = getMediaType(getString(info[2])); erizo::ExtMap anExt(id, uri); @@ -701,7 +701,7 @@ NAN_METHOD(ConnectionDescription::addExtension) { NAN_METHOD(ConnectionDescription::addFeedback) { GET_SDP(); - unsigned int pt = info[0]->IntegerValue(); + unsigned int pt = Nan::To(info[0]).FromJust(); std::string feedback = getString(info[1]); auto map_element = sdp->payload_parsed_map_.find(pt); if (map_element != sdp->payload_parsed_map_.end()) { @@ -716,7 +716,7 @@ NAN_METHOD(ConnectionDescription::addFeedback) { NAN_METHOD(ConnectionDescription::addParameter) { GET_SDP(); - unsigned int pt = info[0]->IntegerValue(); + unsigned int pt = Nan::To(info[0]).FromJust(); std::string option = getString(info[1]); std::string value = getString(info[2]); auto map_element = sdp->payload_parsed_map_.find(pt); @@ -736,7 +736,7 @@ NAN_METHOD(ConnectionDescription::getRids) { for (const erizo::Rid& rid : sdp->rids()) { std::ostringstream direction; direction << rid.direction; - rids->Set(Nan::New(rid.id).ToLocalChecked(), Nan::New(direction.str()).ToLocalChecked()); + Nan::Set(rids, Nan::New(rid.id).ToLocalChecked(), Nan::New(direction.str()).ToLocalChecked()); } info.GetReturnValue().Set(rids); } diff --git a/erizoAPI/ExternalInput.cc b/erizoAPI/ExternalInput.cc index d69701ea7b..70376b3dd2 100644 --- a/erizoAPI/ExternalInput.cc +++ b/erizoAPI/ExternalInput.cc @@ -53,12 +53,12 @@ NAN_MODULE_INIT(ExternalInput::Init) { Nan::SetPrototypeMethod(tpl, "setVideoReceiver", setVideoReceiver); Nan::SetPrototypeMethod(tpl, "generatePLIPacket", generatePLIPacket); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("ExternalInput").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } NAN_METHOD(ExternalInput::New) { - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string url = std::string(*param); ExternalInput* obj = new ExternalInput(); diff --git a/erizoAPI/ExternalOutput.cc b/erizoAPI/ExternalOutput.cc index 0c3625f837..70bd9db941 100644 --- a/erizoAPI/ExternalOutput.cc +++ b/erizoAPI/ExternalOutput.cc @@ -55,15 +55,15 @@ NAN_MODULE_INIT(ExternalOutput::Init) { Nan::SetPrototypeMethod(tpl, "close", close); Nan::SetPrototypeMethod(tpl, "init", init); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("ExternalOutput").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } NAN_METHOD(ExternalOutput::New) { ThreadPool* thread_pool = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); - v8::String::Utf8Value param(Nan::To(info[1]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[1]).ToLocalChecked()); std::string url = std::string(*param); - v8::String::Utf8Value json_param(Nan::To(info[2]).ToLocalChecked()); + Nan::Utf8String json_param(Nan::To(info[2]).ToLocalChecked()); std::string media_config_string = std::string(*json_param); json media_config = json::parse(media_config_string); std::vector rtp_mappings; diff --git a/erizoAPI/IOThreadPool.cc b/erizoAPI/IOThreadPool.cc index 0144e6b11a..ba852c568f 100644 --- a/erizoAPI/IOThreadPool.cc +++ b/erizoAPI/IOThreadPool.cc @@ -29,7 +29,7 @@ NAN_MODULE_INIT(IOThreadPool::Init) { Nan::SetPrototypeMethod(tpl, "close", close); Nan::SetPrototypeMethod(tpl, "start", start); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("IOThreadPool").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -38,7 +38,7 @@ NAN_METHOD(IOThreadPool::New) { Nan::ThrowError("Wrong number of arguments"); } - unsigned int num_workers = info[0]->IntegerValue(); + unsigned int num_workers = Nan::To(info[0]).FromJust(); IOThreadPool* obj = new IOThreadPool(); obj->me.reset(new erizo::IOThreadPool(num_workers)); diff --git a/erizoAPI/MediaStream.cc b/erizoAPI/MediaStream.cc index 24a42cef35..19d85c41e1 100644 --- a/erizoAPI/MediaStream.cc +++ b/erizoAPI/MediaStream.cc @@ -146,7 +146,7 @@ NAN_MODULE_INIT(MediaStream::Init) { Nan::SetPrototypeMethod(tpl, "enableHandler", enableHandler); Nan::SetPrototypeMethod(tpl, "disableHandler", disableHandler); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("MediaStream").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -165,13 +165,13 @@ NAN_METHOD(MediaStream::New) { std::shared_ptr wrtc = connection->me; - v8::String::Utf8Value paramId(Nan::To(info[2]).ToLocalChecked()); + Nan::Utf8String paramId(Nan::To(info[2]).ToLocalChecked()); std::string wrtc_id = std::string(*paramId); - v8::String::Utf8Value paramLabel(Nan::To(info[3]).ToLocalChecked()); + Nan::Utf8String paramLabel(Nan::To(info[3]).ToLocalChecked()); std::string stream_label = std::string(*paramLabel); - bool is_publisher = info[5]->BooleanValue(); + bool is_publisher = Nan::To(info[5]).FromJust(); std::shared_ptr worker = thread_pool->me->getLessUsedWorker(); @@ -190,7 +190,7 @@ NAN_METHOD(MediaStream::New) { NAN_METHOD(MediaStream::close) { MediaStream* obj = Nan::ObjectWrap::Unwrap(info.Holder()); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); obj->close().then( @@ -207,7 +207,7 @@ NAN_METHOD(MediaStream::init) { if (!me || obj->closed_) { return; } - bool force = info.Length() > 0 ? info[0]->BooleanValue() : false; + bool force = info.Length() > 0 ? Nan::To(info[0]).FromJust() : false; bool r = me->init(force); info.GetReturnValue().Set(Nan::New(r)); @@ -220,7 +220,7 @@ NAN_METHOD(MediaStream::setSlideShowMode) { return; } - bool v = info[0]->BooleanValue(); + bool v = Nan::To(info[0]).FromJust(); me->setSlideShowMode(v); info.GetReturnValue().Set(Nan::New(v)); } @@ -232,8 +232,8 @@ NAN_METHOD(MediaStream::muteStream) { return; } - bool mute_video = info[0]->BooleanValue(); - bool mute_audio = info[1]->BooleanValue(); + bool mute_video = Nan::To(info[0]).FromJust(); + bool mute_audio = Nan::To(info[1]).FromJust(); me->muteStream(mute_video, mute_audio); } @@ -244,7 +244,7 @@ NAN_METHOD(MediaStream::setMaxVideoBW) { return; } - int max_video_bw = info[0]->IntegerValue(); + int max_video_bw = Nan::To(info[0]).FromJust(); me->setMaxVideoBW(max_video_bw); } @@ -254,9 +254,9 @@ NAN_METHOD(MediaStream::setVideoConstraints) { if (!me || obj->closed_) { return; } - int max_video_width = info[0]->IntegerValue(); - int max_video_height = info[1]->IntegerValue(); - int max_video_frame_rate = info[2]->IntegerValue(); + int max_video_width = Nan::To(info[0]).FromJust(); + int max_video_height = Nan::To(info[1]).FromJust(); + int max_video_frame_rate = Nan::To(info[2]).FromJust(); me->setVideoConstraints(max_video_width, max_video_height, max_video_frame_rate); } @@ -267,7 +267,7 @@ NAN_METHOD(MediaStream::setMetadata) { return; } - v8::String::Utf8Value json_param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String json_param(Nan::To(info[0]).ToLocalChecked()); std::string metadata_string = std::string(*json_param); json metadata_json = json::parse(metadata_string); std::map metadata; @@ -347,7 +347,7 @@ NAN_METHOD(MediaStream::enableHandler) { return; } - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string name = std::string(*param); me->enableHandler(name); @@ -361,7 +361,7 @@ NAN_METHOD(MediaStream::disableHandler) { return; } - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string name = std::string(*param); me->disableHandler(name); @@ -374,8 +374,8 @@ NAN_METHOD(MediaStream::setQualityLayer) { return; } - int spatial_layer = info[0]->IntegerValue(); - int temporal_layer = info[1]->IntegerValue(); + int spatial_layer = Nan::To(info[0]).FromJust(); + int temporal_layer = Nan::To(info[1]).FromJust(); me->setQualityLayer(spatial_layer, temporal_layer); } @@ -387,8 +387,8 @@ NAN_METHOD(MediaStream::enableSlideShowBelowSpatialLayer) { return; } - bool enabled = info[0]->BooleanValue(); - int spatial_layer = info[1]->IntegerValue(); + bool enabled = Nan::To(info[0]).FromJust(); + int spatial_layer = Nan::To(info[1]).FromJust(); me->enableSlideShowBelowSpatialLayer(enabled, spatial_layer); } @@ -399,10 +399,10 @@ NAN_METHOD(MediaStream::setPeriodicKeyframeRequests) { return; } - bool activated = info[0]->BooleanValue(); + bool activated = Nan::To(info[0]).FromJust(); int interval = 0; if (info.Length() > 1) { - interval = info[1]->IntegerValue(); + interval = Nan::To(info[1]).FromJust(); } me->setPeriodicKeyframeRequests(activated, interval); } @@ -448,8 +448,8 @@ NAN_METHOD(MediaStream::setFeedbackReports) { return; } - bool v = info[0]->BooleanValue(); - int fbreps = info[1]->IntegerValue(); // From bps to Kbps + bool v = Nan::To(info[0]).FromJust(); + int fbreps = Nan::To(info[1]).FromJust(); // From bps to Kbps me->setFeedbackReports(v, fbreps); } @@ -551,7 +551,7 @@ NAUV_WORK_CB(MediaStream::closePromiseResolver) { while (!obj->futures.empty()) { auto persistent = obj->futures.front(); v8::Local resolver = Nan::New(*persistent); - resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()); + resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()).IsNothing(); obj->futures.pop(); obj->Unref(); } diff --git a/erizoAPI/OneToManyProcessor.cc b/erizoAPI/OneToManyProcessor.cc index 63c496e60f..0f6c582352 100644 --- a/erizoAPI/OneToManyProcessor.cc +++ b/erizoAPI/OneToManyProcessor.cc @@ -80,7 +80,7 @@ NAN_MODULE_INIT(OneToManyProcessor::Init) { Nan::SetPrototypeMethod(tpl, "addSubscriber", addSubscriber); Nan::SetPrototypeMethod(tpl, "removeSubscriber", removeSubscriber); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("OneToManyProcessor").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -137,7 +137,7 @@ NAN_METHOD(OneToManyProcessor::addExternalOutput) { auto ms = std::dynamic_pointer_cast(wr); // get the param - v8::String::Utf8Value param1(Nan::To(info[1]).ToLocalChecked()); + Nan::Utf8String param1(Nan::To(info[1]).ToLocalChecked()); // convert it to string std::string peerId = std::string(*param1); @@ -199,7 +199,7 @@ NAN_METHOD(OneToManyProcessor::addSubscriber) { std::shared_ptr ms = std::dynamic_pointer_cast(wr); // get the param - v8::String::Utf8Value param1(Nan::To(info[1]).ToLocalChecked()); + Nan::Utf8String param1(Nan::To(info[1]).ToLocalChecked()); // convert it to string std::string peerId = std::string(*param1); @@ -214,7 +214,7 @@ NAN_METHOD(OneToManyProcessor::removeSubscriber) { } // get the param - v8::String::Utf8Value param1(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param1(Nan::To(info[0]).ToLocalChecked()); // convert it to string std::string peerId = std::string(*param1); diff --git a/erizoAPI/SyntheticInput.cc b/erizoAPI/SyntheticInput.cc index 4aecbe04c0..75f9940138 100644 --- a/erizoAPI/SyntheticInput.cc +++ b/erizoAPI/SyntheticInput.cc @@ -54,7 +54,7 @@ NAN_MODULE_INIT(SyntheticInput::Init) { Nan::SetPrototypeMethod(tpl, "setVideoReceiver", setVideoReceiver); Nan::SetPrototypeMethod(tpl, "setFeedbackSource", setFeedbackSource); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("SyntheticInput").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -64,9 +64,9 @@ NAN_METHOD(SyntheticInput::New) { } ThreadPool* thread_pool = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); - uint32_t audio_bitrate = info[1]->IntegerValue(); - uint32_t min_video_bitrate = info[2]->IntegerValue(); - uint32_t max_video_bitrate = info[3]->IntegerValue(); + uint32_t audio_bitrate = Nan::To(info[1]).FromJust(); + uint32_t min_video_bitrate = Nan::To(info[2]).FromJust(); + uint32_t max_video_bitrate = Nan::To(info[3]).FromJust(); std::shared_ptr worker = thread_pool->me->getLessUsedWorker(); diff --git a/erizoAPI/ThreadPool.cc b/erizoAPI/ThreadPool.cc index 0015ccb97b..f1c58dde4d 100644 --- a/erizoAPI/ThreadPool.cc +++ b/erizoAPI/ThreadPool.cc @@ -33,7 +33,7 @@ NAN_MODULE_INIT(ThreadPool::Init) { Nan::SetPrototypeMethod(tpl, "getDurationDistribution", getDurationDistribution); Nan::SetPrototypeMethod(tpl, "resetStats", resetStats); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("ThreadPool").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -42,7 +42,7 @@ NAN_METHOD(ThreadPool::New) { Nan::ThrowError("Wrong number of arguments"); } - unsigned int num_workers = info[0]->IntegerValue(); + unsigned int num_workers = Nan::To(info[0]).FromJust(); ThreadPool* obj = new ThreadPool(); obj->me.reset(new erizo::ThreadPool(num_workers)); diff --git a/erizoAPI/WebRtcConnection.cc b/erizoAPI/WebRtcConnection.cc index 8c19bcbba0..e3a75f7d87 100644 --- a/erizoAPI/WebRtcConnection.cc +++ b/erizoAPI/WebRtcConnection.cc @@ -127,7 +127,7 @@ NAN_MODULE_INIT(WebRtcConnection::Init) { Nan::SetPrototypeMethod(tpl, "copySdpToLocalDescription", copySdpToLocalDescription); Nan::SetPrototypeMethod(tpl, "getStats", getStats); - constructor.Reset(tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); Nan::Set(target, Nan::New("WebRtcConnection").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } @@ -141,17 +141,17 @@ NAN_METHOD(WebRtcConnection::New) { // Invoked as a constructor with 'new WebRTC()' ThreadPool* thread_pool = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); IOThreadPool* io_thread_pool = Nan::ObjectWrap::Unwrap(Nan::To(info[1]).ToLocalChecked()); - v8::String::Utf8Value paramId(Nan::To(info[2]).ToLocalChecked()); + Nan::Utf8String paramId(Nan::To(info[2]).ToLocalChecked()); std::string wrtcId = std::string(*paramId); - v8::String::Utf8Value param(Nan::To(info[3]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[3]).ToLocalChecked()); std::string stunServer = std::string(*param); - int stunPort = info[4]->IntegerValue(); - int minPort = info[5]->IntegerValue(); - int maxPort = info[6]->IntegerValue(); - bool trickle = (info[7]->ToBoolean())->BooleanValue(); - v8::String::Utf8Value json_param(Nan::To(info[8]).ToLocalChecked()); - bool use_nicer = (info[9]->ToBoolean())->BooleanValue(); - bool enable_connection_quality_check = (info[10]->ToBoolean())->BooleanValue(); + int stunPort = Nan::To(info[4]).FromJust(); + int minPort = Nan::To(info[5]).FromJust(); + int maxPort = Nan::To(info[6]).FromJust(); + bool trickle = Nan::To((info[7])).FromJust(); + Nan::Utf8String json_param(Nan::To(info[8]).ToLocalChecked()); + bool use_nicer = Nan::To((info[9])).FromJust(); + bool enable_connection_quality_check = Nan::To((info[10])).FromJust(); std::string media_config_string = std::string(*json_param); json media_config = json::parse(media_config_string); std::vector rtp_mappings; @@ -220,14 +220,14 @@ NAN_METHOD(WebRtcConnection::New) { erizo::IceConfig iceConfig; if (info.Length() == 16) { - v8::String::Utf8Value param2(Nan::To(info[11]).ToLocalChecked()); + Nan::Utf8String param2(Nan::To(info[11]).ToLocalChecked()); std::string turnServer = std::string(*param2); - int turnPort = info[12]->IntegerValue(); - v8::String::Utf8Value param3(Nan::To(info[13]).ToLocalChecked()); + int turnPort = Nan::To(info[12]).FromJust(); + Nan::Utf8String param3(Nan::To(info[13]).ToLocalChecked()); std::string turnUsername = std::string(*param3); - v8::String::Utf8Value param4(Nan::To(info[14]).ToLocalChecked()); + Nan::Utf8String param4(Nan::To(info[14]).ToLocalChecked()); std::string turnPass = std::string(*param4); - v8::String::Utf8Value param5(Nan::To(info[15]).ToLocalChecked()); + Nan::Utf8String param5(Nan::To(info[15]).ToLocalChecked()); std::string network_interface = std::string(*param5); iceConfig.turn_server = turnServer; @@ -288,11 +288,11 @@ NAN_METHOD(WebRtcConnection::createOffer) { if (info.Length() < 3) { Nan::ThrowError("Wrong number of arguments"); } - bool video_enabled = info[0]->BooleanValue(); - bool audio_enabled = info[1]->BooleanValue(); - bool bundle = info[2]->BooleanValue(); + bool video_enabled = Nan::To(info[0]).FromJust(); + bool audio_enabled = Nan::To(info[1]).FromJust(); + bool bundle = Nan::To(info[2]).FromJust(); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); me->createOffer(video_enabled, audio_enabled, bundle).then( @@ -310,7 +310,7 @@ NAN_METHOD(WebRtcConnection::setMetadata) { return; } - v8::String::Utf8Value json_param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String json_param(Nan::To(info[0]).ToLocalChecked()); std::string metadata_string = std::string(*json_param); json metadata_json = json::parse(metadata_string); std::map metadata; @@ -337,10 +337,10 @@ NAN_METHOD(WebRtcConnection::setRemoteSdp) { return; } - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string sdp = std::string(*param); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); me->setRemoteSdp(sdp).then( @@ -363,7 +363,7 @@ NAN_METHOD(WebRtcConnection::setRemoteDescription) { Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); auto sdp = std::make_shared(*param->me.get()); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); @@ -381,7 +381,7 @@ NAN_METHOD(WebRtcConnection::getLocalDescription) { if (!me) { return; } - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); @@ -421,12 +421,12 @@ NAN_METHOD(WebRtcConnection::addRemoteCandidate) { return; } - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string mid = std::string(*param); - int sdpMLine = info[1]->IntegerValue(); + int sdpMLine = Nan::To(info[1]).FromJust(); - v8::String::Utf8Value param2(Nan::To(info[2]).ToLocalChecked()); + Nan::Utf8String param2(Nan::To(info[2]).ToLocalChecked()); std::string sdp = std::string(*param2); me->addRemoteCandidate(mid, sdpMLine, sdp); @@ -480,7 +480,7 @@ NAN_METHOD(WebRtcConnection::addMediaStream) { MediaStream* param = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); auto ms = std::shared_ptr(param->me); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); me->addMediaStream(ms).then( @@ -498,10 +498,10 @@ NAN_METHOD(WebRtcConnection::removeMediaStream) { return; } - v8::String::Utf8Value param(Nan::To(info[0]).ToLocalChecked()); + Nan::Utf8String param(Nan::To(info[0]).ToLocalChecked()); std::string stream_id = std::string(*param); - v8::Local resolver = v8::Promise::Resolver::New(info.GetIsolate()); + v8::Local resolver = v8::Promise::Resolver::New(Nan::GetCurrentContext()).ToLocalChecked(); Nan::Persistent *persistent = new Nan::Persistent(resolver); obj->Ref(); me->removeMediaStream(stream_id).then( @@ -551,7 +551,7 @@ NAUV_WORK_CB(WebRtcConnection::eventsCallback) { Local args[] = {Nan::New(obj->event_status.front()), Nan::New(obj->event_messages.front().c_str()).ToLocalChecked()}; Nan::AsyncResource resource("erizo::addon.connection.eventsCallback"); - resource.runInAsyncScope(Nan::GetCurrentContext()->Global(), obj->event_callback_->GetFunction(), 2, args); + obj->event_callback_->Call(2, args, &resource); obj->event_messages.pop(); obj->event_status.pop(); } @@ -583,16 +583,17 @@ NAUV_WORK_CB(WebRtcConnection::promiseResolver) { v8::Local resolver = Nan::New(*persistent); ResultVariant r = obj->futures.front().second; if (boost::get(&r) != nullptr) { - resolver->Resolve(Nan::GetCurrentContext(), Nan::New(boost::get(r).c_str()).ToLocalChecked()); + resolver->Resolve(Nan::GetCurrentContext(), Nan::New(boost::get(r).c_str()).ToLocalChecked()) + .IsNothing(); } else if (boost::get>(&r) != nullptr) { std::shared_ptr sdp_info = boost::get>(r); v8::Local instance = ConnectionDescription::NewInstance(); ConnectionDescription* description = ObjectWrap::Unwrap(instance); description->me = sdp_info; - resolver->Resolve(Nan::GetCurrentContext(), instance); + resolver->Resolve(Nan::GetCurrentContext(), instance).IsNothing(); } else { ELOG_WARN("%s, message: Resolving promise with no valid value, using empty string", obj->toLog()); - resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()); + resolver->Resolve(Nan::GetCurrentContext(), Nan::New("").ToLocalChecked()).IsNothing(); } obj->futures.pop(); obj->Unref(); diff --git a/erizoAPI/package.json b/erizoAPI/package.json index 8dbe403886..c2f01e199b 100644 --- a/erizoAPI/package.json +++ b/erizoAPI/package.json @@ -4,10 +4,10 @@ "description": "Open Source Communication Provider - Erizo API", "license": "MIT", "private": true, - "devDependencies": { - "nan": "~2.13.1" + "devDependencies": {}, + "dependencies": { + "nan": "^2.14.0" }, - "dependencies": {}, "contributors": [ { "name": "Alvaro Alonso", diff --git a/erizo_controller/erizoClient/gulp/erizoTasks.js b/erizo_controller/erizoClient/gulp/erizoTasks.js index bfff0279bd..34c8728c5c 100644 --- a/erizo_controller/erizoClient/gulp/erizoTasks.js +++ b/erizo_controller/erizoClient/gulp/erizoTasks.js @@ -41,9 +41,11 @@ const erizoTasks = (gulp, plugins, config) => { gulp.src(`${erizoConfig.debug}/**/*.js*`) .pipe(gulp.dest(config.paths.basicExample)); - that.clean = () => + that.clean = (cb) => { plugins.del([`${erizoConfig.debug}/**/*.js*`, `${erizoConfig.production}/**/*.js*`], { force: true }); + cb(); + } return that; }; diff --git a/erizo_controller/erizoClient/gulpfile.js b/erizo_controller/erizoClient/gulpfile.js index 4943926972..063791b89b 100644 --- a/erizo_controller/erizoClient/gulpfile.js +++ b/erizo_controller/erizoClient/gulpfile.js @@ -1,7 +1,7 @@ const gulp = require('gulp'); +const log = require('fancy-log'); const plugins = {}; -plugins.runSequence = require('run-sequence'); plugins.del = require('del'); plugins.sourcemaps = require('gulp-sourcemaps'); @@ -10,11 +10,10 @@ plugins.closureCompiler = require('google-closure-compiler-js').gulp(); plugins.webpack = require('webpack'); plugins.webpackGulp = require('webpack-stream'); - const errorExitCode = 2; plugins.exitOnError = (error) => { - console.log('Error running task', error); + log('Error running task', error); return process.exit(errorExitCode); } @@ -44,33 +43,28 @@ const createTasks = (target, targetTasks, sourceTasks) => { (task) => { const taskName = `${task}_${target}`; targetTasks.push(taskName); - gulp.task(taskName, () => taskFunctions[target][task]()); + gulp.task(taskName, taskFunctions[target][task]); }); }; +gulp.task('lint', () => gulp.src(config.paths.js) + .pipe(plugins.eslint()) + .pipe(plugins.eslint.format()) + .pipe(plugins.eslint.failAfterError())); + targets.forEach( (target) => { const targetTasks = ['lint']; createTasks(target, targetTasks, tasks); createTasks(target, watchTasks, debugTasks); - gulp.task(target, () => { - plugins.runSequence(...targetTasks); - }); + gulp.task(target, gulp.series(...targetTasks)); }); -gulp.task('lint', () => gulp.src(config.paths.js) - .pipe(plugins.eslint()) - .pipe(plugins.eslint.format()) - .pipe(plugins.eslint.failAfterError())); - gulp.task('watch', () => { const watcher = gulp.watch('src/**/*.js'); watcher.on('change', (event) => { - console.log(`File ${event.path} was ${event.type} running tasks...`); - plugins.runSequence(...watchTasks); + log(`File ${event.path} was ${event.type} running tasks...`); + gulp.series(...watchTasks)(); }); }); - -gulp.task('default', () => { - plugins.runSequence(...targets); -}); +gulp.task('default', gulp.series(...targets)); diff --git a/erizo_controller/package.json b/erizo_controller/package.json index 53cc28b375..656b12bbf1 100644 --- a/erizo_controller/package.json +++ b/erizo_controller/package.json @@ -9,6 +9,7 @@ "amqp": "~0.2.7", "aws-sdk": "~2.566.0", "express": "~4.17.1", + "fancy-log": "^1.3.3", "log4js": "~1.0.1", "node-getopt": "~0.3.2", "prom-client": "~11.2.1", diff --git a/package.json b/package.json index c20a186665..67da0c2772 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "eslint-plugin-react": "^7.1.0", "expose-loader": "~0.7.5", "google-closure-compiler-js": "~20170521.0.0", - "gulp": "~3.9.1", + "gulp": "^4.0.2", "gulp-eslint": "~3.0.1", "gulp-sourcemaps": "~2.6.4", "mocha": "^3.1.2", @@ -53,5 +53,6 @@ "lint": "npm run lintErizoController && npm run lintBasicExample && npm run lintNuve && npm run lintSpine", "lintErizoAPI": "./erizo/utils/cpplint.py --filter=-legal/copyright,-build/include --linelength=120 ./erizoAPI/*.cc *.h", "buildErizoAPI": "export ERIZO_HOME=$(pwd)/erizo/ && echo $ERIZO_HOME && cd ./erizoAPI/ && env JOBS=4 ./build.sh" - } + }, + "dependencies": {} }