nodejs: fix binding, update to Node 16 LTS

Change-Id: Id4eaaebee19c9739334b0652e7cdf560d8f8a202
This commit is contained in:
Adrien Béraud
2022-04-26 14:58:52 -04:00
parent 222934d9ee
commit 8750049b0c
3 changed files with 36 additions and 23 deletions

View File

@ -5,11 +5,11 @@ BUILT_SOURCES= \
build/Makefile \
build/Release/obj.target/jami.node
jami_wrapper.cpp: nodejs_interface.i configurationmanager.i managerimpl.i
jami_wrapper.cpp: nodejs_interface.i configurationmanager.i managerimpl.i callmanager.i
$(SWIG) -v -c++ -javascript -node -o jami_wrapper.cpp nodejs_interface.i
build/Makefile: jami_wrapper.cpp binding.gyp
node-gyp configure --target=v14.16.1 --arch=x64
node-gyp configure --target=v16.14.2 --arch=x64
build/Release/obj.target/jami.node: build/Makefile jami_wrapper.cpp callback.h
node-gyp build

View File

@ -441,16 +441,22 @@ incomingTrustRequest(const std::string& accountId,
}
void
callStateChanged(const std::string& callId, const std::string& state, int detail_code)
callStateChanged(const std::string& accountId,
const std::string& callId,
const std::string& state,
int detail_code)
{
std::lock_guard<std::mutex> lock(pendingSignalsLock);
pendingSignals.emplace([callId, state, detail_code]() {
pendingSignals.emplace([accountId, callId, state, detail_code]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), callStateChangedCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(callId),
V8_STRING_NEW_LOCAL(state),
SWIGV8_INTEGER_NEW(detail_code)};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args);
SWIGV8_VALUE callback_args[] = {
V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(callId),
V8_STRING_NEW_LOCAL(state),
SWIGV8_INTEGER_NEW(detail_code)
};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 4, callback_args);
}
});
@ -466,9 +472,11 @@ mediaChangeRequested(const std::string& accountId,
pendingSignals.emplace([accountId, callId, mediaList]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), mediaChangeRequestedCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(callId),
stringMapVecToJsMapArray(mediaList)};
SWIGV8_VALUE callback_args[] = {
V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(callId),
stringMapVecToJsMapArray(mediaList)
};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args);
}
});
@ -477,15 +485,17 @@ mediaChangeRequested(const std::string& accountId,
}
void
incomingMessage(const std::string& id,
incomingMessage(const std::string& accountId,
const std::string& id,
const std::string& from,
const std::map<std::string, std::string>& messages)
{
std::lock_guard<std::mutex> lock(pendingSignalsLock);
pendingSignals.emplace([id, from, messages]() {
pendingSignals.emplace([accountId, id, from, messages]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), incomingMessageCb);
if (!func.IsEmpty()) {
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(id),
SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId),
V8_STRING_NEW_LOCAL(id),
V8_STRING_NEW_LOCAL(from),
stringMapToJsMap(messages)};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args);

View File

@ -28,7 +28,7 @@
class Callback {
public:
virtual ~Callback() {}
virtual void callStateChanged(const std::string& callId, const std::string& state, int detail_code){}
virtual void callStateChanged(const std::string& accountId, const std::string& callId, const std::string& state, int detail_code){}
virtual void transferFailed(void){}
virtual void transferSucceeded(void){}
virtual void recordPlaybackStopped(const std::string& path){}
@ -40,9 +40,9 @@ public:
virtual void mediaChangeRequested(const std::string& accountId, const std::string& callId,
const std::vector<std::map<std::string, std::string>>& mediaList){}
virtual void recordPlaybackFilepath(const std::string& id, const std::string& filename){}
virtual void conferenceCreated(const std::string& accountId, const std::string& conf_id){}
virtual void conferenceChanged(const std::string& accountId, const std::string& conf_id, const std::string& state){}
virtual void conferenceRemoved(const std::string& accountId, const std::string& conf_id){}
virtual void conferenceCreated(const std::string& accountId, const std::string& confId){}
virtual void conferenceChanged(const std::string& accountId, const std::string& confId, const std::string& state){}
virtual void conferenceRemoved(const std::string& accountId, const std::string& confId){}
virtual void updatePlaybackScale(const std::string& filepath, int position, int scale){}
virtual void newCall(const std::string& accountId, const std::string& callId, const std::string& to){}
virtual void recordingStateChanged(const std::string& callId, int code){}
@ -50,6 +50,8 @@ public:
virtual void onRtcpReportReceived(const std::string& callId, const std::map<std::string, int>& stats){}
virtual void onConferenceInfosUpdated(const std::string& confId, const std::vector<std::map<std::string, std::string>>& infos) {}
virtual void peerHold(const std::string& callId, bool holding){}
virtual void audioMuted(const std::string& callId, bool muted){}
virtual void videoMuted(const std::string& callId, bool muted){}
virtual void connectionUpdate(const std::string& id, int state){}
virtual void remoteRecordingChanged(const std::string& callId, const std::string& peer_number, bool state){}
virtual void mediaNegotiationStatus(const std::string& callId, const std::string& event,
@ -64,7 +66,6 @@ public:
namespace DRing {
/* Call related methods */
std::string placeCall(const std::string& accountId, const std::string& to, const std::map<std::string, std::string>& volatileCallDetails);
std::string placeCallWithMedia(const std::string& accountId,
const std::string& to,
const std::vector<std::map<std::string, std::string>>& mediaList);
@ -129,7 +130,7 @@ void sendTextMessage(const std::string& accountId, const std::string& callId, co
class Callback {
public:
virtual ~Callback() {}
virtual void callStateChanged(const std::string& callId, const std::string& state, int detail_code){}
virtual void callStateChanged(const std::string& accountId, const std::string& callId, const std::string& state, int detail_code){}
virtual void transferFailed(void){}
virtual void transferSucceeded(void){}
virtual void recordPlaybackStopped(const std::string& path){}
@ -141,9 +142,9 @@ public:
virtual void mediaChangeRequested(const std::string& accountId, const std::string& callId,
const std::vector<std::map<std::string, std::string>>& mediaList){}
virtual void recordPlaybackFilepath(const std::string& id, const std::string& filename){}
virtual void conferenceCreated(const std::string& accountId, const std::string& conf_id){}
virtual void conferenceChanged(const std::string& accountId, const std::string& conf_id, const std::string& state){}
virtual void conferenceRemoved(const std::string& accountId, const std::string& conf_id){}
virtual void conferenceCreated(const std::string& accountId, const std::string& confId){}
virtual void conferenceChanged(const std::string& accountId, const std::string& confId, const std::string& state){}
virtual void conferenceRemoved(const std::string& accountId, const std::string& confId){}
virtual void updatePlaybackScale(const std::string& filepath, int position, int scale){}
virtual void newCall(const std::string& accountId, const std::string& callId, const std::string& to){}
virtual void recordingStateChanged(const std::string& callId, int code){}
@ -151,6 +152,8 @@ public:
virtual void onRtcpReportReceived(const std::string& callId, const std::map<std::string, int>& stats){}
virtual void onConferenceInfosUpdated(const std::string& confId, const std::vector<std::map<std::string, std::string>>& infos) {}
virtual void peerHold(const std::string& callId, bool holding){}
virtual void audioMuted(const std::string& callId, bool muted){}
virtual void videoMuted(const std::string& callId, bool muted){}
virtual void connectionUpdate(const std::string& id, int state){}
virtual void remoteRecordingChanged(const std::string& callId, const std::string& peer_number, bool state){}
virtual void mediaNegotiationStatus(const std::string& callId, const std::string& event,