Commit c4d03c6d authored by Adrien Béraud's avatar Adrien Béraud

nodejs: add initial module

Change-Id: I12310bd4a5826e5658e5b7fe72a8a5ae6efe82d0
parent a72465d8
include $(top_srcdir)/globals.mk
BUILT_SOURCES= \
ring_wrapper.cpp
ring_wrapper.cpp: jni_interface.i configurationmanager.i managerimpl.i
$(SWIG) -v -c++ -javascript -node -o ring_wrapper.cpp jni_interface.i
CLEANFILES= \
$(BUILT_SOURCES)
{
"targets": [
{
"target_name": "dring",
"sources": [ "ring_wrapper.cpp" ],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ]
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
*
* Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
* Alexandre Lision <alexnadre.L@savoirfairelinux.com>
* Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
%header %{
#include "dring/dring.h"
#include "dring/callmanager_interface.h"
class Callback {
public:
virtual ~Callback() {}
virtual void callStateChanged(const std::string& call_id, const std::string& state, int detail_code){}
virtual void transferFailed(void){}
virtual void transferSucceeded(void){}
virtual void recordPlaybackStopped(const std::string& path){}
virtual void voiceMailNotify(const std::string& call_id, int nd_msg){}
virtual void incomingMessage(const std::string& id, const std::string& from, const std::map<std::string, std::string>& messages){}
virtual void incomingCall(const std::string& account_id, const std::string& call_id, const std::string& from){}
virtual void recordPlaybackFilepath(const std::string& id, const std::string& filename){}
virtual void conferenceCreated(const std::string& conf_id){}
virtual void conferenceChanged(const std::string& conf_id, const std::string& state){}
virtual void conferenceRemoved(const std::string& conf_id){}
virtual void newCallCreated(const std::string& call_id, const std::string&, const std::string&){}
virtual void updatePlaybackScale(const std::string& filepath, int position, int scale){}
virtual void conferenceRemove(const std::string& conf_id){}
virtual void newCall(const std::string& account_id, const std::string& call_id, const std::string& to){}
virtual void sipCallStateChange(const std::string& call_id, const std::string& state, int code){}
virtual void recordingStateChanged(const std::string& call_id, int code){}
virtual void recordStateChange(const std::string& call_id, int state){}
virtual void onRtcpReportReceived(const std::string& call_id, const std::map<std::string, int>& stats){}
virtual void peerHold(const std::string& call_id, bool holding){}
};
%}
%feature("director") Callback;
namespace DRing {
/* Call related methods */
std::string placeCall(const std::string& accountID, const std::string& to);
bool refuse(const std::string& callID);
bool accept(const std::string& callID);
bool hangUp(const std::string& callID);
bool hold(const std::string& callID);
bool unhold(const std::string& callID);
bool muteLocalMedia(const std::string& callid, const std::string& mediaType, bool mute);
bool transfer(const std::string& callID, const std::string& to);
bool attendedTransfer(const std::string& transferID, const std::string& targetID);
std::map<std::string, std::string> getCallDetails(const std::string& callID);
std::vector<std::string> getCallList();
/* Conference related methods */
void removeConference(const std::string& conference_id);
bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
void createConfFromParticipantList(const std::vector<std::string>& participants);
bool isConferenceParticipant(const std::string& call_id);
bool addParticipant(const std::string& callID, const std::string& confID);
bool addMainParticipant(const std::string& confID);
bool detachParticipant(const std::string& callID);
bool joinConference(const std::string& sel_confID, const std::string& drag_confID);
bool hangUpConference(const std::string& confID);
bool holdConference(const std::string& confID);
bool unholdConference(const std::string& confID);
std::vector<std::string> getConferenceList();
std::vector<std::string> getParticipantList(const std::string& confID);
std::vector<std::string> getDisplayNames(const std::string& confID);
std::string getConferenceId(const std::string& callID);
std::map<std::string, std::string> getConferenceDetails(const std::string& callID);
/* File Playback methods */
bool startRecordedFilePlayback(const std::string& filepath);
void stopRecordedFilePlayback(const std::string& filepath);
/* General audio methods */
bool toggleRecording(const std::string& callID);
/* DEPRECATED */
void setRecording(const std::string& callID);
void recordPlaybackSeek(double value);
bool getIsRecording(const std::string& callID);
std::string getCurrentAudioCodecName(const std::string& callID);
void playDTMF(const std::string& key);
void startTone(int32_t start, int32_t type);
bool switchInput(const std::string& callID, const std::string& resource);
/* Instant messaging */
void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, const bool& isMixed);
}
class Callback {
public:
virtual ~Callback() {}
virtual void callStateChanged(const std::string& call_id, const std::string& state, int detail_code){}
virtual void transferFailed(void){}
virtual void transferSucceeded(void){}
virtual void recordPlaybackStopped(const std::string& path){}
virtual void voiceMailNotify(const std::string& call_id, int nd_msg){}
virtual void incomingMessage(const std::string& id, const std::string& from, const std::map<std::string, std::string>& messages){}
virtual void incomingCall(const std::string& account_id, const std::string& call_id, const std::string& from){}
virtual void recordPlaybackFilepath(const std::string& id, const std::string& filename){}
virtual void conferenceCreated(const std::string& conf_id){}
virtual void conferenceChanged(const std::string& conf_id, const std::string& state){}
virtual void conferenceRemoved(const std::string& conf_id){}
virtual void newCallCreated(const std::string& call_id, const std::string&, const std::string&){}
virtual void updatePlaybackScale(const std::string& filepath, int position, int scale){}
virtual void conferenceRemove(const std::string& conf_id){}
virtual void newCall(const std::string& account_id, const std::string& call_id, const std::string& to){}
virtual void sipCallStateChange(const std::string& call_id, const std::string& state, int code){}
virtual void recordingStateChanged(const std::string& call_id, int code){}
virtual void recordStateChange(const std::string& call_id, int state){}
virtual void onRtcpReportReceived(const std::string& call_id, const std::map<std::string, int>& stats){}
virtual void peerHold(const std::string& call_id, bool holding){}
};
This diff is collapsed.
/*
* Copyright (c) 2017 Savoir-faire Linux Inc.
*
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
'use strict';
require("./build/Release/dring")
This diff is collapsed.
/*
* Copyright (C) 2004-2016 Savoir-faire Linux Inc.
*
* Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* %nodefaultctor ManagerImpl;
%nodefaultdtor ManagerImpl; */
%header %{
#include "dring/dring.h"
%}
namespace DRing {
/**
* Finalizes libsflphone, freeing any resource allocated by the library.
*/
void fini(void);
/**
* Poll for events
*/
void pollEvents(void);
}
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%header %{
#include "dring/dring.h"
#include "dring/presencemanager_interface.h"
class PresenceCallback {
public:
virtual ~PresenceCallback(){}
virtual void newServerSubscriptionRequest(const std::string& /*remote*/){}
virtual void serverError(const std::string& /*account_id*/, const std::string& /*error*/, const std::string& /*msg*/){}
virtual void newBuddyNotification(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*status*/, const std::string& /*line_status*/){}
virtual void subscriptionStateChanged(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*state*/){}
};
%}
%feature("director") PresenceCallback;
namespace DRing {
/* Presence subscription/Notification. */
void publish(const std::string& accountID, bool status, const std::string& note);
void answerServerRequest(const std::string& uri, bool flag);
void subscribeBuddy(const std::string& accountID, const std::string& uri, bool flag);
std::vector<std::map<std::string, std::string>> getSubscriptions(const std::string& accountID);
void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris);
}
class PresenceCallback {
public:
virtual ~PresenceCallback(){}
virtual void newServerSubscriptionRequest(const std::string& /*remote*/){}
virtual void serverError(const std::string& /*account_id*/, const std::string& /*error*/, const std::string& /*msg*/){}
virtual void newBuddyNotification(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*status*/, const std::string& /*line_status*/){}
virtual void subscriptionStateChanged(const std::string& /*account_id*/, const std::string& /*buddy_uri*/, int /*state*/){}
};
\ No newline at end of file
#include "logger.h"
JavaVM *gJavaVM;
const char *kringservicePath = "cx/ring/daemon/RingserviceJNI";
void deinitClassHelper(JNIEnv *env, jobject obj) {
RING_INFO("deinitClassHelper");
/* delete cached object instances */
env->DeleteGlobalRef(obj);
RING_INFO("deinitClassHelper: object %x deleted", obj);
}
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
jclass clazz;
jint r;
RING_INFO("JNI_OnLoad");
//Assume it is c++
r = vm->GetEnv ((void **) &env, JNI_VERSION_1_6);
if (r != JNI_OK) {
RING_ERR("JNI_OnLoad: failed to get the environment using GetEnv()");
return -1;
}
RING_INFO("JNI_Onload: GetEnv %p", env);
clazz = env->FindClass (kringservicePath);
if (!clazz) {
RING_ERR("JNI_Onload: whoops, %s class not found!", kringservicePath);
}
gJavaVM = vm;
RING_INFO("JNI_Onload: JavaVM %p", gJavaVM);
/* put instances of class object we need into cache */
//initClassHelper(env, kManagerPath, &gManagerObject);
JNINativeMethod methods[] = {
$defs
};
r = env->RegisterNatives (clazz, methods, (int) (sizeof(methods) / sizeof(methods[0])));
return JNI_VERSION_1_6;
}
void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
JNIEnv* env;
jclass clazz;
RING_INFO("JNI_OnUnLoad");
/* get env */
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
RING_ERR("JNI_OnUnLoad: failed to get the environment using GetEnv()");
return;
}
RING_INFO("JNI_OnUnLoad: GetEnv %p", env);
/* Get jclass with env->FindClass */
clazz = env->FindClass(kringservicePath);
if (!clazz) {
RING_ERR("JNI_OnUnLoad: whoops, %s class not found!", kringservicePath);
}
/* remove instances of class object we need into cache */
//deinitClassHelper(env, gManagerObject);
env->UnregisterNatives(clazz);
RING_INFO("JNI_OnUnLoad: Native functions unregistered");
}
/*
* Copyright (C) 2015-2016 Savoir-faire Linux Inc.
*
* Authors: Damien Riegel <damien.riegel@savoirfairelinux.com>
* Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Ciro Santilli <ciro.santilli@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%header %{
#include <functional>
#include <list>
#include <mutex>
#include "dring/dring.h"
#include "dring/videomanager_interface.h"
class VideoCallback {
public:
virtual ~VideoCallback(){}
virtual void getCameraInfo(const std::string& device, std::vector<int> *formats, std::vector<unsigned> *sizes, std::vector<unsigned> *rates) {}
virtual void setParameters(const std::string, const int format, const int width, const int height, const int rate) {}
virtual void startCapture(const std::string& camid) {}
virtual void stopCapture() {}
virtual void decodingStarted(const std::string& id, const std::string& shm_path, int w, int h, bool is_mixer) {}
virtual void decodingStopped(const std::string& id, const std::string& shm_path, bool is_mixer) {}
};
%}
%feature("director") VideoCallback;
namespace DRing {
void setDefaultDevice(const std::string& name);
std::string getDefaultDevice();
void startCamera();
void stopCamera();
bool hasCameraStarted();
bool switchInput(const std::string& resource);
bool switchToCamera();
std::map<std::string, std::string> getSettings(const std::string& name);
void applySettings(const std::string& name, const std::map<std::string, std::string>& settings);
void registerSinkTarget(const std::string& sinkId, const DRing::SinkTarget& target);
}
class VideoCallback {
public:
virtual ~VideoCallback(){}
virtual void getCameraInfo(const std::string& device, std::vector<int> *formats, std::vector<unsigned> *sizes, std::vector<unsigned> *rates){}
virtual void setParameters(const std::string, const int format, const int width, const int height, const int rate) {}
virtual void startCapture(const std::string& camid) {}
virtual void stopCapture() {}
virtual void decodingStarted(const std::string& id, const std::string& shm_path, int w, int h, bool is_mixer) {}
virtual void decodingStopped(const std::string& id, const std::string& shm_path, bool is_mixer) {}
};
......@@ -390,6 +390,20 @@ AC_ARG_ENABLE([ringns], AS_HELP_STRING([--disable-ringns], [Enable Ring Name Ser
AM_CONDITIONAL([RINGNS], test "x$enable_ringns" != "xno", [Define if you use the Ring Name Service])
AC_DEFINE_UNQUOTED([HAVE_RINGNS], `if test "x$enable_ringns" != "xno"; then echo 1; else echo 0; fi`, [Define if you use the Ring Name Service])
dnl Ring nodejs module
AC_ARG_WITH([nodejs], AS_HELP_STRING([--with-nodejs], [Enable Ring NodeJS module]))
AM_CONDITIONAL([RING_NODEJS], test "x$enable_nodejs" != "xno", [Define if you use the Ring NodeJS module])
AC_DEFINE_UNQUOTED([HAVE_NODEJS], `if test "x$enable_ringns" != "xno"; then echo 1; else echo 0; fi`, [Define if you use the Ring NodeJS module])
AS_IF([test "x$with_nodejs" = "xyes"], [
AC_PATH_PROG(SWIG, swig, "")
AS_AC_EXPAND(SBINDIR, $sbindir)
AC_SUBST(SBINDIR)
AC_CONFIG_FILES([bin/nodejs/Makefile])
AM_CONDITIONAL(RING_NODEJS, true)
],
AM_CONDITIONAL(RING_NODEJS, false)
);
# Rest C++ with restbed
AC_ARG_WITH([restcpp],
AS_HELP_STRING([--with-restcpp], [enable rest support with C++]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment