From 2130f067b601ca9dfa0a8c7c4f1d1a1a32915204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 2 Apr 2019 17:10:48 -0400 Subject: [PATCH] sources: rename to jami * rename namespace from ring to jami * rename logs methods from RING_* to JAMI_* * rename RING_VIDEO to ENABLE_VIDEO Change-Id: Ic98498652d7059fafe58a96220d565bcdfa53658 --- MSVC/config.h | 2 +- bin/dbus/Makefile.am | 6 +- bin/dbus/dbusclient.cpp | 12 +- bin/dbus/dbusclient.h | 4 +- bin/jni/ringservice.c.template | 26 +- bin/main.cpp | 4 +- bin/osxmain.cpp | 6 +- bin/restcpp/restclient.cpp | 20 +- bin/restcpp/restclient.h | 2 +- bin/restcpp/restconfigurationmanager.cpp | 176 ++++---- bin/restcpp/restconfigurationmanager.h | 2 +- bin/restcpp/restvideomanager.cpp | 4 +- bin/restcpp/restvideomanager.h | 2 +- bin/winmain.cpp | 6 +- configure.ac | 10 +- src/Makefile.am | 22 +- src/account.cpp | 24 +- src/account.h | 12 +- src/account_factory.cpp | 16 +- src/account_factory.h | 4 +- src/account_schema.h | 4 +- src/archiver.cpp | 30 +- src/archiver.h | 4 +- src/array_size.h | 4 +- src/base64.cpp | 4 +- src/base64.h | 4 +- src/call.cpp | 36 +- src/call.h | 4 +- src/call_factory.cpp | 10 +- src/call_factory.h | 8 +- src/channel.h | 4 +- src/client/Makefile.am | 2 +- src/client/callmanager.cpp | 92 ++--- src/client/configurationmanager.cpp | 352 ++++++++-------- src/client/datatransfer.cpp | 12 +- src/client/presencemanager.cpp | 40 +- src/client/ring_signal.cpp | 10 +- src/client/ring_signal.h | 8 +- src/client/videomanager.cpp | 122 +++--- src/client/videomanager.h | 4 +- src/conference.cpp | 24 +- src/conference.h | 10 +- src/config/serializable.h | 4 +- src/config/yamlparser.cpp | 4 +- src/config/yamlparser.h | 4 +- src/data_transfer.cpp | 34 +- src/data_transfer.h | 4 +- src/debug_utils.h | 8 +- src/dring/videomanager_interface.h | 12 +- src/enumclass_utils.h | 8 +- src/fileutils.cpp | 62 +-- src/fileutils.h | 4 +- src/ftp_server.cpp | 14 +- src/ftp_server.h | 4 +- src/generic_io.h | 4 +- src/hooks/urlhook.cpp | 4 +- src/hooks/urlhook.h | 4 +- src/ice_socket.h | 2 +- src/ice_transport.cpp | 106 ++--- src/ice_transport.h | 2 +- src/im/instant_messaging.cpp | 20 +- src/im/instant_messaging.h | 4 +- src/im/message_engine.cpp | 28 +- src/im/message_engine.h | 4 +- src/ip_utils.cpp | 18 +- src/ip_utils.h | 4 +- src/logger.cpp | 10 +- src/logger.h | 24 +- src/manager.cpp | 308 +++++++------- src/manager.h | 10 +- src/map_utils.h | 4 +- src/media/Makefile.am | 4 +- src/media/audio/alsa/alsalayer.cpp | 44 +- src/media/audio/alsa/alsalayer.h | 4 +- src/media/audio/audio_frame_resizer.cpp | 12 +- src/media/audio/audio_frame_resizer.h | 4 +- src/media/audio/audio_input.cpp | 26 +- src/media/audio/audio_input.h | 4 +- src/media/audio/audio_receive_thread.cpp | 18 +- src/media/audio/audio_receive_thread.h | 4 +- src/media/audio/audio_rtp_session.cpp | 26 +- src/media/audio/audio_rtp_session.h | 4 +- src/media/audio/audio_sender.cpp | 14 +- src/media/audio/audio_sender.h | 8 +- src/media/audio/audiobuffer.cpp | 10 +- src/media/audio/audiobuffer.h | 4 +- src/media/audio/audiolayer.cpp | 8 +- src/media/audio/audiolayer.h | 4 +- src/media/audio/audioloop.cpp | 10 +- src/media/audio/audioloop.h | 4 +- src/media/audio/coreaudio/ios/corelayer.cpp | 20 +- src/media/audio/coreaudio/ios/corelayer.h | 6 +- src/media/audio/coreaudio/osx/audiodevice.cpp | 4 +- src/media/audio/coreaudio/osx/audiodevice.h | 2 +- src/media/audio/coreaudio/osx/corelayer.cpp | 14 +- src/media/audio/coreaudio/osx/corelayer.h | 4 +- src/media/audio/dcblocker.cpp | 4 +- src/media/audio/dcblocker.h | 4 +- src/media/audio/dsp.cpp | 6 +- src/media/audio/dsp.h | 4 +- src/media/audio/jack/jacklayer.cpp | 20 +- src/media/audio/jack/jacklayer.h | 2 +- src/media/audio/opensl/audio_common.h | 4 +- src/media/audio/opensl/audio_player.cpp | 18 +- src/media/audio/opensl/audio_player.h | 6 +- src/media/audio/opensl/audio_recorder.cpp | 10 +- src/media/audio/opensl/audio_recorder.h | 6 +- src/media/audio/opensl/opensllayer.cpp | 56 +-- src/media/audio/opensl/opensllayer.h | 2 +- src/media/audio/portaudio/portaudiolayer.cpp | 44 +- src/media/audio/portaudio/portaudiolayer.h | 4 +- src/media/audio/pulseaudio/audiostream.cpp | 32 +- src/media/audio/pulseaudio/audiostream.h | 2 +- src/media/audio/pulseaudio/pulselayer.cpp | 50 +-- src/media/audio/pulseaudio/pulselayer.h | 4 +- src/media/audio/resampler.cpp | 12 +- src/media/audio/resampler.h | 4 +- src/media/audio/ringbuffer.cpp | 8 +- src/media/audio/ringbuffer.h | 4 +- src/media/audio/ringbufferpool.cpp | 26 +- src/media/audio/ringbufferpool.h | 4 +- src/media/audio/sound/audiofile.cpp | 6 +- src/media/audio/sound/audiofile.h | 4 +- src/media/audio/sound/dtmf.cpp | 4 +- src/media/audio/sound/dtmf.h | 4 +- src/media/audio/sound/dtmfgenerator.cpp | 4 +- src/media/audio/sound/dtmfgenerator.h | 4 +- src/media/audio/sound/tone.cpp | 4 +- src/media/audio/sound/tone.h | 4 +- src/media/audio/sound/tonelist.cpp | 4 +- src/media/audio/sound/tonelist.h | 4 +- src/media/audio/tonecontrol.cpp | 6 +- src/media/audio/tonecontrol.h | 4 +- src/media/decoder_finder.h | 4 +- src/media/libav_utils.cpp | 8 +- src/media/libav_utils.h | 4 +- src/media/localrecorder.cpp | 20 +- src/media/localrecorder.h | 8 +- src/media/localrecordermanager.cpp | 4 +- src/media/localrecordermanager.h | 4 +- src/media/media_buffer.cpp | 8 +- src/media/media_buffer.h | 8 +- src/media/media_codec.cpp | 14 +- src/media/media_codec.h | 6 +- src/media/media_decoder.cpp | 58 +-- src/media/media_decoder.h | 12 +- src/media/media_device.h | 2 +- src/media/media_encoder.cpp | 73 ++-- src/media/media_encoder.h | 14 +- src/media/media_filter.cpp | 14 +- src/media/media_filter.h | 4 +- src/media/media_io_handle.cpp | 4 +- src/media/media_io_handle.h | 4 +- src/media/media_recorder.cpp | 50 +-- src/media/media_recorder.h | 4 +- src/media/media_stream.h | 4 +- src/media/recordable.cpp | 14 +- src/media/recordable.h | 4 +- src/media/rtp_session.h | 4 +- src/media/socket_pair.cpp | 18 +- src/media/socket_pair.h | 4 +- src/media/system_codec_container.cpp | 12 +- src/media/system_codec_container.h | 4 +- src/media/video/accel.cpp | 32 +- src/media/video/accel.h | 4 +- .../video/androidvideo/video_device_impl.cpp | 10 +- .../video_device_monitor_impl.cpp | 4 +- src/media/video/filter_transpose.cpp | 6 +- src/media/video/filter_transpose.h | 2 +- .../video/iosvideo/video_device_impl.cpp | 10 +- .../iosvideo/video_device_monitor_impl.cpp | 4 +- src/media/video/osxvideo/video_device_impl.mm | 4 +- .../osxvideo/video_device_monitor_impl.mm | 8 +- src/media/video/sinkclient.cpp | 22 +- src/media/video/sinkclient.h | 10 +- .../video/uwpvideo/video_device_impl.cpp | 10 +- .../uwpvideo/video_device_monitor_impl.cpp | 4 +- src/media/video/v4l2/video_device_impl.cpp | 10 +- .../video/v4l2/video_device_monitor_impl.cpp | 20 +- src/media/video/video_base.cpp | 14 +- src/media/video/video_base.h | 14 +- src/media/video/video_device.h | 16 +- src/media/video/video_device_monitor.cpp | 8 +- src/media/video/video_device_monitor.h | 4 +- src/media/video/video_input.cpp | 46 +-- src/media/video/video_input.h | 6 +- src/media/video/video_mixer.cpp | 10 +- src/media/video/video_mixer.h | 4 +- src/media/video/video_receive_thread.cpp | 16 +- src/media/video/video_receive_thread.h | 8 +- src/media/video/video_rtp_session.cpp | 64 +-- src/media/video/video_rtp_session.h | 8 +- src/media/video/video_scaler.cpp | 8 +- src/media/video/video_scaler.h | 4 +- src/media/video/video_sender.cpp | 10 +- src/media/video/video_sender.h | 6 +- .../video/winvideo/capture_graph_interfaces.h | 4 +- .../video/winvideo/video_device_impl.cpp | 14 +- .../winvideo/video_device_monitor_impl.cpp | 12 +- src/observer.h | 4 +- src/peer_connection.cpp | 22 +- src/peer_connection.h | 4 +- src/preferences.cpp | 28 +- src/preferences.h | 8 +- src/rational.h | 2 +- src/registration_states.h | 4 +- src/ring_api.cpp | 12 +- src/ring_types.h | 4 +- src/ringdht/accountarchive.cpp | 10 +- src/ringdht/accountarchive.h | 2 +- src/ringdht/configkeys.h | 2 +- src/ringdht/namedirectory.cpp | 52 +-- src/ringdht/namedirectory.h | 2 +- src/ringdht/p2p.cpp | 64 +-- src/ringdht/p2p.h | 2 +- src/ringdht/ringaccount.cpp | 386 +++++++++--------- src/ringdht/ringaccount.h | 4 +- src/ringdht/ringcontact.h | 2 +- src/ringdht/sips_transport_ice.cpp | 28 +- src/ringdht/sips_transport_ice.h | 8 +- src/rw_mutex.h | 4 +- src/scheduled_executor.cpp | 4 +- src/scheduled_executor.h | 2 +- src/security/certstore.cpp | 16 +- src/security/certstore.h | 4 +- src/security/diffie-hellman.cpp | 14 +- src/security/diffie-hellman.h | 4 +- src/security/memory.cpp | 4 +- src/security/memory.h | 2 +- src/security/tls_session.cpp | 136 +++--- src/security/tls_session.h | 4 +- src/security/tlsvalidator.cpp | 66 +-- src/security/tlsvalidator.h | 4 +- src/sip/pres_sub_client.cpp | 46 +-- src/sip/pres_sub_client.h | 4 +- src/sip/pres_sub_server.cpp | 34 +- src/sip/pres_sub_server.h | 4 +- src/sip/sdes_negotiator.cpp | 4 +- src/sip/sdes_negotiator.h | 4 +- src/sip/sdp.cpp | 68 +-- src/sip/sdp.h | 4 +- src/sip/sip_utils.cpp | 8 +- src/sip/sip_utils.h | 4 +- src/sip/sipaccount.cpp | 170 ++++---- src/sip/sipaccount.h | 4 +- src/sip/sipaccountbase.cpp | 30 +- src/sip/sipaccountbase.h | 6 +- src/sip/sipcall.cpp | 152 +++---- src/sip/sipcall.h | 12 +- src/sip/sippresence.cpp | 52 +-- src/sip/sippresence.h | 4 +- src/sip/siptransport.cpp | 54 +-- src/sip/siptransport.h | 6 +- src/sip/sipvoiplink.cpp | 146 +++---- src/sip/sipvoiplink.h | 8 +- src/smartools.cpp | 8 +- src/smartools.h | 2 +- src/string_utils.cpp | 6 +- src/string_utils.h | 4 +- src/thread_pool.cpp | 4 +- src/thread_pool.h | 2 +- src/threadloop.cpp | 16 +- src/threadloop.h | 4 +- src/turn_transport.cpp | 14 +- src/turn_transport.h | 4 +- src/upnp/upnp_context.cpp | 158 +++---- src/upnp/upnp_context.h | 6 +- src/upnp/upnp_control.cpp | 6 +- src/upnp/upnp_control.h | 6 +- src/upnp/upnp_igd.cpp | 4 +- src/upnp/upnp_igd.h | 8 +- src/utf8_utils.cpp | 4 +- src/utf8_utils.h | 4 +- test/sip/test_SIP.cpp | 2 +- test/turn/test_TURN.cpp | 2 +- .../account_factory/testAccount_factory.cpp | 6 +- test/unitTest/base64/base64.cpp | 12 +- test/unitTest/certstore.cpp | 44 +- test/unitTest/channel/testChannel.cpp | 10 +- test/unitTest/fileutils/testFileutils.cpp | 6 +- test/unitTest/map_utils/testMap_utils.cpp | 6 +- .../media/audio/test_audio_frame_resizer.cpp | 6 +- test/unitTest/media/audio/test_resampler.cpp | 6 +- test/unitTest/media/test_media_decoder.cpp | 6 +- test/unitTest/media/test_media_encoder.cpp | 12 +- test/unitTest/media/test_media_filter.cpp | 6 +- test/unitTest/media/test_media_frame.cpp | 6 +- test/unitTest/media/video/testVideo_input.cpp | 6 +- .../media/video/test_video_scaler.cpp | 6 +- test/unitTest/smartools/testSmartools.cpp | 6 +- .../string_utils/testString_utils.cpp | 10 +- test/unitTest/utf8_utils/testUtf8_utils.cpp | 6 +- 292 files changed, 2752 insertions(+), 2753 deletions(-) diff --git a/MSVC/config.h b/MSVC/config.h index 7b7428d48e..f5222f2dbf 100644 --- a/MSVC/config.h +++ b/MSVC/config.h @@ -169,7 +169,7 @@ your system. */ /* #undef PTHREAD_CREATE_JOINABLE */ /* Video support enabled */ -#define RING_VIDEO /**/ +#define ENABLE_VIDEO /**/ /* Name directory service support enabled */ #define HAVE_RINGNS 1 diff --git a/bin/dbus/Makefile.am b/bin/dbus/Makefile.am index 99eec615bf..014d9b4d4d 100644 --- a/bin/dbus/Makefile.am +++ b/bin/dbus/Makefile.am @@ -11,7 +11,7 @@ BUILT_SOURCES+=dbuspresencemanager.adaptor.h dbuspresencemanager.adaptor.h: cx.ring.Ring.PresenceManager.xml Makefile.am dbusxx-xml2cpp $< --adaptor=$@ -if RING_VIDEO +if ENABLE_VIDEO BUILT_SOURCES+=dbusvideomanager.adaptor.h dbusvideomanager.adaptor.h: cx.ring.Ring.VideoManager.xml Makefile.am dbusxx-xml2cpp $< --adaptor=$@ @@ -43,7 +43,7 @@ libclient_dbus_la_SOURCES = \ dbuspresencemanager.h \ $(BUILT_SOURCES) -if RING_VIDEO +if ENABLE_VIDEO libclient_dbus_la_SOURCES += dbusvideomanager.cpp dbusvideomanager.h endif @@ -66,7 +66,7 @@ interface_DATA = cx.ring.Ring.CallManager.xml \ cx.ring.Ring.Instance.xml \ cx.ring.Ring.PresenceManager.xml -if RING_VIDEO +if ENABLE_VIDEO interface_DATA += cx.ring.Ring.VideoManager.xml endif diff --git a/bin/dbus/dbusclient.cpp b/bin/dbus/dbusclient.cpp index ac97d336b7..c7038b9ed8 100644 --- a/bin/dbus/dbusclient.cpp +++ b/bin/dbus/dbusclient.cpp @@ -44,7 +44,7 @@ #include "datatransfer_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "dbusvideomanager.h" #include "videomanager_interface.h" #endif @@ -85,7 +85,7 @@ DBusClient::DBusClient(int flags, bool persistent) instanceManager_.reset(new DBusInstance {sessionConnection, onNoMoreClientFunc}); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videoManager_.reset(new DBusVideoManager {sessionConnection}); #endif } catch (const DBus::Error &err) { @@ -103,7 +103,7 @@ DBusClient::~DBusClient() // instances destruction order is important // so we enforce it here -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videoManager_.reset(); #endif instanceManager_.reset(); @@ -131,7 +131,7 @@ DBusClient::initLibrary(int flags) auto confM = configurationManager_.get(); auto presM = presenceManager_.get(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO using DRing::VideoSignal; auto videoM = videoManager_.get(); #endif @@ -208,7 +208,7 @@ DBusClient::initLibrary(int flags) exportable_callback<DataTransferSignal::DataTransferEvent>(bind(&DBusConfigurationManager::dataTransferEvent, confM, _1, _2)), }; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // Video event handlers const std::map<std::string, SharedCallback> videoEvHandlers = { exportable_callback<VideoSignal::DeviceEvent>(bind(&DBusVideoManager::deviceEvent, videoM)), @@ -225,7 +225,7 @@ DBusClient::initLibrary(int flags) registerSignalHandlers(presEvHandlers); registerSignalHandlers(audioEvHandlers); registerSignalHandlers(dataXferEvHandlers); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO registerSignalHandlers(videoEvHandlers); #endif diff --git a/bin/dbus/dbusclient.h b/bin/dbus/dbusclient.h index 4334dd7485..d7032c03bc 100644 --- a/bin/dbus/dbusclient.h +++ b/bin/dbus/dbusclient.h @@ -35,7 +35,7 @@ class DBusNetworkManager; class DBusInstance; class DBusPresenceManager; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO class DBusVideoManager; #endif @@ -64,7 +64,7 @@ class DRING_PUBLIC DBusClient { std::unique_ptr<DBusPresenceManager> presenceManager_; std::unique_ptr<DBusInstance> instanceManager_; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::unique_ptr<DBusVideoManager> videoManager_; #endif }; diff --git a/bin/jni/ringservice.c.template b/bin/jni/ringservice.c.template index 37d03f1be8..6d910ae45e 100644 --- a/bin/jni/ringservice.c.template +++ b/bin/jni/ringservice.c.template @@ -27,11 +27,11 @@ JavaVM *gJavaVM; const char *kringservicePath = "cx/ring/daemon/RingserviceJNI"; void deinitClassHelper(JNIEnv *env, jobject obj) { - RING_INFO("deinitClassHelper"); + JAMI_INFO("deinitClassHelper"); /* delete cached object instances */ env->DeleteGlobalRef(obj); - RING_INFO("deinitClassHelper: object %p deleted", obj); + JAMI_INFO("deinitClassHelper: object %p deleted", obj); } JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { @@ -39,26 +39,26 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { jclass clazz; jint r; - RING_INFO("JNI_OnLoad"); + JAMI_INFO("JNI_OnLoad"); if (av_jni_set_java_vm(vm, reserved)) { - RING_ERR("JNI_OnLoad: av_jni_set_java_vm failed"); + JAMI_ERR("JNI_OnLoad: av_jni_set_java_vm failed"); } //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()"); + JAMI_ERR("JNI_OnLoad: failed to get the environment using GetEnv()"); return -1; } - RING_INFO("JNI_Onload: GetEnv %p", env); + JAMI_INFO("JNI_Onload: GetEnv %p", env); clazz = env->FindClass (kringservicePath); if (!clazz) { - RING_ERR("JNI_Onload: whoops, %s class not found!", kringservicePath); + JAMI_ERR("JNI_Onload: whoops, %s class not found!", kringservicePath); } gJavaVM = vm; - RING_INFO("JNI_Onload: JavaVM %p", gJavaVM); + JAMI_INFO("JNI_Onload: JavaVM %p", gJavaVM); /* put instances of class object we need into cache */ //initClassHelper(env, kManagerPath, &gManagerObject); @@ -77,24 +77,24 @@ void JNI_OnUnLoad(JavaVM* vm, void* reserved) { JNIEnv* env; jclass clazz; - RING_INFO("JNI_OnUnLoad"); + JAMI_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()"); + JAMI_ERR("JNI_OnUnLoad: failed to get the environment using GetEnv()"); return; } - RING_INFO("JNI_OnUnLoad: GetEnv %p", env); + JAMI_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); + JAMI_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"); + JAMI_INFO("JNI_OnUnLoad: Native functions unregistered"); } diff --git a/bin/main.cpp b/bin/main.cpp index bb48e2c3d1..81b7efb6c3 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -56,7 +56,7 @@ print_title() << "Jami Daemon " << DRing::version() << ", by Savoir-faire Linux 2004-2019" << std::endl << "https://jami.net/" << std::endl -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif << std::endl; @@ -191,7 +191,7 @@ main(int argc, char *argv []) std::vector<char> writable(programName.size() + 1); std::copy(programName.begin(), programName.end(), writable.begin()); - ring::fileutils::set_program_dir(writable.data()); + jami::fileutils::set_program_dir(writable.data()); #ifdef TOP_BUILDDIR if (!getenv("CODECS_PATH")) diff --git a/bin/osxmain.cpp b/bin/osxmain.cpp index f1c3face10..023c70ec15 100644 --- a/bin/osxmain.cpp +++ b/bin/osxmain.cpp @@ -31,7 +31,7 @@ #include "callmanager_interface.h" #include "configurationmanager_interface.h" #include "presencemanager_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "videomanager_interface.h" #endif #include "fileutils.h" @@ -45,7 +45,7 @@ print_title() << "Jami Daemon " << DRing::version() << ", by Savoir-faire Linux 2004-2019" << std::endl << "https://jami.net/" << std::endl -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif << std::endl; @@ -197,7 +197,7 @@ main(int argc, char *argv []) std::vector<char> writable(programName.size() + 1); std::copy(programName.begin(), programName.end(), writable.begin()); - ring::fileutils::set_program_dir(writable.data()); + jami::fileutils::set_program_dir(writable.data()); #ifdef TOP_BUILDDIR if (!getenv("CODECS_PATH")) diff --git a/bin/restcpp/restclient.cpp b/bin/restcpp/restclient.cpp index 52896fb8b6..5e60ff84fa 100644 --- a/bin/restcpp/restclient.cpp +++ b/bin/restcpp/restclient.cpp @@ -35,7 +35,7 @@ RestClient::RestClient(int port, int flags, bool persistent) : settings_ = std::make_shared<restbed::Settings>(); settings_->set_port(port); settings_->set_default_header( "Connection", "close" ); - RING_INFO("Restclient running on port [%d]", port); + JAMI_INFO("Restclient running on port [%d]", port); // Make it run in a thread, because this is a blocking function restbed = std::thread([this](){ @@ -45,7 +45,7 @@ RestClient::RestClient(int port, int flags, bool persistent) : RestClient::~RestClient() { - RING_INFO("destroying RestClient"); + JAMI_INFO("destroying RestClient"); exit(); } @@ -53,7 +53,7 @@ int RestClient::event_loop() noexcept { // While the client is running, the events are polled every 10 milliseconds - RING_INFO("Restclient starting to poll events"); + JAMI_INFO("Restclient starting to poll events"); while(!pollNoMore_) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); @@ -96,7 +96,7 @@ RestClient::initLib(int flags) auto confM = configurationManager_.get(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO using DRing::VideoSignal; #endif @@ -125,11 +125,11 @@ RestClient::initLib(int flags) const std::map<std::string, SharedCallback> configEvHandlers = { exportable_callback<ConfigurationSignal::IncomingAccountMessage>([] (const std::string& accountID, const std::string& from, const std::map<std::string, std::string>& payloads){ - RING_INFO("accountID : %s", accountID.c_str()); - RING_INFO("from : %s", from.c_str()); - RING_INFO("payloads"); + JAMI_INFO("accountID : %s", accountID.c_str()); + JAMI_INFO("from : %s", from.c_str()); + JAMI_INFO("payloads"); for(auto& it : payloads) - RING_INFO("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_INFO("%s : %s", it.first.c_str(), it.second.c_str()); }), registeredNameFoundCb, @@ -143,7 +143,7 @@ RestClient::initLib(int flags) // Dummy callbacks are registered for the other managers registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>()); registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>()); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>()); #endif @@ -170,7 +170,7 @@ RestClient::initResources() default_res->set_path("/"); default_res->set_method_handler("GET", [](const std::shared_ptr<restbed::Session> session){ - RING_INFO("[%s] GET /", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /", session->get_origin().c_str()); std::string body = "Available routes are : \r\n/configurationManager\r\n/videoManager\r\n"; diff --git a/bin/restcpp/restclient.h b/bin/restcpp/restclient.h index ec117dc6a7..cc41213251 100644 --- a/bin/restcpp/restclient.h +++ b/bin/restcpp/restclient.h @@ -35,7 +35,7 @@ #include "dring/callmanager_interface.h" #include "dring/configurationmanager_interface.h" #include "dring/presencemanager_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "dring/videomanager_interface.h" #endif #include "logger.h" diff --git a/bin/restcpp/restconfigurationmanager.cpp b/bin/restcpp/restconfigurationmanager.cpp index e4f48d8b17..80a5ce4375 100644 --- a/bin/restcpp/restconfigurationmanager.cpp +++ b/bin/restcpp/restconfigurationmanager.cpp @@ -405,7 +405,7 @@ RestConfigurationManager::populateResources() void RestConfigurationManager::defaultRoute(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /configurationManager", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /configurationManager", session->get_origin().c_str()); std::string body = "Available routes are : \r\n"; body += "GET /accountDetails/{accountID: [a-z0-9]*}\r\n"; @@ -487,7 +487,7 @@ RestConfigurationManager::getAccountDetails(const std::shared_ptr<restbed::Sessi const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /accountDetails/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /accountDetails/%s", session->get_origin().c_str(), accountID.c_str()); std::map<std::string, std::string> accountDetails = DRing::getAccountDetails(accountID); @@ -518,7 +518,7 @@ RestConfigurationManager::getVolatileAccountDetails(const std::shared_ptr<restbe const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /volatileAccountDetails/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /volatileAccountDetails/%s", session->get_origin().c_str(), accountID.c_str()); std::map<std::string, std::string> volatileAccountDetails = DRing::getAccountDetails(accountID); @@ -551,16 +551,16 @@ RestConfigurationManager::setAccountDetails(const std::shared_ptr<restbed::Sessi size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /setAccountDetails/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] POST /setAccountDetails/%s", session->get_origin().c_str(), accountID.c_str()); session->fetch(content_length, [this, request, accountID](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Details received"); + JAMI_DBG("Details received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::setAccountDetails(accountID, details); @@ -575,16 +575,16 @@ RestConfigurationManager::registerName(const std::shared_ptr<restbed::Session> s const std::string accountID = request->get_path_parameter("accountID"); size_t content_length = request->get_header("Content-Length", 0); - RING_INFO("[%s] POST /registerName/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] POST /registerName/%s", session->get_origin().c_str(), accountID.c_str()); if(content_length > 0){ session->fetch(content_length, [this, request, accountID](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Details received"); + JAMI_DBG("Details received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); if (details.find("password") == details.end() ){ session->close(400, "password parameter required"); @@ -631,7 +631,7 @@ RestConfigurationManager::lookupName(const std::shared_ptr<restbed::Session> ses const auto request = session->get_request(); const std::string name = request->get_path_parameter("name"); - RING_WARN("[%s] GET /lookupName/%s", session->get_origin().c_str(), name.c_str()); + JAMI_WARN("[%s] GET /lookupName/%s", session->get_origin().c_str(), name.c_str()); addPendingNameResolutions(name, session); DRing::lookupName("", "", name); @@ -646,7 +646,7 @@ RestConfigurationManager::setAccountActive(const std::shared_ptr<restbed::Sessio const std::string accountID = request->get_path_parameter("accountID"); const bool active = (request->get_path_parameter("status") == "true" ? true : false); - RING_INFO("[%s] GET /setAccountActive/%s/%s", session->get_origin().c_str(), accountID.c_str(), (active ? "true" : "false")); + JAMI_INFO("[%s] GET /setAccountActive/%s/%s", session->get_origin().c_str(), accountID.c_str(), (active ? "true" : "false")); DRing::setAccountActive(accountID, active); @@ -659,7 +659,7 @@ RestConfigurationManager::getAccountTemplate(const std::shared_ptr<restbed::Sess const auto request = session->get_request(); const std::string accountType = request->get_path_parameter("type"); - RING_INFO("[%s] GET /accountTemplate/%s", session->get_origin().c_str(), accountType.c_str()); + JAMI_INFO("[%s] GET /accountTemplate/%s", session->get_origin().c_str(), accountType.c_str()); std::map<std::string, std::string> accountTemplate = DRing::getAccountTemplate(accountType);; @@ -684,16 +684,16 @@ RestConfigurationManager::addAccount(const std::shared_ptr<restbed::Session> ses size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /addAccount", session->get_origin().c_str()); + JAMI_INFO("[%s] POST /addAccount", session->get_origin().c_str()); session->fetch(content_length, [this, request](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Details received"); + JAMI_DBG("Details received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::addAccount(details); @@ -707,7 +707,7 @@ RestConfigurationManager::removeAccount(const std::shared_ptr<restbed::Session> const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /removeAccount/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /removeAccount/%s", session->get_origin().c_str(), accountID.c_str()); DRing::removeAccount(accountID); @@ -719,7 +719,7 @@ RestConfigurationManager::removeAccount(const std::shared_ptr<restbed::Session> void RestConfigurationManager::getAccountList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /accountList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /accountList", session->get_origin().c_str()); std::vector<std::string> accountList = DRing::getAccountList(); @@ -750,7 +750,7 @@ RestConfigurationManager::sendRegister(const std::shared_ptr<restbed::Session> s const std::string accountID = request->get_path_parameter("accountID"); const bool enable = (request->get_path_parameter("status") == "true" ? true : false); - RING_INFO("[%s] GET /sendRegister/%s/%s", session->get_origin().c_str(), accountID.c_str(), (enable ? "true" : "false")); + JAMI_INFO("[%s] GET /sendRegister/%s/%s", session->get_origin().c_str(), accountID.c_str(), (enable ? "true" : "false")); DRing::sendRegister(accountID, enable); @@ -760,7 +760,7 @@ RestConfigurationManager::sendRegister(const std::shared_ptr<restbed::Session> s void RestConfigurationManager::registerAllAccounts(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /registerAllAccounts", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /registerAllAccounts", session->get_origin().c_str()); DRing::registerAllAccounts(); @@ -777,15 +777,15 @@ RestConfigurationManager::sendTextMessage(const std::shared_ptr<restbed::Session size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /sendTextMessage/%s/%s", session->get_origin().c_str(), accountID.c_str(), to.c_str()); + JAMI_INFO("[%s] POST /sendTextMessage/%s/%s", session->get_origin().c_str(), accountID.c_str(), to.c_str()); session->fetch(content_length, [this, request, accountID, to](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> payloads = parsePost(data); - RING_DBG("Payloads received"); + JAMI_DBG("Payloads received"); for(auto& it : payloads) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::sendAccountTextMessage(accountID, to, payloads); @@ -799,25 +799,25 @@ RestConfigurationManager::getMessageStatus(const std::shared_ptr<restbed::Sessio const auto request = session->get_request(); const std::string id = request->get_path_parameter("id"); - RING_INFO("[%s] GET /messageStatus/%s", session->get_origin().c_str(), id.c_str()); + JAMI_INFO("[%s] GET /messageStatus/%s", session->get_origin().c_str(), id.c_str()); const std::uint64_t status = DRing::getMessageStatus(std::stoull(id)); std::string body = ""; - if (status != static_cast<int>(ring::im::MessageStatus::UNKNOWN)) { + if (status != static_cast<int>(jami::im::MessageStatus::UNKNOWN)) { switch (status) { - case static_cast<int>(ring::im::MessageStatus::IDLE): - case static_cast<int>(ring::im::MessageStatus::SENDING): + case static_cast<int>(jami::im::MessageStatus::IDLE): + case static_cast<int>(jami::im::MessageStatus::SENDING): body = "SENDING"; break; - case static_cast<int>(ring::im::MessageStatus::SENT): + case static_cast<int>(jami::im::MessageStatus::SENT): body = "SENT"; break; - case static_cast<int>(ring::im::MessageStatus::READ): + case static_cast<int>(jami::im::MessageStatus::READ): body = "READ"; break; - case static_cast<int>(ring::im::MessageStatus::FAILURE): + case static_cast<int>(jami::im::MessageStatus::FAILURE): body = "FAILURE"; break; default: @@ -843,7 +843,7 @@ RestConfigurationManager::getMessageStatus(const std::shared_ptr<restbed::Sessio void RestConfigurationManager::getTlsDefaultSettings(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /tlsDefaultSettings", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /tlsDefaultSettings", session->get_origin().c_str()); std::map<std::string, std::string> tlsDefault = DRing::getTlsDefaultSettings(); @@ -864,7 +864,7 @@ RestConfigurationManager::getTlsDefaultSettings(const std::shared_ptr<restbed::S void RestConfigurationManager::getCodecList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /codecList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /codecList", session->get_origin().c_str()); std::vector<unsigned> codec = DRing::getCodecList(); @@ -885,7 +885,7 @@ RestConfigurationManager::getCodecList(const std::shared_ptr<restbed::Session> s void RestConfigurationManager::getSupportedTlsMethod(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /supportedTlsMethod", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /supportedTlsMethod", session->get_origin().c_str()); std::vector<std::string> supported = DRing::getSupportedTlsMethod(); @@ -909,7 +909,7 @@ RestConfigurationManager::getSupportedCiphers(const std::shared_ptr<restbed::Ses const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /supportedCiphers/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /supportedCiphers/%s", session->get_origin().c_str(), accountID.c_str()); std::vector<std::string> supported = DRing::getSupportedCiphers(accountID); @@ -934,7 +934,7 @@ RestConfigurationManager::getCodecDetails(const std::shared_ptr<restbed::Session const std::string accountID = request->get_path_parameter("accountID"); const std::string codecID = request->get_path_parameter("codecID"); - RING_INFO("[%s] GET /codecDetails/%s/%s", session->get_origin().c_str(), accountID.c_str(), codecID.c_str()); + JAMI_INFO("[%s] GET /codecDetails/%s/%s", session->get_origin().c_str(), accountID.c_str(), codecID.c_str()); std::map<std::string, std::string> details = DRing::getCodecDetails(accountID, std::stoi(codecID)); @@ -962,16 +962,16 @@ RestConfigurationManager::setCodecDetails(const std::shared_ptr<restbed::Session size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /setCodecDetails/%s/%s", session->get_origin().c_str(), accountID.c_str(), codecID.c_str()); + JAMI_INFO("[%s] POST /setCodecDetails/%s/%s", session->get_origin().c_str(), accountID.c_str(), codecID.c_str()); session->fetch(content_length, [this, request, accountID, codecID](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Details received"); + JAMI_DBG("Details received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::setCodecDetails(accountID, std::stoi(codecID), details); @@ -985,7 +985,7 @@ RestConfigurationManager::getActiveCodecList(const std::shared_ptr<restbed::Sess const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /activeCodecList/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /activeCodecList/%s", session->get_origin().c_str(), accountID.c_str()); std::vector<unsigned> codecs = DRing::getActiveCodecList(accountID); @@ -1014,7 +1014,7 @@ RestConfigurationManager::setActiveCodecList(const std::string& accountID, const void RestConfigurationManager::getAudioPluginList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /audioPluginList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /audioPluginList", session->get_origin().c_str()); std::vector<std::string> list = DRing::getAudioPluginList(); @@ -1038,7 +1038,7 @@ RestConfigurationManager::setAudioPlugin(const std::shared_ptr<restbed::Session> const auto request = session->get_request(); const std::string plugin = request->get_path_parameter("plugin"); - RING_INFO("[%s] GET /setAudioPlugin/%s", session->get_origin().c_str(), plugin.c_str()); + JAMI_INFO("[%s] GET /setAudioPlugin/%s", session->get_origin().c_str(), plugin.c_str()); DRing::setAudioPlugin(plugin); @@ -1048,7 +1048,7 @@ RestConfigurationManager::setAudioPlugin(const std::shared_ptr<restbed::Session> void RestConfigurationManager::getAudioOutputDeviceList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /audioOutputDeviceList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /audioOutputDeviceList", session->get_origin().c_str()); std::vector<std::string> list = DRing::getAudioOutputDeviceList(); @@ -1072,7 +1072,7 @@ RestConfigurationManager::setAudioOutputDevice(const std::shared_ptr<restbed::Se const auto request = session->get_request(); const std::string index = request->get_path_parameter("index"); - RING_INFO("[%s] GET /setAudioOutputDevice/%s", session->get_origin().c_str(), index.c_str()); + JAMI_INFO("[%s] GET /setAudioOutputDevice/%s", session->get_origin().c_str(), index.c_str()); DRing::setAudioOutputDevice(std::stoi(index)); @@ -1085,7 +1085,7 @@ RestConfigurationManager::setAudioInputDevice(const std::shared_ptr<restbed::Ses const auto request = session->get_request(); const std::string index = request->get_path_parameter("index"); - RING_INFO("[%s] GET /setAudioInputDevice/%s", session->get_origin().c_str(), index.c_str()); + JAMI_INFO("[%s] GET /setAudioInputDevice/%s", session->get_origin().c_str(), index.c_str()); DRing::setAudioInputDevice(std::stoi(index)); @@ -1098,7 +1098,7 @@ RestConfigurationManager::setAudioRingtoneDevice(const std::shared_ptr<restbed:: const auto request = session->get_request(); const std::string index = request->get_path_parameter("index"); - RING_INFO("[%s] GET /setAudioRingtoneDevice/%s", session->get_origin().c_str(), index.c_str()); + JAMI_INFO("[%s] GET /setAudioRingtoneDevice/%s", session->get_origin().c_str(), index.c_str()); DRing::setAudioRingtoneDevice(std::stoi(index)); @@ -1108,7 +1108,7 @@ RestConfigurationManager::setAudioRingtoneDevice(const std::shared_ptr<restbed:: void RestConfigurationManager::getAudioInputDeviceList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /audioInputDeviceList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /audioInputDeviceList", session->get_origin().c_str()); std::vector<std::string> list = DRing::getAudioInputDeviceList(); @@ -1129,7 +1129,7 @@ RestConfigurationManager::getAudioInputDeviceList(const std::shared_ptr<restbed: void RestConfigurationManager::getCurrentAudioDevicesIndex(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /currentAudioDevicesIndex", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /currentAudioDevicesIndex", session->get_origin().c_str()); std::vector<std::string> list = DRing::getCurrentAudioDevicesIndex(); @@ -1153,7 +1153,7 @@ RestConfigurationManager::getAudioInputDeviceIndex(const std::shared_ptr<restbed const auto request = session->get_request(); const std::string name = request->get_path_parameter("name"); - RING_INFO("[%s] GET /audioInputDeviceIndex/%s", session->get_origin().c_str(), name.c_str()); + JAMI_INFO("[%s] GET /audioInputDeviceIndex/%s", session->get_origin().c_str(), name.c_str()); std::int32_t index = DRing::getAudioInputDeviceIndex(name); @@ -1174,7 +1174,7 @@ RestConfigurationManager::getAudioOutputDeviceIndex(const std::shared_ptr<restbe const auto request = session->get_request(); const std::string name = request->get_path_parameter("name"); - RING_INFO("[%s] GET /audioOutputDeviceIndex/%s", session->get_origin().c_str(), name.c_str()); + JAMI_INFO("[%s] GET /audioOutputDeviceIndex/%s", session->get_origin().c_str(), name.c_str()); std::int32_t index = DRing::getAudioOutputDeviceIndex(name); @@ -1192,7 +1192,7 @@ RestConfigurationManager::getAudioOutputDeviceIndex(const std::shared_ptr<restbe void RestConfigurationManager::getCurrentAudioOutputPlugin(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /currentAudioOutputPlugin", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /currentAudioOutputPlugin", session->get_origin().c_str()); std::string body = DRing::getCurrentAudioOutputPlugin(); @@ -1208,7 +1208,7 @@ RestConfigurationManager::getCurrentAudioOutputPlugin(const std::shared_ptr<rest void RestConfigurationManager::getNoiseSuppressState(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /noiseSuppressState", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /noiseSuppressState", session->get_origin().c_str()); std::string body = (DRing::getNoiseSuppressState() ? "true" : "false"); @@ -1227,7 +1227,7 @@ RestConfigurationManager::setNoiseSuppressState(const std::shared_ptr<restbed::S const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /setNoiseSuppressState/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /setNoiseSuppressState/%s", session->get_origin().c_str(), state.c_str()); DRing::setNoiseSuppressState((state == "true" ? true : false)); @@ -1237,7 +1237,7 @@ RestConfigurationManager::setNoiseSuppressState(const std::shared_ptr<restbed::S void RestConfigurationManager::isAgcEnabled(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isAgcEnable", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isAgcEnable", session->get_origin().c_str()); bool status = DRing::isAgcEnabled(); std::string body = (status ? "true" : "false"); @@ -1257,7 +1257,7 @@ RestConfigurationManager::setAgcState(const std::shared_ptr<restbed::Session> se const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /setAgcState/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /setAgcState/%s", session->get_origin().c_str(), state.c_str()); DRing::setAgcState((state == "true" ? true : false)); @@ -1270,7 +1270,7 @@ RestConfigurationManager::muteDtmf(const std::shared_ptr<restbed::Session> sessi const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /muteDtmf/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /muteDtmf/%s", session->get_origin().c_str(), state.c_str()); DRing::muteDtmf((state == "true" ? true : false)); @@ -1280,7 +1280,7 @@ RestConfigurationManager::muteDtmf(const std::shared_ptr<restbed::Session> sessi void RestConfigurationManager::isDtmfMuted(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isDtmfMuted", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isDtmfMuted", session->get_origin().c_str()); bool status = DRing::isDtmfMuted(); std::string body = (status ? "true" : "false"); @@ -1297,7 +1297,7 @@ RestConfigurationManager::isDtmfMuted(const std::shared_ptr<restbed::Session> se void RestConfigurationManager::isCaptureMuted(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isCaptureMuted", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isCaptureMuted", session->get_origin().c_str()); bool status = DRing::isCaptureMuted(); std::string body = (status ? "true" : "false"); @@ -1317,7 +1317,7 @@ RestConfigurationManager::muteCapture(const std::shared_ptr<restbed::Session> se const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /muteCapture/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /muteCapture/%s", session->get_origin().c_str(), state.c_str()); DRing::muteCapture((state == "true" ? true : false)); @@ -1327,7 +1327,7 @@ RestConfigurationManager::muteCapture(const std::shared_ptr<restbed::Session> se void RestConfigurationManager::isPlaybackMuted(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isPlaybackMuted", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isPlaybackMuted", session->get_origin().c_str()); bool status = DRing::isPlaybackMuted(); std::string body = (status ? "true" : "false"); @@ -1347,7 +1347,7 @@ RestConfigurationManager::mutePlayback(const std::shared_ptr<restbed::Session> s const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /mutePlayback/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /mutePlayback/%s", session->get_origin().c_str(), state.c_str()); DRing::mutePlayback((state == "true" ? true : false)); @@ -1357,7 +1357,7 @@ RestConfigurationManager::mutePlayback(const std::shared_ptr<restbed::Session> s void RestConfigurationManager::isRingtoneMuted(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isRingtoneMuted", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isRingtoneMuted", session->get_origin().c_str()); bool status = DRing::isRingtoneMuted(); std::string body = (status ? "true" : "false"); @@ -1377,7 +1377,7 @@ RestConfigurationManager::muteRingtone(const std::shared_ptr<restbed::Session> s const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /muteRingtone/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /muteRingtone/%s", session->get_origin().c_str(), state.c_str()); DRing::muteRingtone((state == "true" ? true : false)); @@ -1387,7 +1387,7 @@ RestConfigurationManager::muteRingtone(const std::shared_ptr<restbed::Session> s void RestConfigurationManager::getAudioManager(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /audioManager", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /audioManager", session->get_origin().c_str()); std::string body = DRing::getAudioManager(); @@ -1406,7 +1406,7 @@ RestConfigurationManager::setAudioManager(const std::shared_ptr<restbed::Session const auto request = session->get_request(); const std::string api = request->get_path_parameter("api"); - RING_INFO("[%s] GET /setAudioManager/%s", session->get_origin().c_str(), api.c_str()); + JAMI_INFO("[%s] GET /setAudioManager/%s", session->get_origin().c_str(), api.c_str()); bool status = DRing::setAudioManager(api); std::string body = (status ? "true" : "false"); @@ -1425,7 +1425,7 @@ RestConfigurationManager::getSupportedAudioManagers(const std::shared_ptr<restbe { const auto request = session->get_request(); - RING_INFO("[%s] GET /supportedAudioManager", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /supportedAudioManager", session->get_origin().c_str()); std::string body = ""; #if HAVE_ALSA @@ -1450,7 +1450,7 @@ RestConfigurationManager::getSupportedAudioManagers(const std::shared_ptr<restbe void RestConfigurationManager::getRecordPath(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /recordPath", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /recordPath", session->get_origin().c_str()); std::string body = DRing::getRecordPath(); @@ -1469,7 +1469,7 @@ RestConfigurationManager::setRecordPath(const std::shared_ptr<restbed::Session> const auto request = session->get_request(); const std::string path = request->get_path_parameter("path"); - RING_INFO("[%s] GET /setRecordPath/%s", session->get_origin().c_str(), path.c_str()); + JAMI_INFO("[%s] GET /setRecordPath/%s", session->get_origin().c_str(), path.c_str()); DRing::setRecordPath(path); @@ -1479,7 +1479,7 @@ RestConfigurationManager::setRecordPath(const std::shared_ptr<restbed::Session> void RestConfigurationManager::getIsAlwaysRecording(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /isAlwaysRecording", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /isAlwaysRecording", session->get_origin().c_str()); bool status = DRing::getIsAlwaysRecording(); std::string body = (status ? "true" : "false"); @@ -1499,7 +1499,7 @@ RestConfigurationManager::setIsAlwaysRecording(const std::shared_ptr<restbed::Se const auto request = session->get_request(); const std::string state = request->get_path_parameter("state"); - RING_INFO("[%s] GET /setIsAlwaysRecording/%s", session->get_origin().c_str(), state.c_str()); + JAMI_INFO("[%s] GET /setIsAlwaysRecording/%s", session->get_origin().c_str(), state.c_str()); DRing::setIsAlwaysRecording((state == "true" ? true : false)); @@ -1512,7 +1512,7 @@ RestConfigurationManager::setHistoryLimit(const std::shared_ptr<restbed::Session const auto request = session->get_request(); const std::string days = request->get_path_parameter("limit"); - RING_INFO("[%s] GET /setHistoryLimit/%s", session->get_origin().c_str(), days.c_str()); + JAMI_INFO("[%s] GET /setHistoryLimit/%s", session->get_origin().c_str(), days.c_str()); DRing::setHistoryLimit(std::stoi(days)); @@ -1522,7 +1522,7 @@ RestConfigurationManager::setHistoryLimit(const std::shared_ptr<restbed::Session void RestConfigurationManager::getHistoryLimit(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /getHistoryLimit", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /getHistoryLimit", session->get_origin().c_str()); std::string body = std::to_string(DRing::getHistoryLimit()); @@ -1545,16 +1545,16 @@ RestConfigurationManager::setAccountsOrder(const std::shared_ptr<restbed::Sessio size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /setAccountsOrder", session->get_origin().c_str()); + JAMI_INFO("[%s] POST /setAccountsOrder", session->get_origin().c_str()); session->fetch(content_length, [this](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Order received"); + JAMI_DBG("Order received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); std::regex order("[a-z0-9]{16}\\/"); @@ -1569,7 +1569,7 @@ RestConfigurationManager::setAccountsOrder(const std::shared_ptr<restbed::Sessio void RestConfigurationManager::getHookSettings(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /hookSettings", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /hookSettings", session->get_origin().c_str()); std::map<std::string, std::string> hooks = DRing::getHookSettings(); @@ -1595,16 +1595,16 @@ RestConfigurationManager::setHookSettings(const std::shared_ptr<restbed::Session size_t content_length = 0; request->get_header("Content-Length", content_length); - RING_INFO("[%s] POST /setHookSettings", session->get_origin().c_str()); + JAMI_INFO("[%s] POST /setHookSettings", session->get_origin().c_str()); session->fetch(content_length, [this](const std::shared_ptr<restbed::Session> session, const restbed::Bytes & body) { std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> settings = parsePost(data); - RING_DBG("Settings received"); + JAMI_DBG("Settings received"); for(auto& it : settings) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::setHookSettings(settings); @@ -1618,7 +1618,7 @@ RestConfigurationManager::getCredentials(const std::shared_ptr<restbed::Session> const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] GET /credentials/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] GET /credentials/%s", session->get_origin().c_str(), accountID.c_str()); std::vector<std::map<std::string, std::string>> credentials = DRing::getCredentials(accountID); @@ -1643,7 +1643,7 @@ RestConfigurationManager::setCredentials(const std::shared_ptr<restbed::Session> const auto request = session->get_request(); const std::string accountID = request->get_path_parameter("accountID"); - RING_INFO("[%s] POST /setCredentials/%s", session->get_origin().c_str(), accountID.c_str()); + JAMI_INFO("[%s] POST /setCredentials/%s", session->get_origin().c_str(), accountID.c_str()); size_t content_length = 0; request->get_header("Content-Length", content_length); @@ -1653,9 +1653,9 @@ RestConfigurationManager::setCredentials(const std::shared_ptr<restbed::Session> std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> details = parsePost(data); - RING_DBG("Details received"); + JAMI_DBG("Details received"); for(auto& it : details) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::setCredentials(accountID, std::vector<std::map<std::string, std::string>>{details}); @@ -1669,7 +1669,7 @@ RestConfigurationManager::getAddrFromInterfaceName(const std::shared_ptr<restbed const auto request = session->get_request(); const std::string interface = request->get_path_parameter("interface"); - RING_INFO("[%s] GET /addrFromInterfaceName/%s", session->get_origin().c_str(), interface.c_str()); + JAMI_INFO("[%s] GET /addrFromInterfaceName/%s", session->get_origin().c_str(), interface.c_str()); std::string body = DRing::getAddrFromInterfaceName(interface); @@ -1685,7 +1685,7 @@ RestConfigurationManager::getAddrFromInterfaceName(const std::shared_ptr<restbed void RestConfigurationManager::getAllIpInterface(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /allIpInterface", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /allIpInterface", session->get_origin().c_str()); std::vector<std::string> interfaces = DRing::getAllIpInterface(); @@ -1706,7 +1706,7 @@ RestConfigurationManager::getAllIpInterface(const std::shared_ptr<restbed::Sessi void RestConfigurationManager::getAllIpInterfaceByName(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /allIpInterfaceByName", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /allIpInterfaceByName", session->get_origin().c_str()); std::vector<std::string> interfaces = DRing::getAllIpInterfaceByName(); @@ -1727,7 +1727,7 @@ RestConfigurationManager::getAllIpInterfaceByName(const std::shared_ptr<restbed: void RestConfigurationManager::getShortcuts(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /shortcuts", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /shortcuts", session->get_origin().c_str()); std::map<std::string, std::string> shortcuts = DRing::getShortcuts(); @@ -1750,7 +1750,7 @@ RestConfigurationManager::setShortcuts(const std::shared_ptr<restbed::Session> s { const auto request = session->get_request(); - RING_INFO("[%s] POST /setShortcuts", session->get_origin().c_str()); + JAMI_INFO("[%s] POST /setShortcuts", session->get_origin().c_str()); size_t content_length = 0; request->get_header("Content-Length", content_length); @@ -1760,9 +1760,9 @@ RestConfigurationManager::setShortcuts(const std::shared_ptr<restbed::Session> s std::string data(std::begin(body), std::end(body)); std::map<std::string, std::string> shortcutsMap = parsePost(data); - RING_DBG("shortcutsMap received"); + JAMI_DBG("shortcutsMap received"); for(auto& it : shortcutsMap) - RING_DBG("%s : %s", it.first.c_str(), it.second.c_str()); + JAMI_DBG("%s : %s", it.first.c_str(), it.second.c_str()); DRing::setShortcuts(shortcutsMap); diff --git a/bin/restcpp/restconfigurationmanager.h b/bin/restcpp/restconfigurationmanager.h index 29f11c0c83..fb1e716db8 100644 --- a/bin/restcpp/restconfigurationmanager.h +++ b/bin/restcpp/restconfigurationmanager.h @@ -35,7 +35,7 @@ #include "dring/callmanager_interface.h" #include "dring/configurationmanager_interface.h" #include "dring/presencemanager_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "dring/videomanager_interface.h" #endif #include "logger.h" diff --git a/bin/restcpp/restvideomanager.cpp b/bin/restcpp/restvideomanager.cpp index 66ca4882cd..74080458f6 100644 --- a/bin/restcpp/restvideomanager.cpp +++ b/bin/restcpp/restvideomanager.cpp @@ -92,7 +92,7 @@ RestVideoManager::populateResources() void RestVideoManager::defaultRoute(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /videoManager", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /videoManager", session->get_origin().c_str()); std::string body = "Available routes are : \r\n"; @@ -107,7 +107,7 @@ RestVideoManager::defaultRoute(const std::shared_ptr<restbed::Session> session) void RestVideoManager::getDeviceList(const std::shared_ptr<restbed::Session> session) { - RING_INFO("[%s] GET /deviceList", session->get_origin().c_str()); + JAMI_INFO("[%s] GET /deviceList", session->get_origin().c_str()); std::vector<std::string> list = DRing::getDeviceList(); std::string body = ""; diff --git a/bin/restcpp/restvideomanager.h b/bin/restcpp/restvideomanager.h index 259f3e779b..86fc19bab0 100644 --- a/bin/restcpp/restvideomanager.h +++ b/bin/restcpp/restvideomanager.h @@ -33,7 +33,7 @@ #include "dring/callmanager_interface.h" #include "dring/configurationmanager_interface.h" #include "dring/presencemanager_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "dring/videomanager_interface.h" #endif #include "logger.h" diff --git a/bin/winmain.cpp b/bin/winmain.cpp index d6991c50b2..7c0b042991 100644 --- a/bin/winmain.cpp +++ b/bin/winmain.cpp @@ -29,7 +29,7 @@ #include "callmanager_interface.h" #include "configurationmanager_interface.h" #include "presencemanager_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "videomanager_interface.h" #endif #include "fileutils.h" @@ -49,7 +49,7 @@ print_title() << "Jami Daemon " << DRing::version() << ", by Savoir-faire Linux 2004-2019" << std::endl << "https://jami.net/" << std::endl -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif << std::endl; @@ -213,7 +213,7 @@ main(int argc, char *argv []) std::vector<char> writable(programName.size() + 1); std::copy(std::begin(programName), std::end(programName),std::begin(writable)); - ring::fileutils::set_program_dir(writable.data()); + jami::fileutils::set_program_dir(writable.data()); print_title(); diff --git a/configure.ac b/configure.ac index 599f604b31..3011b6cf23 100644 --- a/configure.ac +++ b/configure.ac @@ -481,15 +481,15 @@ AC_ARG_ENABLE([video], AS_HELP_STRING([--disable-video], [Disable video])) AS_IF([test "x$enable_video" != "xno"], [ - AC_DEFINE(RING_VIDEO, [], [Video support enabled]) - AM_CONDITIONAL(RING_VIDEO, true) + AC_DEFINE(ENABLE_VIDEO, [], [Video support enabled]) + AM_CONDITIONAL(ENABLE_VIDEO, true) AS_IF([test "$SYS" = linux && test -z "${HAVE_ANDROID_FALSE}"],[ PKG_CHECK_MODULES(UDEV, libudev,, AC_MSG_ERROR([Missing libudev development files])) ],[ ]) ], [ - AM_CONDITIONAL(RING_VIDEO, false) + AM_CONDITIONAL(ENABLE_VIDEO, false) ]); AC_ARG_ENABLE([accel], AS_HELP_STRING([--disable-accel], [Disable all hardware accelerations (enabled by default)])) @@ -527,7 +527,7 @@ AS_IF([test "x$enable_video" != "xno" -a "x$enable_accel" != "xno"], [ AC_CHECK_HEADER([VideoToolbox/VideoToolbox.h], [ AC_CHECK_HEADER([libavcodec/videotoolbox.h], [ ring_vt="yes" - AC_DEFINE([RING_VIDEOTOOLBOX], [1], [Defined if videotoolbox is available]) + AC_DEFINE([ENABLE_VIDEOTOOLBOX], [1], [Defined if videotoolbox is available]) ]) ]) ]) @@ -536,7 +536,7 @@ AS_IF([test "x$enable_video" != "xno" -a "x$enable_accel" != "xno"], [ AM_CONDITIONAL([RING_ACCEL], [test "x${ring_accel}" = "xyes"]) AM_CONDITIONAL([RING_VAAPI], [test "x${ring_vaapi}" = "xyes"]) AM_CONDITIONAL([RING_VDPAU], [test "x${ring_vdpau}" = "xyes"]) -AM_CONDITIONAL([RING_VIDEOTOOLBOX], [test "x${ring_vt}" = "xyes"]) +AM_CONDITIONAL([ENABLE_VIDEOTOOLBOX], [test "x${ring_vt}" = "xyes"]) dnl check for GnuTLS PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.4.14], [HAVE_GNUTLS=1], [HAVE_GNUTLS=0]) diff --git a/src/Makefile.am b/src/Makefile.am index f97fd075bc..bec1636cc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,33 +1,33 @@ include ../globals.mk -RING_VIDEO_LIBS= +ENABLE_VIDEO_LIBS= -if RING_VIDEO -RING_VIDEO_LIBS+=./media/video/libvideo.la +if ENABLE_VIDEO +ENABLE_VIDEO_LIBS+=./media/video/libvideo.la if HAVE_LINUX if HAVE_ANDROID -RING_VIDEO_LIBS+= \ +ENABLE_VIDEO_LIBS+= \ ./media/video/androidvideo/libandroidvideo.la else -RING_VIDEO_LIBS+= \ +ENABLE_VIDEO_LIBS+= \ ./media/video/v4l2/libv4l2.la endif endif if HAVE_OSX -RING_VIDEO_LIBS+= \ +ENABLE_VIDEO_LIBS+= \ ./media/video/osxvideo/libosxvideo.la endif if HAVE_IOS -RING_VIDEO_LIBS+= \ +ENABLE_VIDEO_LIBS+= \ ./media/video/iosvideo/libiosvideo.la endif if HAVE_WIN32 -RING_VIDEO_LIBS+= \ +ENABLE_VIDEO_LIBS+= \ ./media/video/winvideo/libwinvideo.la endif endif -SUBDIRS = client media config hooks sip upnp security ringdht im $(RING_VIDEO_SUBDIR) +SUBDIRS = client media config hooks sip upnp security ringdht im $(ENABLE_VIDEO_SUBDIR) # libring @@ -43,7 +43,7 @@ libring_la_LIBADD = \ ./upnp/libupnpcontrol.la \ ./ringdht/libringacc.la \ ./im/libim.la \ - $(RING_VIDEO_LIBS) + $(ENABLE_VIDEO_LIBS) libring_la_LDFLAGS = \ @PJPROJECT_LIBS@ \ @@ -167,7 +167,7 @@ nobase_include_HEADERS= dring/dring.h \ dring/media_const.h \ dring/def.h -if RING_VIDEO +if ENABLE_VIDEO nobase_include_HEADERS+= \ dring/videomanager_interface.h endif diff --git a/src/account.cpp b/src/account.cpp index 3475c5d5a7..ca264d14c6 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -29,7 +29,7 @@ #include <iterator> #include <mutex> -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "libav_utils.h" #endif @@ -58,7 +58,7 @@ using random_device = dht::crypto::random_device; #include "compiler_intrinsics.h" #include "dring/account_const.h" -namespace ring { +namespace jami { const char * const Account::ALL_CODECS_KEY = "allCodecs"; const char * const Account::VIDEO_CODEC_ENABLED = "enabled"; @@ -306,7 +306,7 @@ Account::getAccountDetails() const {Conf::CONFIG_ACCOUNT_USERAGENT, hasCustomUserAgent_ ? userAgent_ : DEFAULT_USER_AGENT}, {Conf::CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT, hasCustomUserAgent_ ? userAgent_ : DEFAULT_USER_AGENT}, {Conf::CONFIG_ACCOUNT_AUTOANSWER, autoAnswerEnabled_ ? TRUE_STR : FALSE_STR}, - {DRing::Account::ConfProperties::ACTIVE_CALL_LIMIT, ring::to_string(activeCallLimit_)}, + {DRing::Account::ConfProperties::ACTIVE_CALL_LIMIT, jami::to_string(activeCallLimit_)}, {Conf::CONFIG_RINGTONE_ENABLED, ringtoneEnabled_ ? TRUE_STR : FALSE_STR}, {Conf::CONFIG_RINGTONE_PATH, ringtonePath_}, {Conf::CONFIG_UPNP_ENABLED, upnp_ ? TRUE_STR : FALSE_STR} @@ -357,11 +357,11 @@ Account::setActiveCodecs(const std::vector<unsigned>& list) }); if (!hasActiveCodec(MEDIA_AUDIO)) { - RING_WARN("All audio codecs disabled, enabling all"); + JAMI_WARN("All audio codecs disabled, enabling all"); setAllCodecsActive(MEDIA_AUDIO, true); } if (!hasActiveCodec(MEDIA_VIDEO)) { - RING_WARN("All video codecs disabled, enabling all"); + JAMI_WARN("All video codecs disabled, enabling all"); setAllCodecsActive(MEDIA_VIDEO, true); } } @@ -401,14 +401,14 @@ Account::getDefaultCodecsId() std::map<std::string, std::string> Account::getDefaultCodecDetails(const unsigned& codecId) { - auto codec = ring::getSystemCodecContainer()->searchCodecById(codecId, ring::MEDIA_ALL); + auto codec = jami::getSystemCodecContainer()->searchCodecById(codecId, jami::MEDIA_ALL); if (codec) { - if (codec->mediaType & ring::MEDIA_AUDIO) { - auto audioCodec = std::static_pointer_cast<ring::SystemAudioCodecInfo>(codec); + if (codec->mediaType & jami::MEDIA_AUDIO) { + auto audioCodec = std::static_pointer_cast<jami::SystemAudioCodecInfo>(codec); return audioCodec->getCodecSpecifications(); } - if (codec->mediaType & ring::MEDIA_VIDEO) { - auto videoCodec = std::static_pointer_cast<ring::SystemVideoCodecInfo>(codec); + if (codec->mediaType & jami::MEDIA_VIDEO) { + auto videoCodec = std::static_pointer_cast<jami::SystemVideoCodecInfo>(codec); return videoCodec->getCodecSpecifications(); } } @@ -418,7 +418,7 @@ Account::getDefaultCodecDetails(const unsigned& codecId) #define find_iter() \ const auto& iter = details.find(key); \ if (iter == details.end()) { \ - RING_ERR("Couldn't find key \"%s\"", key); \ + JAMI_ERR("Couldn't find key \"%s\"", key); \ return; \ } @@ -582,4 +582,4 @@ Account::getIceOptions() const noexcept return opts; } -} // namespace ring +} // namespace jami diff --git a/src/account.h b/src/account.h index 429bc542a6..9e92aed14e 100644 --- a/src/account.h +++ b/src/account.h @@ -49,16 +49,16 @@ #include <mutex> #include <chrono> -namespace ring { namespace upnp { +namespace jami { namespace upnp { class Controller; -}} // namespace ring::upnp +}} // namespace jami::upnp namespace YAML { class Emitter; class Node; } // namespace YAML -namespace ring { +namespace jami { class Call; class SystemCodecContainer; @@ -344,7 +344,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account parseInt(const std::map<std::string, std::string>& details, const char* key, T& i) { const auto& iter = details.find(key); if (iter == details.end()) { - RING_ERR("Couldn't find key \"%s\"", key); + JAMI_ERR("Couldn't find key \"%s\"", key); return; } i = atoi(iter->second.c_str()); @@ -480,7 +480,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account /** * UPnP IGD controller and the mutex to access it */ - std::unique_ptr<ring::upnp::Controller> upnp_; + std::unique_ptr<jami::upnp::Controller> upnp_; mutable std::mutex upnp_mtx {}; /** @@ -498,6 +498,6 @@ operator<< (std::ostream& os, const Account& acc) return os; } -} // namespace ring +} // namespace jami #endif diff --git a/src/account_factory.cpp b/src/account_factory.cpp index 2d43466525..5f41a6e779 100644 --- a/src/account_factory.cpp +++ b/src/account_factory.cpp @@ -29,7 +29,7 @@ #include <stdexcept> -namespace ring { +namespace jami { const char* const AccountFactory::DEFAULT_ACCOUNT_TYPE = SIPAccount::ACCOUNT_TYPE; @@ -37,10 +37,10 @@ AccountFactory::AccountFactory() { auto sipfunc = [](const std::string& id){ return std::make_shared<SIPAccount>(id, true); }; generators_.insert(std::make_pair(SIPAccount::ACCOUNT_TYPE, sipfunc)); - RING_DBG("registered %s account", SIPAccount::ACCOUNT_TYPE); + JAMI_DBG("registered %s account", SIPAccount::ACCOUNT_TYPE); auto dhtfunc = [](const std::string& id){ return std::make_shared<RingAccount>(id, false); }; generators_.insert(std::make_pair(RingAccount::ACCOUNT_TYPE, dhtfunc)); - RING_DBG("registered %s account", RingAccount::ACCOUNT_TYPE); + JAMI_DBG("registered %s account", RingAccount::ACCOUNT_TYPE); } std::shared_ptr<Account> @@ -48,7 +48,7 @@ AccountFactory::createAccount(const char* const accountType, const std::string& id) { if (hasAccount(id)) { - RING_ERR("Existing account %s", id.c_str()); + JAMI_ERR("Existing account %s", id.c_str()); return nullptr; } @@ -80,10 +80,10 @@ AccountFactory::removeAccount(Account& account) std::lock_guard<std::recursive_mutex> lock(mutex_); const auto& id = account.getAccountID(); - RING_DBG("Removing account %s", id.c_str()); + JAMI_DBG("Removing account %s", id.c_str()); auto& map = accountMaps_.at(account_type); map.erase(id); - RING_DBG("Remaining %zu %s account(s)", map.size(), account_type); + JAMI_DBG("Remaining %zu %s account(s)", map.size(), account_type); } void @@ -94,7 +94,7 @@ AccountFactory::removeAccount(const std::string& id) if (auto account = getAccount(id)) { removeAccount(*account); } else - RING_ERR("No account with ID %s", id.c_str()); + JAMI_ERR("No account with ID %s", id.c_str()); } template <> bool @@ -179,4 +179,4 @@ AccountFactory::accountCount() const return count; } -} // namespace ring +} // namespace jami diff --git a/src/account_factory.h b/src/account_factory.h index 1b62bd6959..568e99a758 100644 --- a/src/account_factory.h +++ b/src/account_factory.h @@ -30,7 +30,7 @@ #include <functional> #include <ciso646> -namespace ring { +namespace jami { class Account; class AccountGeneratorBase; @@ -158,6 +158,6 @@ template <> std::size_t AccountFactory::accountCount() const; -} // namespace ring +} // namespace jami #endif // ACCOUNT_FACTORY_H diff --git a/src/account_schema.h b/src/account_schema.h index 35944f5891..8641361fd7 100644 --- a/src/account_schema.h +++ b/src/account_schema.h @@ -27,7 +27,7 @@ * @brief Account specific keys/constants that must be shared in daemon and clients. */ -namespace ring { namespace Conf { +namespace jami { namespace Conf { // Common account parameters static const char *const CONFIG_ACCOUNT_TYPE = "Account.type"; @@ -106,6 +106,6 @@ static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.regis static const char *const CONFIG_TRANSPORT_STATE_CODE = "Transport.statusCode"; static const char *const CONFIG_TRANSPORT_STATE_DESC = "Transport.statusDescription"; -}} // namespace ring::Conf +}} // namespace jami::Conf #endif // ACCOUNT_SCHEMA_H_ diff --git a/src/archiver.cpp b/src/archiver.cpp index dd0511c3fc..c524326398 100644 --- a/src/archiver.cpp +++ b/src/archiver.cpp @@ -35,7 +35,7 @@ #include <sys/stat.h> #include <fstream> -namespace ring { +namespace jami { namespace archiver { std::map<std::string, std::string> @@ -94,7 +94,7 @@ exportAccounts(std::vector<std::string> accountIDs, std::string password) { if (filepath.empty() || !accountIDs.size()) { - RING_ERR("Missing arguments"); + JAMI_ERR("Missing arguments"); return EINVAL; } @@ -103,7 +103,7 @@ exportAccounts(std::vector<std::string> accountIDs, auto filename = filepath.substr(found+1); if (!fileutils::isDirectory(toDir)) { - RING_ERR("%s is not a directory", toDir.c_str()); + JAMI_ERR("%s is not a directory", toDir.c_str()); return ENOTDIR; } @@ -114,7 +114,7 @@ exportAccounts(std::vector<std::string> accountIDs, for (size_t i = 0; i < accountIDs.size(); ++i) { auto detailsMap = Manager::instance().getAccountDetails(accountIDs[i]); if (detailsMap.empty()) { - RING_WARN("Can't export account %s", accountIDs[i].c_str()); + JAMI_WARN("Can't export account %s", accountIDs[i].c_str()); continue; } @@ -132,7 +132,7 @@ exportAccounts(std::vector<std::string> accountIDs, try { compressed = compress(output); } catch (const std::runtime_error& ex) { - RING_ERR("Export failed: %s", ex.what()); + JAMI_ERR("Export failed: %s", ex.what()); return 1; } @@ -143,7 +143,7 @@ exportAccounts(std::vector<std::string> accountIDs, try { fileutils::saveFile(toDir + DIR_SEPARATOR_STR + filename, encrypted); } catch (const std::runtime_error& ex) { - RING_ERR("Export failed: %s", ex.what()); + JAMI_ERR("Export failed: %s", ex.what()); return EIO; } return 0; @@ -153,7 +153,7 @@ int importAccounts(std::string archivePath, std::string password) { if (archivePath.empty()) { - RING_ERR("Missing arguments"); + JAMI_ERR("Missing arguments"); return EINVAL; } @@ -162,7 +162,7 @@ importAccounts(std::string archivePath, std::string password) try { file = fileutils::loadFile(archivePath); } catch (const std::exception& ex) { - RING_ERR("Read failed: %s", ex.what()); + JAMI_ERR("Read failed: %s", ex.what()); return ENOENT; } @@ -170,7 +170,7 @@ importAccounts(std::string archivePath, std::string password) try { file = dht::crypto::aesDecrypt(file, password); } catch (const std::exception& ex) { - RING_ERR("Decryption failed: %s", ex.what()); + JAMI_ERR("Decryption failed: %s", ex.what()); return EPERM; } @@ -178,7 +178,7 @@ importAccounts(std::string archivePath, std::string password) try { file = decompress(file); } catch (const std::exception& ex) { - RING_ERR("Decompression failed: %s", ex.what()); + JAMI_ERR("Decompression failed: %s", ex.what()); return ERANGE; } @@ -192,19 +192,19 @@ importAccounts(std::string archivePath, std::string password) Json::CharReaderBuilder rbuilder; auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); if (!reader->parse(char_file_begin, char_file_end, &root, &err)) { - RING_ERR() << "Failed to parse " << err; + JAMI_ERR() << "Failed to parse " << err; return ERANGE; } auto& accounts = root["accounts"]; for (int i = 0, n = accounts.size(); i < n; ++i) { // Generate a new account id - auto accountId = ring::Manager::instance().getNewAccountId(); + auto accountId = jami::Manager::instance().getNewAccountId(); auto details = jsonValueToAccount(accounts[i], accountId); - ring::Manager::instance().addAccount(details, accountId); + jami::Manager::instance().addAccount(details, accountId); } } catch (const std::exception& ex) { - RING_ERR("Import failed: %s", ex.what()); + JAMI_ERR("Import failed: %s", ex.what()); return ERANGE; } return 0; @@ -297,4 +297,4 @@ decompress(const std::vector<uint8_t>& str) return out; } -}} // namespace ring::archiver +}} // namespace jami::archiver diff --git a/src/archiver.h b/src/archiver.h index 2f4aab5b01..d3518648e5 100644 --- a/src/archiver.h +++ b/src/archiver.h @@ -26,7 +26,7 @@ #include <vector> #include <map> -namespace ring { +namespace jami { /** * Archiver is used to generate/read encrypted archives @@ -76,4 +76,4 @@ std::vector<uint8_t> decompressGzip(const std::string& path); } -} // namespace ring +} // namespace jami diff --git a/src/array_size.h b/src/array_size.h index 14aebcc7d5..5992a612fa 100644 --- a/src/array_size.h +++ b/src/array_size.h @@ -22,11 +22,11 @@ #include <cstdlib> -namespace ring { +namespace jami { // Returns the number of elements in given-by-reference array of type T. // Borrowed from Scott Meyers in "Effective Modern C++". template<typename T, std::size_t N> constexpr std::size_t arraySize(T (&)[N]) noexcept { return N; } -} // namespace ring +} // namespace jami diff --git a/src/base64.cpp b/src/base64.cpp index 1de53117be..b46732f6da 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -24,7 +24,7 @@ #include <pjlib.h> #include <pjlib-util/base64.h> -namespace ring { +namespace jami { namespace base64 { std::string @@ -68,4 +68,4 @@ decode(const std::string& str) return out; } -}} // namespace ring::base64 +}} // namespace jami::base64 diff --git a/src/base64.h b/src/base64.h index eb603f3d3c..922d3067f0 100644 --- a/src/base64.h +++ b/src/base64.h @@ -25,7 +25,7 @@ #include <vector> #include <exception> -namespace ring { +namespace jami { namespace base64 { class base64_exception : public std::exception { }; @@ -34,4 +34,4 @@ std::string encode(const std::vector<uint8_t>::const_iterator begin, const std:: std::string encode(const std::vector<uint8_t>& dat); std::vector<uint8_t> decode(const std::string& str); -}} // namespace ring::base64 +}} // namespace jami::base64 diff --git a/src/call.cpp b/src/call.cpp index 1565cbc32a..50436bb740 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -42,7 +42,7 @@ #include <functional> #include <utility> -namespace ring { +namespace jami { /// Hangup many calls with same error code, filtered by a predicate /// @@ -59,7 +59,7 @@ hangupCallsIf(Call::SubcallSet callptr_list, int errcode, const std::function<bo try { call_ptr->hangup(errcode); } catch (const std::exception& e) { - RING_ERR("[call:%s] hangup failed: %s", + JAMI_ERR("[call:%s] hangup failed: %s", call_ptr->getCallId().c_str(), e.what()); } } @@ -94,13 +94,13 @@ Call::Call(Account& account, const std::string& id, Call::CallType type, // if call just started ringing, schedule call timeout if (type_ == CallType::INCOMING and cnx_state == ConnectionState::RINGING) { auto timeout = Manager::instance().getRingingTimeout(); - RING_DBG("Scheduling call timeout in %d seconds", timeout); + JAMI_DBG("Scheduling call timeout in %d seconds", timeout); std::weak_ptr<Call> callWkPtr = shared_from_this(); Manager::instance().scheduler().scheduleIn([callWkPtr]{ if (auto callShPtr = callWkPtr.lock()) { if (callShPtr->getConnectionState() == Call::ConnectionState::RINGING) { - RING_DBG("Call %s is still ringing after timeout, setting state to BUSY", + JAMI_DBG("Call %s is still ringing after timeout, setting state to BUSY", callShPtr->getCallId().c_str()); callShPtr->hangup(PJSIP_SC_BUSY_HERE); Manager::instance().callFailure(*callShPtr); @@ -213,13 +213,13 @@ bool Call::setState(CallState call_state, ConnectionState cnx_state, signed code) { std::lock_guard<std::recursive_mutex> lock(callMutex_); - RING_DBG("[call:%s] state change %u/%u, cnx %u/%u, code %d", id_.c_str(), + JAMI_DBG("[call:%s] state change %u/%u, cnx %u/%u, code %d", id_.c_str(), (unsigned)callState_, (unsigned)call_state, (unsigned)connectionState_, (unsigned)cnx_state, code); if (callState_ != call_state) { if (not validStateTransition(call_state)) { - RING_ERR("[call:%s] invalid call state transition from %u to %u", + JAMI_ERR("[call:%s] invalid call state transition from %u to %u", id_.c_str(), (unsigned)callState_, (unsigned)call_state); return false; } @@ -237,7 +237,7 @@ Call::setState(CallState call_state, ConnectionState cnx_state, signed code) if (old_client_state != new_client_state) { if (not parent_) { - RING_DBG("[call:%s] emit client call state change %s, code %d", + JAMI_DBG("[call:%s] emit client call state change %s, code %d", id_.c_str(), new_client_state.c_str(), code); emitSignal<DRing::CallSignal::StateChange>(id_, new_client_state, code); } @@ -336,12 +336,12 @@ std::map<std::string, std::string> Call::getDetails() const { return { - {DRing::Call::Details::CALL_TYPE, ring::to_string((unsigned)type_)}, + {DRing::Call::Details::CALL_TYPE, jami::to_string((unsigned)type_)}, {DRing::Call::Details::PEER_NUMBER, peerNumber_}, {DRing::Call::Details::DISPLAY_NAME, peerDisplayName_}, {DRing::Call::Details::CALL_STATE, getStateStr()}, {DRing::Call::Details::CONF_ID, confID_}, - {DRing::Call::Details::TIMESTAMP_START, ring::to_string(timestamp_start_)}, + {DRing::Call::Details::TIMESTAMP_START, jami::to_string(timestamp_start_)}, {DRing::Call::Details::ACCOUNTID, getAccountId()}, {DRing::Call::Details::AUDIO_MUTED, std::string(bool_to_str(isAudioMuted_))}, {DRing::Call::Details::VIDEO_MUTED, std::string(bool_to_str(isVideoMuted_))}, @@ -401,11 +401,11 @@ Call::addSubCall(Call& subcall) } if (not subcalls_.emplace(getPtr(subcall)).second) { - RING_ERR("[call:%s] add twice subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); + JAMI_ERR("[call:%s] add twice subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); return; } - RING_DBG("[call:%s] add subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); + JAMI_DBG("[call:%s] add subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); subcall.parent_ = getPtr(*this); for (const auto& msg : pendingOutMessages_) @@ -442,7 +442,7 @@ Call::subcallStateChanged(Call& subcall, // We found a responding device: hangup all other subcalls and merge if (new_state == CallState::ACTIVE and new_cstate == ConnectionState::CONNECTED) { - RING_DBG("[call:%s] subcall %s answered by peer", getCallId().c_str(), + JAMI_DBG("[call:%s] subcall %s answered by peer", getCallId().c_str(), subcall.getCallId().c_str()); hangupCallsIf(safePopSubcalls(), 0, [&](const Call* call){ return call != &subcall; }); @@ -454,7 +454,7 @@ Call::subcallStateChanged(Call& subcall, // Hangup the call if any device hangup // XXX: not sure it's what we really want if (new_state == CallState::ACTIVE and new_cstate == ConnectionState::DISCONNECTED) { - RING_WARN("[call:%s] subcall %s hangup by peer", getCallId().c_str(), + JAMI_WARN("[call:%s] subcall %s hangup by peer", getCallId().c_str(), subcall.getCallId().c_str()); hangupCalls(safePopSubcalls(), 0); @@ -466,9 +466,9 @@ Call::subcallStateChanged(Call& subcall, // Subcall is busy or failed if (new_state >= CallState::BUSY) { if (new_state == CallState::BUSY || new_state == CallState::PEER_BUSY) - RING_WARN("[call:%s] subcall %s busy", getCallId().c_str(), subcall.getCallId().c_str()); + JAMI_WARN("[call:%s] subcall %s busy", getCallId().c_str(), subcall.getCallId().c_str()); else - RING_WARN("[call:%s] subcall %s failed", getCallId().c_str(), subcall.getCallId().c_str()); + JAMI_WARN("[call:%s] subcall %s failed", getCallId().c_str(), subcall.getCallId().c_str()); std::lock_guard<std::recursive_mutex> lk {callMutex_}; subcalls_.erase(getPtr(subcall)); @@ -485,7 +485,7 @@ Call::subcallStateChanged(Call& subcall, } removeCall(); } else { - RING_DBG("[call:%s] remains %zu subcall(s)", getCallId().c_str(), subcalls_.size()); + JAMI_DBG("[call:%s] remains %zu subcall(s)", getCallId().c_str(), subcalls_.size()); } return; @@ -506,7 +506,7 @@ Call::subcallStateChanged(Call& subcall, void Call::merge(Call& subcall) { - RING_DBG("[call:%s] merge subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); + JAMI_DBG("[call:%s] merge subcall %s", getCallId().c_str(), subcall.getCallId().c_str()); // Merge data { @@ -572,4 +572,4 @@ Call::safePopSubcalls() return old_value; } -} // namespace ring +} // namespace jami diff --git a/src/call.h b/src/call.h index 9b08888bb2..9ee0373340 100644 --- a/src/call.h +++ b/src/call.h @@ -42,7 +42,7 @@ #include <list> #include <functional> -namespace ring { +namespace jami { class VoIPLink; class Account; @@ -402,4 +402,4 @@ inline std::shared_ptr<Call> getPtr(Call& call) return call.shared_from_this(); } -} // namespace ring +} // namespace jami diff --git a/src/call_factory.cpp b/src/call_factory.cpp index 3ad0f4f724..02ff85a025 100644 --- a/src/call_factory.cpp +++ b/src/call_factory.cpp @@ -22,7 +22,7 @@ #include <stdexcept> -namespace ring { +namespace jami { void CallFactory::forbid() @@ -36,11 +36,11 @@ CallFactory::removeCall(Call& call) std::lock_guard<std::recursive_mutex> lk(callMapsMutex_); const auto& id = call.getCallId(); - RING_DBG("Removing call %s", id.c_str()); + JAMI_DBG("Removing call %s", id.c_str()); const auto& linkType = call.getLinkType(); auto& map = callMaps_.at(linkType); map.erase(id); - RING_DBG("Remaining %zu %s call(s)", map.size(), linkType); + JAMI_DBG("Remaining %zu %s call(s)", map.size(), linkType); } void @@ -51,7 +51,7 @@ CallFactory::removeCall(const std::string& id) if (auto call = getCall(id)) { removeCall(*call); } else - RING_ERR("No call with ID %s", id.c_str()); + JAMI_ERR("No call with ID %s", id.c_str()); } //============================================================================== @@ -149,4 +149,4 @@ CallFactory::callCount<Call>() return count; } -} // namespace ring +} // namespace jami diff --git a/src/call_factory.h b/src/call_factory.h index 6490d9c048..2554337630 100644 --- a/src/call_factory.h +++ b/src/call_factory.h @@ -31,7 +31,7 @@ #include <string> #include <utility> -namespace ring { +namespace jami { class CallFactory { public: @@ -74,7 +74,7 @@ class CallFactory { std::shared_ptr<T> newCall(A& account, const std::string& id, Call::CallType type, const std::map<std::string, std::string>& details={}) { if (!allowNewCall_) { - RING_WARN("newCall aborted : CallFactory in forbid state"); + JAMI_WARN("newCall aborted : CallFactory in forbid state"); return nullptr; } @@ -88,7 +88,7 @@ class CallFactory { }; if (hasCall(id)) { - RING_ERR("Call %s is already created", id.c_str()); + JAMI_ERR("Call %s is already created", id.c_str()); return nullptr; } @@ -232,6 +232,6 @@ CallFactory::getCallIDs<Call>() const; template <> std::size_t CallFactory::callCount<Call>(); -} // namespace ring +} // namespace jami #endif // CALL_FACTORY_H diff --git a/src/channel.h b/src/channel.h index 4d98c259e0..8a903e57d9 100644 --- a/src/channel.h +++ b/src/channel.h @@ -32,7 +32,7 @@ /// This is a C++11-ish class that mimic Python "queue" module and/or Go "Channel" type. /// -namespace ring +namespace jami { class ChannelEmpty : public std::exception{ @@ -207,4 +207,4 @@ public: } }; -} // namespace ring +} // namespace jami diff --git a/src/client/Makefile.am b/src/client/Makefile.am index 142b843f98..9d9ab36ff1 100644 --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -7,7 +7,7 @@ noinst_HEADERS = \ PRESENCE_SRC = presencemanager.cpp -if RING_VIDEO +if ENABLE_VIDEO VIDEO_SRC = videomanager.cpp noinst_HEADERS += videomanager.h endif diff --git a/src/client/callmanager.cpp b/src/client/callmanager.cpp index 8671308ff9..e59d435ae6 100644 --- a/src/client/callmanager.cpp +++ b/src/client/callmanager.cpp @@ -49,10 +49,10 @@ placeCall(const std::string& accountID, const std::string& to) { // Check if a destination number is available if (to.empty()) { - RING_DBG("No number entered - Call stopped"); + JAMI_DBG("No number entered - Call stopped"); return {}; } else { - return ring::Manager::instance().outgoingCall(accountID, to); + return jami::Manager::instance().outgoingCall(accountID, to); } } @@ -61,192 +61,192 @@ placeCall(const std::string& accountID, const std::string& to, const std::map<st { // Check if a destination number is available if (to.empty()) { - RING_DBG("No number entered - Call stopped"); + JAMI_DBG("No number entered - Call stopped"); return {}; } else { - return ring::Manager::instance().outgoingCall(accountID, to, "", volatileCallDetails); + return jami::Manager::instance().outgoingCall(accountID, to, "", volatileCallDetails); } } bool refuse(const std::string& callID) { - return ring::Manager::instance().refuseCall(callID); + return jami::Manager::instance().refuseCall(callID); } bool accept(const std::string& callID) { - return ring::Manager::instance().answerCall(callID); + return jami::Manager::instance().answerCall(callID); } bool hangUp(const std::string& callID) { - return ring::Manager::instance().hangupCall(callID); + return jami::Manager::instance().hangupCall(callID); } bool hangUpConference(const std::string& confID) { - return ring::Manager::instance().hangupConference(confID); + return jami::Manager::instance().hangupConference(confID); } bool hold(const std::string& callID) { - return ring::Manager::instance().onHoldCall(callID); + return jami::Manager::instance().onHoldCall(callID); } bool unhold(const std::string& callID) { - return ring::Manager::instance().offHoldCall(callID); + return jami::Manager::instance().offHoldCall(callID); } bool muteLocalMedia(const std::string& callid, const std::string& mediaType, bool mute) { - return ring::Manager::instance().muteMediaCall(callid, mediaType, mute); + return jami::Manager::instance().muteMediaCall(callid, mediaType, mute); } bool transfer(const std::string& callID, const std::string& to) { - return ring::Manager::instance().transferCall(callID, to); + return jami::Manager::instance().transferCall(callID, to); } bool attendedTransfer(const std::string& transferID, const std::string& targetID) { - return ring::Manager::instance().attendedTransfer(transferID, targetID); + return jami::Manager::instance().attendedTransfer(transferID, targetID); } bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID) { - return ring::Manager::instance().joinParticipant(sel_callID, drag_callID); + return jami::Manager::instance().joinParticipant(sel_callID, drag_callID); } void createConfFromParticipantList(const std::vector<std::string>& participants) { - ring::Manager::instance().createConfFromParticipantList(participants); + jami::Manager::instance().createConfFromParticipantList(participants); } bool isConferenceParticipant(const std::string& callID) { - return ring::Manager::instance().isConferenceParticipant(callID); + return jami::Manager::instance().isConferenceParticipant(callID); } void removeConference(const std::string& conference_id) { - ring::Manager::instance().removeConference(conference_id); + jami::Manager::instance().removeConference(conference_id); } void startSmartInfo(uint32_t refreshTimeMs) { - ring::Smartools::getInstance().start(std::chrono::milliseconds(refreshTimeMs)); + jami::Smartools::getInstance().start(std::chrono::milliseconds(refreshTimeMs)); } void stopSmartInfo() { - ring::Smartools::getInstance().stop(); + jami::Smartools::getInstance().stop(); } bool addParticipant(const std::string& callID, const std::string& confID) { - return ring::Manager::instance().addParticipant(callID, confID); + return jami::Manager::instance().addParticipant(callID, confID); } bool addMainParticipant(const std::string& confID) { - return ring::Manager::instance().addMainParticipant(confID); + return jami::Manager::instance().addMainParticipant(confID); } bool detachLocalParticipant() { - return ring::Manager::instance().detachLocalParticipant(); + return jami::Manager::instance().detachLocalParticipant(); } bool detachParticipant(const std::string& callID) { - return ring::Manager::instance().detachParticipant(callID); + return jami::Manager::instance().detachParticipant(callID); } bool joinConference(const std::string& sel_confID, const std::string& drag_confID) { - return ring::Manager::instance().joinConference(sel_confID, drag_confID); + return jami::Manager::instance().joinConference(sel_confID, drag_confID); } bool holdConference(const std::string& confID) { - return ring::Manager::instance().holdConference(confID); + return jami::Manager::instance().holdConference(confID); } bool unholdConference(const std::string& confID) { - return ring::Manager::instance().unHoldConference(confID); + return jami::Manager::instance().unHoldConference(confID); } std::map<std::string, std::string> getConferenceDetails(const std::string& callID) { - return ring::Manager::instance().getConferenceDetails(callID); + return jami::Manager::instance().getConferenceDetails(callID); } std::vector<std::string> getConferenceList() { - return ring::Manager::instance().getConferenceList(); + return jami::Manager::instance().getConferenceList(); } std::vector<std::string> getParticipantList(const std::string& confID) { - return ring::Manager::instance().getParticipantList(confID); + return jami::Manager::instance().getParticipantList(confID); } std::vector<std::string> getDisplayNames(const std::string& confID) { - return ring::Manager::instance().getDisplayNames(confID); + return jami::Manager::instance().getDisplayNames(confID); } std::string getConferenceId(const std::string& callID) { - return ring::Manager::instance().getConferenceId(callID); + return jami::Manager::instance().getConferenceId(callID); } bool startRecordedFilePlayback(const std::string& filepath) { - return ring::Manager::instance().startRecordedFilePlayback(filepath); + return jami::Manager::instance().startRecordedFilePlayback(filepath); } void stopRecordedFilePlayback() { - ring::Manager::instance().stopRecordedFilePlayback(); + jami::Manager::instance().stopRecordedFilePlayback(); } bool toggleRecording(const std::string& callID) { - return ring::Manager::instance().toggleRecordingCall(callID); + return jami::Manager::instance().toggleRecordingCall(callID); } void @@ -258,41 +258,41 @@ setRecording(const std::string& callID) void recordPlaybackSeek(double value) { - ring::Manager::instance().recordingPlaybackSeek(value); + jami::Manager::instance().recordingPlaybackSeek(value); } bool getIsRecording(const std::string& callID) { - return ring::Manager::instance().isRecording(callID); + return jami::Manager::instance().isRecording(callID); } std::string getCurrentAudioCodecName(const std::string&) { - RING_WARN("Deprecated"); + JAMI_WARN("Deprecated"); return ""; } std::map<std::string, std::string> getCallDetails(const std::string& callID) { - return ring::Manager::instance().getCallDetails(callID); + return jami::Manager::instance().getCallDetails(callID); } std::vector<std::string> getCallList() { - return ring::Manager::instance().getCallList(); + return jami::Manager::instance().getCallList(); } void playDTMF(const std::string& key) { auto code = key.data()[0]; - ring::Manager::instance().playDtmf(code); + jami::Manager::instance().playDtmf(code); - if (auto current_call = ring::Manager::instance().getCurrentCall()) + if (auto current_call = jami::Manager::instance().getCurrentCall()) current_call->carryingDTMFdigits(code); } @@ -301,23 +301,23 @@ startTone(int32_t start, int32_t type) { if (start) { if (type == 0) - ring::Manager::instance().playTone(); + jami::Manager::instance().playTone(); else - ring::Manager::instance().playToneWithMessage(); + jami::Manager::instance().playToneWithMessage(); } else - ring::Manager::instance().stopTone(); + jami::Manager::instance().stopTone(); } bool switchInput(const std::string& callID, const std::string& resource) { - return ring::Manager::instance().switchInput(callID, resource); + return jami::Manager::instance().switchInput(callID, resource); } void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, bool isMixed) { - ring::Manager::instance().sendCallTextMessage(callID, messages, from, isMixed); + jami::Manager::instance().sendCallTextMessage(callID, messages, from, isMixed); } } // namespace DRing diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index 77fd50d889..0270f2ce0b 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -65,12 +65,12 @@ namespace DRing { constexpr unsigned CODECS_NOT_LOADED = 0x1000; /** Codecs not found */ -using ring::SIPAccount; -using ring::RingAccount; -using ring::tls::TlsValidator; -using ring::tls::CertificateStore; -using ring::DeviceType; -using ring::HookPreference; +using jami::SIPAccount; +using jami::RingAccount; +using jami::tls::TlsValidator; +using jami::tls::CertificateStore; +using jami::DeviceType; +using jami::HookPreference; void registerConfHandlers(const std::map<std::string, @@ -82,40 +82,40 @@ registerConfHandlers(const std::map<std::string, std::map<std::string, std::string> getAccountDetails(const std::string& accountID) { - return ring::Manager::instance().getAccountDetails(accountID); + return jami::Manager::instance().getAccountDetails(accountID); } std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID) { - return ring::Manager::instance().getVolatileAccountDetails(accountID); + return jami::Manager::instance().getVolatileAccountDetails(accountID); } std::map<std::string, std::string> testAccountICEInitialization(const std::string& accountID) { - return ring::Manager::instance().testAccountICEInitialization(accountID); + return jami::Manager::instance().testAccountICEInitialization(accountID); } std::map<std::string, std::string> getTlsDefaultSettings() { std::stringstream portstr; - portstr << ring::sip_utils::DEFAULT_SIP_TLS_PORT; + portstr << jami::sip_utils::DEFAULT_SIP_TLS_PORT; return { - {ring::Conf::CONFIG_TLS_LISTENER_PORT, portstr.str()}, - {ring::Conf::CONFIG_TLS_CA_LIST_FILE, ""}, - {ring::Conf::CONFIG_TLS_CERTIFICATE_FILE, ""}, - {ring::Conf::CONFIG_TLS_PRIVATE_KEY_FILE, ""}, - {ring::Conf::CONFIG_TLS_PASSWORD, ""}, - {ring::Conf::CONFIG_TLS_METHOD, "Default"}, - {ring::Conf::CONFIG_TLS_CIPHERS, ""}, - {ring::Conf::CONFIG_TLS_SERVER_NAME, ""}, - {ring::Conf::CONFIG_TLS_VERIFY_SERVER, "true"}, - {ring::Conf::CONFIG_TLS_VERIFY_CLIENT, "true"}, - {ring::Conf::CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, "true"}, - {ring::Conf::CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, "2"} + {jami::Conf::CONFIG_TLS_LISTENER_PORT, portstr.str()}, + {jami::Conf::CONFIG_TLS_CA_LIST_FILE, ""}, + {jami::Conf::CONFIG_TLS_CERTIFICATE_FILE, ""}, + {jami::Conf::CONFIG_TLS_PRIVATE_KEY_FILE, ""}, + {jami::Conf::CONFIG_TLS_PASSWORD, ""}, + {jami::Conf::CONFIG_TLS_METHOD, "Default"}, + {jami::Conf::CONFIG_TLS_CIPHERS, ""}, + {jami::Conf::CONFIG_TLS_SERVER_NAME, ""}, + {jami::Conf::CONFIG_TLS_VERIFY_SERVER, "true"}, + {jami::Conf::CONFIG_TLS_VERIFY_CLIENT, "true"}, + {jami::Conf::CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, "true"}, + {jami::Conf::CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, "2"} }; } @@ -126,7 +126,7 @@ validateCertificate(const std::string&, try { return TlsValidator{CertificateStore::instance().getCertificate(certificate)}.getSerializedChecks(); } catch(const std::runtime_error& e) { - RING_WARN("Certificate loading failed: %s", e.what()); + JAMI_WARN("Certificate loading failed: %s", e.what()); return {{Certificate::ChecksNames::EXIST, Certificate::CheckValuesNames::FAILED}}; } } @@ -141,7 +141,7 @@ validateCertificatePath(const std::string&, try { return TlsValidator{certificate, privateKey, privateKeyPass, caList}.getSerializedChecks(); } catch(const std::runtime_error& e) { - RING_WARN("Certificate loading failed: %s", e.what()); + JAMI_WARN("Certificate loading failed: %s", e.what()); return {{Certificate::ChecksNames::EXIST, Certificate::CheckValuesNames::FAILED}}; } } @@ -152,7 +152,7 @@ getCertificateDetails(const std::string& certificate) try { return TlsValidator{CertificateStore::instance().getCertificate(certificate)}.getSerializedDetails(); } catch(const std::runtime_error& e) { - RING_WARN("Certificate loading failed: %s", e.what()); + JAMI_WARN("Certificate loading failed: %s", e.what()); } return {}; } @@ -161,12 +161,12 @@ std::map<std::string, std::string> getCertificateDetailsPath(const std::string& certificate, const std::string& privateKey, const std::string& privateKeyPassword) { try { - auto crt = std::make_shared<dht::crypto::Certificate>(ring::fileutils::loadFile(certificate)); + auto crt = std::make_shared<dht::crypto::Certificate>(jami::fileutils::loadFile(certificate)); TlsValidator validator {certificate, privateKey, privateKeyPassword}; CertificateStore::instance().pinCertificate(validator.getCertificate(), false); return validator.getSerializedDetails(); } catch(const std::runtime_error& e) { - RING_WARN("Certificate loading failed: %s", e.what()); + JAMI_WARN("Certificate loading failed: %s", e.what()); } return {}; } @@ -174,37 +174,37 @@ getCertificateDetailsPath(const std::string& certificate, const std::string& pri std::vector<std::string> getPinnedCertificates() { - return ring::tls::CertificateStore::instance().getPinnedCertificates(); + return jami::tls::CertificateStore::instance().getPinnedCertificates(); } std::vector<std::string> pinCertificate(const std::vector<uint8_t>& certificate, bool local) { - return ring::tls::CertificateStore::instance().pinCertificate(certificate, local); + return jami::tls::CertificateStore::instance().pinCertificate(certificate, local); } void pinCertificatePath(const std::string& path) { - ring::tls::CertificateStore::instance().pinCertificatePath(path); + jami::tls::CertificateStore::instance().pinCertificatePath(path); } bool unpinCertificate(const std::string& certId) { - return ring::tls::CertificateStore::instance().unpinCertificate(certId); + return jami::tls::CertificateStore::instance().unpinCertificate(certId); } unsigned unpinCertificatePath(const std::string& path) { - return ring::tls::CertificateStore::instance().unpinCertificatePath(path); + return jami::tls::CertificateStore::instance().unpinCertificatePath(path); } bool pinRemoteCertificate(const std::string& accountId, const std::string& certId) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->findCertificate(certId); return false; } @@ -214,9 +214,9 @@ setCertificateStatus(const std::string& accountId, const std::string& certId, co { try { if (accountId.empty()) { - ring::tls::CertificateStore::instance().setTrustedCertificate(certId, ring::tls::trustStatusFromStr(ststr.c_str())); - } else if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) { - auto status = ring::tls::TrustStore::statusFromStr(ststr.c_str()); + jami::tls::CertificateStore::instance().setTrustedCertificate(certId, jami::tls::trustStatusFromStr(ststr.c_str())); + } else if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) { + auto status = jami::tls::TrustStore::statusFromStr(ststr.c_str()); return acc->setCertificateStatus(certId, status); } } catch (const std::out_of_range&) {} @@ -226,8 +226,8 @@ setCertificateStatus(const std::string& accountId, const std::string& certId, co std::vector<std::string> getCertificatesByStatus(const std::string& accountId, const std::string& ststr) { - auto status = ring::tls::TrustStore::statusFromStr(ststr.c_str()); - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + auto status = jami::tls::TrustStore::statusFromStr(ststr.c_str()); + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->getCertificatesByStatus(status); return {}; } @@ -235,37 +235,37 @@ getCertificatesByStatus(const std::string& accountId, const std::string& ststr) void setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details) { - ring::Manager::instance().setAccountDetails(accountID, details); + jami::Manager::instance().setAccountDetails(accountID, details); } void setAccountActive(const std::string& accountID, bool enable) { - ring::Manager::instance().setAccountActive(accountID, enable); + jami::Manager::instance().setAccountActive(accountID, enable); } void sendRegister(const std::string& accountID, bool enable) { - ring::Manager::instance().sendRegister(accountID, enable); + jami::Manager::instance().sendRegister(accountID, enable); } void registerAllAccounts() { - ring::Manager::instance().registerAccounts(); + jami::Manager::instance().registerAccounts(); } uint64_t sendAccountTextMessage(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& payloads) { - return ring::Manager::instance().sendTextMessage(accountID, to, payloads); + return jami::Manager::instance().sendTextMessage(accountID, to, payloads); } std::vector<Message> getLastMessages(const std::string& accountID, const uint64_t& base_timestamp) { - if (const auto acc = ring::Manager::instance().getAccount(accountID)) + if (const auto acc = jami::Manager::instance().getAccount(accountID)) return acc->getLastMessages(base_timestamp); return {}; } @@ -273,19 +273,19 @@ getLastMessages(const std::string& accountID, const uint64_t& base_timestamp) int getMessageStatus(uint64_t messageId) { - return ring::Manager::instance().getMessageStatus(messageId); + return jami::Manager::instance().getMessageStatus(messageId); } int getMessageStatus(const std::string& accountID, uint64_t messageId) { - return ring::Manager::instance().getMessageStatus(accountID, messageId); + return jami::Manager::instance().getMessageStatus(accountID, messageId); } bool cancelMessage(const std::string& accountID, uint64_t messageId) { - if (const auto acc = ring::Manager::instance().getAccount(accountID)) + if (const auto acc = jami::Manager::instance().getAccount(accountID)) return acc->cancelMessage(messageId); return {}; } @@ -293,7 +293,7 @@ cancelMessage(const std::string& accountID, uint64_t messageId) bool exportOnRing(const std::string& accountID, const std::string& password) { - if (const auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { + if (const auto account = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) { account->addDevice(password); return true; } @@ -303,7 +303,7 @@ exportOnRing(const std::string& accountID, const std::string& password) bool exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password) { - if (const auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { + if (const auto account = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) { return account->exportArchive(destinationPath, password); } return false; @@ -312,7 +312,7 @@ exportToFile(const std::string& accountID, const std::string& destinationPath, c bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID) { - if (const auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { + if (const auto account = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) { return account->revokeDevice(password, deviceID); } return false; @@ -321,7 +321,7 @@ revokeDevice(const std::string& accountID, const std::string& password, const st std::map<std::string, std::string> getKnownRingDevices(const std::string& accountId) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->getKnownDevices(); return {}; } @@ -329,7 +329,7 @@ getKnownRingDevices(const std::string& accountId) bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) return acc->changeArchivePassword(password_old, password_new); return false; } @@ -338,20 +338,20 @@ changeAccountPassword(const std::string& accountID, const std::string& password_ void addContact(const std::string& accountId, const std::string& uri) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->addContact(uri); } void removeContact(const std::string& accountId, const std::string& uri, bool ban) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->removeContact(uri, ban); } std::map<std::string, std::string> getContactDetails(const std::string& accountId, const std::string& uri) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->getContactDetails(uri); return {}; } @@ -359,7 +359,7 @@ getContactDetails(const std::string& accountId, const std::string& uri) std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->getContacts(); return {}; } @@ -368,7 +368,7 @@ getContacts(const std::string& accountId) std::vector<std::map<std::string, std::string>> getTrustRequests(const std::string& accountId) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->getTrustRequests(); return {}; } @@ -376,7 +376,7 @@ getTrustRequests(const std::string& accountId) bool acceptTrustRequest(const std::string& accountId, const std::string& from) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->acceptTrustRequest(from); return false; } @@ -384,7 +384,7 @@ acceptTrustRequest(const std::string& accountId, const std::string& from) bool discardTrustRequest(const std::string& accountId, const std::string& from) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) return acc->discardTrustRequest(from); return false; } @@ -392,7 +392,7 @@ discardTrustRequest(const std::string& accountId, const std::string& from) void sendTrustRequest(const std::string& accountId, const std::string& to, const std::vector<uint8_t>& payload) { - if (auto acc = ring::Manager::instance().getAccount<ring::RingAccount>(accountId)) + if (auto acc = jami::Manager::instance().getAccount<jami::RingAccount>(accountId)) acc->sendTrustRequest(to, payload); } @@ -402,13 +402,13 @@ sendTrustRequest(const std::string& accountId, const std::string& to, const std: int exportAccounts(const std::vector<std::string>& accountIDs, const std::string& filepath, const std::string& password) { - return ring::archiver::exportAccounts(accountIDs, filepath, password); + return jami::archiver::exportAccounts(accountIDs, filepath, password); } int importAccounts(const std::string& archivePath, const std::string& password) { - return ring::archiver::importAccounts(archivePath, password); + return jami::archiver::importAccounts(archivePath, password); } ///This function is used as a base for new accounts for clients that support it @@ -416,28 +416,28 @@ std::map<std::string, std::string> getAccountTemplate(const std::string& accountType) { if (accountType == Account::ProtocolNames::RING) - return ring::RingAccount("dummy", false).getAccountDetails(); + return jami::RingAccount("dummy", false).getAccountDetails(); else if (accountType == Account::ProtocolNames::SIP) - return ring::SIPAccount("dummy", false).getAccountDetails(); + return jami::SIPAccount("dummy", false).getAccountDetails(); return {}; } std::string addAccount(const std::map<std::string, std::string>& details) { - return ring::Manager::instance().addAccount(details); + return jami::Manager::instance().addAccount(details); } void removeAccount(const std::string& accountID) { - return ring::Manager::instance().removeAccount(accountID, true); // with 'flush' enabled + return jami::Manager::instance().removeAccount(accountID, true); // with 'flush' enabled } std::vector<std::string> getAccountList() { - return ring::Manager::instance().getAccountList(); + return jami::Manager::instance().getAccountList(); } /** @@ -447,9 +447,9 @@ getAccountList() std::vector<unsigned> getCodecList() { - std::vector<unsigned> list {ring::getSystemCodecContainer()->getSystemCodecInfoIdList(ring::MEDIA_ALL)}; + std::vector<unsigned> list {jami::getSystemCodecContainer()->getSystemCodecInfoIdList(jami::MEDIA_ALL)}; if (list.empty()) - ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); + jami::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); return list; } @@ -462,9 +462,9 @@ getSupportedTlsMethod() std::vector<std::string> getSupportedCiphers(const std::string& accountID) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) return SIPAccount::getSupportedTlsCiphers(); - RING_ERR("SIP account %s doesn't exist", accountID.c_str()); + JAMI_ERR("SIP account %s doesn't exist", accountID.c_str()); return {}; } @@ -474,46 +474,46 @@ setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details) { - auto acc = ring::Manager::instance().getAccount(accountID); + auto acc = jami::Manager::instance().getAccount(accountID); if (!acc) { - RING_ERR("Could not find account %s. can not set codec details" + JAMI_ERR("Could not find account %s. can not set codec details" , accountID.c_str()); return false; } - auto codec = acc->searchCodecById(codecId, ring::MEDIA_ALL); + auto codec = acc->searchCodecById(codecId, jami::MEDIA_ALL); if (!codec) { - RING_ERR("can not find codec %d", codecId); + JAMI_ERR("can not find codec %d", codecId); return false; } try { - if (codec->systemCodecInfo.mediaType & ring::MEDIA_AUDIO) { - if (auto foundCodec = std::static_pointer_cast<ring::AccountAudioCodecInfo>(codec)) { + if (codec->systemCodecInfo.mediaType & jami::MEDIA_AUDIO) { + if (auto foundCodec = std::static_pointer_cast<jami::AccountAudioCodecInfo>(codec)) { foundCodec->setCodecSpecifications(details); - ring::emitSignal<ConfigurationSignal::MediaParametersChanged>(accountID); + jami::emitSignal<ConfigurationSignal::MediaParametersChanged>(accountID); return true; } } - if (codec->systemCodecInfo.mediaType & ring::MEDIA_VIDEO) { - if (auto foundCodec = std::static_pointer_cast<ring::AccountVideoCodecInfo>(codec)) { + if (codec->systemCodecInfo.mediaType & jami::MEDIA_VIDEO) { + if (auto foundCodec = std::static_pointer_cast<jami::AccountVideoCodecInfo>(codec)) { foundCodec->setCodecSpecifications(details); - RING_WARN("parameters for %s changed ", + JAMI_WARN("parameters for %s changed ", foundCodec->systemCodecInfo.name.c_str()); - if (auto call = ring::Manager::instance().getCurrentCall()) { + if (auto call = jami::Manager::instance().getCurrentCall()) { if (call->useVideoCodec(foundCodec.get())) { - RING_WARN("%s running. Need to restart encoding", + JAMI_WARN("%s running. Need to restart encoding", foundCodec->systemCodecInfo.name.c_str()); call->restartMediaSender(); } } - ring::emitSignal<ConfigurationSignal::MediaParametersChanged>(accountID); + jami::emitSignal<ConfigurationSignal::MediaParametersChanged>(accountID); return true; } } } catch (const std::exception& e) { - RING_ERR("Cannot set codec specifications: %s", e.what()); + JAMI_ERR("Cannot set codec specifications: %s", e.what()); } return false; @@ -522,52 +522,52 @@ setCodecDetails(const std::string& accountID, std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId) { - auto acc = ring::Manager::instance().getAccount(accountID); + auto acc = jami::Manager::instance().getAccount(accountID); if (!acc) { - RING_ERR("Could not find account %s return default codec details" + JAMI_ERR("Could not find account %s return default codec details" , accountID.c_str()); - return ring::Account::getDefaultCodecDetails(codecId); + return jami::Account::getDefaultCodecDetails(codecId); } - auto codec = acc->searchCodecById(codecId, ring::MEDIA_ALL); + auto codec = acc->searchCodecById(codecId, jami::MEDIA_ALL); if (!codec) { - ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); + jami::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); return {}; } - if (codec->systemCodecInfo.mediaType & ring::MEDIA_AUDIO) - if (auto foundCodec = std::static_pointer_cast<ring::AccountAudioCodecInfo>(codec)) + if (codec->systemCodecInfo.mediaType & jami::MEDIA_AUDIO) + if (auto foundCodec = std::static_pointer_cast<jami::AccountAudioCodecInfo>(codec)) return foundCodec->getCodecSpecifications(); - if (codec->systemCodecInfo.mediaType & ring::MEDIA_VIDEO) - if (auto foundCodec = std::static_pointer_cast<ring::AccountVideoCodecInfo>(codec)) + if (codec->systemCodecInfo.mediaType & jami::MEDIA_VIDEO) + if (auto foundCodec = std::static_pointer_cast<jami::AccountVideoCodecInfo>(codec)) return foundCodec->getCodecSpecifications(); - ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); + jami::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED); return {}; } std::vector<unsigned> getActiveCodecList(const std::string& accountID) { - if (auto acc = ring::Manager::instance().getAccount(accountID)) + if (auto acc = jami::Manager::instance().getAccount(accountID)) return acc->getActiveCodecs(); - RING_ERR("Could not find account %s, returning default", accountID.c_str()); - return ring::Account::getDefaultCodecsId(); + JAMI_ERR("Could not find account %s, returning default", accountID.c_str()); + return jami::Account::getDefaultCodecsId(); } void setActiveCodecList(const std::string& accountID , const std::vector<unsigned>& list) { - if (auto acc = ring::Manager::instance().getAccount(accountID)) + if (auto acc = jami::Manager::instance().getAccount(accountID)) { acc->setActiveCodecs(list); - ring::Manager::instance().saveConfig(acc); + jami::Manager::instance().saveConfig(acc); } else { - RING_ERR("Could not find account %s", accountID.c_str()); + JAMI_ERR("Could not find account %s", accountID.c_str()); } } @@ -580,177 +580,177 @@ getAudioPluginList() void setAudioPlugin(const std::string& audioPlugin) { - return ring::Manager::instance().setAudioPlugin(audioPlugin); + return jami::Manager::instance().setAudioPlugin(audioPlugin); } std::vector<std::string> getAudioOutputDeviceList() { - return ring::Manager::instance().getAudioOutputDeviceList(); + return jami::Manager::instance().getAudioOutputDeviceList(); } std::vector<std::string> getAudioInputDeviceList() { - return ring::Manager::instance().getAudioInputDeviceList(); + return jami::Manager::instance().getAudioInputDeviceList(); } void setAudioOutputDevice(int32_t index) { - return ring::Manager::instance().setAudioDevice(index, DeviceType::PLAYBACK); + return jami::Manager::instance().setAudioDevice(index, DeviceType::PLAYBACK); } void setAudioInputDevice(int32_t index) { - return ring::Manager::instance().setAudioDevice(index, DeviceType::CAPTURE); + return jami::Manager::instance().setAudioDevice(index, DeviceType::CAPTURE); } void setAudioRingtoneDevice(int32_t index) { - return ring::Manager::instance().setAudioDevice(index, DeviceType::RINGTONE); + return jami::Manager::instance().setAudioDevice(index, DeviceType::RINGTONE); } std::vector<std::string> getCurrentAudioDevicesIndex() { - return ring::Manager::instance().getCurrentAudioDevicesIndex(); + return jami::Manager::instance().getCurrentAudioDevicesIndex(); } int32_t getAudioInputDeviceIndex(const std::string& name) { - return ring::Manager::instance().getAudioInputDeviceIndex(name); + return jami::Manager::instance().getAudioInputDeviceIndex(name); } int32_t getAudioOutputDeviceIndex(const std::string& name) { - return ring::Manager::instance().getAudioOutputDeviceIndex(name); + return jami::Manager::instance().getAudioOutputDeviceIndex(name); } std::string getCurrentAudioOutputPlugin() { - auto plugin = ring::Manager::instance().getCurrentAudioOutputPlugin(); - RING_DBG("Get audio plugin %s", plugin.c_str()); + auto plugin = jami::Manager::instance().getCurrentAudioOutputPlugin(); + JAMI_DBG("Get audio plugin %s", plugin.c_str()); return plugin; } bool getNoiseSuppressState() { - return ring::Manager::instance().getNoiseSuppressState(); + return jami::Manager::instance().getNoiseSuppressState(); } void setNoiseSuppressState(bool state) { - ring::Manager::instance().setNoiseSuppressState(state); + jami::Manager::instance().setNoiseSuppressState(state); } bool isAgcEnabled() { - return ring::Manager::instance().isAGCEnabled(); + return jami::Manager::instance().isAGCEnabled(); } void setAgcState(bool enabled) { - ring::Manager::instance().setAGCState(enabled); + jami::Manager::instance().setAGCState(enabled); } std::string getRecordPath() { - return ring::Manager::instance().audioPreference.getRecordPath(); + return jami::Manager::instance().audioPreference.getRecordPath(); } void setRecordPath(const std::string& recPath) { - ring::Manager::instance().audioPreference.setRecordPath(recPath); + jami::Manager::instance().audioPreference.setRecordPath(recPath); } bool getIsAlwaysRecording() { - return ring::Manager::instance().getIsAlwaysRecording(); + return jami::Manager::instance().getIsAlwaysRecording(); } void setIsAlwaysRecording(bool rec) { - ring::Manager::instance().setIsAlwaysRecording(rec); + jami::Manager::instance().setIsAlwaysRecording(rec); } int32_t getHistoryLimit() { - return ring::Manager::instance().getHistoryLimit(); + return jami::Manager::instance().getHistoryLimit(); } void setHistoryLimit(int32_t days) { - ring::Manager::instance().setHistoryLimit(days); + jami::Manager::instance().setHistoryLimit(days); } int32_t getRingingTimeout() { - return ring::Manager::instance().getRingingTimeout(); + return jami::Manager::instance().getRingingTimeout(); } void setRingingTimeout(int32_t timeout) { - ring::Manager::instance().setRingingTimeout(timeout); + jami::Manager::instance().setRingingTimeout(timeout); } bool setAudioManager(const std::string& api) { - return ring::Manager::instance().setAudioManager(api); + return jami::Manager::instance().setAudioManager(api); } std::string getAudioManager() { - return ring::Manager::instance().getAudioManager(); + return jami::Manager::instance().getAudioManager(); } void setVolume(const std::string& device, double value) { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) { - RING_DBG("set volume for %s: %f", device.c_str(), value); + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) { + JAMI_DBG("set volume for %s: %f", device.c_str(), value); if (device == "speaker") audiolayer->setPlaybackGain(value); else if (device == "mic") audiolayer->setCaptureGain(value); - ring::emitSignal<ConfigurationSignal::VolumeChanged>(device, value); + jami::emitSignal<ConfigurationSignal::VolumeChanged>(device, value); } else { - RING_ERR("Audio layer not valid while updating volume"); + JAMI_ERR("Audio layer not valid while updating volume"); } } double getVolume(const std::string& device) { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) { + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) { if (device == "speaker") return audiolayer->getPlaybackGain(); if (device == "mic") return audiolayer->getCaptureGain(); } - RING_ERR("Audio layer not valid while updating volume"); + JAMI_ERR("Audio layer not valid while updating volume"); return 0.0; } @@ -759,128 +759,128 @@ getVolume(const std::string& device) bool isDtmfMuted() { - return not ring::Manager::instance().voipPreferences.getPlayDtmf(); + return not jami::Manager::instance().voipPreferences.getPlayDtmf(); } void muteDtmf(bool mute) { - ring::Manager::instance().voipPreferences.setPlayDtmf(not mute); + jami::Manager::instance().voipPreferences.setPlayDtmf(not mute); } bool isCaptureMuted() { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->isCaptureMuted(); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return false; } void muteCapture(bool mute) { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->muteCapture(mute); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return; } bool isPlaybackMuted() { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->isPlaybackMuted(); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return false; } void mutePlayback(bool mute) { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->mutePlayback(mute); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return; } bool isRingtoneMuted() { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->isRingtoneMuted(); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return false; } void muteRingtone(bool mute) { - if (auto audiolayer = ring::Manager::instance().getAudioDriver()) + if (auto audiolayer = jami::Manager::instance().getAudioDriver()) return audiolayer->muteRingtone(mute); - RING_ERR("Audio layer not valid"); + JAMI_ERR("Audio layer not valid"); return; } std::map<std::string, std::string> getHookSettings() { - return ring::Manager::instance().hookPreference.toMap(); + return jami::Manager::instance().hookPreference.toMap(); } void setHookSettings(const std::map<std::string, std::string>& settings) { - ring::Manager::instance().hookPreference = HookPreference(settings); + jami::Manager::instance().hookPreference = HookPreference(settings); } void setAccountsOrder(const std::string& order) { - ring::Manager::instance().setAccountsOrder(order); + jami::Manager::instance().setAccountsOrder(order); } std::string getAddrFromInterfaceName(const std::string& interface) { - return ring::ip_utils::getInterfaceAddr(interface); + return jami::ip_utils::getInterfaceAddr(interface); } std::vector<std::string> getAllIpInterface() { - return ring::ip_utils::getAllIpInterface(); + return jami::ip_utils::getAllIpInterface(); } std::vector<std::string> getAllIpInterfaceByName() { - return ring::ip_utils::getAllIpInterfaceByName(); + return jami::ip_utils::getAllIpInterfaceByName(); } std::map<std::string, std::string> getShortcuts() { - return ring::Manager::instance().shortcutPreferences.getShortcuts(); + return jami::Manager::instance().shortcutPreferences.getShortcuts(); } void setShortcuts(const std::map<std::string, std::string>& shortcutsMap) { - ring::Manager::instance().shortcutPreferences.setShortcuts(shortcutsMap); - ring::Manager::instance().saveConfig(); + jami::Manager::instance().shortcutPreferences.setShortcuts(shortcutsMap); + jami::Manager::instance().saveConfig(); } std::vector<std::map<std::string, std::string>> getCredentials(const std::string& accountID) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) return sipaccount->getCredentials(); return {}; } @@ -889,7 +889,7 @@ void setCredentials(const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) { + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) { sipaccount->doUnregister([&](bool /* transport_free */) { sipaccount->setCredentials(details); if (sipaccount->isEnabled()) @@ -901,18 +901,18 @@ setCredentials(const std::string& accountID, void connectivityChanged() { - RING_WARN("received connectivity changed - trying to re-connect enabled accounts"); + JAMI_WARN("received connectivity changed - trying to re-connect enabled accounts"); // reset the UPnP context #if !(defined(TARGET_OS_IOS) && TARGET_OS_IOS) try { - ring::upnp::getUPnPContext()->connectivityChanged(); + jami::upnp::getUPnPContext()->connectivityChanged(); } catch (std::runtime_error& e) { - RING_ERR("UPnP context error: %s", e.what()); + JAMI_ERR("UPnP context error: %s", e.what()); } #endif - for (const auto &account : ring::Manager::instance().getAllAccounts()) { + for (const auto &account : jami::Manager::instance().getAllAccounts()) { account->connectivityChanged(); } } @@ -921,15 +921,15 @@ bool lookupName(const std::string& account, const std::string& nameserver, const { #if HAVE_RINGNS if (account.empty()) { - auto cb = [name](const std::string& result, ring::NameDirectory::Response response) { - ring::emitSignal<DRing::ConfigurationSignal::RegisteredNameFound>("", (int)response, result, name); + auto cb = [name](const std::string& result, jami::NameDirectory::Response response) { + jami::emitSignal<DRing::ConfigurationSignal::RegisteredNameFound>("", (int)response, result, name); }; if (nameserver.empty()) - ring::NameDirectory::lookupUri(name, "", cb); + jami::NameDirectory::lookupUri(name, "", cb); else - ring::NameDirectory::instance(nameserver).lookupName(name, cb); + jami::NameDirectory::instance(nameserver).lookupName(name, cb); return true; - } else if (auto acc = ring::Manager::instance().getAccount<RingAccount>(account)) { + } else if (auto acc = jami::Manager::instance().getAccount<RingAccount>(account)) { acc->lookupName(name); return true; } @@ -941,11 +941,11 @@ bool lookupAddress(const std::string& account, const std::string& nameserver, co { #if HAVE_RINGNS if (account.empty()) { - ring::NameDirectory::instance(nameserver).lookupAddress(address, [address](const std::string& result, ring::NameDirectory::Response response) { - ring::emitSignal<DRing::ConfigurationSignal::RegisteredNameFound>("", (int)response, address, result); + jami::NameDirectory::instance(nameserver).lookupAddress(address, [address](const std::string& result, jami::NameDirectory::Response response) { + jami::emitSignal<DRing::ConfigurationSignal::RegisteredNameFound>("", (int)response, address, result); }); return true; - } else if (auto acc = ring::Manager::instance().getAccount<RingAccount>(account)) { + } else if (auto acc = jami::Manager::instance().getAccount<RingAccount>(account)) { acc->lookupAddress(address); return true; } @@ -956,7 +956,7 @@ bool lookupAddress(const std::string& account, const std::string& nameserver, co bool registerName(const std::string& account, const std::string& password, const std::string& name) { #if HAVE_RINGNS - if (auto acc = ring::Manager::instance().getAccount<RingAccount>(account)) { + if (auto acc = jami::Manager::instance().getAccount<RingAccount>(account)) { acc->registerName(password, name); return true; } @@ -966,36 +966,36 @@ bool registerName(const std::string& account, const std::string& password, const void enableProxyClient(const std::string& accountID, bool enable) { - if (auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) + if (auto account = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) account->enableProxyClient(enable); } void setPushNotificationToken(const std::string& token) { - for (const auto &account : ring::Manager::instance().getAllAccounts<RingAccount>()) + for (const auto &account : jami::Manager::instance().getAllAccounts<RingAccount>()) account->setPushNotificationToken(token); } void pushNotificationReceived(const std::string& from, const std::map<std::string, std::string>& data) { try { - if (auto account = ring::Manager::instance().getAccount<ring::RingAccount>(data.at("to"))) + if (auto account = jami::Manager::instance().getAccount<jami::RingAccount>(data.at("to"))) account->pushNotificationReceived(from, data); } catch (const std::exception& e) { - RING_ERR("Error processing push notification: %s", e.what()); + JAMI_ERR("Error processing push notification: %s", e.what()); } } bool isAudioMeterActive(const std::string& id) { - return ring::Manager::instance().getRingBufferPool().isAudioMeterActive(id); + return jami::Manager::instance().getRingBufferPool().isAudioMeterActive(id); } void setAudioMeterState(const std::string& id, bool state) { - ring::Manager::instance().getRingBufferPool().setAudioMeterState(id, state); + jami::Manager::instance().getRingBufferPool().setAudioMeterState(id, state); } } // namespace DRing diff --git a/src/client/datatransfer.cpp b/src/client/datatransfer.cpp index ae29cabf14..d66ab884b5 100644 --- a/src/client/datatransfer.cpp +++ b/src/client/datatransfer.cpp @@ -36,37 +36,37 @@ registerDataXferHandlers(const std::map<std::string, std::vector<DataTransferId> dataTransferList() noexcept { - return ring::Manager::instance().dataTransfers->list(); + return jami::Manager::instance().dataTransfers->list(); } DataTransferError sendFile(const DataTransferInfo& info, DataTransferId& id) noexcept { - return ring::Manager::instance().dataTransfers->sendFile(info, id); + return jami::Manager::instance().dataTransfers->sendFile(info, id); } DataTransferError acceptFileTransfer(const DataTransferId& id, const std::string& file_path, int64_t offset) noexcept { - return ring::Manager::instance().dataTransfers->acceptAsFile(id, file_path, offset); + return jami::Manager::instance().dataTransfers->acceptAsFile(id, file_path, offset); } DataTransferError cancelDataTransfer(const DataTransferId& id) noexcept { - return ring::Manager::instance().dataTransfers->cancel(id); + return jami::Manager::instance().dataTransfers->cancel(id); } DataTransferError dataTransferBytesProgress(const DataTransferId& id, int64_t& total, int64_t& progress) noexcept { - return ring::Manager::instance().dataTransfers->bytesProgress(id, total, progress); + return jami::Manager::instance().dataTransfers->bytesProgress(id, total, progress); } DataTransferError dataTransferInfo(const DataTransferId& id, DataTransferInfo& info) noexcept { - return ring::Manager::instance().dataTransfers->info(id, info); + return jami::Manager::instance().dataTransfers->info(id, info); } } // namespace DRing diff --git a/src/client/presencemanager.cpp b/src/client/presencemanager.cpp index 395a900903..cc98f746e3 100644 --- a/src/client/presencemanager.cpp +++ b/src/client/presencemanager.cpp @@ -42,7 +42,7 @@ namespace DRing { -using ring::SIPAccount; +using jami::SIPAccount; void registerPresHandlers(const std::map<std::string, @@ -57,17 +57,17 @@ registerPresHandlers(const std::map<std::string, void subscribeBuddy(const std::string& accountID, const std::string& uri, bool flag) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) { + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) { auto pres = sipaccount->getPresence(); if (pres and pres->isEnabled() and pres->isSupported(PRESENCE_FUNCTION_SUBSCRIBE)) { - RING_DBG("%subscribePresence (acc:%s, buddy:%s)", + JAMI_DBG("%subscribePresence (acc:%s, buddy:%s)", flag ? "S" : "Uns", accountID.c_str(), uri.c_str()); pres->subscribeClient(uri, flag); } - } else if (auto ringaccount = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { + } else if (auto ringaccount = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) { ringaccount->trackBuddyPresence(uri, flag); } else - RING_ERR("Could not find account %s", accountID.c_str()); + JAMI_ERR("Could not find account %s", accountID.c_str()); } /** @@ -77,15 +77,15 @@ subscribeBuddy(const std::string& accountID, const std::string& uri, bool flag) void publish(const std::string& accountID, bool status, const std::string& note) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) { + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) { auto pres = sipaccount->getPresence(); if (pres and pres->isEnabled() and pres->isSupported(PRESENCE_FUNCTION_PUBLISH)) { - RING_DBG("Send Presence (acc:%s, status %s).", accountID.c_str(), + JAMI_DBG("Send Presence (acc:%s, status %s).", accountID.c_str(), status ? "online" : "offline"); pres->sendPresence(status, note); } } else - RING_ERR("Could not find account %s.", accountID.c_str()); + JAMI_ERR("Could not find account %s.", accountID.c_str()); } /** @@ -95,19 +95,19 @@ void answerServerRequest(UNUSED const std::string& uri, UNUSED bool flag) { #if 0 // DISABLED: removed IP2IP support, tuleap: #448 - auto account = ring::Manager::instance().getIP2IPAccount(); + auto account = jami::Manager::instance().getIP2IPAccount(); if (auto sipaccount = static_cast<SIPAccount *>(account.get())) { - RING_DBG("Approve presence (acc:IP2IP, serv:%s, flag:%s)", uri.c_str(), + JAMI_DBG("Approve presence (acc:IP2IP, serv:%s, flag:%s)", uri.c_str(), flag ? "true" : "false"); if (auto pres = sipaccount->getPresence()) pres->approvePresSubServer(uri, flag); else - RING_ERR("Presence not initialized"); + JAMI_ERR("Presence not initialized"); } else - RING_ERR("Could not find account IP2IP"); + JAMI_ERR("Could not find account IP2IP"); #else - RING_ERR("answerServerRequest() is deprecated and does nothing"); + JAMI_ERR("answerServerRequest() is deprecated and does nothing"); #endif } @@ -119,7 +119,7 @@ getSubscriptions(const std::string& accountID) { std::vector<std::map<std::string, std::string>> ret; - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) { + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) { if (auto pres = sipaccount->getPresence()) { for (const auto& s : pres->getClientSubscriptions()) { ret.push_back({ @@ -129,8 +129,8 @@ getSubscriptions(const std::string& accountID) }); } } else - RING_ERR("Presence not initialized"); - } else if (auto ringaccount = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { + JAMI_ERR("Presence not initialized"); + } else if (auto ringaccount = jami::Manager::instance().getAccount<jami::RingAccount>(accountID)) { for (const auto& tracked_id : ringaccount->getTrackedBuddyPresence()) { ret.push_back({ {DRing::Presence::BUDDY_KEY, tracked_id.first}, @@ -138,7 +138,7 @@ getSubscriptions(const std::string& accountID) }); } } else - RING_ERR("Could not find account %s.", accountID.c_str()); + JAMI_ERR("Could not find account %s.", accountID.c_str()); return ret; } @@ -149,14 +149,14 @@ getSubscriptions(const std::string& accountID) void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris) { - if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) { + if (auto sipaccount = jami::Manager::instance().getAccount<SIPAccount>(accountID)) { if (auto pres = sipaccount->getPresence()) { for (const auto &u : uris) pres->subscribeClient(u, true); } else - RING_ERR("Presence not initialized"); + JAMI_ERR("Presence not initialized"); } else - RING_ERR("Could not find account %s.", accountID.c_str()); + JAMI_ERR("Could not find account %s.", accountID.c_str()); } } // namespace DRing diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp index a40925eceb..e60d5460f5 100644 --- a/src/client/ring_signal.cpp +++ b/src/client/ring_signal.cpp @@ -20,7 +20,7 @@ #include "ring_signal.h" -namespace ring { +namespace jami { SignalHandlerMap& getSignalHandlers() @@ -100,7 +100,7 @@ getSignalHandlers() /* DataTransfer */ exported_callback<DRing::DataTransferSignal::DataTransferEvent>(), -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /* Video */ exported_callback<DRing::VideoSignal::DeviceEvent>(), exported_callback<DRing::VideoSignal::DecodingStarted>(), @@ -120,7 +120,7 @@ getSignalHandlers() return handlers; } -}; // namespace ring +}; // namespace jami namespace DRing { @@ -128,11 +128,11 @@ void registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&handlers) { - auto& handlers_ = ring::getSignalHandlers(); + auto& handlers_ = jami::getSignalHandlers(); for (auto& item : handlers) { auto iter = handlers_.find(item.first); if (iter == handlers_.end()) { - RING_ERR("Signal %s not supported", item.first.c_str()); + JAMI_ERR("Signal %s not supported", item.first.c_str()); continue; } iter->second = std::move(item.second); diff --git a/src/client/ring_signal.h b/src/client/ring_signal.h index cb74dece21..e647e5020a 100644 --- a/src/client/ring_signal.h +++ b/src/client/ring_signal.h @@ -29,7 +29,7 @@ #include "presencemanager_interface.h" #include "datatransfer_interface.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "videomanager_interface.h" #endif @@ -46,7 +46,7 @@ #include <utility> #include <string> -namespace ring { +namespace jami { using SignalHandlerMap = std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>; extern SignalHandlerMap& getSignalHandlers(); @@ -62,7 +62,7 @@ static void emitSignal(Args...args) { try { cb(args...); } catch (std::exception& e) { - RING_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what()); + JAMI_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what()); } } } @@ -73,4 +73,4 @@ exported_callback() { return std::make_pair((const std::string&)Ts::name, std::make_shared<DRing::CallbackWrapper<typename Ts::cb_type>>()); } -} // namespace ring +} // namespace jami diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 55e16e0eb6..fd0836082c 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -81,7 +81,7 @@ MediaFrame::setPacket(std::unique_ptr<AVPacket, void(*)(AVPacket*)>&& pkt) packet_ = std::move(pkt); } -AudioFrame::AudioFrame(const ring::AudioFormat& format, size_t nb_samples) +AudioFrame::AudioFrame(const jami::AudioFormat& format, size_t nb_samples) : MediaFrame() { setFormat(format); @@ -90,7 +90,7 @@ AudioFrame::AudioFrame(const ring::AudioFormat& format, size_t nb_samples) } void -AudioFrame::setFormat(const ring::AudioFormat& format) +AudioFrame::setFormat(const jami::AudioFormat& format) { auto d = pointer(); d->channels = format.nb_channels; @@ -122,7 +122,7 @@ AudioFrame::mix(const AudioFrame& frame) } if (f.nb_samples == 0) { reserve(fIn.nb_samples); - ring::libav_utils::fillWithSilence(&f); + jami::libav_utils::fillWithSilence(&f); } else if (f.nb_samples != fIn.nb_samples) { throw std::invalid_argument("Can't mix frames with different length"); } @@ -179,7 +179,7 @@ AudioFrame::calcRMS() const } } else { // Should not happen - RING_ERR() << "Unsupported format for getting volume level: " << av_get_sample_fmt_name(fmt); + JAMI_ERR() << "Unsupported format for getting volume level: " << av_get_sample_fmt_name(fmt); return 0.0; } // divide by the number of multi-byte samples @@ -303,14 +303,14 @@ VideoFrame::noise() VideoFrame* getNewFrame() { - if (auto input = ring::Manager::instance().getVideoManager().videoInput.lock()) + if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock()) return &input->getNewFrame(); return nullptr; } void publishFrame() { - if (auto input = ring::Manager::instance().getVideoManager().videoInput.lock()) + if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock()) return input->publishFrame(); } @@ -324,39 +324,39 @@ registerVideoHandlers(const std::map<std::string, std::vector<std::string> getDeviceList() { - return ring::Manager::instance().getVideoManager().videoDeviceMonitor.getDeviceList(); + return jami::Manager::instance().getVideoManager().videoDeviceMonitor.getDeviceList(); } VideoCapabilities getCapabilities(const std::string& name) { - return ring::Manager::instance().getVideoManager().videoDeviceMonitor.getCapabilities(name); + return jami::Manager::instance().getVideoManager().videoDeviceMonitor.getCapabilities(name); } std::string getDefaultDevice() { - return ring::Manager::instance().getVideoManager().videoDeviceMonitor.getDefaultDevice(); + return jami::Manager::instance().getVideoManager().videoDeviceMonitor.getDefaultDevice(); } void setDefaultDevice(const std::string& name) { - RING_DBG("Setting default device to %s", name.c_str()); - ring::Manager::instance().getVideoManager().videoDeviceMonitor.setDefaultDevice(name); - ring::Manager::instance().saveConfig(); + JAMI_DBG("Setting default device to %s", name.c_str()); + jami::Manager::instance().getVideoManager().videoDeviceMonitor.setDefaultDevice(name); + jami::Manager::instance().saveConfig(); } void setDeviceOrientation(const std::string& name, int angle) { - ring::Manager::instance().getVideoManager().setDeviceOrientation(name, angle); + jami::Manager::instance().getVideoManager().setDeviceOrientation(name, angle); } std::map<std::string, std::string> getDeviceParams(const std::string& name) { - auto params = ring::Manager::instance().getVideoManager().videoDeviceMonitor.getDeviceParams(name); + auto params = jami::Manager::instance().getVideoManager().videoDeviceMonitor.getDeviceParams(name); std::stringstream width, height, rate; width << params.width; height << params.height; @@ -372,73 +372,73 @@ getDeviceParams(const std::string& name) std::map<std::string, std::string> getSettings(const std::string& name) { - return ring::Manager::instance().getVideoManager().videoDeviceMonitor.getSettings(name).to_map(); + return jami::Manager::instance().getVideoManager().videoDeviceMonitor.getSettings(name).to_map(); } void applySettings(const std::string& name, const std::map<std::string, std::string>& settings) { - ring::Manager::instance().getVideoManager().videoDeviceMonitor.applySettings(name, settings); + jami::Manager::instance().getVideoManager().videoDeviceMonitor.applySettings(name, settings); } void startCamera() { - ring::Manager::instance().getVideoManager().videoPreview = ring::getVideoCamera(); - ring::Manager::instance().getVideoManager().started = switchToCamera(); + jami::Manager::instance().getVideoManager().videoPreview = jami::getVideoCamera(); + jami::Manager::instance().getVideoManager().started = switchToCamera(); } void stopCamera() { if (switchInput("")) - ring::Manager::instance().getVideoManager().started = false; - ring::Manager::instance().getVideoManager().videoPreview.reset(); + jami::Manager::instance().getVideoManager().started = false; + jami::Manager::instance().getVideoManager().videoPreview.reset(); } void startAudioDevice() { // Don't start audio layer if already done - auto audioLayer = ring::Manager::instance().getAudioDriver(); + auto audioLayer = jami::Manager::instance().getAudioDriver(); if (!audioLayer) - ring::Manager::instance().initAudioDriver(); + jami::Manager::instance().initAudioDriver(); if (!audioLayer->isStarted()) - ring::Manager::instance().startAudioDriverStream(); - ring::Manager::instance().getVideoManager().audioPreview = ring::getAudioInput(ring::RingBufferPool::DEFAULT_ID); + jami::Manager::instance().startAudioDriverStream(); + jami::Manager::instance().getVideoManager().audioPreview = jami::getAudioInput(jami::RingBufferPool::DEFAULT_ID); } void stopAudioDevice() { - ring::Manager::instance().getVideoManager().audioPreview.reset(); - ring::Manager::instance().checkAudio(); // stops audio layer if no calls + jami::Manager::instance().getVideoManager().audioPreview.reset(); + jami::Manager::instance().checkAudio(); // stops audio layer if no calls } std::string startLocalRecorder(const bool& audioOnly, const std::string& filepath) { - if (!audioOnly && !ring::Manager::instance().getVideoManager().started) { - RING_ERR("Couldn't start local video recorder (camera is not started)"); + if (!audioOnly && !jami::Manager::instance().getVideoManager().started) { + JAMI_ERR("Couldn't start local video recorder (camera is not started)"); return ""; } - auto rec = std::make_unique<ring::LocalRecorder>(audioOnly); + auto rec = std::make_unique<jami::LocalRecorder>(audioOnly); rec->setPath(filepath); // retrieve final path (containing file extension) auto path = rec->getPath(); try { - ring::LocalRecorderManager::instance().insertRecorder(path, std::move(rec)); + jami::LocalRecorderManager::instance().insertRecorder(path, std::move(rec)); } catch (const std::invalid_argument&) { return ""; } - auto ret = ring::LocalRecorderManager::instance().getRecorderByPath(path)->startRecording(); + auto ret = jami::LocalRecorderManager::instance().getRecorderByPath(path)->startRecording(); if (!ret) { - ring::LocalRecorderManager::instance().removeRecorderByPath(filepath); + jami::LocalRecorderManager::instance().removeRecorderByPath(filepath); return ""; } @@ -448,31 +448,31 @@ startLocalRecorder(const bool& audioOnly, const std::string& filepath) void stopLocalRecorder(const std::string& filepath) { - ring::LocalRecorder *rec = ring::LocalRecorderManager::instance().getRecorderByPath(filepath); + jami::LocalRecorder *rec = jami::LocalRecorderManager::instance().getRecorderByPath(filepath); if (!rec) { - RING_WARN("Can't stop non existing local recorder."); + JAMI_WARN("Can't stop non existing local recorder."); return; } rec->stopRecording(); - ring::LocalRecorderManager::instance().removeRecorderByPath(filepath); + jami::LocalRecorderManager::instance().removeRecorderByPath(filepath); } bool switchInput(const std::string& resource) { - if (auto call = ring::Manager::instance().getCurrentCall()) { - // TODO remove this part when clients are updated to use Callring::Manager::switchInput + if (auto call = jami::Manager::instance().getCurrentCall()) { + // TODO remove this part when clients are updated to use Calljami::Manager::switchInput call->switchInput(resource); return true; } else { bool ret = true; - if (auto input = ring::Manager::instance().getVideoManager().videoInput.lock()) + if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock()) ret = input->switchInput(resource).valid(); else - RING_WARN("Video input not initialized"); + JAMI_WARN("Video input not initialized"); - if (auto input = ring::getAudioInput(ring::RingBufferPool::DEFAULT_ID)) + if (auto input = jami::getAudioInput(jami::RingBufferPool::DEFAULT_ID)) ret &= input->switchInput(resource).valid(); return ret; } @@ -481,42 +481,42 @@ switchInput(const std::string& resource) bool switchToCamera() { - return switchInput(ring::Manager::instance().getVideoManager().videoDeviceMonitor.getMRLForDefaultDevice()); + return switchInput(jami::Manager::instance().getVideoManager().videoDeviceMonitor.getMRLForDefaultDevice()); } bool hasCameraStarted() { - return ring::Manager::instance().getVideoManager().started; + return jami::Manager::instance().getVideoManager().started; } void registerSinkTarget(const std::string& sinkId, const SinkTarget& target) { - if (auto sink = ring::Manager::instance().getSinkClient(sinkId)) + if (auto sink = jami::Manager::instance().getSinkClient(sinkId)) sink->registerTarget(target); else - RING_WARN("No sink found for id '%s'", sinkId.c_str()); + JAMI_WARN("No sink found for id '%s'", sinkId.c_str()); } void registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target) { - if (auto sink = ring::Manager::instance().getSinkClient(sinkId)) + if (auto sink = jami::Manager::instance().getSinkClient(sinkId)) sink->registerAVTarget(target); else - RING_WARN("No sink found for id '%s'", sinkId.c_str()); + JAMI_WARN("No sink found for id '%s'", sinkId.c_str()); } std::map<std::string, std::string> getRenderer(const std::string& callId) { - if (auto sink = ring::Manager::instance().getSinkClient(callId)) + if (auto sink = jami::Manager::instance().getSinkClient(callId)) return { {DRing::Media::Details::CALL_ID, callId}, {DRing::Media::Details::SHM_PATH, sink->openedName()}, - {DRing::Media::Details::WIDTH, ring::to_string(sink->getWidth())}, - {DRing::Media::Details::HEIGHT, ring::to_string(sink->getHeight())}, + {DRing::Media::Details::WIDTH, jami::to_string(sink->getWidth())}, + {DRing::Media::Details::HEIGHT, jami::to_string(sink->getHeight())}, }; else return { @@ -531,7 +531,7 @@ bool getDecodingAccelerated() { #ifdef RING_ACCEL - return ring::Manager::instance().videoPreferences.getDecodingAccelerated(); + return jami::Manager::instance().videoPreferences.getDecodingAccelerated(); #else return false; #endif @@ -541,8 +541,8 @@ void setDecodingAccelerated(bool state) { #ifdef RING_ACCEL - RING_DBG("%s hardware acceleration", (state ? "Enabling" : "Disabling")); - ring::Manager::instance().videoPreferences.setDecodingAccelerated(state); + JAMI_DBG("%s hardware acceleration", (state ? "Enabling" : "Disabling")); + jami::Manager::instance().videoPreferences.setDecodingAccelerated(state); #endif } @@ -550,7 +550,7 @@ bool getEncodingAccelerated() { #ifdef RING_ACCEL - return ring::Manager::instance().videoPreferences.getEncodingAccelerated(); + return jami::Manager::instance().videoPreferences.getEncodingAccelerated(); #else return false; #endif @@ -560,8 +560,8 @@ void setEncodingAccelerated(bool state) { #ifdef RING_ACCEL - RING_DBG("%s hardware acceleration", (state ? "Enabling" : "Disabling")); - ring::Manager::instance().videoPreferences.setEncodingAccelerated(state); + JAMI_DBG("%s hardware acceleration", (state ? "Enabling" : "Disabling")); + jami::Manager::instance().videoPreferences.setEncodingAccelerated(state); #endif } @@ -569,19 +569,19 @@ setEncodingAccelerated(bool state) void addVideoDevice(const std::string &node, std::vector<std::map<std::string, std::string>> const * devInfo) { - ring::Manager::instance().getVideoManager().videoDeviceMonitor.addDevice(node, devInfo); + jami::Manager::instance().getVideoManager().videoDeviceMonitor.addDevice(node, devInfo); } void removeVideoDevice(const std::string &node) { - ring::Manager::instance().getVideoManager().videoDeviceMonitor.removeDevice(node); + jami::Manager::instance().getVideoManager().videoDeviceMonitor.removeDevice(node); } void* obtainFrame(int length) { - if (auto input = ring::Manager::instance().getVideoManager().videoInput.lock()) + if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock()) return (*input).obtainFrame(length); return nullptr; @@ -590,14 +590,14 @@ obtainFrame(int length) void releaseFrame(void* frame) { - if (auto input = ring::Manager::instance().getVideoManager().videoInput.lock()) + if (auto input = jami::Manager::instance().getVideoManager().videoInput.lock()) (*input).releaseFrame(frame); } #endif } // namespace DRing -namespace ring { +namespace jami { std::shared_ptr<video::VideoFrameActiveWriter> getVideoCamera() @@ -650,4 +650,4 @@ VideoManager::setDeviceOrientation(const std::string& name, int angle) videoDeviceMonitor.setDeviceOrientation(name, angle); } -} // namespace ring +} // namespace jami diff --git a/src/client/videomanager.h b/src/client/videomanager.h index 9c55f689e1..520fef040b 100644 --- a/src/client/videomanager.h +++ b/src/client/videomanager.h @@ -34,7 +34,7 @@ #include "video/video_base.h" #include "video/video_input.h" -namespace ring { +namespace jami { struct VideoManager { @@ -69,6 +69,6 @@ std::shared_ptr<video::VideoFrameActiveWriter> getVideoCamera(); video::VideoDeviceMonitor& getVideoDeviceMonitor(); std::shared_ptr<AudioInput> getAudioInput(const std::string& id); -} // namespace ring +} // namespace jami #endif // VIDEOMANAGER_H_ diff --git a/src/conference.cpp b/src/conference.cpp index b3d61a0102..795ef50845 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -26,7 +26,7 @@ #include "audio/audiolayer.h" #include "audio/ringbufferpool.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "sip/sipcall.h" #include "client/videomanager.h" #include "video/video_input.h" @@ -37,13 +37,13 @@ #include "logger.h" -namespace ring { +namespace jami { Conference::Conference() : id_(Manager::instance().getNewCallID()) , confState_(ACTIVE_ATTACHED) , participants_() -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO , videoMixer_(nullptr) #endif { @@ -51,12 +51,12 @@ Conference::Conference() Conference::~Conference() { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO for (const auto &participant_id : participants_) { if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) call->getVideoRtp().exitConference(); } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO } Conference::ConferenceState Conference::getState() const @@ -72,22 +72,22 @@ void Conference::setState(ConferenceState state) void Conference::add(const std::string &participant_id) { if (participants_.insert(participant_id).second) { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) call->getVideoRtp().enterConference(this); else - RING_ERR("no call associate to participant %s", participant_id.c_str()); -#endif // RING_VIDEO + JAMI_ERR("no call associate to participant %s", participant_id.c_str()); +#endif // ENABLE_VIDEO } } void Conference::remove(const std::string &participant_id) { if (participants_.erase(participant_id)) { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) call->getVideoRtp().exitConference(); -#endif // RING_VIDEO +#endif // ENABLE_VIDEO } } @@ -153,7 +153,7 @@ std::string Conference::getConfID() const { return id_; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::shared_ptr<video::VideoMixer> Conference::getVideoMixer() { if (!videoMixer_) @@ -162,4 +162,4 @@ std::shared_ptr<video::VideoMixer> Conference::getVideoMixer() } #endif -} // namespace ring +} // namespace jami diff --git a/src/conference.h b/src/conference.h index 100bd356f5..64abd03b5c 100644 --- a/src/conference.h +++ b/src/conference.h @@ -31,9 +31,9 @@ #include "recordable.h" -namespace ring { +namespace jami { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO namespace video { class VideoMixer; } @@ -106,7 +106,7 @@ class Conference : public Recordable { */ virtual bool toggleRecording(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::shared_ptr<video::VideoMixer> getVideoMixer(); #endif @@ -115,11 +115,11 @@ class Conference : public Recordable { ConferenceState confState_; ParticipantSet participants_; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::shared_ptr<video::VideoMixer> videoMixer_; #endif }; -} // namespace ring +} // namespace jami #endif diff --git a/src/config/serializable.h b/src/config/serializable.h index 094e173a4b..9cda8bf658 100644 --- a/src/config/serializable.h +++ b/src/config/serializable.h @@ -26,7 +26,7 @@ namespace YAML { class Node; } -namespace ring { +namespace jami { class Serializable { @@ -36,6 +36,6 @@ class Serializable { virtual void unserialize(const YAML::Node &node) = 0; }; -} // namespace ring +} // namespace jami #endif diff --git a/src/config/yamlparser.cpp b/src/config/yamlparser.cpp index 3b8f8e8dca..581d9ad278 100644 --- a/src/config/yamlparser.cpp +++ b/src/config/yamlparser.cpp @@ -21,7 +21,7 @@ #include "yamlparser.h" #include "fileutils.h" -namespace ring { namespace yaml_utils { +namespace jami { namespace yaml_utils { void parsePath(const YAML::Node &node, const char *key, std::string& path, const std::string& base) @@ -47,4 +47,4 @@ parseVectorMap(const YAML::Node &node, const std::initializer_list<std::string> return result; } -}} // namespace ring::yaml_utils +}} // namespace jami::yaml_utils diff --git a/src/config/yamlparser.h b/src/config/yamlparser.h index a01446c7f4..a0f60f1955 100644 --- a/src/config/yamlparser.h +++ b/src/config/yamlparser.h @@ -22,7 +22,7 @@ #include <yaml-cpp/yaml.h> -namespace ring { namespace yaml_utils { +namespace jami { namespace yaml_utils { // set T to the value stored at key, or leaves T unchanged // if no value is stored. @@ -37,4 +37,4 @@ void parsePath(const YAML::Node &node, const char *key, std::string& path, const std::vector<std::map<std::string, std::string>> parseVectorMap(const YAML::Node &node, const std::initializer_list<std::string> &keys); -}} // namespace ring::yaml_utils +}} // namespace jami::yaml_utils diff --git a/src/data_transfer.cpp b/src/data_transfer.cpp index cae3938508..5667528446 100644 --- a/src/data_transfer.cpp +++ b/src/data_transfer.cpp @@ -42,7 +42,7 @@ #include <opendht/rng.h> -namespace ring { +namespace jami { static DRing::DataTransferId generateUID() @@ -347,7 +347,7 @@ SubOutgoingFileTransfer::read(std::vector<uint8_t>& buf) const // File end reached? if (input_.eof()) { - RING_DBG() << "FTP#" << getId() << ": sent " << info_.bytesProgress << " bytes"; + JAMI_DBG() << "FTP#" << getId() << ": sent " << info_.bytesProgress << " bytes"; emit(DRing::DataTransferEventCode::finished); return false; } @@ -367,7 +367,7 @@ SubOutgoingFileTransfer::write(const std::vector<uint8_t>& buffer) emit(DRing::DataTransferEventCode::ongoing); } else { // consider any other response as a cancel msg - RING_WARN() << "FTP#" << getId() << ": refused by peer"; + JAMI_WARN() << "FTP#" << getId() << ": refused by peer"; emit(DRing::DataTransferEventCode::closed_by_peer); return false; } @@ -393,7 +393,7 @@ SubOutgoingFileTransfer::emit(DRing::DataTransferEventCode code) const if (stopTimeout_.load()) return; // not waiting anymore } - RING_WARN() << "FTP#" << this->getId() << ": timeout. Cancel"; + JAMI_WARN() << "FTP#" << this->getId() << ": timeout. Cancel"; this->closeAndEmit(DRing::DataTransferEventCode::timeout_expired); })); } else if (timeoutThread_) { @@ -488,7 +488,7 @@ IncomingFileTransfer::IncomingFileTransfer(DRing::DataTransferId tid, const DRing::DataTransferInfo& info) : DataTransfer(tid) { - RING_WARN() << "[FTP] incoming transfert of " << info.totalSize << " byte(s): " << info.displayName; + JAMI_WARN() << "[FTP] incoming transfert of " << info.totalSize << " byte(s): " << info.displayName; info_ = info; info_.flags |= (uint32_t)1 << int(DRing::DataTransferFlags::direction); // incoming @@ -520,7 +520,7 @@ IncomingFileTransfer::start() fout_.open(&info_.path[0], std::ios::binary); if (!fout_) { - RING_ERR() << "[FTP] Can't open file " << info_.path; + JAMI_ERR() << "[FTP] Can't open file " << info_.path; return false; } @@ -543,7 +543,7 @@ IncomingFileTransfer::close() noexcept auto account = Manager::instance().getAccount<RingAccount>(info_.accountId); account->closePeerConnection(info_.peer, id); - RING_DBG() << "[FTP] file closed, rx " << info_.bytesProgress + JAMI_DBG() << "[FTP] file closed, rx " << info_.bytesProgress << " on " << info_.totalSize; if (info_.bytesProgress >= info_.totalSize) emit(DRing::DataTransferEventCode::finished); @@ -561,7 +561,7 @@ IncomingFileTransfer::accept(const std::string& filename, std::size_t offset) try { filenamePromise_.set_value(); } catch (const std::future_error& e) { - RING_WARN() << "transfer already accepted"; + JAMI_WARN() << "transfer already accepted"; } } @@ -660,12 +660,12 @@ DataTransferFacade::Impl::onConnectionRequestReply(const DRing::DataTransferId& DataTransferFacade::DataTransferFacade() : pimpl_ {std::make_unique<Impl>()} { - RING_WARN("[XFER] facade created, pimpl @%p", pimpl_.get()); + JAMI_WARN("[XFER] facade created, pimpl @%p", pimpl_.get()); } DataTransferFacade::~DataTransferFacade() { - RING_WARN("[XFER] facade destroy, pimpl @%p", pimpl_.get()); + JAMI_WARN("[XFER] facade destroy, pimpl @%p", pimpl_.get()); }; std::vector<DRing::DataTransferId> @@ -681,19 +681,19 @@ DataTransferFacade::sendFile(const DRing::DataTransferInfo& info, { auto account = Manager::instance().getAccount<RingAccount>(info.accountId); if (!account) { - RING_ERR() << "[XFER] unknown id " << tid; + JAMI_ERR() << "[XFER] unknown id " << tid; return DRing::DataTransferError::invalid_argument; } if (!fileutils::isFile(info.path)) { - RING_ERR() << "[XFER] invalid filename '" << info.path << "'"; + JAMI_ERR() << "[XFER] invalid filename '" << info.path << "'"; return DRing::DataTransferError::invalid_argument; } try { pimpl_->createOutgoingFileTransfer(info, tid); } catch (const std::exception& ex) { - RING_ERR() << "[XFER] exception during createFileTransfer(): " << ex.what(); + JAMI_ERR() << "[XFER] exception during createFileTransfer(): " << ex.what(); return DRing::DataTransferError::io; } @@ -709,7 +709,7 @@ DataTransferFacade::sendFile(const DRing::DataTransferInfo& info, }); return DRing::DataTransferError::success; } catch (const std::exception& ex) { - RING_ERR() << "[XFER] exception during sendFile(): " << ex.what(); + JAMI_ERR() << "[XFER] exception during sendFile(): " << ex.what(); return DRing::DataTransferError::unknown; } } @@ -752,7 +752,7 @@ DataTransferFacade::bytesProgress(const DRing::DataTransferId& id, } return DRing::DataTransferError::invalid_argument; } catch (const std::exception& ex) { - RING_ERR() << "[XFER] exception during bytesProgress(): " << ex.what(); + JAMI_ERR() << "[XFER] exception during bytesProgress(): " << ex.what(); } return DRing::DataTransferError::unknown; } @@ -768,7 +768,7 @@ DataTransferFacade::info(const DRing::DataTransferId& id, } return DRing::DataTransferError::invalid_argument; } catch (const std::exception& ex) { - RING_ERR() << "[XFER] exception during info(): " << ex.what(); + JAMI_ERR() << "[XFER] exception during info(): " << ex.what(); } return DRing::DataTransferError::unknown; } @@ -784,4 +784,4 @@ DataTransferFacade::onIncomingFileRequest(const DRing::DataTransferInfo& info) return {}; } -} // namespace ring +} // namespace jami diff --git a/src/data_transfer.h b/src/data_transfer.h index 712bba75b5..dfe8c2b9d5 100644 --- a/src/data_transfer.h +++ b/src/data_transfer.h @@ -25,7 +25,7 @@ #include <memory> #include <string> -namespace ring { +namespace jami { class Stream; @@ -68,4 +68,4 @@ private: std::unique_ptr<Impl> pimpl_; }; -} // namespace ring +} // namespace jami diff --git a/src/debug_utils.h b/src/debug_utils.h index df93966505..450d857594 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -38,13 +38,13 @@ using Clock = std::chrono::steady_clock; -namespace ring { namespace debug { +namespace jami { namespace debug { /** * Ex: * Timer t; * std::this_thread::sleep_for(std::chrono::milliseconds(10)); - * RING_DBG() << "Task took " << t.getDuration<std::chrono::nanoseconds>() << " ns"; + * JAMI_DBG() << "Task took " << t.getDuration<std::chrono::nanoseconds>() << " ns"; */ class Timer { @@ -201,7 +201,7 @@ public: ~VideoWriter() { fclose(f_); - RING_DBG("Play video file with: ffplay -f rawvideo -pixel_format %s -video_size %dx%d %s", + JAMI_DBG("Play video file with: ffplay -f rawvideo -pixel_format %s -video_size %dx%d %s", av_get_pix_fmt_name(format_), width_, height_, filename_.c_str()); } @@ -238,4 +238,4 @@ private: int width_, height_; }; -}} // namespace ring::debug +}} // namespace jami::debug diff --git a/src/dring/videomanager_interface.h b/src/dring/videomanager_interface.h index 96a014e0bd..5541cecb65 100644 --- a/src/dring/videomanager_interface.h +++ b/src/dring/videomanager_interface.h @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef DRING_VIDEOMANAGERI_H -#define DRING_VIDEOMANAGERI_H +#ifndef DENABLE_VIDEOMANAGERI_H +#define DENABLE_VIDEOMANAGERI_H #include "dring.h" @@ -43,7 +43,7 @@ struct AVPacket; #import "TargetConditionals.h" #endif -namespace ring { +namespace jami { struct AudioFormat; } @@ -99,13 +99,13 @@ protected: class DRING_PUBLIC AudioFrame : public MediaFrame { public: AudioFrame() : MediaFrame() {} - AudioFrame(const ring::AudioFormat& format, size_t nb_samples = 0); + AudioFrame(const jami::AudioFormat& format, size_t nb_samples = 0); ~AudioFrame() {}; void mix(const AudioFrame& o); float calcRMS() const; private: - void setFormat(const ring::AudioFormat& format); + void setFormat(const jami::AudioFormat& format); void reserve(size_t nb_samples = 0); }; @@ -246,4 +246,4 @@ struct DRING_PUBLIC VideoSignal { } // namespace DRing -#endif // DRING_VIDEOMANAGERI_H +#endif // DENABLE_VIDEOMANAGERI_H diff --git a/src/enumclass_utils.h b/src/enumclass_utils.h index 3660727f26..036481ded7 100644 --- a/src/enumclass_utils.h +++ b/src/enumclass_utils.h @@ -26,7 +26,7 @@ #include <vector> #include <cassert> -namespace ring { +namespace jami { /** * This function adds a safe way to get an enum class size @@ -186,7 +186,7 @@ template<class Row, typename Value, typename Accessor> Value Matrix1D<Row,Value,Accessor>::operator[](Row v) { //ASSERT(size_t(v) >= size_t(Row::COUNT__),"State Machine Out of Bounds\n"); if (size_t(v) >= enum_class_size<Row>() || static_cast<int>(v) < 0) { - RING_ERR("State Machine Out of Bounds %d\n", size_t(v)); + JAMI_ERR("State Machine Out of Bounds %d\n", size_t(v)); assert(false); throw v; } @@ -197,7 +197,7 @@ template<class Row, typename Value, typename Accessor> const Value Matrix1D<Row,Value,Accessor>::operator[](Row v) const { assert(size_t(v) <= enum_class_size<Row>()+1 && size_t(v)>=0); //COUNT__ is also valid if (size_t(v) >= enum_class_size<Row>()) { - RING_ERR("State Machine Out of Bounds %zu\n", size_t(v)); + JAMI_ERR("State Machine Out of Bounds %zu\n", size_t(v)); assert(false); throw v; } @@ -290,6 +290,6 @@ typename Matrix1D<Row,Value,Accessor>::EnumClassIter Matrix1D<Row,Value,Accessor return Matrix1D<Row,Value,Accessor>::EnumClassIter( this, enum_class_size<Row>() ); } -} // namespace ring +} // namespace jami #endif //ENUM_CLASS_UTILS_H diff --git a/src/fileutils.cpp b/src/fileutils.cpp index ffd2eceefc..bb1cfddbb8 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -84,7 +84,7 @@ #include <cstddef> #include <ciso646> -namespace ring { namespace fileutils { +namespace jami { namespace fileutils { // returns true if directory exists bool check_dir(const char *path, @@ -100,7 +100,7 @@ bool check_dir(const char *path, } #ifndef _WIN32 if (chmod(path, dirmode) < 0) { - RING_ERR("fileutils::check_dir(): chmod() failed on '%s', %s", path, strerror(errno)); + JAMI_ERR("fileutils::check_dir(): chmod() failed on '%s', %s", path, strerror(errno)); return false; } #endif @@ -138,23 +138,23 @@ create_pidfile() char buf[100]; f.fd = open(f.name.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); if (f.fd == -1) { - RING_ERR("Could not open PID file %s", f.name.c_str()); + JAMI_ERR("Could not open PID file %s", f.name.c_str()); return f; } if (lockRegion(f.fd, F_WRLCK, SEEK_SET, 0, 0) == -1) { if (errno == EAGAIN or errno == EACCES) - RING_ERR("PID file '%s' is locked; probably " + JAMI_ERR("PID file '%s' is locked; probably " "'%s' is already running", f.name.c_str(), PACKAGE_NAME); else - RING_ERR("Unable to lock PID file '%s'", f.name.c_str()); + JAMI_ERR("Unable to lock PID file '%s'", f.name.c_str()); close(f.fd); f.fd = -1; return f; } if (ftruncate(f.fd, 0) == -1) { - RING_ERR("Could not truncate PID file '%s'", f.name.c_str()); + JAMI_ERR("Could not truncate PID file '%s'", f.name.c_str()); close(f.fd); f.fd = -1; return f; @@ -164,7 +164,7 @@ create_pidfile() const int buf_strlen = strlen(buf); if (write(f.fd, buf, buf_strlen) != buf_strlen) { - RING_ERR("Problem writing to PID file '%s'", f.name.c_str()); + JAMI_ERR("Problem writing to PID file '%s'", f.name.c_str()); close(f.fd); f.fd = -1; return f; @@ -178,7 +178,7 @@ std::string expand_path(const std::string &path) { #if defined __ANDROID__ || defined _MSC_VER || defined WIN32 || defined __APPLE__ - RING_ERR("Path expansion not implemented, returning original"); + JAMI_ERR("Path expansion not implemented, returning original"); return path; #else @@ -189,20 +189,20 @@ expand_path(const std::string &path) switch (ret) { case WRDE_BADCHAR: - RING_ERR("Illegal occurrence of newline or one of |, &, ;, <, >, " + JAMI_ERR("Illegal occurrence of newline or one of |, &, ;, <, >, " "(, ), {, }."); return result; case WRDE_BADVAL: - RING_ERR("An undefined shell variable was referenced"); + JAMI_ERR("An undefined shell variable was referenced"); return result; case WRDE_CMDSUB: - RING_ERR("Command substitution occurred"); + JAMI_ERR("Command substitution occurred"); return result; case WRDE_SYNTAX: - RING_ERR("Shell syntax error"); + JAMI_ERR("Shell syntax error"); return result; case WRDE_NOSPACE: - RING_ERR("Out of memory."); + JAMI_ERR("Out of memory."); // This is the only error where we must call wordfree break; default: @@ -255,7 +255,7 @@ bool isSymLink(const std::string& path) if (lstat(path.c_str(), &s) == 0) return S_ISLNK(s.st_mode); #elif !defined(_MSC_VER) - DWORD attr = GetFileAttributes(ring::to_wstring(path).c_str()); + DWORD attr = GetFileAttributes(jami::to_wstring(path).c_str()); if (attr & FILE_ATTRIBUTE_REPARSE_POINT) return true; #endif @@ -280,11 +280,11 @@ writeTime(const std::string& path) ext_params.dwSecurityQosFlags = SECURITY_ANONYMOUS; ext_params.lpSecurityAttributes = nullptr; ext_params.hTemplateFile = nullptr; - HANDLE h = CreateFile2(ring::to_wstring(path).c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, &ext_params); + HANDLE h = CreateFile2(jami::to_wstring(path).c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, &ext_params); #elif _MSC_VER HANDLE h = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #else - HANDLE h = CreateFile(ring::to_wstring(path).c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE h = CreateFile(jami::to_wstring(path).c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if (h == INVALID_HANDLE_VALUE) throw std::runtime_error("Can't open: " + path); @@ -360,13 +360,13 @@ saveFile(const std::string& path, { std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { - RING_ERR("Could not write data to %s", path.c_str()); + JAMI_ERR("Could not write data to %s", path.c_str()); return; } file.write((char*)data.data(), data.size()); #ifndef _WIN32 if (chmod(path.c_str(), mode) < 0) - RING_WARN("fileutils::saveFile(): chmod() failed on '%s', %s", path.c_str(), strerror(errno)); + JAMI_WARN("fileutils::saveFile(): chmod() failed on '%s', %s", path.c_str(), strerror(errno)); #endif } @@ -424,7 +424,7 @@ readDirectory(const std::string& dir) std::vector<uint8_t> readArchive(const std::string& path, const std::string& pwd) { - RING_DBG("Reading archive from %s", path.c_str()); + JAMI_DBG("Reading archive from %s", path.c_str()); std::vector<uint8_t> data; if (pwd.empty()) { @@ -434,14 +434,14 @@ readArchive(const std::string& path, const std::string& pwd) try { data = loadFile(path); } catch (const std::exception& e) { - RING_ERR("Error loading archive: %s", e.what()); + JAMI_ERR("Error loading archive: %s", e.what()); throw; } // Decrypt try { data = archiver::decompress(dht::crypto::aesDecrypt(data, pwd)); } catch (const std::exception& e) { - RING_ERR("Error decrypting archive: %s", e.what()); + JAMI_ERR("Error decrypting archive: %s", e.what()); throw; } } @@ -451,7 +451,7 @@ readArchive(const std::string& path, const std::string& pwd) void writeArchive(const std::string& archive_str, const std::string& path, const std::string& password) { - RING_DBG("Writing archive to %s", path.c_str()); + JAMI_DBG("Writing archive to %s", path.c_str()); if (not password.empty()) { // Encrypt using provided password @@ -460,11 +460,11 @@ writeArchive(const std::string& archive_str, const std::string& path, const std: try { saveFile(path, data); } catch (const std::runtime_error& ex) { - RING_ERR("Export failed: %s", ex.what()); + JAMI_ERR("Export failed: %s", ex.what()); return; } } else { - RING_WARN("Unsecured archiving (no password)"); + JAMI_WARN("Unsecured archiving (no password)"); archiver::compressGzip(archive_str, path); } } @@ -479,7 +479,7 @@ FileHandle::~FileHandle() if (fd != -1) { close(fd); if (unlink(name.c_str()) == -1) - RING_ERR("%s", strerror(errno)); + JAMI_ERR("%s", strerror(errno)); } } @@ -511,7 +511,7 @@ get_cache_dir(const char* pkg) if (fileutils::recursive_mkdir(cache_path.data(), 0700) != true) { // If directory creation failed if (errno != EEXIST) - RING_DBG("Cannot create directory: %s!", cache_path.c_str()); + JAMI_DBG("Cannot create directory: %s!", cache_path.c_str()); } return cache_path; #else @@ -612,7 +612,7 @@ get_data_dir(const char* pkg) if (fileutils::recursive_mkdir(files_path.data(), 0700) != true) { // If directory creation failed if (errno != EEXIST) - RING_DBG("Cannot create directory: %s!", files_path.c_str()); + JAMI_DBG("Cannot create directory: %s!", files_path.c_str()); } return files_path; #else @@ -651,7 +651,7 @@ get_config_dir(const char* pkg) if (fileutils::recursive_mkdir(config_path.data(), 0700) != true) { // If directory creation failed if (errno != EEXIST) - RING_DBG("Cannot create directory: %s!", config_path.c_str()); + JAMI_DBG("Cannot create directory: %s!", config_path.c_str()); } return config_path; #else @@ -670,7 +670,7 @@ get_config_dir(const char* pkg) if (fileutils::recursive_mkdir(configdir.data(), 0700) != true) { // If directory creation failed if (errno != EEXIST) - RING_DBG("Cannot create directory: %s!", configdir.c_str()); + JAMI_DBG("Cannot create directory: %s!", configdir.c_str()); } return configdir; #endif @@ -697,7 +697,7 @@ recursive_mkdir(const std::string& path, mode_t mode) #else if (mkdir(path.data()) != 0) { #endif - RING_ERR("Could not create directory."); + JAMI_ERR("Could not create directory."); return false; } } @@ -720,4 +720,4 @@ removeAll(const std::string& path) return remove(path); } -}} // namespace ring::fileutils +}} // namespace jami::fileutils diff --git a/src/fileutils.h b/src/fileutils.h index c54476cfdd..c1faccd301 100644 --- a/src/fileutils.h +++ b/src/fileutils.h @@ -53,7 +53,7 @@ #define DIR_SEPARATOR_CH '\\' // Directory separator string #endif -namespace ring { namespace fileutils { +namespace jami { namespace fileutils { std::string get_home_dir(); std::string get_config_dir(const char* pkg); @@ -134,6 +134,6 @@ namespace ring { namespace fileutils { */ int removeAll(const std::string& path); -}} // namespace ring::fileutils +}} // namespace jami::fileutils #endif // FILEUTILS_H_ diff --git a/src/ftp_server.cpp b/src/ftp_server.cpp index a360cc65d4..1de9f40f5e 100644 --- a/src/ftp_server.cpp +++ b/src/ftp_server.cpp @@ -31,7 +31,7 @@ #include <iterator> #include <cstdlib> // strtoull -namespace ring { +namespace jami { //============================================================================== @@ -55,7 +55,7 @@ void FtpServer::close() noexcept { closeCurrentFile(); - RING_WARN() << "[FTP] server closed"; + JAMI_WARN() << "[FTP] server closed"; } bool @@ -71,7 +71,7 @@ FtpServer::startNewFile() rx_ = 0; out_ = Manager::instance().dataTransfers->onIncomingFileRequest(info); // we block here until answer from client if (!out_) { - RING_DBG() << "[FTP] transfer aborted by client"; + JAMI_DBG() << "[FTP] transfer aborted by client"; closed_ = true; // send NOK msg at next read() } else { go_ = true; @@ -98,7 +98,7 @@ FtpServer::read(std::vector<uint8_t>& buffer) const if (rx_ < fileSize_) { buffer.resize(4); buffer[0] = 'N'; buffer[1] = 'G'; buffer[2] = 'O'; buffer[3] = '\n'; - RING_DBG() << "[FTP] sending NGO (cancel) order"; + JAMI_DBG() << "[FTP] sending NGO (cancel) order"; return true; } } @@ -107,7 +107,7 @@ FtpServer::read(std::vector<uint8_t>& buffer) const go_ = false; buffer.resize(3); buffer[0] = 'G'; buffer[1] = 'O'; buffer[2] = '\n'; - RING_DBG() << "[FTP] sending GO order"; + JAMI_DBG() << "[FTP] sending GO order"; } else { // Nothing to send. Avoid to have an useless buffer filled with 0. buffer.resize(0); @@ -207,7 +207,7 @@ FtpServer::parseLine(const std::string& line) void FtpServer::handleHeader(const std::string& key, const std::string& value) { - RING_DBG() << "[FTP] header: '" << key << "' = '"<< value << "'"; + JAMI_DBG() << "[FTP] header: '" << key << "' = '"<< value << "'"; if (key == "Content-Length") { fileSize_ = std::strtoull(&value[0], nullptr, 10); @@ -216,4 +216,4 @@ FtpServer::handleHeader(const std::string& key, const std::string& value) } } -} // namespace ring +} // namespace jami diff --git a/src/ftp_server.h b/src/ftp_server.h index 483807f1a5..1225f06067 100644 --- a/src/ftp_server.h +++ b/src/ftp_server.h @@ -27,7 +27,7 @@ #include <sstream> #include <memory> -namespace ring { +namespace jami { class FtpServer final : public Stream { @@ -64,4 +64,4 @@ private: FtpState state_ {FtpState::PARSE_HEADERS}; }; -} // namespace ring +} // namespace jami diff --git a/src/generic_io.h b/src/generic_io.h index 604df658be..eb4597b369 100644 --- a/src/generic_io.h +++ b/src/generic_io.h @@ -32,7 +32,7 @@ using ssize_t = SSIZE_T; #endif -namespace ring { +namespace jami { template <typename T> class GenericSocket @@ -121,4 +121,4 @@ protected: GenericSocket() = default; }; -} // namespace ring +} // namespace jami diff --git a/src/hooks/urlhook.cpp b/src/hooks/urlhook.cpp index 66ef370ffb..c27b0354cf 100644 --- a/src/hooks/urlhook.cpp +++ b/src/hooks/urlhook.cpp @@ -21,7 +21,7 @@ #include "urlhook.h" #include <cstdlib> -namespace ring { +namespace jami { int UrlHook::runAction(const std::string &command, const std::string &args) { @@ -41,4 +41,4 @@ int UrlHook::runAction(const std::string &command, const std::string &args) #endif } -} // namespace ring +} // namespace jami diff --git a/src/hooks/urlhook.h b/src/hooks/urlhook.h index 181d16ff13..6a0b6788d7 100644 --- a/src/hooks/urlhook.h +++ b/src/hooks/urlhook.h @@ -23,10 +23,10 @@ #include <string> -namespace ring { namespace UrlHook { +namespace jami { namespace UrlHook { int runAction(const std::string &command, const std::string &arg); -}} // namespace ring::UrlHook +}} // namespace jami::UrlHook #endif // URL_HOOK_H diff --git a/src/ice_socket.h b/src/ice_socket.h index 191f91a7f4..9ee350295d 100644 --- a/src/ice_socket.h +++ b/src/ice_socket.h @@ -29,7 +29,7 @@ using ssize_t = SSIZE_T; #endif -namespace ring { +namespace jami { class IceTransport; using IceRecvCb = std::function<ssize_t(unsigned char* buf, size_t len)>; diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index 6af97227c6..9077144fcd 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -47,7 +47,7 @@ throw std::runtime_error(#ret " failed"); \ } while (0) -namespace ring { +namespace jami { static constexpr unsigned STUN_MAX_PACKET_SIZE {8192}; static constexpr uint16_t IPV6_HEADER_SIZE = 40; ///< Size in bytes of IPV6 packet header @@ -185,7 +185,7 @@ add_stun_server(pj_ice_strans_cfg& cfg, int af) stun.cfg.max_pkt_size = STUN_MAX_PACKET_SIZE; stun.af = af; - RING_DBG("[ice] added host stun server"); + JAMI_DBG("[ice] added host stun server"); } static void @@ -199,7 +199,7 @@ add_stun_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const StunServerInfo& i // Given URI cannot be DNS resolved or not IPv4 or IPv6? // This prevents a crash into PJSIP when ip.toString() is called. if (ip.getFamily() == AF_UNSPEC) { - RING_WARN("[ice] STUN server '%s' not used, unresolvable address", info.uri.c_str()); + JAMI_WARN("[ice] STUN server '%s' not used, unresolvable address", info.uri.c_str()); return; } @@ -210,7 +210,7 @@ add_stun_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const StunServerInfo& i stun.port = PJ_STUN_PORT; stun.cfg.max_pkt_size = STUN_MAX_PACKET_SIZE; - RING_DBG("[ice] added stun server '%s', port %d", pj_strbuf(&stun.server), stun.port); + JAMI_DBG("[ice] added stun server '%s', port %d", pj_strbuf(&stun.server), stun.port); } static void @@ -223,7 +223,7 @@ add_turn_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const TurnServerInfo& i // Same comment as add_stun_server() if (ip.getFamily() == AF_UNSPEC) { - RING_WARN("[ice] TURN server '%s' not used, unresolvable address", info.uri.c_str()); + JAMI_WARN("[ice] TURN server '%s' not used, unresolvable address", info.uri.c_str()); return; } @@ -243,7 +243,7 @@ add_turn_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const TurnServerInfo& i pj_cstr(&turn.auth_cred.data.static_cred.data, info.password.c_str()); } - RING_DBG("[ice] added turn server '%s', port %d", pj_strbuf(&turn.server), turn.port); + JAMI_DBG("[ice] added turn server '%s', port %d", pj_strbuf(&turn.server), turn.port); } //============================================================================== @@ -279,7 +279,7 @@ IceTransport::Impl::Impl(const char* name, int component_count, bool master, if (auto* tr = static_cast<Impl*>(pj_ice_strans_get_user_data(ice_st))) tr->onReceiveData(comp_id, pkt, size); else - RING_WARN("null IceTransport"); + JAMI_WARN("null IceTransport"); }; icecb.on_ice_complete = \ @@ -287,7 +287,7 @@ IceTransport::Impl::Impl(const char* name, int component_count, bool master, if (auto* tr = static_cast<Impl*>(pj_ice_strans_get_user_data(ice_st))) tr->onComplete(ice_st, op, status); else - RING_WARN("null IceTransport"); + JAMI_WARN("null IceTransport"); }; // Add STUN servers @@ -407,7 +407,7 @@ IceTransport::Impl::handleEvents(unsigned max_msec) const auto err = pj_get_os_error(); // Kept as debug as some errors are "normal" in regular context last_errmsg_ = sip_utils::sip_strerror(err); - RING_DBG("[ice:%p] ioqueue error %d: %s", this, err, last_errmsg_.c_str()); + JAMI_DBG("[ice:%p] ioqueue error %d: %s", this, err, last_errmsg_.c_str()); std::this_thread::sleep_for(std::chrono::milliseconds(PJ_TIME_VAL_MSEC(timeout))); return; } @@ -426,11 +426,11 @@ IceTransport::Impl::onComplete(pj_ice_strans* ice_st, pj_ice_strans_op op, pj_st const bool done = status == PJ_SUCCESS; if (done) { - RING_DBG("[ice:%p] %s success", this, opname); + JAMI_DBG("[ice:%p] %s success", this, opname); } else { last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("[ice:%p] %s failed: %s", this, opname, last_errmsg_.c_str()); + JAMI_ERR("[ice:%p] %s failed: %s", this, opname, last_errmsg_.c_str()); } { @@ -466,7 +466,7 @@ IceTransport::Impl::onComplete(pj_ice_strans* ice_st, pj_ice_strans_op op, pj_st out << " [" << i << "] disabled\n"; } } - RING_DBG("[ice:%p] connection pairs (local <-> remote):\n%s", this, out.str().c_str()); + JAMI_DBG("[ice:%p] connection pairs (local <-> remote):\n%s", this, out.str().c_str()); } if (on_negodone_cb_) on_negodone_cb_(done); @@ -479,13 +479,13 @@ IceTransport::Impl::onComplete(pj_ice_strans* ice_st, pj_ice_strans_op op, pj_st bool IceTransport::Impl::setInitiatorSession() { - RING_DBG("ICE as master"); + JAMI_DBG("ICE as master"); initiatorSession_ = true; if (_isInitialized()) { auto status = pj_ice_strans_change_role(icest_.get(), PJ_ICE_SESS_ROLE_CONTROLLING); if (status != PJ_SUCCESS) { last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("[ice:%p] role change failed: %s", this, last_errmsg_.c_str()); + JAMI_ERR("[ice:%p] role change failed: %s", this, last_errmsg_.c_str()); return false; } return true; @@ -496,13 +496,13 @@ IceTransport::Impl::setInitiatorSession() bool IceTransport::Impl::setSlaveSession() { - RING_DBG("ICE as slave"); + JAMI_DBG("ICE as slave"); initiatorSession_ = false; if (_isInitialized()) { auto status = pj_ice_strans_change_role(icest_.get(), PJ_ICE_SESS_ROLE_CONTROLLED); if (status != PJ_SUCCESS) { last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("[ice:%p] role change failed: %s", this, last_errmsg_.c_str()); + JAMI_ERR("[ice:%p] role change failed: %s", this, last_errmsg_.c_str()); return false; } return true; @@ -520,13 +520,13 @@ IceTransport::Impl::getLocalAddress(unsigned comp_id) const else return {}; // disabled component } else - RING_WARN("[ice:%p] bad call: non-negotiated transport", this); + JAMI_WARN("[ice:%p] bad call: non-negotiated transport", this); // Return the default IP (could be not nominated and valid after negotiation) if (_isInitialized()) return cand_[comp_id].addr; - RING_ERR("[ice:%p] bad call: non-initialized transport", this); + JAMI_ERR("[ice:%p] bad call: non-initialized transport", this); return {}; } @@ -540,9 +540,9 @@ IceTransport::Impl::getRemoteAddress(unsigned comp_id) const else return {}; // disabled component } else - RING_WARN("[ice:%p] bad call: non-negotiated transport", this); + JAMI_WARN("[ice:%p] bad call: non-negotiated transport", this); - RING_ERR("[ice:%p] bad call: non-negotiated transport", this); + JAMI_ERR("[ice:%p] bad call: non-negotiated transport", this); return {}; } @@ -566,14 +566,14 @@ bool IceTransport::Impl::createIceSession(pj_ice_sess_role role) { if (pj_ice_strans_init_ice(icest_.get(), role, nullptr, nullptr) != PJ_SUCCESS) { - RING_ERR("[ice:%p] pj_ice_strans_init_ice() failed", this); + JAMI_ERR("[ice:%p] pj_ice_strans_init_ice() failed", this); return false; } // Fetch some information on local configuration getUFragPwd(); getDefaultCanditates(); - RING_DBG("[ice:%p] (local) ufrag=%s, pwd=%s", this, local_ufrag_.c_str(), local_pwd_.c_str()); + JAMI_DBG("[ice:%p] (local) ufrag=%s, pwd=%s", this, local_ufrag_.c_str(), local_pwd_.c_str()); return true; } @@ -585,7 +585,7 @@ IceTransport::Impl::getLocalCandidatesAddr(unsigned comp_id) const unsigned cand_cnt = PJ_ARRAY_SIZE(cand); if (pj_ice_strans_enum_cands(icest_.get(), comp_id, &cand_cnt, cand) != PJ_SUCCESS) { - RING_ERR("[ice:%p] pj_ice_strans_enum_cands() failed", this); + JAMI_ERR("[ice:%p] pj_ice_strans_enum_cands() failed", this); return cand_addrs; } @@ -623,7 +623,7 @@ IceTransport::Impl::addReflectiveCandidate(int comp_id, const IpAddr& base, cons int idx = -1; auto af = addr.getFamily(); if (af == AF_UNSPEC) { - RING_ERR("[ice:%p] Unable to add reflective IP %s: unknown addess familly", this, + JAMI_ERR("[ice:%p] Unable to add reflective IP %s: unknown addess familly", this, addr.toString().c_str()); return; } @@ -635,7 +635,7 @@ IceTransport::Impl::addReflectiveCandidate(int comp_id, const IpAddr& base, cons } } if (idx < 0) { - RING_ERR("[ice:%p] Unable to add reflective IP %s: no suitable local STUN host found", this, + JAMI_ERR("[ice:%p] Unable to add reflective IP %s: no suitable local STUN host found", this, addr.toString().c_str()); return; } @@ -669,12 +669,12 @@ IceTransport::Impl::addReflectiveCandidate(int comp_id, const IpAddr& base, cons if (ret != PJ_SUCCESS) { last_errmsg_ = sip_utils::sip_strerror(ret); - RING_ERR("[ice:%p] pj_ice_sess_add_cand failed with error %d: %s", this, ret, + JAMI_ERR("[ice:%p] pj_ice_sess_add_cand failed with error %d: %s", this, ret, last_errmsg_.c_str()); - RING_ERR("[ice:%p] failed to add candidate for comp_id=%d : %s : %s", this, comp_id, + JAMI_ERR("[ice:%p] failed to add candidate for comp_id=%d : %s : %s", this, comp_id, base.toString().c_str(), addr.toString().c_str()); } else { - RING_DBG("[ice:%p] succeed to add candidate for comp_id=%d : %s : %s", this, comp_id, + JAMI_DBG("[ice:%p] succeed to add candidate for comp_id=%d : %s : %s", this, comp_id, base.toString().c_str(), addr.toString().c_str()); } } @@ -691,7 +691,7 @@ IceTransport::Impl::selectUPnPIceCandidates() if (auto publicIP = upnp_->getExternalIP()) { /* comp_id start at 1 */ for (unsigned comp_id = 1; comp_id <= component_count_; ++comp_id) { - RING_DBG("[ice:%p] UPnP: Opening port(s) for ICE comp %d and adding candidate with public IP", + JAMI_DBG("[ice:%p] UPnP: Opening port(s) for ICE comp %d and adding candidate with public IP", this, comp_id); auto candidates = getLocalCandidatesAddr(comp_id); for (IpAddr addr : candidates) { @@ -705,11 +705,11 @@ IceTransport::Impl::selectUPnPIceCandidates() publicIP.setPort(port_used); addReflectiveCandidate(comp_id, addr, publicIP); } else - RING_WARN("[ice:%p] UPnP: Could not create a port mapping for the ICE candide", this); + JAMI_WARN("[ice:%p] UPnP: Could not create a port mapping for the ICE candide", this); } } } else { - RING_WARN("[ice:%p] UPnP: Could not determine public IP for ICE candidates", this); + JAMI_WARN("[ice:%p] UPnP: Could not determine public IP for ICE candidates", this); } } } @@ -718,7 +718,7 @@ void IceTransport::Impl::onReceiveData(unsigned comp_id, void *pkt, pj_size_t size) { if (!comp_id or comp_id > component_count_) { - RING_ERR("rx: invalid comp_id (%u)", comp_id); + JAMI_ERR("rx: invalid comp_id (%u)", comp_id); return; } if (!size) @@ -792,18 +792,18 @@ bool IceTransport::start(const Attribute& rem_attrs, const std::vector<IceCandidate>& rem_candidates) { if (not isInitialized()) { - RING_ERR("[ice:%p] not initialized transport", this); + JAMI_ERR("[ice:%p] not initialized transport", this); return false; } // pj_ice_strans_start_ice crashes if remote candidates array is empty if (rem_candidates.empty()) { - RING_ERR("[ice:%p] start failed: no remote candidates", this); + JAMI_ERR("[ice:%p] start failed: no remote candidates", this); return false; } pj_str_t ufrag, pwd; - RING_DBG("[ice:%p] negotiation starting (%zu remote candidates)", this, rem_candidates.size()); + JAMI_DBG("[ice:%p] negotiation starting (%zu remote candidates)", this, rem_candidates.size()); auto status = pj_ice_strans_start_ice(pimpl_->icest_.get(), pj_cstr(&ufrag, rem_attrs.ufrag.c_str()), pj_cstr(&pwd, rem_attrs.pwd.c_str()), @@ -811,7 +811,7 @@ IceTransport::start(const Attribute& rem_attrs, const std::vector<IceCandidate>& rem_candidates.data()); if (status != PJ_SUCCESS) { pimpl_->last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("[ice:%p] start failed: %s", this, pimpl_->last_errmsg_.c_str()); + JAMI_ERR("[ice:%p] start failed: %s", this, pimpl_->last_errmsg_.c_str()); return false; } return true; @@ -831,7 +831,7 @@ IceTransport::start(const std::vector<uint8_t>& rem_data) std::size_t offset = 0; auto result = msgpack::unpack(data, size, offset); auto version = result.get().as<uint8_t>(); - RING_DBG("[ice:%p] rx msg v%u", this, version); + JAMI_DBG("[ice:%p] rx msg v%u", this, version); if (version == 1) { result = msgpack::unpack(data, size, offset); std::tie(rem_ufrag, rem_pwd) = result.get().as<std::pair<std::string, std::string>>(); @@ -846,21 +846,21 @@ IceTransport::start(const std::vector<uint8_t>& rem_data) } } } else { - RING_ERR("[ice:%p] invalid msg version", this); + JAMI_ERR("[ice:%p] invalid msg version", this); return false; } } catch (const msgpack::unpack_error& e) { - RING_ERR("[ice:%p] remote msg unpack error: %s", this, e.what()); + JAMI_ERR("[ice:%p] remote msg unpack error: %s", this, e.what()); return false; } if (rem_ufrag.empty() or rem_pwd.empty() or rem_candidates.empty()) { - RING_ERR("[ice:%p] invalid remote attributes", this); + JAMI_ERR("[ice:%p] invalid remote attributes", this); return false; } if (pimpl_->onlyIPv4Private_) - RING_WARN("[ice:%p] no public IPv4 found, your connection may fail!", this); + JAMI_WARN("[ice:%p] no public IPv4 found, your connection may fail!", this); return start({rem_ufrag, rem_pwd}, rem_candidates); } @@ -872,7 +872,7 @@ IceTransport::stop() auto status = pj_ice_strans_stop_ice(pimpl_->icest_.get()); if (status != PJ_SUCCESS) { pimpl_->last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("ICE stop failed: %s", pimpl_->last_errmsg_.c_str()); + JAMI_ERR("ICE stop failed: %s", pimpl_->last_errmsg_.c_str()); return false; } } @@ -905,7 +905,7 @@ IceTransport::getLocalCandidates(unsigned comp_id) const unsigned cand_cnt = PJ_ARRAY_SIZE(cand); if (pj_ice_strans_enum_cands(pimpl_->icest_.get(), comp_id+1, &cand_cnt, cand) != PJ_SUCCESS) { - RING_ERR("[ice:%p] pj_ice_strans_enum_cands() failed", this); + JAMI_ERR("[ice:%p] pj_ice_strans_enum_cands() failed", this); return res; } @@ -929,7 +929,7 @@ bool IceTransport::registerPublicIP(unsigned compId, const IpAddr& publicIP) { if (not isInitialized()) { - RING_ERR("[ice:%p] registerPublicIP() called on non initialized transport", this); + JAMI_ERR("[ice:%p] registerPublicIP() called on non initialized transport", this); return false; } @@ -988,7 +988,7 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand) type); if (cnt != 7) { - RING_WARN("[ice:%p] invalid remote candidate line", this); + JAMI_WARN("[ice:%p] invalid remote candidate line", this); return false; } @@ -1003,7 +1003,7 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand) else if (strcmp(type, "relay")==0) cand.type = PJ_ICE_CAND_TYPE_RELAYED; else { - RING_WARN("[ice:%p] invalid remote candidate type '%s'", this, type); + JAMI_WARN("[ice:%p] invalid remote candidate type '%s'", this, type); return false; } @@ -1021,7 +1021,7 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand) pj_sockaddr_init(af, &cand.addr, NULL, 0); auto status = pj_sockaddr_set_str_addr(af, &cand.addr, &tmpaddr); if (status != PJ_SUCCESS) { - RING_ERR("[ice:%p] invalid remote IP address '%s'", this, ipaddr); + JAMI_ERR("[ice:%p] invalid remote IP address '%s'", this, ipaddr); return false; } @@ -1070,7 +1070,7 @@ IceTransport::send(int comp_id, const unsigned char* buf, size_t len) sip_utils::register_thread(); auto remote = getRemoteAddress(comp_id); if (!remote) { - RING_ERR("[ice:%p] can't find remote address for component %d", this, comp_id); + JAMI_ERR("[ice:%p] can't find remote address for component %d", this, comp_id); errno = EINVAL; return -1; } @@ -1080,7 +1080,7 @@ IceTransport::send(int comp_id, const unsigned char* buf, size_t len) errno = EAGAIN; } else { pimpl_->last_errmsg_ = sip_utils::sip_strerror(status); - RING_ERR("[ice:%p] ice send failed: %s", this, pimpl_->last_errmsg_.c_str()); + JAMI_ERR("[ice:%p] ice send failed: %s", this, pimpl_->last_errmsg_.c_str()); errno = EIO; } return -1; @@ -1095,7 +1095,7 @@ IceTransport::waitForInitialization(unsigned timeout) std::unique_lock<std::mutex> lk(pimpl_->iceMutex_); if (!pimpl_->iceCV_.wait_for(lk, std::chrono::seconds(timeout), [this]{ return pimpl_->_isInitialized() or pimpl_->_isFailed(); })) { - RING_WARN("[ice:%p] waitForInitialization: timeout", this); + JAMI_WARN("[ice:%p] waitForInitialization: timeout", this); return -1; } return not pimpl_->_isFailed(); @@ -1107,7 +1107,7 @@ IceTransport::waitForNegotiation(unsigned timeout) std::unique_lock<std::mutex> lk(pimpl_->iceMutex_); if (!pimpl_->iceCV_.wait_for(lk, std::chrono::seconds(timeout), [this]{ return pimpl_->_isRunning() or pimpl_->_isFailed(); })) { - RING_WARN("[ice:%p] waitForIceNegotiation: timeout", this); + JAMI_WARN("[ice:%p] waitForIceNegotiation: timeout", this); return -1; } return not pimpl_->_isFailed(); @@ -1172,7 +1172,7 @@ IceTransportFactory::createTransport(const char* name, int component_count, try { return std::make_shared<IceTransport>(name, component_count, master, options); } catch(const std::exception& e) { - RING_ERR("%s",e.what()); + JAMI_ERR("%s",e.what()); return nullptr; } } @@ -1288,4 +1288,4 @@ IceSocket::getTransportOverhead(){ return (ice_transport_->getRemoteAddress(compId_).getFamily() == AF_INET) ? IPV4_HEADER_SIZE : IPV6_HEADER_SIZE; } -} // namespace ring +} // namespace jami diff --git a/src/ice_transport.h b/src/ice_transport.h index f1e2bc7091..930fe1cd8a 100644 --- a/src/ice_transport.h +++ b/src/ice_transport.h @@ -31,7 +31,7 @@ #include <memory> #include <vector> -namespace ring { +namespace jami { namespace upnp { class Controller; diff --git a/src/im/instant_messaging.cpp b/src/im/instant_messaging.cpp index bf43c130ce..de8d3a29e5 100644 --- a/src/im/instant_messaging.cpp +++ b/src/im/instant_messaging.cpp @@ -28,7 +28,7 @@ #include <pjsip_ua.h> #include <pjsip.h> -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -67,7 +67,7 @@ createMessageBody(pj_pool_t* pool, const std::pair<std::string, std::string>& pa // split mime type to type and subtype sep = mimeType.find('/'); if (std::string::npos == sep) { - RING_DBG("bad mime type: '%.30s'", mimeType.c_str()); + JAMI_DBG("bad mime type: '%.30s'", mimeType.c_str()); throw im::InstantMessageException("invalid mime type"); } @@ -93,7 +93,7 @@ createMessageBody(pj_pool_t* pool, const std::pair<std::string, std::string>& pa // split paramPair into arg and value by '=' auto paramSplit = paramPair.find('='); if (std::string::npos == paramSplit) { - RING_DBG("bad parameter: '%.30s'", paramPair.c_str()); + JAMI_DBG("bad parameter: '%.30s'", paramPair.c_str()); throw im::InstantMessageException("invalid parameter"); } @@ -138,7 +138,7 @@ im::fillPJSIPMessageBody(pjsip_tx_data& tdata, for (const auto& pair: payloads) { auto part = pjsip_multipart_create_part(tdata.pool); if (not part) { - RING_ERR("pjsip_multipart_create_part failed: not enough memory"); + JAMI_ERR("pjsip_multipart_create_part failed: not enough memory"); throw InstantMessageException("Internal SIP error"); } @@ -146,7 +146,7 @@ im::fillPJSIPMessageBody(pjsip_tx_data& tdata, auto status = pjsip_multipart_add_part(tdata.pool, tdata.msg->body, part); if (status != PJ_SUCCESS) { - RING_ERR("pjsip_multipart_add_part failed: %s", + JAMI_ERR("pjsip_multipart_add_part failed: %s", sip_utils::sip_strerror(status).c_str()); throw InstantMessageException("Internal SIP error"); } @@ -158,7 +158,7 @@ im::sendSipMessage(pjsip_inv_session* session, const std::map<std::string, std::string>& payloads) { if (payloads.empty()) { - RING_WARN("the payloads argument is empty; ignoring message"); + JAMI_WARN("the payloads argument is empty; ignoring message"); return; } @@ -171,7 +171,7 @@ im::sendSipMessage(pjsip_inv_session* session, pjsip_tx_data* tdata = nullptr; auto status = pjsip_dlg_create_request(dialog, &msg_method, -1, &tdata); if (status != PJ_SUCCESS) { - RING_ERR("pjsip_dlg_create_request failed: %s", + JAMI_ERR("pjsip_dlg_create_request failed: %s", sip_utils::sip_strerror(status).c_str()); throw InstantMessageException("Internal SIP error"); } @@ -180,7 +180,7 @@ im::sendSipMessage(pjsip_inv_session* session, status = pjsip_dlg_send_request(dialog, tdata, -1, nullptr); if (status != PJ_SUCCESS) { - RING_ERR("pjsip_dlg_send_request failed: %s", + JAMI_ERR("pjsip_dlg_send_request failed: %s", sip_utils::sip_strerror(status).c_str()); throw InstantMessageException("Internal SIP error"); } @@ -233,7 +233,7 @@ im::parseSipMessage(const pjsip_msg* msg) std::map<std::string, std::string> ret; if (!msg->body) { - RING_WARN("message body is empty"); + JAMI_WARN("message body is empty"); return ret; } @@ -257,4 +257,4 @@ im::parseSipMessage(const pjsip_msg* msg) return ret; } -} // namespace ring +} // namespace jami diff --git a/src/im/instant_messaging.h b/src/im/instant_messaging.h index ba5a507be5..e8db77aa33 100644 --- a/src/im/instant_messaging.h +++ b/src/im/instant_messaging.h @@ -35,7 +35,7 @@ struct pjsip_rx_data; struct pjsip_msg; struct pjsip_tx_data; -namespace ring { namespace im { +namespace jami { namespace im { struct InstantMessageException : std::runtime_error { @@ -75,4 +75,4 @@ std::map<std::string, std::string> parseSipMessage(const pjsip_msg* msg); void fillPJSIPMessageBody(pjsip_tx_data& tdata, const std::map<std::string, std::string>& payloads); -}} // namespace ring::im +}} // namespace jami::im diff --git a/src/im/message_engine.cpp b/src/im/message_engine.cpp index a3661f754d..c0cfea9af6 100644 --- a/src/im/message_engine.cpp +++ b/src/im/message_engine.cpp @@ -30,7 +30,7 @@ #include <fstream> -namespace ring { +namespace jami { namespace im { static std::uniform_int_distribution<MessageToken> udist {1}; @@ -94,7 +94,7 @@ MessageEngine::retrySend(const std::string& peer) } // avoid locking while calling callback for (const auto& p : pending) { - RING_DBG() << "[message " << p.token << "] Retry sending"; + JAMI_DBG() << "[message " << p.token << "] Retry sending"; emitSignal<DRing::ConfigurationSignal::AccountMessageStatusChanged>( account_.getAccountID(), p.token, @@ -138,11 +138,11 @@ MessageEngine::cancel(MessageToken t) void MessageEngine::onMessageSent(const std::string& peer, MessageToken token, bool ok) { - RING_DBG() << "[message " << token << "] Message sent: " << (ok ? "success" : "failure"); + JAMI_DBG() << "[message " << token << "] Message sent: " << (ok ? "success" : "failure"); std::lock_guard<std::mutex> lock(messagesMutex_); auto p = messages_.find(peer); if (p == messages_.end()) { - RING_DBG() << "[message " << token << "] Can't find peer"; + JAMI_DBG() << "[message " << token << "] Can't find peer"; return; } auto f = p->second.find(token); @@ -150,7 +150,7 @@ MessageEngine::onMessageSent(const std::string& peer, MessageToken token, bool o if (f->second.status == MessageStatus::SENDING) { if (ok) { f->second.status = MessageStatus::SENT; - RING_DBG() << "[message " << token << "] Status changed to SENT"; + JAMI_DBG() << "[message " << token << "] Status changed to SENT"; emitSignal<DRing::ConfigurationSignal::AccountMessageStatusChanged>(account_.getAccountID(), token, f->second.to, @@ -158,7 +158,7 @@ MessageEngine::onMessageSent(const std::string& peer, MessageToken token, bool o save_(); } else if (f->second.retried >= MAX_RETRIES) { f->second.status = MessageStatus::FAILURE; - RING_DBG() << "[message " << token << "] Status changed to FAILURE"; + JAMI_DBG() << "[message " << token << "] Status changed to FAILURE"; emitSignal<DRing::ConfigurationSignal::AccountMessageStatusChanged>(account_.getAccountID(), token, f->second.to, @@ -166,13 +166,13 @@ MessageEngine::onMessageSent(const std::string& peer, MessageToken token, bool o save_(); } else { f->second.status = MessageStatus::IDLE; - RING_DBG() << "[message " << token << "] Status changed to IDLE"; + JAMI_DBG() << "[message " << token << "] Status changed to IDLE"; } } else { - RING_DBG() << "[message " << token << "] State is not SENDING"; + JAMI_DBG() << "[message " << token << "] State is not SENDING"; } } else { - RING_DBG() << "[message " << token << "] Can't find message"; + JAMI_DBG() << "[message " << token << "] Can't find message"; } } @@ -212,9 +212,9 @@ MessageEngine::load() loaded++; } } - RING_DBG("[Account %s] loaded %lu messages from %s", account_.getAccountID().c_str(), loaded, savePath_.c_str()); + JAMI_DBG("[Account %s] loaded %lu messages from %s", account_.getAccountID().c_str(), loaded, savePath_.c_str()); } catch (const std::exception& e) { - RING_ERR("[Account %s] couldn't load messages from %s: %s", account_.getAccountID().c_str(), savePath_.c_str(), e.what()); + JAMI_ERR("[Account %s] couldn't load messages from %s: %s", account_.getAccountID().c_str(), savePath_.c_str(), e.what()); } } @@ -268,12 +268,12 @@ MessageEngine::save_() const file.open(path, std::ios::trunc); writer->write(root, &file); } catch (const std::exception& e) { - RING_ERR("[Account %s] Couldn't save messages to %s: %s", accountID.c_str(), path.c_str(), e.what()); + JAMI_ERR("[Account %s] Couldn't save messages to %s: %s", accountID.c_str(), path.c_str(), e.what()); } - RING_DBG("[Account %s] saved %zu messages to %s", accountID.c_str(), messageNum, path.c_str()); + JAMI_DBG("[Account %s] saved %zu messages to %s", accountID.c_str(), messageNum, path.c_str()); }); } catch (const std::exception& e) { - RING_ERR("[Account %s] couldn't save messages to %s: %s", account_.getAccountID().c_str(), savePath_.c_str(), e.what()); + JAMI_ERR("[Account %s] couldn't save messages to %s: %s", account_.getAccountID().c_str(), savePath_.c_str(), e.what()); } } diff --git a/src/im/message_engine.h b/src/im/message_engine.h index c68bf0eb27..42d6499f2d 100644 --- a/src/im/message_engine.h +++ b/src/im/message_engine.h @@ -26,7 +26,7 @@ #include <mutex> #include <cstdint> -namespace ring { +namespace jami { class SIPAccountBase; @@ -99,4 +99,4 @@ private: mutable std::mutex messagesMutex_ {}; }; -}} // namespace ring::im +}} // namespace jami::im diff --git a/src/ip_utils.cpp b/src/ip_utils.cpp index 4fb66f7614..eea56e5fef 100644 --- a/src/ip_utils.cpp +++ b/src/ip_utils.cpp @@ -48,7 +48,7 @@ WINSOCK_API_LINKAGE INT WSAAPI InetPtonA(INT Family, LPCSTR pStringBuf, PVOID pA #endif #endif -namespace ring { +namespace jami { std::string ip_utils::getHostname() @@ -90,7 +90,7 @@ ip_utils::getAddrList(const std::string &name, pj_uint16_t family) pj_cstr(&pjname, name.c_str()); auto status = pj_getaddrinfo(family, &pjname, &addr_num, res); if (status != PJ_SUCCESS) { - RING_ERR("Error resolving %s : %s", name.c_str(), + JAMI_ERR("Error resolving %s : %s", name.c_str(), sip_utils::sip_strerror(status).c_str()); return ipList; } @@ -149,12 +149,12 @@ ip_utils::getLocalAddr(pj_uint16_t family) return ip_addr; } #if HAVE_IPV6 - RING_WARN("Could not get preferred address familly (%s)", (family == pj_AF_INET6()) ? "IPv6" : "IPv4"); + JAMI_WARN("Could not get preferred address familly (%s)", (family == pj_AF_INET6()) ? "IPv6" : "IPv4"); family = (family == pj_AF_INET()) ? pj_AF_INET6() : pj_AF_INET(); status = pj_gethostip(family, ip_addr.pjPtr()); if (status == PJ_SUCCESS) return ip_addr; #endif - RING_ERR("Could not get local IP"); + JAMI_ERR("Could not get local IP"); return ip_addr; } @@ -171,14 +171,14 @@ ip_utils::getInterfaceAddr(const std::string &interface, pj_uint16_t family) int fd = socket(unix_family, SOCK_DGRAM, 0); if (fd < 0) { - RING_ERR("Could not open socket: %m"); + JAMI_ERR("Could not open socket: %m"); return addr; } if (unix_family == AF_INET6) { int val = family != pj_AF_UNSPEC(); if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &val, sizeof(val)) < 0) { - RING_ERR("Could not setsockopt: %m"); + JAMI_ERR("Could not setsockopt: %m"); close(fd); return addr; } @@ -208,7 +208,7 @@ ip_utils::getInterfaceAddr(const std::string &interface, pj_uint16_t family) DWORD dwRetval = getaddrinfo(interface.c_str(), "0", &hints, &result); if (dwRetval != 0) { - RING_ERR("getaddrinfo failed with error: %lu", dwRetval); + JAMI_ERR("getaddrinfo failed with error: %lu", dwRetval); return addr; } @@ -254,7 +254,7 @@ ip_utils::getAllIpInterfaceByName() } #else - RING_ERR("Not implemented yet. (iphlpapi.h problem)"); + JAMI_ERR("Not implemented yet. (iphlpapi.h problem)"); #endif return ifaceList; } @@ -378,4 +378,4 @@ IpAddr::isPrivate() const } } -} // namespace ring +} // namespace jami diff --git a/src/ip_utils.h b/src/ip_utils.h index 2abcfe0410..ef5c5353b1 100644 --- a/src/ip_utils.h +++ b/src/ip_utils.h @@ -64,7 +64,7 @@ extern "C" { #define IN_IS_ADDR_UNSPECIFIED(a) (((long int) (a)->s_addr) == 0x00000000) #endif /* IN_IS_ADDR_UNSPECIFIED */ -namespace ring { +namespace jami { /** * Binary representation of an IP address. @@ -322,4 +322,4 @@ bool haveCommonAddr(const std::vector<IpAddr>& a, const std::vector<IpAddr>& b); std::vector<IpAddr> getLocalNameservers(); } // namespace ip_utils -} // namespace ring +} // namespace jami diff --git a/src/logger.cpp b/src/logger.cpp index 36ec1eb7fd..08317d260e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -181,7 +181,7 @@ void strErr(void) { #ifdef __GLIBC__ - RING_ERR("%m"); + JAMI_ERR("%m"); #else char buf[1000]; const char* errstr; @@ -200,11 +200,11 @@ strErr(void) break; } - RING_ERR("%s", errstr); + JAMI_ERR("%s", errstr); #endif } -namespace ring { +namespace jami { void Logger::log(int level, const char* file, int line, bool linefeed, const char* const format, ...) @@ -268,7 +268,7 @@ Logger::vlog(const int level, const char* file, int line, bool linefeed, #ifdef _MSC_VER std::array<char, 4096> tmp; vsnprintf(tmp.data(), tmp.size(), format, ap); - ring::emitSignal<DRing::DebugSignal::MessageSend>(contextHeader(file, line) + tmp.data()); + jami::emitSignal<DRing::DebugSignal::MessageSend>(contextHeader(file, line) + tmp.data()); #endif #ifndef _WIN32 fputs(END_COLOR, stderr); @@ -292,4 +292,4 @@ Logger::vlog(const int level, const char* file, int line, bool linefeed, } } -} // namespace ring; +} // namespace jami; diff --git a/src/logger.h b/src/logger.h index 50eadd7568..549d98247c 100644 --- a/src/logger.h +++ b/src/logger.h @@ -87,7 +87,7 @@ void strErr(); #define PRINTF_ATTRIBUTE(a, b) #endif -namespace ring { +namespace jami { /// /// Level-driven logging class that support printf and C++ stream logging fashions. @@ -118,7 +118,7 @@ public: /// /// Printf fashion logging. /// - /// Example: RING_DBG("%s", "Hello, World!") + /// Example: JAMI_DBG("%s", "Hello, World!") /// static void log(int level, const char* file, int line, bool linefeed, const char* const fmt, ...) PRINTF_ATTRIBUTE(5, 6); @@ -132,7 +132,7 @@ public: /// /// Stream fashion logging. /// - /// Example: RING_DBG() << "Hello, World!" + /// Example: JAMI_DBG() << "Hello, World!" /// static Logger log(int level, const char* file, int line, bool linefeed) { return {level, file, line, linefeed}; @@ -147,14 +147,14 @@ private: }; // We need to use macros for contextual information -#define RING_INFO(...) ::ring::Logger::log(LOG_INFO, __FILE__, __LINE__, true, ## __VA_ARGS__) -#define RING_DBG(...) ::ring::Logger::log(LOG_DEBUG, __FILE__, __LINE__, true, ## __VA_ARGS__) -#define RING_WARN(...) ::ring::Logger::log(LOG_WARNING, __FILE__, __LINE__, true, ## __VA_ARGS__) -#define RING_ERR(...) ::ring::Logger::log(LOG_ERR, __FILE__, __LINE__, true, ## __VA_ARGS__) +#define JAMI_INFO(...) ::jami::Logger::log(LOG_INFO, __FILE__, __LINE__, true, ## __VA_ARGS__) +#define JAMI_DBG(...) ::jami::Logger::log(LOG_DEBUG, __FILE__, __LINE__, true, ## __VA_ARGS__) +#define JAMI_WARN(...) ::jami::Logger::log(LOG_WARNING, __FILE__, __LINE__, true, ## __VA_ARGS__) +#define JAMI_ERR(...) ::jami::Logger::log(LOG_ERR, __FILE__, __LINE__, true, ## __VA_ARGS__) -#define RING_XINFO(...) ::ring::Logger::log(LOG_INFO, __FILE__, __LINE__, false, ## __VA_ARGS__) -#define RING_XDBG(...) ::ring::Logger::log(LOG_DEBUG, __FILE__, __LINE__, false, ## __VA_ARGS__) -#define RING_XWARN(...) ::ring::Logger::log(LOG_WARNING, __FILE__, __LINE__, false, ## __VA_ARGS__) -#define RING_XERR(...) ::ring::Logger::log(LOG_ERR, __FILE__, __LINE__, false, ## __VA_ARGS__) +#define JAMI_XINFO(...) ::jami::Logger::log(LOG_INFO, __FILE__, __LINE__, false, ## __VA_ARGS__) +#define JAMI_XDBG(...) ::jami::Logger::log(LOG_DEBUG, __FILE__, __LINE__, false, ## __VA_ARGS__) +#define JAMI_XWARN(...) ::jami::Logger::log(LOG_WARNING, __FILE__, __LINE__, false, ## __VA_ARGS__) +#define JAMI_XERR(...) ::jami::Logger::log(LOG_ERR, __FILE__, __LINE__, false, ## __VA_ARGS__) -} // namespace ring +} // namespace jami diff --git a/src/manager.cpp b/src/manager.cpp index 84af6c6cd2..d8d88e36b6 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -63,7 +63,7 @@ using random_device = dht::crypto::random_device; #include "audio/sound/dtmf.h" #include "audio/ringbufferpool.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "client/videomanager.h" #include "video/video_scaler.h" #endif @@ -98,7 +98,7 @@ using random_device = dht::crypto::random_device; #include <list> #include <random> -namespace ring { +namespace jami { /** To store conference objects by conference ids */ using ConferenceMap = std::map<std::string, std::shared_ptr<Conference>>; @@ -143,7 +143,7 @@ check_rename(const std::string& old_dir, const std::string& new_dir) if (old_dir == new_dir or not fileutils::isDirectory(old_dir)) return; - RING_WARN() << "Migrating" << old_dir << " to " << new_dir; + JAMI_WARN() << "Migrating" << old_dir << " to " << new_dir; if (not fileutils::isDirectory(new_dir)) { std::rename(old_dir.c_str(), new_dir.c_str()); } else { @@ -184,7 +184,7 @@ setDhtLogLevel() // From 0 (min) to 3 (max) level = std::max(0, std::min(level, 3)); - RING_DBG("DHTLOGLEVEL=%u", level); + JAMI_DBG("DHTLOGLEVEL=%u", level); } Manager::instance().dhtLogLevel = level; #else @@ -222,9 +222,9 @@ setSipLogLevel() pj_log_set_level(level); pj_log_set_log_func([](int level, const char *data, int /*len*/) { - if (level < 2) RING_ERR() << data; - else if (level < 4) RING_WARN() << data; - else RING_DBG() << data; + if (level < 2) JAMI_ERR() << data; + else if (level < 4) JAMI_WARN() << data; + else JAMI_DBG() << data; }); } @@ -239,7 +239,7 @@ static constexpr int RING_TLS_LOGLEVEL = 0; static void tls_print_logs(int level, const char* msg) { - RING_XDBG("[%d]GnuTLS: %s", level, msg); + JAMI_XDBG("[%d]GnuTLS: %s", level, msg); } static void @@ -394,7 +394,7 @@ struct Manager::ManagerPimpl /* Sink ID mapping */ std::map<std::string, std::weak_ptr<video::SinkClient>> sinkMap_; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::unique_ptr<VideoManager> videoManager_; #endif }; @@ -412,7 +412,7 @@ Manager::ManagerPimpl::ManagerPimpl(Manager& base) , ringbufferpool_(new RingBufferPool) , conferenceMap_() , ice_tf_() -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO , videoManager_(new VideoManager) #endif { @@ -423,7 +423,7 @@ Manager::ManagerPimpl::ManagerPimpl(Manager& base) std::seed_seq seed {rdev(), rdev()}; rand_.seed(seed); - ring::libav_utils::ring_avcodec_init(); + jami::libav_utils::ring_avcodec_init(); } bool @@ -436,11 +436,11 @@ Manager::ManagerPimpl::parseConfiguration() const int error_count = base_.loadAccountMap(parsedFile); if (error_count > 0) { - RING_WARN("Errors while parsing %s", path_.c_str()); + JAMI_WARN("Errors while parsing %s", path_.c_str()); result = false; } } catch (const YAML::BadFile &e) { - RING_WARN("Could not open configuration file"); + JAMI_WARN("Could not open configuration file"); } return result; @@ -459,7 +459,7 @@ Manager::ManagerPimpl::playATone(Tone::TONEID toneId) std::lock_guard<std::mutex> lock(audioLayerMutex_); if (not audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return; } @@ -493,7 +493,7 @@ Manager::ManagerPimpl::processRemainingParticipants(Conference &conf) const std::string current_call_id(base_.getCurrentCallId()); ParticipantSet participants(conf.getParticipantList()); const size_t n = participants.size(); - RING_DBG("Process remaining %zu participant(s) from conference %s", + JAMI_DBG("Process remaining %zu participant(s) from conference %s", n, conf.getConfID().c_str()); if (n > 1) { @@ -516,10 +516,10 @@ Manager::ManagerPimpl::processRemainingParticipants(Conference &conf) switchCall(call); } - RING_DBG("No remaining participants, remove conference"); + JAMI_DBG("No remaining participants, remove conference"); base_.removeConference(conf.getConfID()); } else { - RING_DBG("No remaining participants, remove conference"); + JAMI_DBG("No remaining participants, remove conference"); base_.removeConference(conf.getConfID()); unsetCurrentCall(); } @@ -545,7 +545,7 @@ void Manager::ManagerPimpl::switchCall(const std::string& id) { std::lock_guard<std::mutex> m(currentCallMutex_); - RING_DBG("----- Switch current call id to '%s' -----", not id.empty() ? id.c_str() : "none"); + JAMI_DBG("----- Switch current call id to '%s' -----", not id.empty() ? id.c_str() : "none"); currentCall_ = id; } @@ -585,11 +585,11 @@ Manager::ManagerPimpl::loadAccount(const YAML::Node &node, int &errorCount) if (auto a = base_.accountFactory.createAccount(accountType.c_str(), accountid)) { a->unserialize(node); } else { - RING_ERR("Failed to create account type \"%s\"", accountType.c_str()); + JAMI_ERR("Failed to create account type \"%s\"", accountType.c_str()); ++errorCount; } } else { - RING_WARN("Ignoring unknown account type \"%s\"", accountType.c_str()); + JAMI_WARN("Ignoring unknown account type \"%s\"", accountType.c_str()); } } } @@ -608,7 +608,7 @@ Manager::ManagerPimpl::sendTextMessageToConference(const Conference& conf, throw std::runtime_error("no associated call"); call->sendTextMessage(messages, from); } catch (const std::exception& e) { - RING_ERR("Failed to send message to conference participant %s: %s", + JAMI_ERR("Failed to send message to conference participant %s: %s", call_id.c_str(), e.what()); } } @@ -625,7 +625,7 @@ Manager::ManagerPimpl::bindCallToConference(Call& call, Conference& conf) if (base_.isConferenceParticipant(call_id)) base_.detachParticipant(call_id); - RING_DBG("[call:%s] bind to conference %s (callState=%s)", + JAMI_DBG("[call:%s] bind to conference %s (callState=%s)", call_id.c_str(), conf_id.c_str(), state.c_str()); base_.getRingBufferPool().unBindAll(call_id); @@ -645,7 +645,7 @@ Manager::ManagerPimpl::bindCallToConference(Call& call, Conference& conf) conf.bindParticipant(call_id); base_.answerCall(call_id); } else - RING_WARN("[call:%s] call state %s not recognized for conference", + JAMI_WARN("[call:%s] call state %s not recognized for conference", call_id.c_str(), state.c_str()); } @@ -660,7 +660,7 @@ Manager::instance() // This will give a warning that can be ignored the first time instance() // is called...subsequent warnings are more serious if (not Manager::initialized) - RING_WARN("Not initialized"); + JAMI_WARN("Not initialized"); return instance; } @@ -671,7 +671,7 @@ Manager::Manager() , hookPreference() , audioPreference() , shortcutPreferences() -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO , videoPreferences() #endif , callFactory() @@ -720,11 +720,11 @@ Manager::init(const std::string &config_file) PJSIP_TRY(pjnath_init()); #undef PJSIP_TRY - RING_DBG("pjsip version %s for %s initialized", + JAMI_DBG("pjsip version %s for %s initialized", pj_get_version(), PJ_OS_NAME); setGnuTlsLogLevel(); - RING_DBG("GNU TLS version %s initialized", gnutls_check_version(nullptr)); + JAMI_DBG("GNU TLS version %s initialized", gnutls_check_version(nullptr)); setDhtLogLevel(); @@ -735,7 +735,7 @@ Manager::init(const std::string &config_file) pimpl_->ice_tf_.reset(new IceTransportFactory()); pimpl_->path_ = config_file.empty() ? pimpl_->retrieveConfigPath() : config_file; - RING_DBG("Configuration file path: %s", pimpl_->path_.c_str()); + JAMI_DBG("Configuration file path: %s", pimpl_->path_.c_str()); bool no_errors = true; @@ -745,7 +745,7 @@ Manager::init(const std::string &config_file) try { no_errors = pimpl_->parseConfiguration(); } catch (const YAML::Exception &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); no_errors = false; } @@ -754,7 +754,7 @@ Manager::init(const std::string &config_file) make_backup(pimpl_->path_); } else { // restore previous configuration - RING_WARN("Restoring last working configuration"); + JAMI_WARN("Restoring last working configuration"); // keep a reference to sipvoiplink while destroying the accounts const auto sipvoiplink = getSIPVoIPLink(); @@ -765,8 +765,8 @@ Manager::init(const std::string &config_file) restore_backup(pimpl_->path_); pimpl_->parseConfiguration(); } catch (const YAML::Exception &e) { - RING_ERR("%s", e.what()); - RING_WARN("Restoring backup failed"); + JAMI_ERR("%s", e.what()); + JAMI_WARN("Restoring backup failed"); } } @@ -796,7 +796,7 @@ Manager::finish() noexcept callFactory.forbid(); // Hangup all remaining active calls - RING_DBG("Hangup %zu remaining call(s)", callFactory.callCount()); + JAMI_DBG("Hangup %zu remaining call(s)", callFactory.callCount()); for (const auto call : callFactory.getAllCalls()) hangupCall(call->getCallId()); callFactory.clear(); @@ -826,7 +826,7 @@ Manager::finish() noexcept pj_shutdown(); ThreadPool::instance().join(); } catch (const VoipLinkException &err) { - RING_ERR("%s", err.what()); + JAMI_ERR("%s", err.what()); } } @@ -875,11 +875,11 @@ Manager::outgoingCall(const std::string& account_id, const std::map<std::string, std::string>& volatileCallDetails) { if (not conf_id.empty() and not isConference(conf_id)) { - RING_ERR("outgoingCall() failed, invalid conference id"); + JAMI_ERR("outgoingCall() failed, invalid conference id"); return {}; } - RING_DBG() << "try outgoing call to '" << to << "'" + JAMI_DBG() << "try outgoing call to '" << to << "'" << " with account '" << account_id << "'"; const auto& current_call_id(getCurrentCallId()); @@ -889,7 +889,7 @@ Manager::outgoingCall(const std::string& account_id, try { call = newOutgoingCall(to_cleaned, account_id, volatileCallDetails); } catch (const std::exception &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); return {}; } @@ -902,7 +902,7 @@ Manager::outgoingCall(const std::string& account_id, // in any cases we have to detach from current communication if (hasCurrentCall()) { - RING_DBG("Has current call (%s) put it onhold", current_call_id.c_str()); + JAMI_DBG("Has current call (%s) put it onhold", current_call_id.c_str()); bool isConf = isConference(current_call_id); // if this is not a conference and this and is not a conference participant @@ -926,7 +926,7 @@ Manager::answerCall(const std::string& call_id) auto call = getCallFromCallID(call_id); if (!call) { - RING_ERR("Call %s is NULL", call_id.c_str()); + JAMI_ERR("Call %s is NULL", call_id.c_str()); return false; } @@ -939,15 +939,15 @@ Manager::answerCall(const std::string& call_id) // in any cases we have to detach from current communication if (hasCurrentCall() and call_id != current_call_id) { - RING_DBG("Currently conversing with %s", current_call_id.c_str()); + JAMI_DBG("Currently conversing with %s", current_call_id.c_str()); bool isConf = isConference(current_call_id); if (not isConf and not isConferenceParticipant(current_call_id)) { - RING_DBG("Answer call: Put the current call (%s) on hold", current_call_id.c_str()); + JAMI_DBG("Answer call: Put the current call (%s) on hold", current_call_id.c_str()); onHoldCall(current_call_id); } else if (isConf and not isConferenceParticipant(call_id)) { // if we are talking to a conference and we are answering an incoming call - RING_DBG("Detach main participant from conference"); + JAMI_DBG("Detach main participant from conference"); detachLocalParticipant(); } } @@ -955,7 +955,7 @@ Manager::answerCall(const std::string& call_id) try { call->answer(); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); result = false; } @@ -987,10 +987,10 @@ Manager::checkAudio() { // FIXME dirty, the manager should not need to be aware of local recorders if (getCallList().empty() -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO and not getVideoManager().audioPreview #endif - and not ring::LocalRecorderManager::instance().hasRunningRecorders()) { + and not jami::LocalRecorderManager::instance().hasRunningRecorders()) { std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (pimpl_->audiodriver_) pimpl_->audiodriver_->stopStream(); @@ -1009,7 +1009,7 @@ Manager::hangupCall(const std::string& callId) /* We often get here when the call was hungup before being created */ auto call = getCallFromCallID(callId); if (not call) { - RING_WARN("Could not hang up non-existant call %s", callId.c_str()); + JAMI_WARN("Could not hang up non-existant call %s", callId.c_str()); checkAudio(); return false; } @@ -1029,7 +1029,7 @@ Manager::hangupCall(const std::string& callId) call->hangup(0); checkAudio(); } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); return false; } @@ -1039,7 +1039,7 @@ Manager::hangupCall(const std::string& callId) bool Manager::hangupConference(const std::string& id) { - RING_DBG("Hangup conference %s", id.c_str()); + JAMI_DBG("Hangup conference %s", id.c_str()); ConferenceMap::iterator iter_conf = pimpl_->conferenceMap_.find(id); @@ -1052,7 +1052,7 @@ Manager::hangupConference(const std::string& id) for (const auto &item : participants) hangupCall(item); } else { - RING_ERR("No such conference %s", id.c_str()); + JAMI_ERR("No such conference %s", id.c_str()); return false; } } @@ -1078,12 +1078,12 @@ Manager::onHoldCall(const std::string& callId) if (result) removeAudio(*call); // Unbind calls in main buffer } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); result = false; } } else { - RING_DBG("CallID %s doesn't exist in call onHold", callId.c_str()); + JAMI_DBG("CallID %s doesn't exist in call onHold", callId.c_str()); return false; } @@ -1113,7 +1113,7 @@ Manager::offHoldCall(const std::string& callId) if (hasCurrentCall() and currentCallId != callId) { bool isConf = isConference(currentCallId); if (not isConf and not isConferenceParticipant(currentCallId)) { - RING_DBG("Has current call (%s), put on hold", currentCallId.c_str()); + JAMI_DBG("Has current call (%s), put on hold", currentCallId.c_str()); onHoldCall(currentCallId); } else if (isConf and not isConferenceParticipant(callId)) { holdConference(currentCallId); @@ -1128,7 +1128,7 @@ Manager::offHoldCall(const std::string& callId) try { result = call->offhold(); } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); return false; } @@ -1151,7 +1151,7 @@ Manager::muteMediaCall(const std::string& callId, const std::string& mediaType, call->muteMedia(mediaType, is_muted); return true; } else { - RING_DBG("CallID %s doesn't exist in call muting", callId.c_str()); + JAMI_DBG("CallID %s doesn't exist in call muting", callId.c_str()); return false; } } @@ -1223,8 +1223,8 @@ Manager::refuseCall(const std::string& id) void Manager::removeConference(const std::string& conference_id) { - RING_DBG("Remove conference %s", conference_id.c_str()); - RING_DBG("number of participants: %zu", pimpl_->conferenceMap_.size()); + JAMI_DBG("Remove conference %s", conference_id.c_str()); + JAMI_DBG("number of participants: %zu", pimpl_->conferenceMap_.size()); ConferenceMap::iterator iter = pimpl_->conferenceMap_.find(conference_id); std::shared_ptr<Conference> conf; @@ -1233,7 +1233,7 @@ Manager::removeConference(const std::string& conference_id) conf = iter->second; if (not conf) { - RING_ERR("Conference not found"); + JAMI_ERR("Conference not found"); return; } @@ -1254,9 +1254,9 @@ Manager::removeConference(const std::string& conference_id) // Then remove the conference from the conference map if (pimpl_->conferenceMap_.erase(conference_id)) - RING_DBG("Conference %s removed successfully", conference_id.c_str()); + JAMI_DBG("Conference %s removed successfully", conference_id.c_str()); else - RING_ERR("Cannot remove conference: %s", conference_id.c_str()); + JAMI_ERR("Cannot remove conference: %s", conference_id.c_str()); } std::shared_ptr<Conference> @@ -1354,23 +1354,23 @@ Manager::addParticipant(const std::string& callId, { auto iter = pimpl_->conferenceMap_.find(conferenceId); if (iter == pimpl_->conferenceMap_.end() or iter->second == nullptr) { - RING_ERR("Conference id is not valid"); + JAMI_ERR("Conference id is not valid"); return false; } auto call = getCallFromCallID(callId); if (!call) { - RING_ERR("Call id %s is not valid", callId.c_str()); + JAMI_ERR("Call id %s is not valid", callId.c_str()); return false; } // No-op if the call is already a conference participant if (call->getConfId() == conferenceId) { - RING_WARN("Call %s already participant of conf %s", callId.c_str(), conferenceId.c_str()); + JAMI_WARN("Call %s already participant of conf %s", callId.c_str(), conferenceId.c_str()); return true; } - RING_DBG("Add participant %s to %s", callId.c_str(), conferenceId.c_str()); + JAMI_DBG("Add participant %s to %s", callId.c_str(), conferenceId.c_str()); // store the current call id (it will change in offHoldCall or in answerCall) auto current_call_id = getCurrentCallId(); @@ -1434,7 +1434,7 @@ Manager::addMainParticipant(const std::string& conference_id) else if (conf->getState() == Conference::ACTIVE_DETACHED_REC) conf->setState(Conference::ACTIVE_ATTACHED_REC); else - RING_WARN("Invalid conference state while adding main participant"); + JAMI_WARN("Invalid conference state while adding main participant"); emitSignal<DRing::CallSignal::ConferenceChanged>(conference_id, conf->getStateStr()); } @@ -1453,21 +1453,21 @@ bool Manager::joinParticipant(const std::string& callId1, const std::string& callId2) { if (callId1 == callId2) { - RING_ERR("Cannot join participant %s to itself", callId1.c_str()); + JAMI_ERR("Cannot join participant %s to itself", callId1.c_str()); return false; } // Set corresponding conference ids for call 1 auto call1 = getCallFromCallID(callId1); if (!call1) { - RING_ERR("Could not find call %s", callId1.c_str()); + JAMI_ERR("Could not find call %s", callId1.c_str()); return false; } // Set corresponding conderence details auto call2 = getCallFromCallID(callId2); if (!call2) { - RING_ERR("Could not find call %s", callId2.c_str()); + JAMI_ERR("Could not find call %s", callId2.c_str()); return false; } @@ -1500,7 +1500,7 @@ Manager::createConfFromParticipantList(const std::vector< std::string > &partici { // we must at least have 2 participant for a conference if (participantList.size() <= 1) { - RING_ERR("Participant number must be higher or equal to 2"); + JAMI_ERR("Participant number must be higher or equal to 2"); return; } @@ -1537,17 +1537,17 @@ Manager::createConfFromParticipantList(const std::vector< std::string > &partici bool Manager::detachLocalParticipant() { - RING_DBG("Unbind local participant from conference"); + JAMI_DBG("Unbind local participant from conference"); const auto& current_call_id = getCurrentCallId(); if (not isConference(current_call_id)) { - RING_ERR("Current call id (%s) is not a conference", current_call_id.c_str()); + JAMI_ERR("Current call id (%s) is not a conference", current_call_id.c_str()); return false; } auto iter = pimpl_->conferenceMap_.find(current_call_id); if (iter == pimpl_->conferenceMap_.end() or iter->second == nullptr) { - RING_ERR("Conference is NULL"); + JAMI_ERR("Conference is NULL"); return false; } @@ -1562,7 +1562,7 @@ Manager::detachLocalParticipant() conf->setState(Conference::ACTIVE_DETACHED_REC); break; default: - RING_WARN("Undefined behavior, invalid conference state in detach participant"); + JAMI_WARN("Undefined behavior, invalid conference state in detach participant"); } emitSignal<DRing::CallSignal::ConferenceChanged>(conf->getConfID(), conf->getStateStr()); @@ -1574,17 +1574,17 @@ Manager::detachLocalParticipant() bool Manager::detachParticipant(const std::string& call_id) { - RING_DBG("Detach participant %s", call_id.c_str()); + JAMI_DBG("Detach participant %s", call_id.c_str()); auto call = getCallFromCallID(call_id); if (!call) { - RING_ERR("Could not find call %s", call_id.c_str()); + JAMI_ERR("Could not find call %s", call_id.c_str()); return false; } auto conf = getConferenceFromCallID(call_id); if (!conf) { - RING_ERR("Call is not conferencing, cannot detach"); + JAMI_ERR("Call is not conferencing, cannot detach"); return false; } @@ -1599,12 +1599,12 @@ Manager::detachParticipant(const std::string& call_id) void Manager::removeParticipant(const std::string& call_id) { - RING_DBG("Remove participant %s", call_id.c_str()); + JAMI_DBG("Remove participant %s", call_id.c_str()); // this call is no longer a conference participant auto call = getCallFromCallID(call_id); if (!call) { - RING_ERR("Call not found"); + JAMI_ERR("Call not found"); return; } @@ -1612,7 +1612,7 @@ Manager::removeParticipant(const std::string& call_id) auto conf = iter->second; if (iter == pimpl_->conferenceMap_.end() or conf == 0) { - RING_ERR("No conference with id %s, cannot remove participant", call->getConfId().c_str()); + JAMI_ERR("No conference with id %s, cannot remove participant", call->getConfId().c_str()); return; } @@ -1631,12 +1631,12 @@ Manager::joinConference(const std::string& conf_id1, const std::string& conf_id2) { if (pimpl_->conferenceMap_.find(conf_id1) == pimpl_->conferenceMap_.end()) { - RING_ERR("Not a valid conference ID: %s", conf_id1.c_str()); + JAMI_ERR("Not a valid conference ID: %s", conf_id1.c_str()); return false; } if (pimpl_->conferenceMap_.find(conf_id2) == pimpl_->conferenceMap_.end()) { - RING_ERR("Not a valid conference ID: %s", conf_id2.c_str()); + JAMI_ERR("Not a valid conference ID: %s", conf_id2.c_str()); return false; } @@ -1655,7 +1655,7 @@ Manager::addAudio(Call& call) const auto call_id = call.getCallId(); if (isConferenceParticipant(call_id)) { - RING_DBG("[conf:%s] Attach local audio", call_id.c_str()); + JAMI_DBG("[conf:%s] Attach local audio", call_id.c_str()); // bind to conference participant ConferenceMap::iterator iter = pimpl_->conferenceMap_.find(call_id); @@ -1664,14 +1664,14 @@ Manager::addAudio(Call& call) conf->bindParticipant(call_id); } } else { - RING_DBG("[call:%s] Attach audio", call_id.c_str()); + JAMI_DBG("[call:%s] Attach audio", call_id.c_str()); // bind to main getRingBufferPool().bindCallID(call_id, RingBufferPool::DEFAULT_ID); std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (!pimpl_->audiodriver_) { - RING_ERR("Audio driver not initialized"); + JAMI_ERR("Audio driver not initialized"); return; } pimpl_->audiodriver_->flushUrgent(); @@ -1684,7 +1684,7 @@ void Manager::removeAudio(Call& call) { const auto call_id = call.getCallId(); - RING_DBG("[call:%s] Remove local audio", call_id.c_str()); + JAMI_DBG("[call:%s] Remove local audio", call_id.c_str()); getRingBufferPool().unBindAll(call_id); } @@ -1733,16 +1733,16 @@ Manager::saveConfig(const std::shared_ptr<RingAccount>& account) std::lock_guard<std::mutex> lock(fileutils::getFileLock(accountConfig)); std::ofstream fout(accountConfig); fout << accountOut.c_str(); - RING_DBG("Exported account to %s", accountConfig.c_str()); + JAMI_DBG("Exported account to %s", accountConfig.c_str()); } catch (const std::exception& e) { - RING_ERR("Error exporting account: %s", e.what()); + JAMI_ERR("Error exporting account: %s", e.what()); } } void Manager::saveConfig() { - RING_DBG("Saving Configuration to XDG directory %s", pimpl_->path_.c_str()); + JAMI_DBG("Saving Configuration to XDG directory %s", pimpl_->path_.c_str()); if (pimpl_->audiodriver_) { audioPreference.setVolumemic(pimpl_->audiodriver_->getCaptureGain()); @@ -1776,7 +1776,7 @@ Manager::saveConfig() voipPreferences.serialize(out); hookPreference.serialize(out); audioPreference.serialize(out); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videoPreferences.serialize(out); #endif shortcutPreferences.serialize(out); @@ -1785,9 +1785,9 @@ Manager::saveConfig() std::ofstream fout(pimpl_->path_); fout << out.c_str(); } catch (const YAML::Exception &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } } @@ -1798,7 +1798,7 @@ Manager::playDtmf(char code) stopTone(); if (not voipPreferences.getPlayDtmf()) { - RING_DBG("Do not have to play a tone..."); + JAMI_DBG("Do not have to play a tone..."); return; } @@ -1806,7 +1806,7 @@ Manager::playDtmf(char code) int pulselen = voipPreferences.getPulseLength(); if (pulselen == 0) { - RING_DBG("Pulse length is not set..."); + JAMI_DBG("Pulse length is not set..."); return; } @@ -1814,13 +1814,13 @@ Manager::playDtmf(char code) // fast return, no sound, so no dtmf if (not pimpl_->audiodriver_ or not pimpl_->dtmfKey_) { - RING_DBG("No audio layer..."); + JAMI_DBG("No audio layer..."); return; } pimpl_->audiodriver_->startStream(); if (not pimpl_->audiodriver_->waitForStart(std::chrono::seconds(1))) { - RING_ERR("Failed to start audio layer..."); + JAMI_ERR("Failed to start audio layer..."); return; } @@ -1934,11 +1934,11 @@ Manager::incomingMessage(const std::string& callID, if (isConferenceParticipant(callID)) { auto conf = getConferenceFromCallID(callID); if (not conf) { - RING_ERR("no conference associated to ID %s", callID.c_str()); + JAMI_ERR("no conference associated to ID %s", callID.c_str()); return; } - RING_DBG("Is a conference, send incoming message to everyone"); + JAMI_DBG("Is a conference, send incoming message to everyone"); pimpl_->sendTextMessageToConference(*conf, messages, from); // in case of a conference we must notify client using conference id @@ -1956,34 +1956,34 @@ Manager::sendCallTextMessage(const std::string& callID, if (isConference(callID)) { const auto& it = pimpl_->conferenceMap_.find(callID); if (it == pimpl_->conferenceMap_.cend() or not it->second) { - RING_ERR("no conference associated to ID %s", callID.c_str()); + JAMI_ERR("no conference associated to ID %s", callID.c_str()); return; } - RING_DBG("Is a conference, send instant message to everyone"); + JAMI_DBG("Is a conference, send instant message to everyone"); pimpl_->sendTextMessageToConference(*it->second, messages, from); } else if (isConferenceParticipant(callID)) { auto conf = getConferenceFromCallID(callID); if (not conf) { - RING_ERR("no conference associated to call ID %s", callID.c_str()); + JAMI_ERR("no conference associated to call ID %s", callID.c_str()); return; } - RING_DBG("Call is participant in a conference, send instant message to everyone"); + JAMI_DBG("Call is participant in a conference, send instant message to everyone"); pimpl_->sendTextMessageToConference(*conf, messages, from); } else { auto call = getCallFromCallID(callID); if (not call) { - RING_ERR("Failed to send message to %s: inexistant call ID", callID.c_str()); + JAMI_ERR("Failed to send message to %s: inexistant call ID", callID.c_str()); return; } try { call->sendTextMessage(messages, from); } catch (const im::InstantMessageException& e) { - RING_ERR("Failed to send message to call %s: %s", call->getCallId().c_str(), e.what()); + JAMI_ERR("Failed to send message to call %s: %s", call->getCallId().c_str(), e.what()); } } } @@ -1993,7 +1993,7 @@ void Manager::peerAnsweredCall(Call& call) { const auto call_id = call.getCallId(); - RING_DBG("[call:%s] Peer answered", call_id.c_str()); + JAMI_DBG("[call:%s] Peer answered", call_id.c_str()); // The if statement is useful only if we sent two calls at the same time. if (isCurrentCall(call)) @@ -2015,7 +2015,7 @@ Manager::peerAnsweredCall(Call& call) void Manager::peerRingingCall(Call& call) { - RING_DBG("[call:%s] Peer ringing", call.getCallId().c_str()); + JAMI_DBG("[call:%s] Peer ringing", call.getCallId().c_str()); if (isCurrentCall(call)) ringback(); @@ -2026,7 +2026,7 @@ void Manager::peerHungupCall(Call& call) { const auto call_id = call.getCallId(); - RING_DBG("[call:%s] Peer hungup", call_id.c_str()); + JAMI_DBG("[call:%s] Peer hungup", call_id.c_str()); if (isConferenceParticipant(call_id)) { removeParticipant(call_id); @@ -2049,7 +2049,7 @@ Manager::peerHungupCall(Call& call) void Manager::callBusy(Call& call) { - RING_DBG("[call:%s] Busy", call.getCallId().c_str()); + JAMI_DBG("[call:%s] Busy", call.getCallId().c_str()); if (isCurrentCall(call)) { pimpl_->unsetCurrentCall(); @@ -2066,14 +2066,14 @@ void Manager::callFailure(Call& call) { const auto call_id = call.getCallId(); - RING_DBG("[call:%s] Failed", call.getCallId().c_str()); + JAMI_DBG("[call:%s] Failed", call.getCallId().c_str()); if (isCurrentCall(call)) { pimpl_->unsetCurrentCall(); } if (isConferenceParticipant(call_id)) { - RING_DBG("Call %s participating in a conference failed", call_id.c_str()); + JAMI_DBG("Call %s participating in a conference failed", call_id.c_str()); // remove this participant removeParticipant(call_id); } @@ -2150,7 +2150,7 @@ Manager::playRingtone(const std::string& accountID) const auto account = getAccount(accountID); if (!account) { - RING_WARN("Invalid account in ringtone"); + JAMI_WARN("Invalid account in ringtone"); return; } @@ -2175,7 +2175,7 @@ Manager::playRingtone(const std::string& accountID) std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("no audio layer in ringtone"); + JAMI_ERR("no audio layer in ringtone"); return; } // start audio if not started AND flush all buffers (main and urgent) @@ -2217,7 +2217,7 @@ Manager::setAudioPlugin(const std::string& audioPlugin) if (pimpl_->audiodriver_ and wasStarted) pimpl_->audiodriver_->startStream(); else - RING_ERR("No audio layer created, possibly built without audio support"); + JAMI_ERR("No audio layer created, possibly built without audio support"); saveConfig(); } @@ -2231,11 +2231,11 @@ Manager::setAudioDevice(int index, DeviceType type) std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio driver not initialized"); + JAMI_ERR("Audio driver not initialized"); return ; } if (pimpl_->getCurrentDeviceIndex(type) == index) { - RING_WARN("Audio device already selected ; doing nothing."); + JAMI_WARN("Audio device already selected ; doing nothing."); return; } @@ -2260,7 +2260,7 @@ Manager::getAudioOutputDeviceList() std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return {}; } @@ -2276,7 +2276,7 @@ Manager::getAudioInputDeviceList() std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return {}; } @@ -2292,7 +2292,7 @@ Manager::getCurrentAudioDevicesIndex() std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return {}; } @@ -2314,7 +2314,7 @@ Manager::switchInput(const std::string& call_id, const std::string& res) { auto call = getCallFromCallID(call_id); if (!call) { - RING_ERR("Call %s is NULL", call_id.c_str()); + JAMI_ERR("Call %s is NULL", call_id.c_str()); return false; } call->switchInput(res); @@ -2327,7 +2327,7 @@ Manager::isRingtoneEnabled(const std::string& id) const auto account = getAccount(id); if (!account) { - RING_WARN("Invalid account in ringtone enabled"); + JAMI_WARN("Invalid account in ringtone enabled"); return 0; } @@ -2340,7 +2340,7 @@ Manager::ringtoneEnabled(const std::string& id) const auto account = getAccount(id); if (!account) { - RING_WARN("Invalid account in ringtone enabled"); + JAMI_WARN("Invalid account in ringtone enabled"); return; } @@ -2366,10 +2366,10 @@ Manager::toggleRecordingCall(const std::string& id) ConferenceMap::const_iterator it(pimpl_->conferenceMap_.find(id)); if (it == pimpl_->conferenceMap_.end()) { - RING_DBG("toggle recording for call %s", id.c_str()); + JAMI_DBG("toggle recording for call %s", id.c_str()); rec = getCallFromCallID(id); } else { - RING_DBG("toggle recording for conference %s", id.c_str()); + JAMI_DBG("toggle recording for conference %s", id.c_str()); auto conf = it->second; if (conf) { rec = conf; @@ -2381,7 +2381,7 @@ Manager::toggleRecordingCall(const std::string& id) } if (!rec) { - RING_ERR("Could not find recordable instance %s", id.c_str()); + JAMI_ERR("Could not find recordable instance %s", id.c_str()); return false; } @@ -2401,13 +2401,13 @@ Manager::isRecording(const std::string& id) bool Manager::startRecordedFilePlayback(const std::string& filepath) { - RING_DBG("Start recorded file playback %s", filepath.c_str()); + JAMI_DBG("Start recorded file playback %s", filepath.c_str()); { std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("No audio layer in start recorded file playback"); + JAMI_ERR("No audio layer in start recorded file playback"); return false; } @@ -2427,7 +2427,7 @@ Manager::recordingPlaybackSeek(const double value) void Manager::stopRecordedFilePlayback() { - RING_DBG("Stop recorded file playback"); + JAMI_DBG("Stop recorded file playback"); checkAudio(); pimpl_->toneCtrl_.stopAudioFile(); @@ -2436,7 +2436,7 @@ Manager::stopRecordedFilePlayback() void Manager::setHistoryLimit(int days) { - RING_DBG("Set history limit"); + JAMI_DBG("Set history limit"); preferences.setHistoryLimit(days); saveConfig(); } @@ -2450,7 +2450,7 @@ Manager::getHistoryLimit() const void Manager::setRingingTimeout(int timeout) { - RING_DBG("Set ringing timeout"); + JAMI_DBG("Set ringing timeout"); preferences.setRingingTimeout(timeout); saveConfig(); } @@ -2471,7 +2471,7 @@ Manager::setAudioManager(const std::string &api) return false; if (api == audioPreference.getAudioApi()) { - RING_DBG("Audio manager chosen already in use. No changes made. "); + JAMI_DBG("Audio manager chosen already in use. No changes made. "); return true; } } @@ -2505,7 +2505,7 @@ Manager::getAudioInputDeviceIndex(const std::string &name) std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return 0; } @@ -2518,7 +2518,7 @@ Manager::getAudioOutputDeviceIndex(const std::string &name) std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (not pimpl_->audiodriver_) { - RING_ERR("Audio layer not initialized"); + JAMI_ERR("Audio layer not initialized"); return 0; } @@ -2581,7 +2581,7 @@ Manager::audioFormatUsed(AudioFormat format) if (currentFormat == format) return format; - RING_DBG("Audio format changed: %s -> %s", currentFormat.toString().c_str(), + JAMI_DBG("Audio format changed: %s -> %s", currentFormat.toString().c_str(), format.toString().c_str()); pimpl_->ringbufferpool_->setInternalAudioFormat(format); @@ -2594,7 +2594,7 @@ Manager::audioFormatUsed(AudioFormat format) void Manager::setAccountsOrder(const std::string& order) { - RING_DBG("Set accounts order : %s", order.c_str()); + JAMI_DBG("Set accounts order : %s", order.c_str()); // Set the new config preferences.setAccountOrder(order); @@ -2625,7 +2625,7 @@ Manager::getAccountDetails(const std::string& accountID) const if (account) { return account->getAccountDetails(); } else { - RING_ERR("Could not get account details on a non-existing accountID %s", accountID.c_str()); + JAMI_ERR("Could not get account details on a non-existing accountID %s", accountID.c_str()); // return an empty map since we can't throw an exception to D-Bus return std::map<std::string, std::string>(); } @@ -2639,7 +2639,7 @@ Manager::getVolatileAccountDetails(const std::string& accountID) const if (account) { return account->getVolatileAccountDetails(); } else { - RING_ERR("Could not get volatile account details on a non-existing accountID %s", accountID.c_str()); + JAMI_ERR("Could not get volatile account details on a non-existing accountID %s", accountID.c_str()); return {}; } } @@ -2651,12 +2651,12 @@ void Manager::setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details) { - RING_DBG("Set account details for %s", accountID.c_str()); + JAMI_DBG("Set account details for %s", accountID.c_str()); const auto account = getAccount(accountID); if (account == nullptr) { - RING_ERR("Could not find account %s", accountID.c_str()); + JAMI_ERR("Could not find account %s", accountID.c_str()); return; } @@ -2701,12 +2701,12 @@ Manager::testAccountICEInitialization(const std::string& accountID) if (ice->waitForInitialization(ICE_INIT_TIMEOUT) <= 0) { - result["STATUS"] = ring::to_string((int) DRing::Account::testAccountICEInitializationStatus::FAILURE); + result["STATUS"] = jami::to_string((int) DRing::Account::testAccountICEInitializationStatus::FAILURE); result["MESSAGE"] = ice->getLastErrMsg(); } else { - result["STATUS"] = ring::to_string((int) DRing::Account::testAccountICEInitializationStatus::SUCCESS); + result["STATUS"] = jami::to_string((int) DRing::Account::testAccountICEInitializationStatus::SUCCESS); result["MESSAGE"] = ""; } @@ -2744,11 +2744,11 @@ Manager::addAccount(const std::map<std::string, std::string>& details, const std else accountType = AccountFactory::DEFAULT_ACCOUNT_TYPE; - RING_DBG("Adding account %s", newAccountID.c_str()); + JAMI_DBG("Adding account %s", newAccountID.c_str()); auto newAccount = accountFactory.createAccount(accountType, newAccountID); if (!newAccount) { - RING_ERR("Unknown %s param when calling addAccount(): %s", + JAMI_ERR("Unknown %s param when calling addAccount(): %s", Conf::CONFIG_ACCOUNT_TYPE, accountType); return ""; } @@ -2823,11 +2823,11 @@ Manager::loadAccountMap(const YAML::Node& node) int errorCount = 0; try { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videoPreferences.unserialize(node); #endif } catch (const YAML::Exception &e) { - RING_ERR("%s: No video node in config file", e.what()); + JAMI_ERR("%s: No video node in config file", e.what()); ++errorCount; } @@ -2864,7 +2864,7 @@ Manager::loadAccountMap(const YAML::Node& node) a->unserialize(parsedConfig); } } catch (const std::exception& e) { - RING_ERR("Can't import account %s: %s", dir.c_str(), e.what()); + JAMI_ERR("Can't import account %s: %s", dir.c_str(), e.what()); } } { @@ -2887,7 +2887,7 @@ Manager::getCallDetails(const std::string &callID) if (auto call = getCallFromCallID(callID)) { return call->getDetails(); } else { - RING_ERR("Call is NULL"); + JAMI_ERR("Call is NULL"); // FIXME: is this even useful? return Call::getNullDetails(); } @@ -2934,7 +2934,7 @@ Manager::getDisplayNames(const std::string& confID) const if (iter_conf != pimpl_->conferenceMap_.end()) { return iter_conf->second->getDisplayNames(); } else { - RING_WARN("Did not find conference %s", confID.c_str()); + JAMI_WARN("Did not find conference %s", confID.c_str()); } return v; @@ -2950,7 +2950,7 @@ Manager::getParticipantList(const std::string& confID) const const ParticipantSet participants(iter_conf->second->getParticipantList()); std::copy(participants.begin(), participants.end(), std::back_inserter(v));; } else - RING_WARN("Did not find conference %s", confID.c_str()); + JAMI_WARN("Did not find conference %s", confID.c_str()); return v; } @@ -2961,7 +2961,7 @@ Manager::getConferenceId(const std::string& callID) if (auto call = getCallFromCallID(callID)) return call->getConfId(); - RING_ERR("Call is NULL"); + JAMI_ERR("Call is NULL"); return ""; } @@ -2970,7 +2970,7 @@ Manager::startAudioDriverStream() { std::lock_guard<std::mutex> lock(pimpl_->audioLayerMutex_); if (!pimpl_->audiodriver_) { - RING_ERR("Audio driver not initialized"); + JAMI_ERR("Audio driver not initialized"); return; } pimpl_->audiodriver_->startStream(); @@ -3020,7 +3020,7 @@ Manager::sendTextMessage(const std::string& accountID, const std::string& to, try { return acc->sendTextMessage(to, payloads); } catch (const std::exception& e) { - RING_ERR("Exception during text message sending: %s", e.what()); + JAMI_ERR("Exception during text message sending: %s", e.what()); } } return 0; @@ -3094,14 +3094,14 @@ Manager::newOutgoingCall(const std::string& toUrl, { auto account = getAccount(accountId); if (account and !account->isUsable()) { - RING_WARN("Account is not usable for calling"); + JAMI_WARN("Account is not usable for calling"); return nullptr; } return account->newOutgoingCall(toUrl, volatileCallDetails); } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO std::shared_ptr<video::SinkClient> Manager::createSinkClient(const std::string& id, bool mixer) { @@ -3126,7 +3126,7 @@ Manager::getSinkClient(const std::string& id) return sink; return nullptr; } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO RingBufferPool& Manager::getRingBufferPool() @@ -3146,7 +3146,7 @@ Manager::getIceTransportFactory() return *pimpl_->ice_tf_; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO VideoManager& Manager::getVideoManager() const { @@ -3162,4 +3162,4 @@ Manager::getLastMessages(const std::string& accountID, const uint64_t& base_time return {}; } -} // namespace ring +} // namespace jami diff --git a/src/manager.h b/src/manager.h index 083d22eedf..27fc579785 100644 --- a/src/manager.h +++ b/src/manager.h @@ -44,7 +44,7 @@ #include <functional> #include <algorithm> -namespace ring { +namespace jami { namespace video { class SinkClient; @@ -89,7 +89,7 @@ class Manager { */ ShortcutPreferences shortcutPreferences; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /** * Video preferences */ @@ -860,7 +860,7 @@ class Manager { void addTask(std::function<bool()>&& task); std::shared_ptr<Task> scheduleTask(std::function<void()>&& task, std::chrono::steady_clock::time_point when); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /** * Create a new SinkClient instance, store it in an internal cache as a weak_ptr * and return it as a shared_ptr. If a SinkClient is already stored for the given id, @@ -880,7 +880,7 @@ class Manager { std::shared_ptr<video::SinkClient> getSinkClient(const std::string& id); VideoManager& getVideoManager() const; -#endif // RING_VIDEO +#endif // ENABLE_VIDEO std::atomic<unsigned> dhtLogLevel {0}; // default = disable AccountFactory accountFactory; @@ -905,4 +905,4 @@ static void runOnMainThread(Callback&& cb) { }); } -} // namespace ring +} // namespace jami diff --git a/src/map_utils.h b/src/map_utils.h index 3a9e1e0c83..6adeb7464e 100644 --- a/src/map_utils.h +++ b/src/map_utils.h @@ -25,7 +25,7 @@ #include <algorithm> #include <tuple> -namespace ring { namespace map_utils { +namespace jami { namespace map_utils { ///< Return the N-th type of a tuple type used as the Container compliant value type template <typename C, std::size_t N> @@ -55,4 +55,4 @@ inline auto extractValues(const M& map) -> decltype(extractElements<1>(map)) { return extractElements<1>(map); } -}} // namespace ring::map_utils +}} // namespace jami::map_utils diff --git a/src/media/Makefile.am b/src/media/Makefile.am index d3ec4c1e2c..72aa6621d7 100644 --- a/src/media/Makefile.am +++ b/src/media/Makefile.am @@ -4,7 +4,7 @@ noinst_LTLIBRARIES = libmedia.la SUBDIRS = audio -if RING_VIDEO +if ENABLE_VIDEO SUBDIRS += video endif @@ -48,7 +48,7 @@ noinst_HEADERS = \ libmedia_la_LIBADD = \ ./audio/libaudio.la -if RING_VIDEO +if ENABLE_VIDEO libmedia_la_libADD = \ ./video/libvideo.la endif diff --git a/src/media/audio/alsa/alsalayer.cpp b/src/media/audio/alsa/alsalayer.cpp index 906fffc686..b9aa338d64 100644 --- a/src/media/audio/alsa/alsalayer.cpp +++ b/src/media/audio/alsa/alsalayer.cpp @@ -35,7 +35,7 @@ #include <atomic> #include <chrono> -namespace ring { +namespace jami { class AlsaThread { public: @@ -180,7 +180,7 @@ void AlsaLayer::run() // Retry approach taken from pa_linux_alsa.c, part of PortAudio bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stream_t stream, AudioFormat& format) { - RING_DBG("Alsa: Opening %s", dev.c_str()); + JAMI_DBG("Alsa: Opening %s", dev.c_str()); static const int MAX_RETRIES = 20; // times of 100ms int err, tries = 0; @@ -197,7 +197,7 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre } while (err == -EBUSY and ++tries <= MAX_RETRIES); if (err < 0) { - RING_ERR("Alsa: couldn't open %s device %s : %s", + JAMI_ERR("Alsa: couldn't open %s device %s : %s", (stream == SND_PCM_STREAM_CAPTURE)? "capture" : (stream == SND_PCM_STREAM_PLAYBACK)? "playback" : "ringtone", dev.c_str(), @@ -266,7 +266,7 @@ AlsaLayer::stopStream() #define ALSA_CALL(call, error) ({ \ int err_code = call; \ if (err_code < 0) \ - RING_ERR(error ": %s", snd_strerror(err_code)); \ + JAMI_ERR(error ": %s", snd_strerror(err_code)); \ err_code; \ }) @@ -381,8 +381,8 @@ bool AlsaLayer::alsa_set_params(snd_pcm_t *pcm_handle, AudioFormat& format) snd_pcm_hw_params_get_buffer_size_max(hwparams, &buffer_size_max); snd_pcm_hw_params_get_period_size_min(hwparams, &period_size_min, nullptr); snd_pcm_hw_params_get_period_size_max(hwparams, &period_size_max, nullptr); - RING_DBG("Buffer size range from %lu to %lu", buffer_size_min, buffer_size_max); - RING_DBG("Period size range from %lu to %lu", period_size_min, period_size_max); + JAMI_DBG("Buffer size range from %lu to %lu", buffer_size_min, buffer_size_max); + JAMI_DBG("Period size range from %lu to %lu", period_size_min, period_size_max); buffer_size = buffer_size > buffer_size_max ? buffer_size_max : buffer_size; buffer_size = buffer_size < buffer_size_min ? buffer_size_min : buffer_size; period_size = period_size > period_size_max ? period_size_max : period_size; @@ -397,17 +397,17 @@ bool AlsaLayer::alsa_set_params(snd_pcm_t *pcm_handle, AudioFormat& format) snd_pcm_hw_params_get_period_size(hwparams, &period_size, nullptr); snd_pcm_hw_params_get_rate(hwparams, &format.sample_rate, nullptr); snd_pcm_hw_params_get_channels(hwparams, &format.nb_channels); - RING_DBG("Was set period_size = %lu", period_size); - RING_DBG("Was set buffer_size = %lu", buffer_size); + JAMI_DBG("Was set period_size = %lu", period_size); + JAMI_DBG("Was set buffer_size = %lu", buffer_size); if (2 * period_size > buffer_size) { - RING_ERR("buffer to small, could not use"); + JAMI_ERR("buffer to small, could not use"); return false; } #undef HW - RING_DBG("%s using format %s", + JAMI_DBG("%s using format %s", (snd_pcm_stream(pcm_handle) == SND_PCM_STREAM_PLAYBACK) ? "playback" : "capture", format.toString().c_str() ); @@ -463,12 +463,12 @@ AlsaLayer::write(const AudioFrame& buffer, snd_pcm_t * handle) if (ALSA_CALL(snd_pcm_status(handle, status), "Cannot get playback handle status") >= 0) { if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SETUP) { - RING_ERR("Writing in state SND_PCM_STATE_SETUP, should be " + JAMI_ERR("Writing in state SND_PCM_STATE_SETUP, should be " "SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING"); int error = snd_pcm_prepare(handle); if (error < 0) { - RING_ERR("Failed to prepare handle: %s", snd_strerror(error)); + JAMI_ERR("Failed to prepare handle: %s", snd_strerror(error)); stopPlaybackStream(); } } @@ -478,7 +478,7 @@ AlsaLayer::write(const AudioFrame& buffer, snd_pcm_t * handle) } default: - RING_ERR("Unknown write error, dropping frames: %s", snd_strerror(err)); + JAMI_ERR("Unknown write error, dropping frames: %s", snd_strerror(err)); stopPlaybackStream(); break; } @@ -514,12 +514,12 @@ AlsaLayer::read(unsigned frames) startCaptureStream(); } - RING_ERR("XRUN capture ignored (%s)", snd_strerror(err)); + JAMI_ERR("XRUN capture ignored (%s)", snd_strerror(err)); break; } case -EPERM: - RING_ERR("Can't capture, EPERM (%s)", snd_strerror(err)); + JAMI_ERR("Can't capture, EPERM (%s)", snd_strerror(err)); prepareCaptureStream(); startCaptureStream(); break; @@ -551,7 +551,7 @@ safeUpdate(snd_pcm_t *handle, long &samples) samples = snd_pcm_recover(handle, samples, 0); if (samples < 0) { - RING_ERR("Got unrecoverable error from snd_pcm_avail_update: %s", snd_strerror(samples)); + JAMI_ERR("Got unrecoverable error from snd_pcm_avail_update: %s", snd_strerror(samples)); return false; } } @@ -612,11 +612,11 @@ AlsaLayer::getAudioDeviceIndexMap(bool getCapture) const int err; if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) { - RING_WARN("Cannot get info for %s %s: %s", getCapture ? + JAMI_WARN("Cannot get info for %s %s: %s", getCapture ? "capture device" : "playback device", name.c_str(), snd_strerror(err)); } else { - RING_DBG("card %i : %s [%s]", + JAMI_DBG("card %i : %s [%s]", numCard, snd_ctl_card_info_get_id(info), snd_ctl_card_info_get_name(info)); @@ -683,7 +683,7 @@ AlsaLayer::getAudioDeviceName(int index, DeviceType type) const return getCaptureDeviceList().at(index); default: // Should never happen - RING_ERR("Unexpected type"); + JAMI_ERR("Unexpected type"); return ""; } } @@ -695,7 +695,7 @@ void AlsaLayer::capture() int toGetFrames = snd_pcm_avail_update(captureHandle_); if (toGetFrames < 0) - RING_ERR("Audio: Mic error: %s", snd_strerror(toGetFrames)); + JAMI_ERR("Audio: Mic error: %s", snd_strerror(toGetFrames)); if (toGetFrames <= 0) return; @@ -707,7 +707,7 @@ void AlsaLayer::capture() //dcblocker_.process(captureBuff_); mainRingBuffer_->put(std::move(r)); } else - RING_ERR("ALSA MIC : Couldn't read!"); + JAMI_ERR("ALSA MIC : Couldn't read!"); } void AlsaLayer::playback() @@ -760,4 +760,4 @@ void AlsaLayer::updatePreference(AudioPreference &preference, int index, DeviceT } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/alsa/alsalayer.h b/src/media/audio/alsa/alsalayer.h index aeb95ed504..2e9ce67d65 100644 --- a/src/media/audio/alsa/alsalayer.h +++ b/src/media/audio/alsa/alsalayer.h @@ -41,7 +41,7 @@ * @brief Main sound class. Manages the data transfers between the application and the hardware. */ -namespace ring { +namespace jami { class AlsaThread; class RingBuffer; @@ -253,6 +253,6 @@ class AlsaLayer : public AudioLayer { std::shared_ptr<RingBuffer> mainRingBuffer_; }; -} // namespace ring +} // namespace jami #endif // ALSA_LAYER_H_ diff --git a/src/media/audio/audio_frame_resizer.cpp b/src/media/audio/audio_frame_resizer.cpp index 44808a3b75..f561bcf069 100644 --- a/src/media/audio/audio_frame_resizer.cpp +++ b/src/media/audio/audio_frame_resizer.cpp @@ -28,7 +28,7 @@ extern "C" { #include <stdexcept> -namespace ring { +namespace jami { AudioFrameResizer::AudioFrameResizer(const AudioFormat& format, int size, std::function<void(std::shared_ptr<AudioFrame>&&)> cb) : format_(format) @@ -67,7 +67,7 @@ AudioFrameResizer::setFormat(const AudioFormat& format, int size) setFrameSize(size); if (format != format_) { if (auto discarded = samples()) - RING_WARN("Discarding %d samples", discarded); + JAMI_WARN("Discarding %d samples", discarded); av_audio_fifo_free(queue_); format_ = format; queue_ = av_audio_fifo_alloc(format.sampleFormat, format.nb_channels, frameSize_); @@ -92,7 +92,7 @@ AudioFrameResizer::enqueue(std::shared_ptr<AudioFrame>&& frame) auto f = frame->pointer(); AudioFormat format(f->sample_rate, f->channels, (AVSampleFormat)f->format); if (format != format_) { - RING_ERR() << "Expected " << format_ << ", but got " << AudioFormat(f->sample_rate, f->channels, (AVSampleFormat)f->format); + JAMI_ERR() << "Expected " << format_ << ", but got " << AudioFormat(f->sample_rate, f->channels, (AVSampleFormat)f->format); setFormat(format, frameSize_); } @@ -105,7 +105,7 @@ AudioFrameResizer::enqueue(std::shared_ptr<AudioFrame>&& frame) // queue reallocates itself if need be if ((ret = av_audio_fifo_write(queue_, reinterpret_cast<void**>(f->data), f->nb_samples)) < 0) { - RING_ERR() << "Audio resizer error: " << libav_utils::getError(ret); + JAMI_ERR() << "Audio resizer error: " << libav_utils::getError(ret); throw std::runtime_error("Failed to add audio to frame resizer"); } @@ -126,7 +126,7 @@ AudioFrameResizer::dequeue() auto frame = std::make_unique<AudioFrame>(format_, frameSize_); int ret; if ((ret = av_audio_fifo_read(queue_, reinterpret_cast<void**>(frame->pointer()->data), frameSize_)) < 0) { - RING_ERR() << "Could not read samples from queue: " << libav_utils::getError(ret); + JAMI_ERR() << "Could not read samples from queue: " << libav_utils::getError(ret); return {}; } frame->pointer()->pts = nextOutputPts_; @@ -134,4 +134,4 @@ AudioFrameResizer::dequeue() return frame; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_frame_resizer.h b/src/media/audio/audio_frame_resizer.h index 58a5f1d71b..3abba79ff3 100644 --- a/src/media/audio/audio_frame_resizer.h +++ b/src/media/audio/audio_frame_resizer.h @@ -28,7 +28,7 @@ struct AVAudioFifo; -namespace ring { +namespace jami { /** * Buffers extra samples. This is in case an input's frame size (number of samples in @@ -101,4 +101,4 @@ private: int64_t nextOutputPts_ {0}; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_input.cpp b/src/media/audio/audio_input.cpp index d85f35a5ac..82528e4a63 100644 --- a/src/media/audio/audio_input.cpp +++ b/src/media/audio/audio_input.cpp @@ -34,7 +34,7 @@ #include <chrono> #include <memory> -namespace ring { +namespace jami { static constexpr auto MS_PER_PACKET = std::chrono::milliseconds(20); @@ -50,7 +50,7 @@ AudioInput::AudioInput(const std::string& id) : [this] { process(); }, [] {}) { - RING_DBG() << "Creating audio input with id: " << id; + JAMI_DBG() << "Creating audio input with id: " << id; loop_.start(); } @@ -67,9 +67,9 @@ AudioInput::process() //foundDevOpts(devOpts_); if (switchPending_.exchange(false)) { if (devOpts_.input.empty()) - RING_DBG() << "Switching to default audio input"; + JAMI_DBG() << "Switching to default audio input"; else - RING_DBG() << "Switching audio input to '" << devOpts_.input << "'"; + JAMI_DBG() << "Switching audio input to '" << devOpts_.input << "'"; } readFromDevice(); @@ -122,7 +122,7 @@ AudioInput::readFromFile() switch(ret) { case MediaDecoder::Status::ReadError: case MediaDecoder::Status::DecodeError: - RING_ERR() << "Failed to decode frame"; + JAMI_ERR() << "Failed to decode frame"; break; case MediaDecoder::Status::RestartRequired: case MediaDecoder::Status::EOFError: @@ -151,7 +151,7 @@ bool AudioInput::initFile(const std::string& path) { if (access(path.c_str(), R_OK) != 0) { - RING_ERR() << "File '" << path << "' not available"; + JAMI_ERR() << "File '" << path << "' not available"; return false; } @@ -160,7 +160,7 @@ AudioInput::initFile(const std::string& path) devOpts_.loop = "1"; // sets devOpts_'s sample rate and number of channels if (!createDecoder()) { - RING_WARN() << "Cannot decode audio from file, switching back to default device"; + JAMI_WARN() << "Cannot decode audio from file, switching back to default device"; return initDevice(""); } fileBuf_ = Manager::instance().getRingBufferPool().createRingBuffer(fileId_); @@ -178,11 +178,11 @@ AudioInput::switchInput(const std::string& resource) // Always switch inputs, even if it's the same resource, so audio will be in sync with video if (switchPending_) { - RING_ERR() << "Audio switch already requested"; + JAMI_ERR() << "Audio switch already requested"; return {}; } - RING_DBG() << "Switching audio source to match '" << resource << "'"; + JAMI_DBG() << "Switching audio source to match '" << resource << "'"; decoder_.reset(); decodingFile_ = false; @@ -254,13 +254,13 @@ AudioInput::createDecoder() this); if (decoder->openInput(devOpts_) < 0) { - RING_ERR() << "Could not open input '" << devOpts_.input << "'"; + JAMI_ERR() << "Could not open input '" << devOpts_.input << "'"; foundDevOpts(devOpts_); return false; } if (decoder->setupFromAudioData() < 0) { - RING_ERR() << "Could not setup decoder for '" << devOpts_.input << "'"; + JAMI_ERR() << "Could not setup decoder for '" << devOpts_.input << "'"; foundDevOpts(devOpts_); return false; } @@ -268,7 +268,7 @@ AudioInput::createDecoder() auto ms = decoder->getStream(devOpts_.input); devOpts_.channel = ms.nbChannels; devOpts_.framerate = ms.sampleRate; - RING_DBG() << "Created audio decoder: " << ms; + JAMI_DBG() << "Created audio decoder: " << ms; decoder_ = std::move(decoder); foundDevOpts(devOpts_); @@ -297,4 +297,4 @@ AudioInput::getInfo() const return ms; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_input.h b/src/media/audio/audio_input.h index 3f3305d045..770a489330 100644 --- a/src/media/audio/audio_input.h +++ b/src/media/audio/audio_input.h @@ -31,7 +31,7 @@ #include "observer.h" #include "threadloop.h" -namespace ring { +namespace jami { class AudioFrameResizer; class MediaDecoder; @@ -89,4 +89,4 @@ private: void process(); }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_receive_thread.cpp b/src/media/audio/audio_receive_thread.cpp index a8173956d0..ffd765e3c2 100644 --- a/src/media/audio/audio_receive_thread.cpp +++ b/src/media/audio/audio_receive_thread.cpp @@ -32,7 +32,7 @@ #include <memory> -namespace ring { +namespace jami { AudioReceiveThread::AudioReceiveThread(const std::string& id, const AudioFormat& format, @@ -66,20 +66,20 @@ AudioReceiveThread::setup() args_.sdp_flags = "custom_io"; if (stream_.str().empty()) { - RING_ERR("No SDP loaded"); + JAMI_ERR("No SDP loaded"); return false; } audioDecoder_->setIOContext(sdpContext_.get()); if (audioDecoder_->openInput(args_)) { - RING_ERR("Could not open input \"%s\"", SDP_FILENAME); + JAMI_ERR("Could not open input \"%s\"", SDP_FILENAME); return false; } // Now replace our custom AVIOContext with one that will read packets audioDecoder_->setIOContext(demuxContext_.get()); if (audioDecoder_->setupFromAudioData()) { - RING_ERR("decoder IO startup failed"); + JAMI_ERR("decoder IO startup failed"); return false; } @@ -99,17 +99,17 @@ AudioReceiveThread::process() ringbuffer_->put(std::move(decodedFrame)); return; case MediaDecoder::Status::DecodeError: - RING_WARN("decoding failure, trying to reset decoder..."); + JAMI_WARN("decoding failure, trying to reset decoder..."); if (not setup()) { - RING_ERR("fatal error, rx thread re-setup failed"); + JAMI_ERR("fatal error, rx thread re-setup failed"); loop_.stop(); } else if (not audioDecoder_->setupFromAudioData()) { - RING_ERR("fatal error, a-decoder setup failed"); + JAMI_ERR("fatal error, a-decoder setup failed"); loop_.stop(); } break; case MediaDecoder::Status::ReadError: - RING_ERR("fatal error, read failed"); + JAMI_ERR("fatal error, read failed"); loop_.stop(); break; case MediaDecoder::Status::Success: @@ -162,4 +162,4 @@ AudioReceiveThread::startLoop() loop_.start(); } -}; // namespace ring +}; // namespace jami diff --git a/src/media/audio/audio_receive_thread.h b/src/media/audio/audio_receive_thread.h index 22a205d01e..af1aea0732 100644 --- a/src/media/audio/audio_receive_thread.h +++ b/src/media/audio/audio_receive_thread.h @@ -29,7 +29,7 @@ #include <sstream> -namespace ring { +namespace jami { class MediaDecoder; class MediaIOHandle; @@ -84,4 +84,4 @@ private: void cleanup(); }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_rtp_session.cpp b/src/media/audio/audio_rtp_session.cpp index bc2a56e891..306157580b 100644 --- a/src/media/audio/audio_rtp_session.cpp +++ b/src/media/audio/audio_rtp_session.cpp @@ -46,7 +46,7 @@ #include "smartools.h" #include <sstream> -namespace ring { +namespace jami { AudioRtpSession::AudioRtpSession(const std::string& id) : RtpSession(id) @@ -64,7 +64,7 @@ void AudioRtpSession::startSender() { if (not send_.enabled or send_.holding) { - RING_WARN("Audio sending disabled"); + JAMI_WARN("Audio sending disabled"); if (sender_) { if (socketPair_) socketPair_->interrupt(); @@ -74,21 +74,21 @@ AudioRtpSession::startSender() } if (sender_) - RING_WARN("Restarting audio sender"); + JAMI_WARN("Restarting audio sender"); // sender sets up input correctly, we just keep a reference in case startSender is called - audioInput_ = ring::getAudioInput(callID_); + audioInput_ = jami::getAudioInput(callID_); auto newParams = audioInput_->switchInput(input_); try { if (newParams.valid() && newParams.wait_for(NEWPARAMS_TIMEOUT) == std::future_status::ready) { localAudioParams_ = newParams.get(); } else { - RING_ERR() << "No valid new audio parameters"; + JAMI_ERR() << "No valid new audio parameters"; return; } } catch (const std::exception& e) { - RING_ERR() << "Exception while retrieving audio parameters: " << e.what(); + JAMI_ERR() << "Exception while retrieving audio parameters: " << e.what(); return; } @@ -102,7 +102,7 @@ AudioRtpSession::startSender() sender_.reset(new AudioSender(callID_, getRemoteRtpUri(), send_, *socketPair_, initSeqVal_, muteState_, mtu_)); } catch (const MediaEncoderException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); send_.enabled = false; } } @@ -122,13 +122,13 @@ void AudioRtpSession::startReceiver() { if (not receive_.enabled or receive_.holding) { - RING_WARN("Audio receiving disabled"); + JAMI_WARN("Audio receiving disabled"); receiveThread_.reset(); return; } if (receiveThread_) - RING_WARN("Restarting audio receiver"); + JAMI_WARN("Restarting audio receiver"); auto accountAudioCodec = std::static_pointer_cast<AccountAudioCodecInfo>(receive_.codec); receiveThread_.reset(new AudioReceiveThread(callID_, accountAudioCodec->audioformat, @@ -161,7 +161,7 @@ AudioRtpSession::start(std::unique_ptr<IceSocket> rtp_sock, std::unique_ptr<IceS send_.crypto.getSrtpKeyInfo().c_str()); } } catch (const std::runtime_error& e) { - RING_ERR("Socket creation failed: %s", e.what()); + JAMI_ERR("Socket creation failed: %s", e.what()); return; } @@ -196,7 +196,7 @@ AudioRtpSession::initRecorder(std::shared_ptr<MediaRecorder>& rec) { if (receiveThread_) receiveThread_->attach(rec->addStream(receiveThread_->getInfo())); - if (auto input = ring::getAudioInput(callID_)) + if (auto input = jami::getAudioInput(callID_)) input->attach(rec->addStream(input->getInfo())); } @@ -208,11 +208,11 @@ AudioRtpSession::deinitRecorder(std::shared_ptr<MediaRecorder>& rec) receiveThread_->detach(ob); } } - if (auto input = ring::getAudioInput(callID_)) { + if (auto input = jami::getAudioInput(callID_)) { if (auto ob = rec->getStream(input->getInfo().name)) { input->detach(ob); } } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_rtp_session.h b/src/media/audio/audio_rtp_session.h index a32b23a5fc..faac7acd0e 100644 --- a/src/media/audio/audio_rtp_session.h +++ b/src/media/audio/audio_rtp_session.h @@ -30,7 +30,7 @@ #include <string> #include <memory> -namespace ring { +namespace jami { class AudioInput; class AudioReceiveThread; @@ -69,6 +69,6 @@ class AudioRtpSession : public RtpSession { std::string input_; }; -} // namespace ring +} // namespace jami #endif // __AUDIO_RTP_SESSION_H__ diff --git a/src/media/audio/audio_sender.cpp b/src/media/audio/audio_sender.cpp index c4dd029821..ff0ff1f002 100644 --- a/src/media/audio/audio_sender.cpp +++ b/src/media/audio/audio_sender.cpp @@ -32,7 +32,7 @@ #include <memory> -namespace ring { +namespace jami { AudioSender::AudioSender(const std::string& id, const std::string& dest, @@ -69,7 +69,7 @@ AudioSender::setup(SocketPair& socketPair) try { /* Encoder setup */ - RING_DBG("audioEncoder_->openOutput %s", dest_.c_str()); + JAMI_DBG("audioEncoder_->openOutput %s", dest_.c_str()); audioEncoder_->openOutput(dest_, "rtp"); audioEncoder_->setOptions(args_); auto codec = std::static_pointer_cast<AccountAudioCodecInfo>(args_.codec); @@ -79,7 +79,7 @@ AudioSender::setup(SocketPair& socketPair) audioEncoder_->setInitSeqVal(seqVal_); audioEncoder_->setIOContext(muxContext_->getContext()); } catch (const MediaEncoderException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); return false; } @@ -91,7 +91,7 @@ AudioSender::setup(SocketPair& socketPair) // NOTE do after encoder is ready to encode auto codec = std::static_pointer_cast<AccountAudioCodecInfo>(args_.codec); - audioInput_ = ring::getAudioInput(id_); + audioInput_ = jami::getAudioInput(id_); audioInput_->setFormat(codec->audioformat); audioInput_->attach(this); @@ -99,7 +99,7 @@ AudioSender::setup(SocketPair& socketPair) } void -AudioSender::update(Observable<std::shared_ptr<ring::MediaFrame>>* /*obs*/, const std::shared_ptr<ring::MediaFrame>& framePtr) +AudioSender::update(Observable<std::shared_ptr<jami::MediaFrame>>* /*obs*/, const std::shared_ptr<jami::MediaFrame>& framePtr) { auto frame = framePtr->pointer(); auto ms = MediaStream("a:local", frame->format, rational<int>(1, frame->sample_rate), @@ -109,7 +109,7 @@ AudioSender::update(Observable<std::shared_ptr<ring::MediaFrame>>* /*obs*/, cons sent_samples += frame->nb_samples; if (audioEncoder_->encodeAudio(*std::static_pointer_cast<AudioFrame>(framePtr)) < 0) - RING_ERR("encoding failed"); + JAMI_ERR("encoding failed"); } void @@ -125,4 +125,4 @@ AudioSender::getLastSeqValue() return audioEncoder_->getLastSeqValue(); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audio_sender.h b/src/media/audio/audio_sender.h index b67515657c..2d2b123bca 100644 --- a/src/media/audio/audio_sender.h +++ b/src/media/audio/audio_sender.h @@ -26,7 +26,7 @@ #include "observer.h" #include "socket_pair.h" -namespace ring { +namespace jami { class AudioInput; class MediaEncoder; @@ -47,8 +47,8 @@ public: void setMuted(bool isMuted); uint16_t getLastSeqValue(); - void update(Observable<std::shared_ptr<ring::MediaFrame>>*, - const std::shared_ptr<ring::MediaFrame>&) override; + void update(Observable<std::shared_ptr<jami::MediaFrame>>*, + const std::shared_ptr<jami::MediaFrame>&) override; private: NON_COPYABLE(AudioSender); @@ -72,4 +72,4 @@ private: uint16_t mtu_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audiobuffer.cpp b/src/media/audio/audiobuffer.cpp index 0e9ed5e5e9..acbf4b25de 100644 --- a/src/media/audio/audiobuffer.cpp +++ b/src/media/audio/audiobuffer.cpp @@ -25,7 +25,7 @@ #include <cstring> // memset #include <algorithm> -namespace ring { +namespace jami { std::ostream& operator <<(std::ostream& stream, const AudioFormat& f) { stream << f.toString(); @@ -106,7 +106,7 @@ void AudioBuffer::setChannelNum(unsigned n, bool mix /* = false */) return; } - RING_WARN("Unsupported channel mixing: %dch->%dch", c, n); + JAMI_WARN("Unsupported channel mixing: %dch->%dch", c, n); samples_.resize(n, samples_[0]); } @@ -131,7 +131,7 @@ std::vector<AudioSample> * AudioBuffer::getChannel(unsigned chan /* = 0 */) if (chan < samples_.size()) return &samples_[chan]; - RING_ERR("Audio channel %u out of range", chan); + JAMI_ERR("Audio channel %u out of range", chan); return nullptr; } @@ -141,7 +141,7 @@ void AudioBuffer::applyGain(double gain) const double g = std::max(std::min(1.0, gain), -1.0); if (g != gain) - RING_DBG("Normalizing %f to [-1.0, 1.0]", gain); + JAMI_DBG("Normalizing %f to [-1.0, 1.0]", gain); for (auto &channel : samples_) for (auto &sample : channel) @@ -329,4 +329,4 @@ AudioBuffer::append(const AudioFrame& audioFrame) return 0; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audiobuffer.h b/src/media/audio/audiobuffer.h index ff1f0105ee..30b1656eff 100644 --- a/src/media/audio/audiobuffer.h +++ b/src/media/audio/audiobuffer.h @@ -41,7 +41,7 @@ extern "C" { struct AVFrame; -namespace ring { +namespace jami { /** * Structure to hold sample rate and channel number associated with audio data. @@ -375,6 +375,6 @@ class AudioBuffer { std::vector<std::vector<AudioSample> > samples_; }; -} // namespace ring +} // namespace jami #endif // _AUDIO_BUFFER_H diff --git a/src/media/audio/audiolayer.cpp b/src/media/audio/audiolayer.cpp index 7cbf7546b4..d0d5583909 100644 --- a/src/media/audio/audiolayer.cpp +++ b/src/media/audio/audiolayer.cpp @@ -31,7 +31,7 @@ #include <ctime> #include <algorithm> -namespace ring { +namespace jami { AudioLayer::AudioLayer(const AudioPreference &pref) : isCaptureMuted_(pref.getCaptureMuted()) @@ -54,14 +54,14 @@ AudioLayer::~AudioLayer() void AudioLayer::hardwareFormatAvailable(AudioFormat playback) { std::lock_guard<std::mutex> lock(mutex_); - RING_DBG("Hardware audio format available : %s", playback.toString().c_str()); + JAMI_DBG("Hardware audio format available : %s", playback.toString().c_str()); audioFormat_ = Manager::instance().hardwareAudioFormatChanged(playback); urgentRingBuffer_.setFormat(playback); } void AudioLayer::hardwareInputFormatAvailable(AudioFormat capture) { - RING_DBG("Hardware input audio format available : %s", capture.toString().c_str()); + JAMI_DBG("Hardware input audio format available : %s", capture.toString().c_str()); } void AudioLayer::devicesChanged() @@ -168,4 +168,4 @@ AudioLayer::getToPlay(AudioFormat format, size_t writableSamples) return playbackBuf; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audiolayer.h b/src/media/audio/audiolayer.h index fe995ef96c..2821555d01 100644 --- a/src/media/audio/audiolayer.h +++ b/src/media/audio/audiolayer.h @@ -52,7 +52,7 @@ #define PCM_DSNOOP "plug:dsnoop" // Alsa plugin for microphone sharing #define PCM_DMIX_DSNOOP "dmix/dsnoop" // Audio profile using Alsa dmix/dsnoop -namespace ring { +namespace jami { class AudioPreference; class Resampler; @@ -322,6 +322,6 @@ class AudioLayer { std::chrono::system_clock::time_point lastNotificationTime_; }; -} // namespace ring +} // namespace jami #endif // _AUDIO_LAYER_H_ diff --git a/src/media/audio/audioloop.cpp b/src/media/audio/audioloop.cpp index 9cf282dfba..8e7a730913 100644 --- a/src/media/audio/audioloop.cpp +++ b/src/media/audio/audioloop.cpp @@ -31,7 +31,7 @@ #include <algorithm> // std::min -namespace ring { +namespace jami { AudioLoop::AudioLoop(unsigned int sampleRate) : buffer_(new AudioBuffer(0, AudioFormat(sampleRate, 1))), pos_(0) @@ -52,7 +52,7 @@ void AudioLoop::getNext(AudioBuffer& output, double gain) { if (!buffer_) { - RING_ERR("buffer is NULL"); + JAMI_ERR("buffer is NULL"); return; } @@ -62,10 +62,10 @@ AudioLoop::getNext(AudioBuffer& output, double gain) size_t output_pos = 0; if (buf_samples == 0) { - RING_ERR("Audio loop size is 0"); + JAMI_ERR("Audio loop size is 0"); return; } else if (pos >= buf_samples) { - RING_ERR("Invalid loop position %zu", pos); + JAMI_ERR("Invalid loop position %zu", pos); return; } @@ -95,4 +95,4 @@ AudioLoop::getNext(size_t samples) return buff.toAVFrame(); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/audioloop.h b/src/media/audio/audioloop.h index 3545e339dc..447611697a 100644 --- a/src/media/audio/audioloop.h +++ b/src/media/audio/audioloop.h @@ -32,7 +32,7 @@ * @brief Loop on a sound file */ -namespace ring { +namespace jami { class AudioLoop { public: @@ -89,5 +89,5 @@ class AudioLoop { virtual void onBufferFinish(); }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/coreaudio/ios/corelayer.cpp b/src/media/audio/coreaudio/ios/corelayer.cpp index a3c1c39e47..d1c2c3b183 100644 --- a/src/media/audio/coreaudio/ios/corelayer.cpp +++ b/src/media/audio/coreaudio/ios/corelayer.cpp @@ -32,7 +32,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -namespace ring { +namespace jami { // AudioLayer implementation. CoreLayer::CoreLayer(const AudioPreference &pref) @@ -89,7 +89,7 @@ CoreLayer::getAudioDeviceName(int index, DeviceType type) const void CoreLayer::initAudioLayerIO() { - RING_DBG("iOS CoreLayer - initializing audio session"); + JAMI_DBG("iOS CoreLayer - initializing audio session"); AudioComponentDescription outputUnitDescription; outputUnitDescription.componentType = kAudioUnitType_Output; @@ -100,7 +100,7 @@ CoreLayer::initAudioLayerIO() auto comp = AudioComponentFindNext(nullptr, &outputUnitDescription); if (comp == nullptr) { - RING_ERR("Can't find default output audio component."); + JAMI_ERR("Can't find default output audio component."); return; } @@ -112,7 +112,7 @@ CoreLayer::initAudioLayerIO() &audioCategory); auto playBackDeviceList = getPlaybackDeviceList(); - RING_DBG("Setting playback device: %s", playBackDeviceList[indexOut_].c_str()); + JAMI_DBG("Setting playback device: %s", playBackDeviceList[indexOut_].c_str()); switch(indexOut_) { case 0: UInt32 setSpeaker; @@ -142,7 +142,7 @@ CoreLayer::initAudioLayerIO() void CoreLayer::setupOutputBus() { - RING_DBG("iOS CoreLayer - initializing output bus"); + JAMI_DBG("iOS CoreLayer - initializing output bus"); AudioUnitScope outputBus = 0; UInt32 size; @@ -188,7 +188,7 @@ CoreLayer::setupOutputBus() { void CoreLayer::setupInputBus() { - RING_DBG("Initializing input bus"); + JAMI_DBG("Initializing input bus"); AudioUnitScope inputBus = 1; UInt32 size; @@ -310,7 +310,7 @@ CoreLayer::bindCallbacks() { void CoreLayer::startStream() { - RING_DBG("iOS CoreLayer - Start Stream"); + JAMI_DBG("iOS CoreLayer - Start Stream"); { std::lock_guard<std::mutex> lock(mutex_); @@ -339,7 +339,7 @@ CoreLayer::destroyAudioLayer() void CoreLayer::stopStream() { - RING_DBG("iOS CoreLayer - Stop Stream"); + JAMI_DBG("iOS CoreLayer - Stop Stream"); { std::lock_guard<std::mutex> lock(mutex_); @@ -415,7 +415,7 @@ CoreLayer::read(AudioUnitRenderActionFlags* ioActionFlags, (void) ioData; if (inNumberFrames <= 0) { - RING_WARN("No frames for input."); + JAMI_WARN("No frames for input."); return; } @@ -460,6 +460,6 @@ void CoreLayer::updatePreference(AudioPreference &preference, int index, DeviceT } } -} // namespace ring +} // namespace jami #pragma GCC diagnostic pop diff --git a/src/media/audio/coreaudio/ios/corelayer.h b/src/media/audio/coreaudio/ios/corelayer.h index f5caf2dfd0..8fa8cb4d7f 100644 --- a/src/media/audio/coreaudio/ios/corelayer.h +++ b/src/media/audio/coreaudio/ios/corelayer.h @@ -29,7 +29,7 @@ #define checkErr( err) \ if(err) { \ - RING_ERR("CoreAudio Error: %ld", static_cast<long>(err)); \ + JAMI_ERR("CoreAudio Error: %ld", static_cast<long>(err)); \ } /** @@ -37,7 +37,7 @@ * @brief Main iOS sound class. Manages the data transfers between the application and the hardware. */ -namespace ring { +namespace jami { class RingBuffer; @@ -170,6 +170,6 @@ class CoreLayer : public AudioLayer { std::shared_ptr<RingBuffer> mainRingBuffer_; }; -} // namespace ring +} // namespace jami #endif // CORE_LAYER_H_ diff --git a/src/media/audio/coreaudio/osx/audiodevice.cpp b/src/media/audio/coreaudio/osx/audiodevice.cpp index 3c753ab216..4fd750f2be 100644 --- a/src/media/audio/coreaudio/osx/audiodevice.cpp +++ b/src/media/audio/coreaudio/osx/audiodevice.cpp @@ -22,7 +22,7 @@ #if !TARGET_OS_IPHONE -namespace ring { +namespace jami { AudioDevice::AudioDevice(AudioDeviceID devid, bool isInput) { @@ -169,6 +169,6 @@ std::string AudioDevice::getName() const return buf; } -} // namespace ring +} // namespace jami #endif // TARGET_OS_IPHONE diff --git a/src/media/audio/coreaudio/osx/audiodevice.h b/src/media/audio/coreaudio/osx/audiodevice.h index 670256cae6..f9c268c477 100644 --- a/src/media/audio/coreaudio/osx/audiodevice.h +++ b/src/media/audio/coreaudio/osx/audiodevice.h @@ -30,7 +30,7 @@ #include <string> -namespace ring { +namespace jami { class AudioDevice { #if !TARGET_OS_IPHONE diff --git a/src/media/audio/coreaudio/osx/corelayer.cpp b/src/media/audio/coreaudio/osx/corelayer.cpp index 317ee533d3..592d3577cc 100644 --- a/src/media/audio/coreaudio/osx/corelayer.cpp +++ b/src/media/audio/coreaudio/osx/corelayer.cpp @@ -29,7 +29,7 @@ #include <cmath> #include <vector> -namespace ring { +namespace jami { // AudioLayer implementation. CoreLayer::CoreLayer(const AudioPreference &pref) @@ -87,7 +87,7 @@ CoreLayer::initAudioLayerIO() // 3) Set the audio unit callback. // 4) Initialize everything. // 5) Profit... - RING_DBG("INIT AUDIO IO"); + JAMI_DBG("INIT AUDIO IO"); AudioUnitScope outputBus = 0; AudioUnitScope inputBus = 1; @@ -100,7 +100,7 @@ CoreLayer::initAudioLayerIO() auto comp = AudioComponentFindNext(nullptr, &desc); if (comp == nullptr) { - RING_ERR("Can't find default output audio component."); + JAMI_ERR("Can't find default output audio component."); return; } @@ -224,7 +224,7 @@ CoreLayer::initAudioLayerIO() void CoreLayer::startStream() { - RING_DBG("START STREAM"); + JAMI_DBG("START STREAM"); { std::lock_guard<std::mutex> lock(mutex_); @@ -253,7 +253,7 @@ CoreLayer::destroyAudioLayer() void CoreLayer::stopStream() { - RING_DBG("STOP STREAM"); + JAMI_DBG("STOP STREAM"); { std::lock_guard<std::mutex> lock(mutex_); @@ -323,7 +323,7 @@ CoreLayer::read(AudioUnitRenderActionFlags* ioActionFlags, AudioBufferList* ioData) { if (inNumberFrames <= 0) { - RING_WARN("No frames for input."); + JAMI_WARN("No frames for input."); return; } @@ -405,4 +405,4 @@ CoreLayer::getDeviceList(bool getCapture) const return ret; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/coreaudio/osx/corelayer.h b/src/media/audio/coreaudio/osx/corelayer.h index 749d04436f..588da0ed84 100644 --- a/src/media/audio/coreaudio/osx/corelayer.h +++ b/src/media/audio/coreaudio/osx/corelayer.h @@ -42,7 +42,7 @@ * @brief Main OSX sound class. Manages the data transfers between the application and the hardware. */ -namespace ring { +namespace jami { class RingBuffer; class AudioDevice; @@ -177,6 +177,6 @@ class CoreLayer : public AudioLayer { std::vector<AudioDevice> getDeviceList(bool getCapture) const; }; -} // namespace ring +} // namespace jami #endif // CORE_LAYER_H_ diff --git a/src/media/audio/dcblocker.cpp b/src/media/audio/dcblocker.cpp index f4492f509d..f579f80449 100644 --- a/src/media/audio/dcblocker.cpp +++ b/src/media/audio/dcblocker.cpp @@ -22,7 +22,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { DcBlocker::DcBlocker(unsigned channels /* = 1 */) : states(channels, StreamState{0, 0, 0, 0}) @@ -67,4 +67,4 @@ void DcBlocker::process(AudioBuffer& buf) } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/dcblocker.h b/src/media/audio/dcblocker.h index be16270b2b..559a7817d2 100644 --- a/src/media/audio/dcblocker.h +++ b/src/media/audio/dcblocker.h @@ -25,7 +25,7 @@ #include "ring_types.h" #include "audiobuffer.h" -namespace ring { +namespace jami { class DcBlocker { public: @@ -49,6 +49,6 @@ class DcBlocker { std::vector<StreamState> states; }; -} // namespace ring +} // namespace jami #endif diff --git a/src/media/audio/dsp.cpp b/src/media/audio/dsp.cpp index 97a15d3d5d..5d0fa3f86a 100644 --- a/src/media/audio/dsp.cpp +++ b/src/media/audio/dsp.cpp @@ -22,7 +22,7 @@ #include "dsp.h" #include "audiobuffer.h" -namespace ring { +namespace jami { void DSP::speexStateDeleter(SpeexPreprocessState *state) @@ -78,7 +78,7 @@ void DSP::disableDenoise() void DSP::process(AudioBuffer& buff, int samples) { if (samples != smplPerFrame_) { - RING_WARN("Unexpected amount of samples"); + JAMI_WARN("Unexpected amount of samples"); return; } @@ -91,4 +91,4 @@ void DSP::process(AudioBuffer& buff, int samples) } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/dsp.h b/src/media/audio/dsp.h index 452058e12b..bf5eb2f1a4 100644 --- a/src/media/audio/dsp.h +++ b/src/media/audio/dsp.h @@ -27,7 +27,7 @@ #include <memory> #include "noncopyable.h" -namespace ring { +namespace jami { class AudioBuffer; @@ -50,6 +50,6 @@ class DSP { std::vector<SpeexStatePtr> dspStates_; }; -} // namespace ring +} // namespace jami #endif // DSP_H_ diff --git a/src/media/audio/jack/jacklayer.cpp b/src/media/audio/jack/jacklayer.cpp index 300909c310..1ac3a92b0b 100644 --- a/src/media/audio/jack/jacklayer.cpp +++ b/src/media/audio/jack/jacklayer.cpp @@ -42,7 +42,7 @@ * auto connect optional */ -namespace ring { +namespace jami { namespace { @@ -55,12 +55,12 @@ void connectPorts(jack_client_t *client, int portType, const std::vector<jack_po const char *port = jack_port_name(ports[i]); if (portType & JackPortIsInput) { if (jack_connect(client, port, physical_ports[i])) { - RING_ERR("Can't connect %s to %s", port, physical_ports[i]); + JAMI_ERR("Can't connect %s to %s", port, physical_ports[i]); break; } } else { if (jack_connect(client, physical_ports[i], port)) { - RING_ERR("Can't connect port %s to %s", physical_ports[i], port); + JAMI_ERR("Can't connect port %s to %s", physical_ports[i], port); break; } } @@ -247,9 +247,9 @@ JackLayer::~JackLayer() jack_port_unregister(captureClient_, p); if (jack_client_close(playbackClient_)) - RING_ERR("JACK client could not close"); + JAMI_ERR("JACK client could not close"); if (jack_client_close(captureClient_)) - RING_ERR("JACK client could not close"); + JAMI_ERR("JACK client could not close"); for (auto r : out_ringbuffers_) jack_ringbuffer_free(r); @@ -304,7 +304,7 @@ JackLayer::process_capture(jack_nframes_t frames, void *arg) // fill the rest with silence if (bytes_to_rb < bytes_to_read) { // TODO: set some flag for underrun? - RING_WARN("Dropped %lu bytes", bytes_to_read - bytes_to_rb); + JAMI_WARN("Dropped %lu bytes", bytes_to_read - bytes_to_rb); } } @@ -358,7 +358,7 @@ JackLayer::startStream() dcblocker_.reset(); if (jack_activate(playbackClient_) or jack_activate(captureClient_)) { - RING_ERR("Could not activate JACK client"); + JAMI_ERR("Could not activate JACK client"); return; } ringbuffer_thread_ = std::thread(&JackLayer::ringbuffer_worker, this); @@ -369,7 +369,7 @@ JackLayer::startStream() void JackLayer::onShutdown(void * /* data */) { - RING_WARN("JACK server shutdown"); + JAMI_WARN("JACK server shutdown"); // FIXME: handle this safely } @@ -388,7 +388,7 @@ JackLayer::stopStream() data_ready_.notify_one(); if (jack_deactivate(playbackClient_) or jack_deactivate(captureClient_)) { - RING_ERR("JACK client could not deactivate"); + JAMI_ERR("JACK client could not deactivate"); } if (ringbuffer_thread_.joinable()) @@ -398,4 +398,4 @@ JackLayer::stopStream() flushUrgent(); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/jack/jacklayer.h b/src/media/audio/jack/jacklayer.h index f7be728b61..3f6f1c6328 100644 --- a/src/media/audio/jack/jacklayer.h +++ b/src/media/audio/jack/jacklayer.h @@ -33,7 +33,7 @@ #include <condition_variable> #include <memory> -namespace ring { +namespace jami { class RingBuffer; diff --git a/src/media/audio/opensl/audio_common.h b/src/media/audio/opensl/audio_common.h index a72665a63c..b52b0c3891 100644 --- a/src/media/audio/opensl/audio_common.h +++ b/src/media/audio/opensl/audio_common.h @@ -22,7 +22,7 @@ #include "buf_manager.h" -namespace ring { +namespace jami { namespace opensl { /* @@ -33,7 +33,7 @@ namespace opensl { #define DEVICE_SHADOW_BUFFER_QUEUE_LEN 4 #define BUF_COUNT 16 -inline SLDataFormat_PCM convertToSLSampleFormat(const ring::AudioFormat& infos) +inline SLDataFormat_PCM convertToSLSampleFormat(const jami::AudioFormat& infos) { return SLDataFormat_PCM { .formatType = SL_DATAFORMAT_PCM, diff --git a/src/media/audio/opensl/audio_player.cpp b/src/media/audio/opensl/audio_player.cpp index 5283081ab8..dfd7b3be5e 100644 --- a/src/media/audio/opensl/audio_player.cpp +++ b/src/media/audio/opensl/audio_player.cpp @@ -22,7 +22,7 @@ #include <cstdlib> -namespace ring { +namespace jami { namespace opensl { /* @@ -46,7 +46,7 @@ void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { // so recorder could re-use it sample_buf *buf; if(!devShadowQueue_.front(&buf)) { - RING_ERR("AudioPlayer buffer lost"); + JAMI_ERR("AudioPlayer buffer lost"); /* * This should not happen: we got a callback, * but we have no buffer in deviceShadowedQueue @@ -58,7 +58,7 @@ void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { devShadowQueue_.pop(); buf->size_ = 0; if (!freeQueue_->push(buf)) { - RING_ERR("buffer lost"); + JAMI_ERR("buffer lost"); } callback_(false); @@ -66,19 +66,19 @@ void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { while(playQueue_->front(&buf) && devShadowQueue_.push(buf)) { if ((*bq)->Enqueue(bq, buf->buf_, buf->size_) != SL_RESULT_SUCCESS) { devShadowQueue_.pop(); - RING_ERR("enqueue failed %zu %zu %zu %zu", buf->size_, freeQueue_->size(), playQueue_->size(), devShadowQueue_.size()); + JAMI_ERR("enqueue failed %zu %zu %zu %zu", buf->size_, freeQueue_->size(), playQueue_->size(), devShadowQueue_.size()); break; } else playQueue_->pop(); } if (devShadowQueue_.size() == 0) { - RING_ERR("AudioPlayer: nothing to play %zu %zu %zu", freeQueue_->size(), playQueue_->size(), devShadowQueue_.size()); + JAMI_ERR("AudioPlayer: nothing to play %zu %zu %zu", freeQueue_->size(), playQueue_->size(), devShadowQueue_.size()); waiting_ = true; callback_(true); } } -AudioPlayer::AudioPlayer(ring::AudioFormat sampleFormat, SLEngineItf slEngine, SLint32 streamType) : +AudioPlayer::AudioPlayer(jami::AudioFormat sampleFormat, SLEngineItf slEngine, SLint32 streamType) : sampleInfo_(sampleFormat) { SLresult result; @@ -175,7 +175,7 @@ bool AudioPlayer::start() { if(SL_RESULT_SUCCESS != (*playBufferQueueItf_)->Enqueue(playBufferQueueItf_, buf, buf->size_)) { - RING_ERR("====failed to enqueue (%d) in %s", i, __FUNCTION__); + JAMI_ERR("====failed to enqueue (%d) in %s", i, __FUNCTION__); return false; } else { playQueue_->pop(); @@ -227,7 +227,7 @@ void AudioPlayer::playAudioBuffers(unsigned count) { while (count--) { sample_buf *buf = nullptr; if(!playQueue_->front(&buf)) { - RING_ERR("====Run out of buffers in %s @(count = %d)", __FUNCTION__, count); + JAMI_ERR("====Run out of buffers in %s @(count = %d)", __FUNCTION__, count); break; } if(!devShadowQueue_.push(buf)) { @@ -237,7 +237,7 @@ void AudioPlayer::playAudioBuffers(unsigned count) { SLresult result = (*playBufferQueueItf_)->Enqueue(playBufferQueueItf_, buf->buf_, buf->size_); if(result != SL_RESULT_SUCCESS) { - RING_ERR("%s Error @( %p, %d ), result = %d", __FUNCTION__, (void*)buf->buf_, buf->size_, result); + JAMI_ERR("%s Error @( %p, %d ), result = %d", __FUNCTION__, (void*)buf->buf_, buf->size_, result); /* * when this happens, a buffer is lost. Need to remove the buffer * from top of the devShadowQueue. Since I do not have it now, diff --git a/src/media/audio/opensl/audio_player.h b/src/media/audio/opensl/audio_player.h index 2b86070834..7fc470b8c6 100644 --- a/src/media/audio/opensl/audio_player.h +++ b/src/media/audio/opensl/audio_player.h @@ -26,7 +26,7 @@ #include <mutex> -namespace ring { +namespace jami { namespace opensl { class AudioPlayer { @@ -36,7 +36,7 @@ class AudioPlayer { SLPlayItf playItf_; SLAndroidSimpleBufferQueueItf playBufferQueueItf_; - ring::AudioFormat sampleInfo_; + jami::AudioFormat sampleInfo_; AudioQueue *freeQueue_ {nullptr}; // user AudioQueue *playQueue_ {nullptr}; // user AudioQueue devShadowQueue_ {DEVICE_SHADOW_BUFFER_QUEUE_LEN}; // owner @@ -44,7 +44,7 @@ class AudioPlayer { EngineCallback callback_ {}; public: - explicit AudioPlayer(ring::AudioFormat sampleFormat, SLEngineItf engine, SLint32 streamType); + explicit AudioPlayer(jami::AudioFormat sampleFormat, SLEngineItf engine, SLint32 streamType); ~AudioPlayer(); NON_COPYABLE(AudioPlayer); diff --git a/src/media/audio/opensl/audio_recorder.cpp b/src/media/audio/opensl/audio_recorder.cpp index e4436a6ac8..ff6e55d5f8 100644 --- a/src/media/audio/opensl/audio_recorder.cpp +++ b/src/media/audio/opensl/audio_recorder.cpp @@ -19,7 +19,7 @@ #include <cstdlib> #include "audio_recorder.h" -namespace ring { +namespace jami { namespace opensl { /* @@ -52,11 +52,11 @@ void AudioRecorder::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { } callback_(false); } catch (const std::exception& e) { - RING_ERR("processSLCallback exception: %s", e.what()); + JAMI_ERR("processSLCallback exception: %s", e.what()); } } -AudioRecorder::AudioRecorder(ring::AudioFormat sampleFormat, SLEngineItf slEngine) : +AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, SLEngineItf slEngine) : sampleInfo_(sampleFormat) { // configure audio source @@ -107,7 +107,7 @@ bool AudioRecorder::start() { if(!freeQueue_ || !recQueue_) { - RING_ERR("====NULL pointer to Start(%p, %p)", freeQueue_, recQueue_); + JAMI_ERR("====NULL pointer to Start(%p, %p)", freeQueue_, recQueue_); return false; } audioBufCount = 0; @@ -122,7 +122,7 @@ AudioRecorder::start() for(int i =0; i < RECORD_DEVICE_KICKSTART_BUF_COUNT; i++ ) { sample_buf *buf = NULL; if(!freeQueue_->front(&buf)) { - RING_ERR("=====OutOfFreeBuffers @ startingRecording @ (%d)", i); + JAMI_ERR("=====OutOfFreeBuffers @ startingRecording @ (%d)", i); break; } freeQueue_->pop(); diff --git a/src/media/audio/opensl/audio_recorder.h b/src/media/audio/opensl/audio_recorder.h index 096bc0b735..85cf433f2d 100644 --- a/src/media/audio/opensl/audio_recorder.h +++ b/src/media/audio/opensl/audio_recorder.h @@ -25,7 +25,7 @@ #include "buf_manager.h" #include "noncopyable.h" -namespace ring { +namespace jami { namespace opensl { class AudioRecorder { @@ -33,7 +33,7 @@ class AudioRecorder { SLRecordItf recItf_; SLAndroidSimpleBufferQueueItf recBufQueueItf_; - ring::AudioFormat sampleInfo_; + jami::AudioFormat sampleInfo_; AudioQueue *freeQueue_ {nullptr}; // user AudioQueue *recQueue_ {nullptr}; // user AudioQueue devShadowQueue_ {DEVICE_SHADOW_BUFFER_QUEUE_LEN}; // owner @@ -42,7 +42,7 @@ class AudioRecorder { EngineCallback callback_ {}; public: - explicit AudioRecorder(ring::AudioFormat, SLEngineItf engineEngine); + explicit AudioRecorder(jami::AudioFormat, SLEngineItf engineEngine); ~AudioRecorder(); NON_COPYABLE(AudioRecorder); diff --git a/src/media/audio/opensl/opensllayer.cpp b/src/media/audio/opensl/opensllayer.cpp index 8b80f5fd17..0e8de60e1a 100644 --- a/src/media/audio/opensl/opensllayer.cpp +++ b/src/media/audio/opensl/opensllayer.cpp @@ -43,7 +43,7 @@ #define SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ((SLuint32) 0x00000004) #endif -namespace ring { +namespace jami { // Constructor OpenSLLayer::OpenSLLayer(const AudioPreference &pref) @@ -80,7 +80,7 @@ OpenSLLayer::startStream() status_ = Status::Starting; } - RING_DBG("Start OpenSL audio layer"); + JAMI_DBG("Start OpenSL audio layer"); std::vector<int32_t> hw_infos; hw_infos.reserve(4); @@ -93,7 +93,7 @@ OpenSLLayer::startStream() init(); startAudioPlayback(); startAudioCapture(); - RING_WARN("OpenSL audio layer started"); + JAMI_WARN("OpenSL audio layer started"); { std::lock_guard<std::mutex> lock(mutex_); status_ = Status::Started; @@ -113,7 +113,7 @@ OpenSLLayer::stopStream() status_ = Status::Idle; } - RING_WARN("Stop OpenSL audio layer"); + JAMI_WARN("Stop OpenSL audio layer"); stopAudioPlayback(); stopAudioCapture(); @@ -177,7 +177,7 @@ void OpenSLLayer::shutdownAudioEngine() { // destroy engine object, and invalidate all associated interfaces - RING_DBG("Shutdown audio engine"); + JAMI_DBG("Shutdown audio engine"); stopStream(); } @@ -191,17 +191,17 @@ OpenSLLayer::dbgEngineGetBufCount() { count_ringtone += freeRingBufQueue_.size(); count_ringtone += ringBufQueue_.size(); - RING_ERR("Buf Disrtibutions: PlayerDev=%d, PlayQ=%d, FreePlayQ=%d", + JAMI_ERR("Buf Disrtibutions: PlayerDev=%d, PlayQ=%d, FreePlayQ=%d", player_->dbgGetDevBufCount(), playBufQueue_.size(), freePlayBufQueue_.size()); - RING_ERR("Buf Disrtibutions: RingDev=%d, RingQ=%d, FreeRingQ=%d", + JAMI_ERR("Buf Disrtibutions: RingDev=%d, RingQ=%d, FreeRingQ=%d", ringtone_->dbgGetDevBufCount(), ringBufQueue_.size(), freeRingBufQueue_.size()); if(count_player != BUF_COUNT) { - RING_ERR("====Lost Bufs among the queue(supposed = %d, found = %d)", + JAMI_ERR("====Lost Bufs among the queue(supposed = %d, found = %d)", BUF_COUNT, count_player); } return count_player; @@ -219,7 +219,7 @@ OpenSLLayer::engineServicePlay(bool waiting) { buf->size_ = dat->pointer()->nb_samples * dat->pointer()->channels * sizeof(AudioSample); std::copy_n((const AudioSample*)dat->pointer()->data[0], dat->pointer()->nb_samples, (AudioSample*)buf->buf_); if (!playBufQueue_.push(buf)) { - RING_WARN("playThread player_ PLAY_KICKSTART_BUFFER_COUNT 1"); + JAMI_WARN("playThread player_ PLAY_KICKSTART_BUFFER_COUNT 1"); break; } else freePlayBufQueue_.pop(); @@ -241,7 +241,7 @@ OpenSLLayer::engineServiceRing(bool waiting) { buf->size_ = dat->pointer()->nb_samples * dat->pointer()->channels * sizeof(AudioSample); std::copy_n((const AudioSample*)dat->pointer()->data[0], dat->pointer()->nb_samples, (AudioSample*)buf->buf_); if (!ringBufQueue_.push(buf)) { - RING_WARN("playThread ringtone_ PLAY_KICKSTART_BUFFER_COUNT 1"); + JAMI_WARN("playThread ringtone_ PLAY_KICKSTART_BUFFER_COUNT 1"); freeRingBufQueue_.push(buf); break; } @@ -269,7 +269,7 @@ OpenSLLayer::initAudioPlayback() player_->setBufQueue(&playBufQueue_, &freePlayBufQueue_); player_->registerCallback(std::bind(&OpenSLLayer::engineServicePlay, this, _1)); } catch (const std::exception& e) { - RING_ERR("Error initializing audio playback: %s", e.what()); + JAMI_ERR("Error initializing audio playback: %s", e.what()); return; } @@ -278,7 +278,7 @@ OpenSLLayer::initAudioPlayback() ringtone_->setBufQueue(&ringBufQueue_, &freeRingBufQueue_); ringtone_->registerCallback(std::bind(&OpenSLLayer::engineServiceRing, this, _1)); } catch (const std::exception& e) { - RING_ERR("Error initializing ringtone playback: %s", e.what()); + JAMI_ERR("Error initializing ringtone playback: %s", e.what()); } } @@ -292,7 +292,7 @@ OpenSLLayer::initAudioCapture() recorder_->setBufQueues(&freeRecBufQueue_, &recBufQueue_); recorder_->registerCallback(std::bind(&OpenSLLayer::engineServiceRec, this, _1)); } catch (const std::exception& e) { - RING_ERR("Error initializing audio capture: %s", e.what()); + JAMI_ERR("Error initializing audio capture: %s", e.what()); } } @@ -301,7 +301,7 @@ OpenSLLayer::startAudioPlayback() { if (not player_ and not ringtone_) return; - RING_WARN("Start audio playback"); + JAMI_WARN("Start audio playback"); if (player_) player_->start(); @@ -327,7 +327,7 @@ OpenSLLayer::startAudioPlayback() } } }); - RING_WARN("Audio playback started"); + JAMI_WARN("Audio playback started"); } void @@ -335,7 +335,7 @@ OpenSLLayer::startAudioCapture() { if (not recorder_) return; - RING_DBG("Start audio capture"); + JAMI_DBG("Start audio capture"); recorder_->start(); recThread = std::thread([&]() { @@ -363,13 +363,13 @@ OpenSLLayer::startAudioCapture() } }); - RING_DBG("Audio capture started"); + JAMI_DBG("Audio capture started"); } void OpenSLLayer::stopAudioPlayback() { - RING_DBG("Stop audio playback"); + JAMI_DBG("Stop audio playback"); { std::lock_guard<std::mutex> lck(playMtx); @@ -387,13 +387,13 @@ OpenSLLayer::stopAudioPlayback() playThread.join(); } - RING_DBG("Audio playback stopped"); + JAMI_DBG("Audio playback stopped"); } void OpenSLLayer::stopAudioCapture() { - RING_DBG("Stop audio capture"); + JAMI_DBG("Stop audio capture"); { std::lock_guard<std::mutex> lck(recMtx); @@ -405,7 +405,7 @@ OpenSLLayer::stopAudioCapture() recThread.join(); } - RING_DBG("Audio capture stopped"); + JAMI_DBG("Audio capture stopped"); } std::vector<std::string> @@ -449,14 +449,14 @@ OpenSLLayer::getCaptureDeviceList() const if (audioInputDescriptor_.deviceConnection == SL_DEVCONNECTION_ATTACHED_WIRED and audioInputDescriptor_.deviceScope == SL_DEVSCOPE_USER and audioInputDescriptor_.deviceLocation == SL_DEVLOCATION_HEADSET) { - RING_DBG("SL_DEVCONNECTION_ATTACHED_WIRED : mic_deviceID: %d", InputDeviceIDs[i] ); + JAMI_DBG("SL_DEVCONNECTION_ATTACHED_WIRED : mic_deviceID: %d", InputDeviceIDs[i] ); mic_deviceID = InputDeviceIDs[i]; mic_available = SL_BOOLEAN_TRUE; break; } else if (audioInputDescriptor_.deviceConnection == SL_DEVCONNECTION_INTEGRATED and audioInputDescriptor_.deviceScope == SL_DEVSCOPE_USER and audioInputDescriptor_.deviceLocation == SL_DEVLOCATION_HANDSET) { - RING_DBG("SL_DEVCONNECTION_INTEGRATED : mic_deviceID: %d", InputDeviceIDs[i] ); + JAMI_DBG("SL_DEVCONNECTION_INTEGRATED : mic_deviceID: %d", InputDeviceIDs[i] ); mic_deviceID = InputDeviceIDs[i]; mic_available = SL_BOOLEAN_TRUE; break; @@ -464,7 +464,7 @@ OpenSLLayer::getCaptureDeviceList() const } if (!mic_available) - RING_ERR("No mic available"); + JAMI_ERR("No mic available"); return captureDeviceList; } @@ -483,14 +483,14 @@ OpenSLLayer::updatePreference(AudioPreference& /*preference*/, int /*index*/, De void dumpAvailableEngineInterfaces() { SLresult result; - RING_DBG("Engine Interfaces"); + JAMI_DBG("Engine Interfaces"); SLuint32 numSupportedInterfaces; result = slQueryNumSupportedEngineInterfaces(&numSupportedInterfaces); assert(SL_RESULT_SUCCESS == result); result = slQueryNumSupportedEngineInterfaces(NULL); assert(SL_RESULT_PARAMETER_INVALID == result); - RING_DBG("Engine number of supported interfaces %u", numSupportedInterfaces); + JAMI_DBG("Engine number of supported interfaces %u", numSupportedInterfaces); for(SLuint32 i=0; i< numSupportedInterfaces; i++){ SLInterfaceID pInterfaceId; slQuerySupportedEngineInterfaces(i, &pInterfaceId); @@ -546,8 +546,8 @@ void dumpAvailableEngineInterfaces() else if (pInterfaceId==SL_IID_ANDROIDCONFIGURATION) nm="androidconfiguration"; else if (pInterfaceId==SL_IID_ANDROIDSIMPLEBUFFERQUEUE) nm="simplebuferqueue"; //else if (pInterfaceId==//SL_IID_ANDROIDBUFFERQUEUESOURCE) nm="bufferqueuesource"; - RING_DBG("%s,",nm); + JAMI_DBG("%s,",nm); } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/opensl/opensllayer.h b/src/media/audio/opensl/opensllayer.h index 7e89bc4e37..c06d40d771 100644 --- a/src/media/audio/opensl/opensllayer.h +++ b/src/media/audio/opensl/opensllayer.h @@ -36,7 +36,7 @@ class AudioPreference; #include <memory> -namespace ring { +namespace jami { class RingBuffer; diff --git a/src/media/audio/portaudio/portaudiolayer.cpp b/src/media/audio/portaudio/portaudiolayer.cpp index 125cee8443..6c2fd3135b 100644 --- a/src/media/audio/portaudio/portaudiolayer.cpp +++ b/src/media/audio/portaudio/portaudiolayer.cpp @@ -32,7 +32,7 @@ #include <algorithm> #include <cmath> -namespace ring { +namespace jami { enum Direction { Input = 0, Output = 1, IO = 2, End = 3 }; @@ -109,7 +109,7 @@ PortAudioLayer::getAudioDeviceIndex(const std::string& name, DeviceType type) co numDevices = Pa_GetDeviceCount(); if (numDevices < 0) { - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(numDevices)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(numDevices)); } else { const PaDeviceInfo* deviceInfo; for (int i = 0; i < numDevices; i++) { @@ -170,7 +170,7 @@ PortAudioLayer::stopStream() if (status_ != Status::Started) return; - RING_DBG("Stop PortAudio Streams"); + JAMI_DBG("Stop PortAudio Streams"); for (auto& st_ptr : pimpl_->streams_) { if (!st_ptr) @@ -178,11 +178,11 @@ PortAudioLayer::stopStream() auto err = Pa_StopStream(st_ptr); if (err != paNoError) - RING_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err)); + JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err)); err = Pa_CloseStream(st_ptr); if (err != paNoError) - RING_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err)); + JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err)); } { @@ -239,7 +239,7 @@ PortAudioLayer::PortAudioLayerImpl::getDeviceByType(DeviceType type) const numDevices = Pa_GetDeviceCount(); if (numDevices < 0) - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(numDevices)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(numDevices)); else { for (int i = 0; i < numDevices; i++) { const auto deviceInfo = Pa_GetDeviceInfo(i); @@ -258,10 +258,10 @@ PortAudioLayer::PortAudioLayerImpl::getDeviceByType(DeviceType type) const void PortAudioLayer::PortAudioLayerImpl::init(PortAudioLayer& parent) { - RING_DBG("Init PortAudioLayer"); + JAMI_DBG("Init PortAudioLayer"); const auto err = Pa_Initialize(); if (err != paNoError) { - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); terminate(); } @@ -350,10 +350,10 @@ PortAudioLayer::PortAudioLayerImpl::getInternalIndexByType(const int index, Devi void PortAudioLayer::PortAudioLayerImpl::terminate() const { - RING_DBG("PortAudioLayer terminate."); + JAMI_DBG("PortAudioLayer terminate."); auto err = Pa_Terminate(); if (err != paNoError) - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); } static void @@ -382,7 +382,7 @@ openStreamDevice(PaStream** stream, user_data); if (err != paNoError) - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); } static void @@ -418,7 +418,7 @@ openFullDuplexStream(PaStream** stream, user_data); if (err != paNoError) - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); } void @@ -428,9 +428,9 @@ PortAudioLayer::PortAudioLayerImpl::initStream(PortAudioLayer& parent) auto apiIndex = Pa_GetDefaultHostApi(); auto apiInfo = Pa_GetHostApiInfo(apiIndex); - RING_DBG() << "Initializing Portaudio streams using: " << apiInfo->name; + JAMI_DBG() << "Initializing Portaudio streams using: " << apiInfo->name; - RING_DBG("Open PortAudio Full-duplex input/output stream"); + JAMI_DBG("Open PortAudio Full-duplex input/output stream"); if (indexOut_ != paNoDevice && indexIn_ != paNoDevice) { openFullDuplexStream(&streams_[Direction::IO], indexIn_, @@ -451,7 +451,7 @@ PortAudioLayer::PortAudioLayerImpl::initStream(PortAudioLayer& parent) }, &parent); } else { - RING_DBG("Open PortAudio Output Stream"); + JAMI_DBG("Open PortAudio Output Stream"); if (indexOut_ != paNoDevice) { openStreamDevice(&streams_[Direction::Output], indexOut_, @@ -472,10 +472,10 @@ PortAudioLayer::PortAudioLayerImpl::initStream(PortAudioLayer& parent) }, &parent); } else { - RING_ERR("Error: No valid output device. There will be no sound."); + JAMI_ERR("Error: No valid output device. There will be no sound."); } - RING_DBG("Open PortAudio Input Stream"); + JAMI_DBG("Open PortAudio Input Stream"); if (indexIn_ != paNoDevice) { openStreamDevice(&streams_[Direction::Input], indexIn_, @@ -496,16 +496,16 @@ PortAudioLayer::PortAudioLayerImpl::initStream(PortAudioLayer& parent) }, &parent); } else { - RING_ERR("Error: No valid input device. There will be no mic."); + JAMI_ERR("Error: No valid input device. There will be no mic."); } } - RING_DBG("Start PortAudio Streams"); + JAMI_DBG("Start PortAudio Streams"); for (auto& st_ptr : streams_) { if (st_ptr) { auto err = Pa_StartStream(st_ptr); if (err != paNoError) - RING_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); + JAMI_ERR("PortAudioLayer error : %s", Pa_GetErrorText(err)); } } } @@ -549,7 +549,7 @@ PortAudioLayer::PortAudioLayerImpl::paInputCallback(PortAudioLayer& parent, (void)statusFlags; if (framesPerBuffer == 0) { - RING_WARN("No frames for input."); + JAMI_WARN("No frames for input."); return paContinue; } @@ -576,4 +576,4 @@ PortAudioLayer::PortAudioLayerImpl::paIOCallback(PortAudioLayer& parent, return paContinue; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/portaudio/portaudiolayer.h b/src/media/audio/portaudio/portaudiolayer.h index cdce00a901..cf3342e6a9 100644 --- a/src/media/audio/portaudio/portaudiolayer.h +++ b/src/media/audio/portaudio/portaudiolayer.h @@ -27,7 +27,7 @@ #include <memory> #include <array> -namespace ring { +namespace jami { class PortAudioLayer : public AudioLayer { @@ -64,4 +64,4 @@ private: std::unique_ptr<PortAudioLayerImpl> pimpl_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/pulseaudio/audiostream.cpp b/src/media/audio/pulseaudio/audiostream.cpp index 8b311ab567..abe0c47238 100644 --- a/src/media/audio/pulseaudio/audiostream.cpp +++ b/src/media/audio/pulseaudio/audiostream.cpp @@ -26,7 +26,7 @@ #include <stdexcept> -namespace ring { +namespace jami { AudioStream::AudioStream(pa_context *c, pa_threaded_mainloop *m, @@ -46,7 +46,7 @@ AudioStream::AudioStream(pa_context *c, channel_map.channels }; - RING_DBG("%s: trying to create stream with device %s (%dHz, %d channels)", desc, infos->name.c_str(), samplrate, channel_map.channels); + JAMI_DBG("%s: trying to create stream with device %s (%dHz, %d channels)", desc, infos->name.c_str(), samplrate, channel_map.channels); assert(pa_sample_spec_valid(&sample_spec)); assert(pa_channel_map_valid(&channel_map)); @@ -56,7 +56,7 @@ AudioStream::AudioStream(pa_context *c, audiostream_ = pa_stream_new_with_proplist(c, desc, &sample_spec, &channel_map, ec ? pl.get() : nullptr); if (!audiostream_) { - RING_ERR("%s: pa_stream_new() failed : %s" , desc, pa_strerror(pa_context_errno(c))); + JAMI_ERR("%s: pa_stream_new() failed : %s" , desc, pa_strerror(pa_context_errno(c))); throw std::runtime_error("Could not create stream\n"); } @@ -121,7 +121,7 @@ AudioStream::start() { void AudioStream::moved(pa_stream* s) { audiostream_ = s; - RING_DBG("Stream %d to %s", pa_stream_get_index(s), pa_stream_get_device_name(s)); + JAMI_DBG("Stream %d to %s", pa_stream_get_index(s), pa_stream_get_device_name(s)); } void @@ -131,31 +131,31 @@ AudioStream::stateChanged(pa_stream* s) switch (pa_stream_get_state(s)) { case PA_STREAM_CREATING: - RING_DBG("Stream is creating..."); + JAMI_DBG("Stream is creating..."); break; case PA_STREAM_TERMINATED: - RING_DBG("Stream is terminating..."); + JAMI_DBG("Stream is terminating..."); break; case PA_STREAM_READY: - RING_DBG("Stream successfully created, connected to %s", pa_stream_get_device_name(s)); - //RING_DBG("maxlength %u", pa_stream_get_buffer_attr(s)->maxlength); - //RING_DBG("tlength %u", pa_stream_get_buffer_attr(s)->tlength); - //RING_DBG("prebuf %u", pa_stream_get_buffer_attr(s)->prebuf); - //RING_DBG("minreq %u", pa_stream_get_buffer_attr(s)->minreq); - //RING_DBG("fragsize %u", pa_stream_get_buffer_attr(s)->fragsize); - //RING_DBG("samplespec %s", pa_sample_spec_snprint(str, sizeof(str), pa_stream_get_sample_spec(s))); + JAMI_DBG("Stream successfully created, connected to %s", pa_stream_get_device_name(s)); + //JAMI_DBG("maxlength %u", pa_stream_get_buffer_attr(s)->maxlength); + //JAMI_DBG("tlength %u", pa_stream_get_buffer_attr(s)->tlength); + //JAMI_DBG("prebuf %u", pa_stream_get_buffer_attr(s)->prebuf); + //JAMI_DBG("minreq %u", pa_stream_get_buffer_attr(s)->minreq); + //JAMI_DBG("fragsize %u", pa_stream_get_buffer_attr(s)->fragsize); + //JAMI_DBG("samplespec %s", pa_sample_spec_snprint(str, sizeof(str), pa_stream_get_sample_spec(s))); onReady_(); break; case PA_STREAM_UNCONNECTED: - RING_DBG("Stream unconnected"); + JAMI_DBG("Stream unconnected"); break; case PA_STREAM_FAILED: default: - RING_ERR("Stream failure: %s" , pa_strerror(pa_context_errno(pa_stream_get_context(s)))); + JAMI_ERR("Stream failure: %s" , pa_strerror(pa_context_errno(pa_stream_get_context(s)))); break; } } @@ -168,4 +168,4 @@ bool AudioStream::isReady() return pa_stream_get_state(audiostream_) == PA_STREAM_READY; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/pulseaudio/audiostream.h b/src/media/audio/pulseaudio/audiostream.h index fb6fb42175..b843752fca 100644 --- a/src/media/audio/pulseaudio/audiostream.h +++ b/src/media/audio/pulseaudio/audiostream.h @@ -26,7 +26,7 @@ #include <pulse/pulseaudio.h> #include <string> -namespace ring { +namespace jami { /** * This data structure contains the different king of audio streams available diff --git a/src/media/audio/pulseaudio/pulselayer.cpp b/src/media/audio/pulseaudio/pulselayer.cpp index 7f7efe2d06..bce1191e20 100644 --- a/src/media/audio/pulseaudio/pulselayer.cpp +++ b/src/media/audio/pulseaudio/pulselayer.cpp @@ -44,7 +44,7 @@ // uncomment to log pulseaudio sink and sources //#define PA_LOG_SINK_SOURCES -namespace ring { +namespace jami { static const std::regex PA_EC_SUFFIX {"\\.echo-cancel(?:\\..+)?$"}; @@ -133,11 +133,11 @@ void PulseLayer::contextStateChanged(pa_context* c) case PA_CONTEXT_CONNECTING: case PA_CONTEXT_AUTHORIZING: case PA_CONTEXT_SETTING_NAME: - RING_DBG("Waiting...."); + JAMI_DBG("Waiting...."); break; case PA_CONTEXT_READY: - RING_DBG("Connection to PulseAudio server established"); + JAMI_DBG("Connection to PulseAudio server established"); pa_threaded_mainloop_signal(mainloop_.get(), 0); subscribeOp_ = pa_context_subscribe(c, mask, nullptr, this); pa_context_set_subscribe_callback(c, context_changed_callback, this); @@ -156,7 +156,7 @@ void PulseLayer::contextStateChanged(pa_context* c) case PA_CONTEXT_FAILED: default: - RING_ERR("%s" , pa_strerror(pa_context_errno(c))); + JAMI_ERR("%s" , pa_strerror(pa_context_errno(c))); pa_threaded_mainloop_signal(mainloop_.get(), 0); break; } @@ -166,7 +166,7 @@ void PulseLayer::updateSinkList() { std::unique_lock<std::mutex> lk(readyMtx_); if (not enumeratingSinks_) { - RING_DBG("Updating PulseAudio sink list"); + JAMI_DBG("Updating PulseAudio sink list"); enumeratingSinks_ = true; sinkList_.clear(); sinkList_.emplace_back(); @@ -182,7 +182,7 @@ void PulseLayer::updateSourceList() { std::unique_lock<std::mutex> lk(readyMtx_); if (not enumeratingSources_) { - RING_DBG("Updating PulseAudio source list"); + JAMI_DBG("Updating PulseAudio source list"); enumeratingSources_ = true; sourceList_.clear(); sourceList_.emplace_back(); @@ -198,7 +198,7 @@ void PulseLayer::updateServerInfo() { std::unique_lock<std::mutex> lk(readyMtx_); if (not gettingServerInfo_) { - RING_DBG("Updating PulseAudio server infos"); + JAMI_DBG("Updating PulseAudio server infos"); gettingServerInfo_ = true; if (auto op = pa_context_get_server_info(context_, server_info_callback, this)) pa_operation_unref(op); @@ -244,7 +244,7 @@ int PulseLayer::getAudioDeviceIndex(const std::string& descr, DeviceType type) c case DeviceType::CAPTURE: return std::distance(sourceList_.begin(), std::find_if(sourceList_.begin(), sourceList_.end(), PaDeviceInfos::DescriptionComparator(descr))); default: - RING_ERR("Unexpected device type"); + JAMI_ERR("Unexpected device type"); return 0; } } @@ -260,7 +260,7 @@ int PulseLayer::getAudioDeviceIndexByName(const std::string& name, DeviceType ty case DeviceType::CAPTURE: return std::distance(sourceList_.begin(), std::find_if(sourceList_.begin(), sourceList_.end(), PaDeviceInfos::NameComparator(name))); default: - RING_ERR("Unexpected device type"); + JAMI_ERR("Unexpected device type"); return 0; } } @@ -287,7 +287,7 @@ const PaDeviceInfos* PulseLayer::getDeviceInfos(const std::vector<PaDeviceInfos> { auto dev_info = std::find_if(list.begin(), list.end(), PaDeviceInfos::NameComparator(name)); if (dev_info == list.end()) { - RING_WARN("Preferred device %s not found in device list, selecting default %s instead.", + JAMI_WARN("Preferred device %s not found in device list, selecting default %s instead.", name.c_str(), list.front().name.c_str()); return &list.front(); } @@ -300,21 +300,21 @@ std::string PulseLayer::getAudioDeviceName(int index, DeviceType type) const case DeviceType::PLAYBACK: case DeviceType::RINGTONE: if (index < 0 or static_cast<size_t>(index) >= sinkList_.size()) { - RING_ERR("Index %d out of range", index); + JAMI_ERR("Index %d out of range", index); return ""; } return sinkList_[index].name; case DeviceType::CAPTURE: if (index < 0 or static_cast<size_t>(index) >= sourceList_.size()) { - RING_ERR("Index %d out of range", index); + JAMI_ERR("Index %d out of range", index); return ""; } return sourceList_[index].name; default: // Should never happen - RING_ERR("Unexpected type"); + JAMI_ERR("Unexpected type"); return ""; } } @@ -328,7 +328,7 @@ void PulseLayer::createStreams(pa_context* c) bool ringtoneReady = not ringtone_ or ringtone_->isReady(); bool recordReady = not record_ or record_->isReady(); if (playbackReady and recordReady and ringtoneReady) { - RING_DBG("All streams ready, starting !"); + JAMI_DBG("All streams ready, starting !"); if (playback_) playback_->start(); if (ringtone_) ringtone_->start(); if (record_) record_->start(); @@ -466,7 +466,7 @@ void PulseLayer::readFromMic() std::memcpy(out->pointer()->data[0], data, bytes); if (pa_stream_drop(record_->stream()) < 0) - RING_ERR("Capture stream drop failed: %s" , pa_strerror(pa_context_errno(context_))); + JAMI_ERR("Capture stream drop failed: %s" , pa_strerror(pa_context_errno(context_))); //dcblocker_.process(*out); mainRingBuffer_->put(std::move(out)); @@ -539,7 +539,7 @@ PulseLayer::contextChanged(pa_context* c UNUSED, pa_subscription_event_type_t ty break; default: - RING_DBG("Unhandled event type 0x%x", type); + JAMI_DBG("Unhandled event type 0x%x", type); break; } @@ -579,11 +579,11 @@ void PulseLayer::waitForDeviceList() recordInfo->name != stripEchoSufix(record_->getDeviceName())); if (playbackDeviceChanged or recordDeviceChanged) { - RING_WARN("Audio devices changed, restarting streams."); + JAMI_WARN("Audio devices changed, restarting streams."); stopStream(); startStream(); } else { - RING_WARN("Staying on \n %s \n %s", playback_->getDeviceName().c_str(), record_->getDeviceName().c_str()); + JAMI_WARN("Staying on \n %s \n %s", playback_->getDeviceName().c_str(), record_->getDeviceName().c_str()); status_ = Status::Started; startedCv_.notify_all(); } @@ -594,7 +594,7 @@ void PulseLayer::server_info_callback(pa_context*, const pa_server_info *i, void { if (!i) return; char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; - RING_DBG("PulseAudio server info:\n" + JAMI_DBG("PulseAudio server info:\n" " Server name: %s\n" " Server version: %s\n" " Default Sink %s\n" @@ -637,7 +637,7 @@ void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_sourc } #ifdef PA_LOG_SINK_SOURCES char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; - RING_DBG("Source %u\n" + JAMI_DBG("Source %u\n" " Name: %s\n" " Driver: %s\n" " Description: %s\n" @@ -681,7 +681,7 @@ void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_in } #ifdef PA_LOG_SINK_SOURCES char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; - RING_DBG("Sink %u\n" + JAMI_DBG("Sink %u\n" " Name: %s\n" " Driver: %s\n" " Description: %s\n" @@ -717,17 +717,17 @@ void PulseLayer::updatePreference(AudioPreference &preference, int index, Device switch (type) { case DeviceType::PLAYBACK: - RING_DBG("setting %s for playback", devName.c_str()); + JAMI_DBG("setting %s for playback", devName.c_str()); preference.setPulseDevicePlayback(devName); break; case DeviceType::CAPTURE: - RING_DBG("setting %s for capture", devName.c_str()); + JAMI_DBG("setting %s for capture", devName.c_str()); preference.setPulseDeviceRecord(devName); break; case DeviceType::RINGTONE: - RING_DBG("setting %s for ringer", devName.c_str()); + JAMI_DBG("setting %s for ringer", devName.c_str()); preference.setPulseDeviceRingtone(devName); break; } @@ -773,4 +773,4 @@ PulseLayer::getPreferredCaptureDevice() const { } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/pulseaudio/pulselayer.h b/src/media/audio/pulseaudio/pulselayer.h index 7a4492263d..fb52917f42 100644 --- a/src/media/audio/pulseaudio/pulselayer.h +++ b/src/media/audio/pulseaudio/pulselayer.h @@ -36,7 +36,7 @@ #include <memory> #include <thread> -namespace ring { +namespace jami { class AudioPreference; class AudioStream; @@ -241,6 +241,6 @@ class PulseLayer : public AudioLayer { friend class AudioLayerTest; }; -} // namespace ring +} // namespace jami #endif // PULSE_LAYER_H_ diff --git a/src/media/audio/resampler.cpp b/src/media/audio/resampler.cpp index 3700a05fe1..875951c4ce 100644 --- a/src/media/audio/resampler.cpp +++ b/src/media/audio/resampler.cpp @@ -28,7 +28,7 @@ extern "C" { #include <libswresample/swresample.h> } -namespace ring { +namespace jami { Resampler::Resampler() : swrCtx_(swr_alloc()) @@ -46,7 +46,7 @@ Resampler::reinit(const AVFrame* in, const AVFrame* out) // NOTE swr_set_matrix should be called on an uninitialized context auto swrCtx = swr_alloc(); if (!swrCtx) { - RING_ERR() << "Cannot allocate resampler context"; + JAMI_ERR() << "Cannot allocate resampler context"; throw std::bad_alloc(); } @@ -109,7 +109,7 @@ Resampler::reinit(const AVFrame* in, const AVFrame* out) ++initCount_; } else { std::string msg = "Failed to initialize resampler context"; - RING_ERR() << msg; + JAMI_ERR() << msg; throw std::runtime_error(msg); } } @@ -127,13 +127,13 @@ Resampler::resample(const AVFrame* input, AVFrame* output) // doesn't get mangled with a bunch of calls to Resampler::resample if (initCount_ > 1) { std::string msg = "Infinite loop detected in audio resampler, please open an issue on https://git.jami.net"; - RING_ERR() << msg; + JAMI_ERR() << msg; throw std::runtime_error(msg); } reinit(input, output); return resample(input, output); } else if (ret < 0) { - RING_ERR() << "Failed to resample frame"; + JAMI_ERR() << "Failed to resample frame"; return -1; } @@ -190,4 +190,4 @@ Resampler::resample(std::shared_ptr<AudioFrame>&& in, const AudioFormat& format) return output; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/resampler.h b/src/media/audio/resampler.h index b85395e7d9..77fc1ee4eb 100644 --- a/src/media/audio/resampler.h +++ b/src/media/audio/resampler.h @@ -29,7 +29,7 @@ struct AVFrame; struct SwrContext; -namespace ring { +namespace jami { /** * Wrapper class for libswresample @@ -78,4 +78,4 @@ private: unsigned initCount_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/ringbuffer.cpp b/src/media/audio/ringbuffer.cpp index 9a10c1dd1c..6a610659f1 100644 --- a/src/media/audio/ringbuffer.cpp +++ b/src/media/audio/ringbuffer.cpp @@ -34,7 +34,7 @@ #include <cstring> #include <algorithm> -namespace ring { +namespace jami { // corresponds to 160 ms (about 5 rtp packets) static const size_t MIN_BUFFER_SIZE = 1024; @@ -87,7 +87,7 @@ size_t RingBuffer::getLength(const std::string &call_id) const void RingBuffer::debug() { - RING_DBG("Start=%zu; End=%zu; BufferSize=%zu", getSmallestReadOffset(), endPos_, buffer_.size()); + JAMI_DBG("Start=%zu; End=%zu; BufferSize=%zu", getSmallestReadOffset(), endPos_, buffer_.size()); } size_t RingBuffer::getReadOffset(const std::string &call_id) const @@ -115,7 +115,7 @@ RingBuffer::storeReadOffset(size_t offset, const std::string &call_id) if (iter != readoffsets_.end()) iter->second.offset = offset; else - RING_ERR("RingBuffer::storeReadOffset() failed: unknown call '%s'", call_id.c_str()); + JAMI_ERR("RingBuffer::storeReadOffset() failed: unknown call '%s'", call_id.c_str()); } void @@ -292,4 +292,4 @@ RingBuffer::discard(size_t toDiscard) return toDiscard; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/ringbuffer.h b/src/media/audio/ringbuffer.h index 9eba33d64d..546d98b032 100644 --- a/src/media/audio/ringbuffer.h +++ b/src/media/audio/ringbuffer.h @@ -36,7 +36,7 @@ #include <vector> #include <fstream> -namespace ring { +namespace jami { /** * A ring buffer for mutichannel audio samples @@ -207,4 +207,4 @@ private: int rmsFrameCount_ {0}; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/ringbufferpool.cpp b/src/media/audio/ringbufferpool.cpp index bf7630c25f..b9fef773db 100644 --- a/src/media/audio/ringbufferpool.cpp +++ b/src/media/audio/ringbufferpool.cpp @@ -29,7 +29,7 @@ #include <cstring> #include <algorithm> -namespace ring { +namespace jami { const char * const RingBufferPool::DEFAULT_ID = "audiolayer_id"; @@ -47,7 +47,7 @@ RingBufferPool::~RingBufferPool() for (const auto& item : ringBufferMap_) { const auto& weak = item.second; if (not weak.expired()) - RING_WARN("Leaking RingBuffer '%s'", item.first.c_str()); + JAMI_WARN("Leaking RingBuffer '%s'", item.first.c_str()); } } @@ -110,12 +110,12 @@ RingBufferPool::createRingBuffer(const std::string& id) auto rbuf = getRingBuffer(id); if (rbuf) { - RING_DBG("Ringbuffer already exists for id '%s'", id.c_str()); + JAMI_DBG("Ringbuffer already exists for id '%s'", id.c_str()); return rbuf; } rbuf.reset(new RingBuffer(id, SIZEBUF, internalAudioFormat_)); - RING_DBG("Ringbuffer created with id '%s'", id.c_str()); + JAMI_DBG("Ringbuffer created with id '%s'", id.c_str()); ringBufferMap_.insert(std::make_pair(id, std::weak_ptr<RingBuffer>(rbuf))); return rbuf; } @@ -138,7 +138,7 @@ void RingBufferPool::removeReadBindings(const std::string& call_id) { if (not readBindingsMap_.erase(call_id)) - RING_ERR("CallID set %s does not exist!", call_id.c_str()); + JAMI_ERR("CallID set %s does not exist!", call_id.c_str()); } /** @@ -149,11 +149,11 @@ RingBufferPool::addReaderToRingBuffer(const std::shared_ptr<RingBuffer>& rbuf, const std::string& call_id) { if (call_id != DEFAULT_ID and rbuf->getId() == call_id) - RING_WARN("RingBuffer has a readoffset on itself"); + JAMI_WARN("RingBuffer has a readoffset on itself"); rbuf->createReadOffset(call_id); readBindingsMap_[call_id].insert(rbuf); // bindings list created if not existing - RING_DBG("Bind rbuf '%s' to callid '%s'", rbuf->getId().c_str(), call_id.c_str()); + JAMI_DBG("Bind rbuf '%s' to callid '%s'", rbuf->getId().c_str(), call_id.c_str()); } void @@ -175,13 +175,13 @@ RingBufferPool::bindCallID(const std::string& call_id1, { const auto& rb_call1 = getRingBuffer(call_id1); if (not rb_call1) { - RING_ERR("No ringbuffer associated to call '%s'", call_id1.c_str()); + JAMI_ERR("No ringbuffer associated to call '%s'", call_id1.c_str()); return; } const auto& rb_call2 = getRingBuffer(call_id2); if (not rb_call2) { - RING_ERR("No ringbuffer associated to call '%s'", call_id2.c_str()); + JAMI_ERR("No ringbuffer associated to call '%s'", call_id2.c_str()); return; } @@ -210,13 +210,13 @@ RingBufferPool::unBindCallID(const std::string& call_id1, { const auto& rb_call1 = getRingBuffer(call_id1); if (not rb_call1) { - RING_ERR("No ringbuffer associated to call '%s'", call_id1.c_str()); + JAMI_ERR("No ringbuffer associated to call '%s'", call_id1.c_str()); return; } const auto& rb_call2 = getRingBuffer(call_id2); if (not rb_call2) { - RING_ERR("No ringbuffer associated to call '%s'", call_id2.c_str()); + JAMI_ERR("No ringbuffer associated to call '%s'", call_id2.c_str()); return; } @@ -241,7 +241,7 @@ RingBufferPool::unBindAll(const std::string& call_id) { const auto& rb_call = getRingBuffer(call_id); if (not rb_call) { - RING_ERR("No ringbuffer associated to call '%s'", call_id.c_str()); + JAMI_ERR("No ringbuffer associated to call '%s'", call_id.c_str()); return; } @@ -441,4 +441,4 @@ RingBufferPool::setAudioMeterState(const std::string& id, bool state) } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/ringbufferpool.h b/src/media/audio/ringbufferpool.h index 4234406f76..ba10a678f5 100644 --- a/src/media/audio/ringbufferpool.h +++ b/src/media/audio/ringbufferpool.h @@ -30,7 +30,7 @@ #include <mutex> #include <memory> -namespace ring { +namespace jami { class RingBuffer; @@ -150,4 +150,4 @@ private: std::shared_ptr<RingBuffer> defaultRingBuffer_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/audiofile.cpp b/src/media/audio/sound/audiofile.cpp index fe257417e9..7c177f5e25 100644 --- a/src/media/audio/sound/audiofile.cpp +++ b/src/media/audio/sound/audiofile.cpp @@ -35,7 +35,7 @@ #include "logger.h" -namespace ring { +namespace jami { void AudioFile::onBufferFinish() @@ -44,7 +44,7 @@ AudioFile::onBufferFinish() const int divisor = buffer_->getSampleRate() / 1000; if (divisor == 0) { - RING_ERR("Error cannot update playback slider, sampling rate is 0"); + JAMI_ERR("Error cannot update playback slider, sampling rate is 0"); return; } @@ -104,4 +104,4 @@ AudioFile::AudioFile(const std::string &fileName, unsigned int sampleRate) : buffer_ = buf.release(); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/audiofile.h b/src/media/audio/sound/audiofile.h index 01825556c8..a21347796b 100644 --- a/src/media/audio/sound/audiofile.h +++ b/src/media/audio/sound/audiofile.h @@ -27,7 +27,7 @@ #include <stdexcept> #include "audio/audioloop.h" -namespace ring { +namespace jami { class AudioFileException : public std::runtime_error { public: @@ -56,6 +56,6 @@ class AudioFile : public AudioLoop { unsigned updatePlaybackScale_; }; -} // namespace ring +} // namespace jami #endif // __AUDIOFILE_H__ diff --git a/src/media/audio/sound/dtmf.cpp b/src/media/audio/sound/dtmf.cpp index 97677a5bbf..e6541ca6b9 100644 --- a/src/media/audio/sound/dtmf.cpp +++ b/src/media/audio/sound/dtmf.cpp @@ -24,7 +24,7 @@ #include "dtmf.h" -namespace ring { +namespace jami { DTMF::DTMF(unsigned int sampleRate) : currentTone_(0), newTone_(0), dtmfgenerator_(sampleRate) @@ -72,4 +72,4 @@ bool DTMF::generateDTMF(vector<AudioSample> &buffer) } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/dtmf.h b/src/media/audio/sound/dtmf.h index 063a26cea6..af016bc5e5 100644 --- a/src/media/audio/sound/dtmf.h +++ b/src/media/audio/sound/dtmf.h @@ -32,7 +32,7 @@ * @brief DMTF library to generate a dtmf sample */ -namespace ring { +namespace jami { class DTMF { public: @@ -61,6 +61,6 @@ class DTMF { DTMFGenerator dtmfgenerator_; }; -} // namespace ring +} // namespace jami #endif // __KEY_DTMF_H_ diff --git a/src/media/audio/sound/dtmfgenerator.cpp b/src/media/audio/sound/dtmfgenerator.cpp index 291683ff7e..1dd7e791d7 100644 --- a/src/media/audio/sound/dtmfgenerator.cpp +++ b/src/media/audio/sound/dtmfgenerator.cpp @@ -27,7 +27,7 @@ #include "dtmfgenerator.h" -namespace ring { +namespace jami { /* * Tone frequencies @@ -135,4 +135,4 @@ AudioSample* DTMFGenerator::fillToneBuffer(int index) return ptr; } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/dtmfgenerator.h b/src/media/audio/sound/dtmfgenerator.h index 1906d1b3fc..8639a2ffac 100644 --- a/src/media/audio/sound/dtmfgenerator.h +++ b/src/media/audio/sound/dtmfgenerator.h @@ -37,7 +37,7 @@ * @brief DMTF Generator Exception */ -namespace ring { +namespace jami { class DTMFException : public std::runtime_error { public: @@ -114,6 +114,6 @@ class DTMFGenerator { AudioSample* fillToneBuffer(int index); }; -} // namespace ring +} // namespace jami #endif // DTMFGENERATOR_H diff --git a/src/media/audio/sound/tone.cpp b/src/media/audio/sound/tone.cpp index ae3822d995..c8058d5ddc 100644 --- a/src/media/audio/sound/tone.cpp +++ b/src/media/audio/sound/tone.cpp @@ -30,7 +30,7 @@ #include <cmath> #include <cstdlib> -namespace ring { +namespace jami { Tone::Tone(const std::string& definition, unsigned int sampleRate) : AudioLoop(sampleRate) @@ -128,4 +128,4 @@ Tone::genSin(AudioSample* buffer, int lowFrequency, int highFrequency, size_t nb } } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/tone.h b/src/media/audio/sound/tone.h index dcd2046a99..cf57309a83 100644 --- a/src/media/audio/sound/tone.h +++ b/src/media/audio/sound/tone.h @@ -31,7 +31,7 @@ * @brief Tone sample (dial, busy, ring, congestion) */ -namespace ring { +namespace jami { class Tone : public AudioLoop { public: @@ -71,4 +71,4 @@ class Tone : public AudioLoop { void genBuffer(const std::string& definition); }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/tonelist.cpp b/src/media/audio/sound/tonelist.cpp index 1a271089f8..e51ab8807b 100644 --- a/src/media/audio/sound/tonelist.cpp +++ b/src/media/audio/sound/tonelist.cpp @@ -24,7 +24,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { static const char *toneZone[TelephoneTone::ZID_COUNTRIES][Tone::TONE_NULL] = { { @@ -132,4 +132,4 @@ TelephoneTone::buildTones(unsigned int sampleRate) tones_[Tone::TONE_CONGESTION] = std::make_shared<Tone>(toneZone[countryId_][Tone::TONE_CONGESTION], sampleRate); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/sound/tonelist.h b/src/media/audio/sound/tonelist.h index 2cc2d6b01b..b1163b0ddc 100644 --- a/src/media/audio/sound/tonelist.h +++ b/src/media/audio/sound/tonelist.h @@ -29,7 +29,7 @@ #include <array> #include <memory> -namespace ring { +namespace jami { class TelephoneTone { public: @@ -63,4 +63,4 @@ class TelephoneTone { Tone::TONEID currentTone_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/audio/tonecontrol.cpp b/src/media/audio/tonecontrol.cpp index c3b94fc42c..93daed3919 100644 --- a/src/media/audio/tonecontrol.cpp +++ b/src/media/audio/tonecontrol.cpp @@ -27,7 +27,7 @@ #include "client/ring_signal.h" #include "dring/callmanager_interface.h" // for CallSignal -namespace ring { +namespace jami { static constexpr unsigned DEFAULT_SAMPLE_RATE = 8000; @@ -80,7 +80,7 @@ ToneControl::setAudioFile(const std::string& file) try { audioFile_.reset(new AudioFile(file, sampleRate_)); } catch (const AudioFileException& e) { - RING_WARN("Audio file error: %s", e.what()); + JAMI_WARN("Audio file error: %s", e.what()); } return static_cast<bool>(audioFile_); @@ -129,4 +129,4 @@ ToneControl::seek(double value) audioFile_->seek(value); } -} // namespace ring +} // namespace jami diff --git a/src/media/audio/tonecontrol.h b/src/media/audio/tonecontrol.h index 0934ca4cfc..9a13fe3045 100644 --- a/src/media/audio/tonecontrol.h +++ b/src/media/audio/tonecontrol.h @@ -26,7 +26,7 @@ #include <mutex> -namespace ring { +namespace jami { /** * ToneControl is a class to handle application wide business logic @@ -61,4 +61,4 @@ class ToneControl { std::shared_ptr<AudioFile> audioFile_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/decoder_finder.h b/src/media/decoder_finder.h index 875927c374..17813ad807 100644 --- a/src/media/decoder_finder.h +++ b/src/media/decoder_finder.h @@ -23,7 +23,7 @@ extern "C" { #include <libavcodec/avcodec.h> } -namespace ring { +namespace jami { /** * Attempt to find standalone AVCodec decoder using AVCodecID, @@ -57,4 +57,4 @@ findDecoder(const enum AVCodecID codec_id) return codec; } -} // namespace ring +} // namespace jami diff --git a/src/media/libav_utils.cpp b/src/media/libav_utils.cpp index aade971200..772efffa1e 100644 --- a/src/media/libav_utils.cpp +++ b/src/media/libav_utils.cpp @@ -52,7 +52,7 @@ av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, A #endif } -namespace ring { namespace libav_utils { +namespace jami { namespace libav_utils { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) // protect libav/ffmpeg access @@ -241,7 +241,7 @@ fillWithBlack(AVFrame* frame) int ret = av_image_fill_black(frame->data, linesizes, format, frame->color_range, frame->width, frame->height); if (ret < 0) { - RING_ERR() << "Failed to blacken frame"; + JAMI_ERR() << "Failed to blacken frame"; } } @@ -250,7 +250,7 @@ fillWithSilence(AVFrame* frame) { int ret = av_samples_set_silence(frame->extended_data, 0, frame->nb_samples, frame->channels, (AVSampleFormat)frame->format); if (ret < 0) - RING_ERR() << "Failed to fill frame with silence"; + JAMI_ERR() << "Failed to fill frame with silence"; } -}} // namespace ring::libav_utils +}} // namespace jami::libav_utils diff --git a/src/media/libav_utils.h b/src/media/libav_utils.h index 8f3d32a59d..a5a939da4d 100644 --- a/src/media/libav_utils.h +++ b/src/media/libav_utils.h @@ -29,7 +29,7 @@ struct AVDictionary; struct AVFrame; struct AVPixFmtDescriptor; -namespace ring { namespace libav_utils { +namespace jami { namespace libav_utils { void ring_avcodec_init(); @@ -52,4 +52,4 @@ namespace ring { namespace libav_utils { void fillWithSilence(AVFrame* frame); -}} // namespace ring::libav_utils +}} // namespace jami::libav_utils diff --git a/src/media/localrecorder.cpp b/src/media/localrecorder.cpp index a26ff6a286..281172fe53 100644 --- a/src/media/localrecorder.cpp +++ b/src/media/localrecorder.cpp @@ -28,7 +28,7 @@ #include "logger.h" #include "client/videomanager.h" -namespace ring { +namespace jami { LocalRecorder::LocalRecorder(const bool& audioOnly) { @@ -46,7 +46,7 @@ void LocalRecorder::setPath(const std::string& path) { if (isRecording()) { - RING_ERR("can't set path while recording"); + JAMI_ERR("can't set path while recording"); return; } @@ -58,17 +58,17 @@ bool LocalRecorder::startRecording() { if (isRecording()) { - RING_ERR("recording already started!"); + JAMI_ERR("recording already started!"); return false; } if (path_.empty()) { - RING_ERR("could not start recording (path not set)"); + JAMI_ERR("could not start recording (path not set)"); return false; } if (!recorder_) { - RING_ERR("could not start recording (no recorder)"); + JAMI_ERR("could not start recording (no recorder)"); return false; } @@ -77,18 +77,18 @@ LocalRecorder::startRecording() Manager::instance().getRingBufferPool().bindHalfDuplexOut(path_, RingBufferPool::DEFAULT_ID); Manager::instance().startAudioDriverStream(); - audioInput_ = ring::getAudioInput(path_); + audioInput_ = jami::getAudioInput(path_); audioInput_->setFormat(AudioFormat::STEREO()); audioInput_->attach(recorder_->addStream(audioInput_->getInfo())); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // video recording if (!isAudioOnly_) { - videoInput_ = std::static_pointer_cast<video::VideoInput>(ring::getVideoCamera()); + videoInput_ = std::static_pointer_cast<video::VideoInput>(jami::getVideoCamera()); if (videoInput_) { videoInput_->attach(recorder_->addStream(videoInput_->getInfo())); } else { - RING_ERR() << "Unable to record video (no video input)"; + JAMI_ERR() << "Unable to record video (no video input)"; return false; } } @@ -110,4 +110,4 @@ LocalRecorder::stopRecording() Recordable::stopRecording(); } -} // namespace ring +} // namespace jami diff --git a/src/media/localrecorder.h b/src/media/localrecorder.h index e4ed43363e..d91b3767f1 100644 --- a/src/media/localrecorder.h +++ b/src/media/localrecorder.h @@ -25,7 +25,7 @@ #include "recordable.h" #include "video/video_input.h" -namespace ring { +namespace jami { /* * @file localrecorder.h @@ -63,8 +63,8 @@ class LocalRecorder : public Recordable { std::string path_; // media inputs - std::shared_ptr<ring::video::VideoInput> videoInput_; - std::shared_ptr<ring::AudioInput> audioInput_; + std::shared_ptr<jami::video::VideoInput> videoInput_; + std::shared_ptr<jami::AudioInput> audioInput_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/localrecordermanager.cpp b/src/media/localrecordermanager.cpp index 1a3b04d3fe..6e408ce3fa 100644 --- a/src/media/localrecordermanager.cpp +++ b/src/media/localrecordermanager.cpp @@ -20,7 +20,7 @@ #include "localrecordermanager.h" -namespace ring { +namespace jami { LocalRecorderManager& LocalRecorderManager::instance() @@ -69,4 +69,4 @@ LocalRecorderManager::hasRunningRecorders() return false; } -} // namespace ring +} // namespace jami diff --git a/src/media/localrecordermanager.h b/src/media/localrecordermanager.h index 189525110a..f85600fca0 100644 --- a/src/media/localrecordermanager.h +++ b/src/media/localrecordermanager.h @@ -23,7 +23,7 @@ #include <memory> #include <localrecorder.h> -namespace ring { +namespace jami { class LocalRecorderManager { public: @@ -55,4 +55,4 @@ class LocalRecorderManager { std::mutex recorderMapMutex_; }; -} // namespace ring +} // namespace jami diff --git a/src/media/media_buffer.cpp b/src/media/media_buffer.cpp index a9481fde9d..3fd8f79bc1 100644 --- a/src/media/media_buffer.cpp +++ b/src/media/media_buffer.cpp @@ -28,9 +28,9 @@ #include <cstring> // std::memset #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO //=== HELPERS ================================================================== @@ -40,6 +40,6 @@ videoFrameSize(int format, int width, int height) return av_image_get_buffer_size((AVPixelFormat)format, width, height, 1); } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO -} // namespace ring +} // namespace jami diff --git a/src/media/media_buffer.h b/src/media/media_buffer.h index 3538604d63..4d7389b416 100644 --- a/src/media/media_buffer.h +++ b/src/media/media_buffer.h @@ -32,18 +32,18 @@ namespace DRing { struct FrameBuffer; // from dring/videomanager_interface.h } -namespace ring { +namespace jami { using MediaFrame = DRing::MediaFrame; using AudioFrame = DRing::AudioFrame; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO using VideoFrame = DRing::VideoFrame; // Some helpers int videoFrameSize(int format, int width, int height); -#endif // RING_VIDEO +#endif // ENABLE_VIDEO -} // namespace ring +} // namespace jami diff --git a/src/media/media_codec.cpp b/src/media/media_codec.cpp index eb75d9306c..724204c943 100644 --- a/src/media/media_codec.cpp +++ b/src/media/media_codec.cpp @@ -28,7 +28,7 @@ #include <string> #include <sstream> -namespace ring { +namespace jami { static unsigned generateId() @@ -183,9 +183,9 @@ AccountAudioCodecInfo::getCodecSpecifications() void AccountAudioCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details) { - decltype(bitrate) tmp_bitrate = ring::stoi(details.at(DRing::Account::ConfProperties::CodecInfo::BITRATE)); + decltype(bitrate) tmp_bitrate = jami::stoi(details.at(DRing::Account::ConfProperties::CodecInfo::BITRATE)); decltype(audioformat) tmp_audioformat = audioformat; - tmp_audioformat.sample_rate = ring::stoi(details.at(DRing::Account::ConfProperties::CodecInfo::SAMPLE_RATE)); + tmp_audioformat.sample_rate = jami::stoi(details.at(DRing::Account::ConfProperties::CodecInfo::SAMPLE_RATE)); // copy back if no exception was raised bitrate = tmp_bitrate; @@ -228,15 +228,15 @@ AccountVideoCodecInfo::setCodecSpecifications(const std::map<std::string, std::s auto it = details.find(DRing::Account::ConfProperties::CodecInfo::BITRATE); if (it != details.end()) - copy.bitrate = ring::stoi(it->second); + copy.bitrate = jami::stoi(it->second); it = details.find(DRing::Account::ConfProperties::CodecInfo::FRAME_RATE); if (it != details.end()) - copy.frameRate = ring::stoi(it->second); + copy.frameRate = jami::stoi(it->second); it = details.find(DRing::Account::ConfProperties::CodecInfo::QUALITY); if (it != details.end()) - copy.quality = ring::stoi(it->second); + copy.quality = jami::stoi(it->second); it = details.find(DRing::Account::ConfProperties::CodecInfo::AUTO_QUALITY_ENABLED); if (it != details.end()) @@ -246,4 +246,4 @@ AccountVideoCodecInfo::setCodecSpecifications(const std::map<std::string, std::s *this = std::move(copy); } -} // namespace ring +} // namespace jami diff --git a/src/media/media_codec.h b/src/media/media_codec.h index 1236925dfe..3a7e67de45 100644 --- a/src/media/media_codec.h +++ b/src/media/media_codec.h @@ -35,7 +35,7 @@ #include <iostream> #include <unistd.h> -namespace ring { +namespace jami { enum CodecType : unsigned { CODEC_NONE = 0, // indicates that no codec is used or defined @@ -59,7 +59,7 @@ enum MediaType : unsigned { struct SystemCodecInfo { static constexpr unsigned DEFAULT_CODEC_QUALITY {30}; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO static constexpr unsigned DEFAULT_H264_MIN_QUALITY {35}; static constexpr unsigned DEFAULT_H264_MAX_QUALITY {20}; static constexpr unsigned DEFAULT_VP8_MIN_QUALITY {50}; @@ -284,4 +284,4 @@ struct MediaDescription { CryptoAttribute crypto {}; }; -}//namespace ring +}//namespace jami diff --git a/src/media/media_decoder.cpp b/src/media/media_decoder.cpp index b3d63d6b44..d46a6bf39a 100644 --- a/src/media/media_decoder.cpp +++ b/src/media/media_decoder.cpp @@ -44,7 +44,7 @@ #include <chrono> #include <algorithm> -namespace ring { +namespace jami { // maximum number of packets the jitter buffer can queue const unsigned jitterBufferMaxSize_ {1500}; @@ -75,7 +75,7 @@ int MediaDecoder::openInput(const DeviceParams& params) AVInputFormat *iformat = av_find_input_format(params.format.c_str()); if (!iformat && !params.format.empty()) - RING_WARN("Cannot find format \"%s\"", params.format.c_str()); + JAMI_WARN("Cannot find format \"%s\"", params.format.c_str()); if (params.width and params.height) { std::stringstream ss; @@ -97,30 +97,30 @@ int MediaDecoder::openInput(const DeviceParams& params) if (params.framerate.denominator() == 333333) framerate = (int)(params.framerate.real()); if (params.framerate.denominator() != 4999998) - av_dict_set(&options_, "framerate", ring::to_string(framerate).c_str(), 0); + av_dict_set(&options_, "framerate", std::to_string(framerate).c_str(), 0); #else - av_dict_set(&options_, "framerate", ring::to_string(params.framerate.real()).c_str(), 0); + av_dict_set(&options_, "framerate", std::to_string(params.framerate.real()).c_str(), 0); #endif } if (params.offset_x || params.offset_y) { - av_dict_set(&options_, "offset_x", ring::to_string(params.offset_x).c_str(), 0); - av_dict_set(&options_, "offset_y", ring::to_string(params.offset_y).c_str(), 0); + av_dict_set(&options_, "offset_x", std::to_string(params.offset_x).c_str(), 0); + av_dict_set(&options_, "offset_y", std::to_string(params.offset_y).c_str(), 0); } if (params.channel) - av_dict_set(&options_, "channel", ring::to_string(params.channel).c_str(), 0); + av_dict_set(&options_, "channel", std::to_string(params.channel).c_str(), 0); av_dict_set(&options_, "loop", params.loop.c_str(), 0); av_dict_set(&options_, "sdp_flags", params.sdp_flags.c_str(), 0); // Set jitter buffer options - av_dict_set(&options_, "reorder_queue_size",ring::to_string(jitterBufferMaxSize_).c_str(), 0); + av_dict_set(&options_, "reorder_queue_size", std::to_string(jitterBufferMaxSize_).c_str(), 0); auto us = std::chrono::duration_cast<std::chrono::microseconds>(jitterBufferMaxDelay_).count(); - av_dict_set(&options_, "max_delay",ring::to_string(us).c_str(), 0); + av_dict_set(&options_, "max_delay", std::to_string(us).c_str(), 0); if(!params.pixel_format.empty()){ av_dict_set(&options_, "pixel_format", params.pixel_format.c_str(), 0); } - RING_DBG("Trying to open device %s with format %s, pixel format %s, size %dx%d, rate %lf", params.input.c_str(), + JAMI_DBG("Trying to open device %s with format %s, pixel format %s, size %dx%d, rate %lf", params.input.c_str(), params.format.c_str(), params.pixel_format.c_str(), params.width, params.height, params.framerate.real()); #ifdef RING_ACCEL @@ -136,9 +136,9 @@ int MediaDecoder::openInput(const DeviceParams& params) options_ ? &options_ : NULL); if (ret) { - RING_ERR("avformat_open_input failed: %s", libav_utils::getError(ret).c_str()); + JAMI_ERR("avformat_open_input failed: %s", libav_utils::getError(ret).c_str()); } else { - RING_DBG("Using format %s", params.format.c_str()); + JAMI_DBG("Using format %s", params.format.c_str()); } return ret; @@ -182,29 +182,29 @@ MediaDecoder::setupStream(AVMediaType mediaType) // If fallback from accel, don't check for stream info, it's already done if (!fallback_) { - RING_DBG() << "Finding " << streamType << " stream info"; + JAMI_DBG() << "Finding " << streamType << " stream info"; if ((ret = avformat_find_stream_info(inputCtx_, nullptr)) < 0) { // Always fail here - RING_ERR() << "Could not find " << streamType << " stream info: " << libav_utils::getError(ret); + JAMI_ERR() << "Could not find " << streamType << " stream info: " << libav_utils::getError(ret); return -1; } } if ((streamIndex_ = selectStream(mediaType)) < 0) { - RING_ERR() << "No suitable " << streamType << " stream found"; + JAMI_ERR() << "No suitable " << streamType << " stream found"; return -1; } avStream_ = inputCtx_->streams[streamIndex_]; inputDecoder_ = findDecoder(avStream_->codecpar->codec_id); if (!inputDecoder_) { - RING_ERR() << "Unsupported codec"; + JAMI_ERR() << "Unsupported codec"; return -1; } decoderCtx_ = avcodec_alloc_context3(inputDecoder_); if (!decoderCtx_) { - RING_ERR() << "Failed to create decoder context"; + JAMI_ERR() << "Failed to create decoder context"; return -1; } avcodec_parameters_to_context(decoderCtx_, avStream_->codecpar); @@ -221,7 +221,7 @@ MediaDecoder::setupStream(AVMediaType mediaType) decoderCtx_->thread_count = std::max(1u, std::min(8u, std::thread::hardware_concurrency()/2)); if (emulateRate_) - RING_DBG() << "Using framerate emulation"; + JAMI_DBG() << "Using framerate emulation"; startTime_ = av_gettime(); // used to set pts after decoding, and for rate emulation #ifdef RING_ACCEL @@ -234,25 +234,25 @@ MediaDecoder::setupStream(AVMediaType mediaType) decoderCtx_->opaque = accel_.get(); } } else if (Manager::instance().videoPreferences.getDecodingAccelerated()) { - RING_WARN() << "Hardware decoding disabled because of previous failure"; + JAMI_WARN() << "Hardware decoding disabled because of previous failure"; } else { - RING_WARN() << "Hardware decoding disabled by user preference"; + JAMI_WARN() << "Hardware decoding disabled by user preference"; } } #endif - RING_DBG() << "Decoding " << streamType << " using " << inputDecoder_->long_name << " (" << inputDecoder_->name << ")"; + JAMI_DBG() << "Decoding " << streamType << " using " << inputDecoder_->long_name << " (" << inputDecoder_->name << ")"; ret = avcodec_open2(decoderCtx_, inputDecoder_, nullptr); if (ret < 0) { - RING_ERR() << "Could not open codec: " << libav_utils::getError(ret); + JAMI_ERR() << "Could not open codec: " << libav_utils::getError(ret); return -1; } return 0; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO int MediaDecoder::setupFromVideoData() { return setupStream(AVMEDIA_TYPE_VIDEO); @@ -269,7 +269,7 @@ MediaDecoder::decode(VideoFrame& result) } else if (ret == AVERROR_EOF) { return Status::EOFError; } else if (ret < 0) { - RING_ERR("Couldn't read frame: %s\n", libav_utils::getError(ret).c_str()); + JAMI_ERR("Couldn't read frame: %s\n", libav_utils::getError(ret).c_str()); return Status::ReadError; } @@ -315,7 +315,7 @@ MediaDecoder::decode(VideoFrame& result) return Status::Success; } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO MediaDecoder::Status MediaDecoder::decode(AudioFrame& decodedFrame) @@ -331,7 +331,7 @@ MediaDecoder::decode(AudioFrame& decodedFrame) } else if (ret == AVERROR_EOF) { return Status::EOFError; } else if (ret < 0) { - RING_ERR("Couldn't read frame: %s\n", libav_utils::getError(ret).c_str()); + JAMI_ERR("Couldn't read frame: %s\n", libav_utils::getError(ret).c_str()); return Status::ReadError; } @@ -379,7 +379,7 @@ MediaDecoder::decode(AudioFrame& decodedFrame) return Status::Success; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #ifdef RING_ACCEL void MediaDecoder::enableAccel(bool enableAccel) @@ -419,7 +419,7 @@ MediaDecoder::flush(VideoFrame& result) return Status::Success; } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO int MediaDecoder::getWidth() const { return decoderCtx_->width; } @@ -484,4 +484,4 @@ MediaDecoder::getStream(std::string name) const return ms; } -} // namespace ring +} // namespace jami diff --git a/src/media/media_decoder.h b/src/media/media_decoder.h index 6a69336e11..f412c2cf87 100644 --- a/src/media/media_decoder.h +++ b/src/media/media_decoder.h @@ -23,10 +23,10 @@ #include "rational.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "video/video_base.h" #include "video/video_scaler.h" -#endif // RING_VIDEO +#endif // ENABLE_VIDEO #include "audio/audiobuffer.h" @@ -51,7 +51,7 @@ namespace DRing { class AudioFrame; } -namespace ring { +namespace jami { using AudioFrame = DRing::AudioFrame; struct AudioFormat; @@ -84,11 +84,11 @@ class MediaDecoder { int openInput(const DeviceParams&); void setIOContext(MediaIOHandle *ioctx); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO int setupFromVideoData(); Status decode(VideoFrame&); Status flush(VideoFrame&); -#endif // RING_VIDEO +#endif // ENABLE_VIDEO int setupFromAudioData(); Status decode(AudioFrame&); @@ -139,4 +139,4 @@ class MediaDecoder { AVDictionary *options_ = nullptr; }; -} // namespace ring +} // namespace jami diff --git a/src/media/media_device.h b/src/media/media_device.h index b590b1d3ab..1024e0f59a 100644 --- a/src/media/media_device.h +++ b/src/media/media_device.h @@ -26,7 +26,7 @@ #include <string> #include <chrono> -namespace ring { +namespace jami { constexpr static auto NEWPARAMS_TIMEOUT = std::chrono::milliseconds(1000); diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp index 22bce401d9..5574df82ef 100644 --- a/src/media/media_encoder.cpp +++ b/src/media/media_encoder.cpp @@ -50,7 +50,7 @@ extern "C" { // Define following line if you need to debug libav SDP //#define DEBUG_SDP 1 -namespace ring { +namespace jami { MediaEncoder::MediaEncoder() : outputCtx_(avformat_alloc_context()) @@ -79,7 +79,7 @@ void MediaEncoder::setOptions(const MediaStream& opts) { if (!opts.isValid()) { - RING_ERR() << "Invalid options"; + JAMI_ERR() << "Invalid options"; return; } @@ -99,9 +99,9 @@ MediaEncoder::setOptions(const MediaStream& opts) void MediaEncoder::setOptions(const MediaDescription& args) { - libav_utils::setDictValue(&options_, "payload_type", ring::to_string(args.payload_type)); - libav_utils::setDictValue(&options_, "max_rate", ring::to_string(args.codec->bitrate)); - libav_utils::setDictValue(&options_, "crf", ring::to_string(args.codec->quality)); + libav_utils::setDictValue(&options_, "payload_type", jami::to_string(args.payload_type)); + libav_utils::setDictValue(&options_, "max_rate", jami::to_string(args.codec->bitrate)); + libav_utils::setDictValue(&options_, "crf", jami::to_string(args.codec->quality)); if (not args.parameters.empty()) libav_utils::setDictValue(&options_, "parameters", args.parameters); @@ -197,7 +197,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr outputCodec = avcodec_find_encoder_by_name(accel_->getCodecName().c_str()); } } else { - RING_WARN() << "Hardware encoding disabled"; + JAMI_WARN() << "Hardware encoding disabled"; } } #endif @@ -212,7 +212,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr else outputCodec = avcodec_find_encoder(static_cast<AVCodecID>(systemCodecInfo.avcodecId)); if (!outputCodec) { - RING_ERR("Encoder \"%s\" not found!", systemCodecInfo.name.c_str()); + JAMI_ERR("Encoder \"%s\" not found!", systemCodecInfo.name.c_str()); throw MediaEncoderException("No output encoder"); } } @@ -246,7 +246,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr // Streaming => VBV (constrained encoding) + CRF (Constant Rate Factor) if (crf == SystemCodecInfo::DEFAULT_NO_QUALITY) crf = 30; // good value for H264-720p@30 - RING_DBG("H264 encoder setup: crf=%u, maxrate=%u, bufsize=%u", crf, maxBitrate, bufSize); + JAMI_DBG("H264 encoder setup: crf=%u, maxrate=%u, bufsize=%u", crf, maxBitrate, bufSize); av_opt_set_int(encoderCtx, "crf", crf, AV_OPT_SEARCH_CHILDREN); encoderCtx->rc_buffer_size = bufSize; @@ -274,9 +274,9 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr encoderCtx->bit_rate = maxBitrate; if (crf != SystemCodecInfo::DEFAULT_NO_QUALITY) { av_opt_set_int(encoderCtx, "crf", crf, AV_OPT_SEARCH_CHILDREN); - RING_DBG("Using quality factor %d", crf); + JAMI_DBG("Using quality factor %d", crf); } else { - RING_DBG("Using Max bitrate %d", maxBitrate); + JAMI_DBG("Using Max bitrate %d", maxBitrate); } } else if (systemCodecInfo.avcodecId == AV_CODEC_ID_MPEG4) { // For MPEG4 : @@ -284,11 +284,11 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr // Use CBR (set bitrate) encoderCtx->rc_buffer_size = maxBitrate; encoderCtx->bit_rate = encoderCtx->rc_min_rate = encoderCtx->rc_max_rate = maxBitrate; - RING_DBG("Using Max bitrate %d", maxBitrate); + JAMI_DBG("Using Max bitrate %d", maxBitrate); } else if (systemCodecInfo.avcodecId == AV_CODEC_ID_H263) { encoderCtx->bit_rate = encoderCtx->rc_max_rate = maxBitrate; encoderCtx->rc_buffer_size = maxBitrate; - RING_DBG("Using Max bitrate %d", maxBitrate); + JAMI_DBG("Using Max bitrate %d", maxBitrate); } // add video stream to outputformat context @@ -309,7 +309,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr #endif // framerate is not copied from encoderCtx to stream stream->avg_frame_rate = encoderCtx->framerate; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (systemCodecInfo.mediaType == MEDIA_VIDEO) { // allocate buffers for both scaled (pre-encoder) and encoded frames const int width = encoderCtx->width; @@ -332,7 +332,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr scaledFrameBuffer_.reserve(scaledFrameBufferSize_); scaledFrame_.setFromMemory(scaledFrameBuffer_.data(), format, width, height); } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO return stream->index; } @@ -366,7 +366,7 @@ MediaEncoder::startIO() if (!outputCtx_->pb) openIOContext(); if (avformat_write_header(outputCtx_, options_ ? &options_ : nullptr)) { - RING_ERR("Could not write header for output file... check codec parameters"); + JAMI_ERR("Could not write header for output file... check codec parameters"); throw MediaEncoderException("Failed to write output file header"); } @@ -378,10 +378,9 @@ MediaEncoder::startIO() initialized_ = true; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO int -MediaEncoder::encode(VideoFrame& input, bool is_keyframe, - int64_t frame_number) +MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number) { if (!initialized_) { initStream(videoCodec_, input.pointer()->hw_frames_ctx); @@ -438,7 +437,7 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, return encode(frame, currentStreamIdx_); } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO int MediaEncoder::encodeAudio(AudioFrame& frame) @@ -485,7 +484,7 @@ MediaEncoder::encode(AVFrame* frame, int streamIdx) if (ret == AVERROR(EAGAIN)) break; if (ret < 0 && ret != AVERROR_EOF) { // we still want to write our frame on EOF - RING_ERR() << "Failed to encode frame: " << libav_utils::getError(ret); + JAMI_ERR() << "Failed to encode frame: " << libav_utils::getError(ret); return ret; } @@ -521,7 +520,7 @@ MediaEncoder::send(AVPacket& pkt, int streamIdx) // write the compressed frame auto ret = av_write_frame(outputCtx_, &pkt); if (ret < 0) { - RING_ERR() << "av_write_frame failed: " << libav_utils::getError(ret); + JAMI_ERR() << "av_write_frame failed: " << libav_utils::getError(ret); } return ret >= 0; } @@ -532,7 +531,7 @@ MediaEncoder::flush() int ret = 0; for (size_t i = 0; i < outputCtx_->nb_streams; ++i) { if (encode(nullptr, i) < 0) { - RING_ERR() << "Could not flush stream #" << i; + JAMI_ERR() << "Could not flush stream #" << i; ret |= 1u << i; // provide a way for caller to know which streams failed } } @@ -559,7 +558,7 @@ MediaEncoder::print_sdp() result += line + "\n"; } #ifdef DEBUG_SDP - RING_DBG("Sending SDP:\n%s", result.c_str()); + JAMI_DBG("Sending SDP:\n%s", result.c_str()); #endif return result; } @@ -572,7 +571,7 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video) auto encoderName = outputCodec->name; // guaranteed to be non null if AVCodec is not null encoderCtx->thread_count = std::min(std::thread::hardware_concurrency(), is_video ? 16u : 4u); - RING_DBG("[%s] Using %d threads", encoderName, encoderCtx->thread_count); + JAMI_DBG("[%s] Using %d threads", encoderName, encoderCtx->thread_count); if (is_video) { // resolution must be a multiple of two @@ -605,7 +604,7 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video) encoderCtx->time_base = AVRational{1, encoderCtx->sample_rate}; if (audioOpts_.nbChannels > 2 || audioOpts_.nbChannels < 1) { encoderCtx->channels = std::max(std::min(audioOpts_.nbChannels, 1), 2); - RING_ERR() << "[" << encoderName << "] Clamping invalid channel count: " + JAMI_ERR() << "[" << encoderName << "] Clamping invalid channel count: " << audioOpts_.nbChannels << " -> " << encoderCtx->channels; } else { encoderCtx->channels = audioOpts_.nbChannels; @@ -613,9 +612,9 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video) encoderCtx->channel_layout = av_get_default_channel_layout(encoderCtx->channels); if (audioOpts_.frameSize) { encoderCtx->frame_size = audioOpts_.frameSize; - RING_DBG() << "[" << encoderName << "] Frame size " << encoderCtx->frame_size; + JAMI_DBG() << "[" << encoderName << "] Frame size " << encoderCtx->frame_size; } else { - RING_WARN() << "[" << encoderName << "] Frame size not set"; + JAMI_WARN() << "[" << encoderName << "] Frame size not set"; } } @@ -627,10 +626,10 @@ MediaEncoder::forcePresetX264(AVCodecContext* encoderCtx) { const char *speedPreset = "ultrafast"; if (av_opt_set(encoderCtx, "preset", speedPreset, AV_OPT_SEARCH_CHILDREN)) - RING_WARN("Failed to set x264 preset '%s'", speedPreset); + JAMI_WARN("Failed to set x264 preset '%s'", speedPreset); const char *tune = "zerolatency"; if (av_opt_set(encoderCtx, "tune", tune, AV_OPT_SEARCH_CHILDREN)) - RING_WARN("Failed to set x264 tune '%s'", tune); + JAMI_WARN("Failed to set x264 tune '%s'", tune); } void @@ -679,11 +678,11 @@ MediaEncoder::extractProfileLevelID(const std::string ¶meters, ctx->profile |= FF_PROFILE_H264_INTRA; break; } - RING_DBG("Using profile %x and level %d", ctx->profile, ctx->level); + JAMI_DBG("Using profile %x and level %d", ctx->profile, ctx->level); } bool -MediaEncoder::useCodec(const ring::AccountCodecInfo* codec) const noexcept +MediaEncoder::useCodec(const jami::AccountCodecInfo* codec) const noexcept { if (codec->systemCodecInfo.mediaType == MEDIA_VIDEO) return videoCodec_ == codec->systemCodecInfo.name; @@ -744,16 +743,16 @@ MediaEncoder::readConfig(AVDictionary** dict, AVCodecContext* encoderCtx) std::ifstream file(path); file >> root; if (!root.isObject()) { - RING_ERR() << "Invalid encoder configuration: root is not an object"; + JAMI_ERR() << "Invalid encoder configuration: root is not an object"; return; } const auto& config = root[name]; if (config.isNull()) { - RING_WARN() << "Encoder '" << name << "' not found in configuration file"; + JAMI_WARN() << "Encoder '" << name << "' not found in configuration file"; return; } if (!config.isObject()) { - RING_ERR() << "Invalid encoder configuration: '" << name << "' is not an object"; + JAMI_ERR() << "Invalid encoder configuration: '" << name << "' is not an object"; return; } // If users want to change these, they should use the settings page. @@ -761,7 +760,7 @@ MediaEncoder::readConfig(AVDictionary** dict, AVCodecContext* encoderCtx) Json::Value v = *it; if (!it.key().isConvertibleTo(Json::ValueType::stringValue) || !v.isConvertibleTo(Json::ValueType::stringValue)) { - RING_ERR() << "Invalid configuration for '" << name << "'"; + JAMI_ERR() << "Invalid configuration for '" << name << "'"; return; } const auto& key = it.key().asString(); @@ -791,9 +790,9 @@ MediaEncoder::readConfig(AVDictionary** dict, AVCodecContext* encoderCtx) libav_utils::setDictValue(dict, key, value); } } catch (const Json::Exception& e) { - RING_ERR() << "Failed to load encoder configuration file: " << e.what(); + JAMI_ERR() << "Failed to load encoder configuration file: " << e.what(); } } } -} // namespace ring +} // namespace jami diff --git a/src/media/media_encoder.h b/src/media/media_encoder.h index aca4312414..264cd85019 100644 --- a/src/media/media_encoder.h +++ b/src/media/media_encoder.h @@ -24,7 +24,7 @@ #include "config.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "video/video_base.h" #include "video/video_scaler.h" #endif @@ -44,7 +44,7 @@ struct AVFormatContext; struct AVDictionary; struct AVCodec; -namespace ring { +namespace jami { struct MediaDescription; struct AccountCodecInfo; @@ -74,9 +74,9 @@ public: bool send(AVPacket& packet, int streamIdx = -1); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO int encode(VideoFrame &input, bool is_keyframe, int64_t frame_number); -#endif // RING_VIDEO +#endif // ENABLE_VIDEO int encodeAudio(AudioFrame& frame); @@ -122,10 +122,10 @@ private: unsigned sent_samples = 0; bool initialized_ {false}; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO video::VideoScaler scaler_; VideoFrame scaledFrame_; -#endif // RING_VIDEO +#endif // ENABLE_VIDEO std::vector<uint8_t> scaledFrameBuffer_; int scaledFrameBufferSize_ = 0; @@ -144,6 +144,6 @@ protected: std::string audioCodec_; }; -} // namespace ring +} // namespace jami #endif // __MEDIA_ENCODER_H__ diff --git a/src/media/media_filter.cpp b/src/media/media_filter.cpp index 7d3ac7cfee..13884ea90d 100644 --- a/src/media/media_filter.cpp +++ b/src/media/media_filter.cpp @@ -33,7 +33,7 @@ extern "C" { #include <sstream> #include <thread> -namespace ring { +namespace jami { MediaFilter::MediaFilter() {} @@ -105,7 +105,7 @@ MediaFilter::initialize(const std::string& filterDesc, std::vector<MediaStream> if ((ret = avfilter_graph_config(graph_, nullptr)) < 0) return fail("Failed to configure filter graph", ret); - RING_DBG() << "Filter graph initialized with: " << desc_; + JAMI_DBG() << "Filter graph initialized with: " << desc_; initialized_ = true; return 0; } @@ -214,7 +214,7 @@ MediaFilter::readOutput() } else if (err == AVERROR(EAGAIN)) { // no data available right now, try again } else if (err == AVERROR_EOF) { - RING_WARN() << "Filters have reached EOF, no more frames will be output"; + JAMI_WARN() << "Filters have reached EOF, no more frames will be output"; } else { fail("Error occurred while pulling from filter graph", err); } @@ -227,7 +227,7 @@ MediaFilter::flush() for (size_t i = 0; i < inputs_.size(); ++i) { int ret = av_buffersrc_add_frame_flags(inputs_[i], nullptr, 0); if (ret < 0) { - RING_ERR() << "Failed to flush filter '" << inputParams_[i].name << "': " << libav_utils::getError(ret); + JAMI_ERR() << "Failed to flush filter '" << inputParams_[i].name << "': " << libav_utils::getError(ret); } } } @@ -320,7 +320,7 @@ MediaFilter::reinitialize() clean(); auto ret = initialize(desc, params); if (ret >= 0) - RING_DBG() << "Filter graph reinitialized"; + JAMI_DBG() << "Filter graph reinitialized"; return ret; } @@ -328,7 +328,7 @@ int MediaFilter::fail(std::string msg, int err) const { if (!msg.empty()) - RING_ERR() << msg << ": " << libav_utils::getError(err); + JAMI_ERR() << msg << ": " << libav_utils::getError(err); return err; } @@ -343,4 +343,4 @@ MediaFilter::clean() inputParams_.clear(); } -} // namespace ring +} // namespace jami diff --git a/src/media/media_filter.h b/src/media/media_filter.h index 8791219369..2e000fc0c2 100644 --- a/src/media/media_filter.h +++ b/src/media/media_filter.h @@ -32,7 +32,7 @@ struct AVFilterContext; struct AVFilterGraph; struct AVFilterInOut; -namespace ring { +namespace jami { /** * Provides access to libavfilter. @@ -165,4 +165,4 @@ class MediaFilter { bool initialized_ {false}; }; -}; // namespace ring +}; // namespace jami diff --git a/src/media/media_io_handle.cpp b/src/media/media_io_handle.cpp index 8c1a76d775..d37ff45256 100644 --- a/src/media/media_io_handle.cpp +++ b/src/media/media_io_handle.cpp @@ -21,7 +21,7 @@ #include "libav_deps.h" // MUST BE INCLUDED FIRST #include "media_io_handle.h" -namespace ring { +namespace jami { MediaIOHandle::MediaIOHandle(std::size_t buffer_size, bool writeable, @@ -47,4 +47,4 @@ MediaIOHandle::~MediaIOHandle() av_free(ctx_); } -} // namespace ring +} // namespace jami diff --git a/src/media/media_io_handle.h b/src/media/media_io_handle.h index 03cecef384..c45053dead 100644 --- a/src/media/media_io_handle.h +++ b/src/media/media_io_handle.h @@ -35,7 +35,7 @@ typedef int(*io_readcallback)(void *opaque, uint8_t *buf, int buf_size); typedef int(*io_writecallback)(void *opaque, uint8_t *buf, int buf_size); typedef int64_t(*io_seekcallback)(void *opaque, int64_t offset, int whence); -namespace ring { +namespace jami { class MediaIOHandle { public: @@ -54,6 +54,6 @@ private: AVIOContext *ctx_; }; -} // namespace ring +} // namespace jami #endif // __MEDIA_DECODER_H__ diff --git a/src/media/media_recorder.cpp b/src/media/media_recorder.cpp index bdd25c66b3..72627eac6e 100644 --- a/src/media/media_recorder.cpp +++ b/src/media/media_recorder.cpp @@ -41,7 +41,7 @@ extern "C" { #include <libavutil/display.h> } -namespace ring { +namespace jami { const constexpr char ROTATION_FILTER_INPUT_NAME[] = "in"; @@ -78,7 +78,7 @@ struct MediaRecorder::StreamObserver : public Observer<std::shared_ptr<MediaFram AVFrameSideData* sideData = av_frame_get_side_data(framePtr->pointer(), AV_FRAME_DATA_DISPLAYMATRIX); int angle = sideData ? av_display_rotation_get(reinterpret_cast<int32_t*>(sideData->data)) : 0; if (angle != rotation_) { - videoRotationFilter_ = ring::video::getTransposeFilter(angle, ROTATION_FILTER_INPUT_NAME, framePtr->width(), framePtr->height(), framePtr->format(), true); + videoRotationFilter_ = jami::video::getTransposeFilter(angle, ROTATION_FILTER_INPUT_NAME, framePtr->width(), framePtr->height(), framePtr->format(), true); rotation_ = angle; } if (videoRotationFilter_) { @@ -149,7 +149,7 @@ MediaRecorder::startRecording() encoder_.reset(new MediaEncoder); - RING_DBG() << "Start recording '" << getPath() << "'"; + JAMI_DBG() << "Start recording '" << getPath() << "'"; if (initRecord() >= 0) { isRecording_ = true; // start thread after isRecording_ is set to true @@ -169,7 +169,7 @@ void MediaRecorder::stopRecording() { if (isRecording_) { - RING_DBG() << "Stop recording '" << getPath() << "'"; + JAMI_DBG() << "Stop recording '" << getPath() << "'"; isRecording_ = false; emitSignal<DRing::CallSignal::RecordPlaybackStopped>(getPath()); } @@ -179,7 +179,7 @@ Observer<std::shared_ptr<MediaFrame>>* MediaRecorder::addStream(const MediaStream& ms) { if (audioOnly_ && ms.isVideo) { - RING_ERR() << "Trying to add video stream to audio only recording"; + JAMI_ERR() << "Trying to add video stream to audio only recording"; return nullptr; } @@ -188,14 +188,14 @@ MediaRecorder::addStream(const MediaStream& ms) }); auto p = streams_.insert(std::make_pair(ms.name, std::move(ptr))); if (p.second) { - RING_DBG() << "Recorder input #" << streams_.size() << ": " << ms; + JAMI_DBG() << "Recorder input #" << streams_.size() << ": " << ms; if (ms.isVideo) hasVideo_ = true; else hasAudio_ = true; return p.first->second.get(); } else { - RING_WARN() << "Recorder already has '" << ms.name << "' as input"; + JAMI_WARN() << "Recorder already has '" << ms.name << "' as input"; return p.first->second.get(); } } @@ -268,7 +268,7 @@ MediaRecorder::initRecord() if (hasVideo_) { const MediaStream& videoStream = setupVideoOutput(); if (videoStream.format < 0) { - RING_ERR() << "Could not retrieve video recorder stream properties"; + JAMI_ERR() << "Could not retrieve video recorder stream properties"; return -1; } encoder_->setOptions(videoStream); @@ -278,35 +278,35 @@ MediaRecorder::initRecord() if (hasAudio_) { const MediaStream& audioStream = setupAudioOutput(); if (audioStream.format < 0) { - RING_ERR() << "Could not retrieve audio recorder stream properties"; + JAMI_ERR() << "Could not retrieve audio recorder stream properties"; return -1; } encoder_->setOptions(audioStream); } if (hasVideo_) { - auto videoCodec = std::static_pointer_cast<ring::SystemVideoCodecInfo>( - getSystemCodecContainer()->searchCodecByName("VP8", ring::MEDIA_VIDEO)); + auto videoCodec = std::static_pointer_cast<jami::SystemVideoCodecInfo>( + getSystemCodecContainer()->searchCodecByName("VP8", jami::MEDIA_VIDEO)); videoIdx_ = encoder_->addStream(*videoCodec.get()); if (videoIdx_ < 0) { - RING_ERR() << "Failed to add video stream to encoder"; + JAMI_ERR() << "Failed to add video stream to encoder"; return -1; } } if (hasAudio_) { - auto audioCodec = std::static_pointer_cast<ring::SystemAudioCodecInfo>( - getSystemCodecContainer()->searchCodecByName("opus", ring::MEDIA_AUDIO)); + auto audioCodec = std::static_pointer_cast<jami::SystemAudioCodecInfo>( + getSystemCodecContainer()->searchCodecByName("opus", jami::MEDIA_AUDIO)); audioIdx_ = encoder_->addStream(*audioCodec.get()); if (audioIdx_ < 0) { - RING_ERR() << "Failed to add audio stream to encoder"; + JAMI_ERR() << "Failed to add audio stream to encoder"; return -1; } } encoder_->setIOContext(nullptr); - RING_DBG() << "Recording initialized"; + JAMI_DBG() << "Recording initialized"; return 0; } @@ -345,15 +345,15 @@ MediaRecorder::setupVideoOutput() ret = videoFilter_->initialize(buildVideoFilter({peer}, local), {peer, local}); break; default: - RING_ERR() << "Recording more than 2 video streams is not supported"; + JAMI_ERR() << "Recording more than 2 video streams is not supported"; break; } if (ret >= 0) { encoderStream = videoFilter_->getOutputParams(); - RING_DBG() << "Recorder output: " << encoderStream; + JAMI_DBG() << "Recorder output: " << encoderStream; } else { - RING_ERR() << "Failed to initialize video filter"; + JAMI_ERR() << "Failed to initialize video filter"; } return encoderStream; @@ -389,7 +389,7 @@ MediaRecorder::buildVideoFilter(const std::vector<MediaStream>& peers, const Med } break; default: - RING_ERR() << "Video recordings with more than 2 video streams are not supported"; + JAMI_ERR() << "Video recordings with more than 2 video streams are not supported"; break; } @@ -431,15 +431,15 @@ MediaRecorder::setupAudioOutput() ret = audioFilter_->initialize(buildAudioFilter({peer}, local), {peer, local}); break; default: - RING_ERR() << "Recording more than 2 audio streams is not supported"; + JAMI_ERR() << "Recording more than 2 audio streams is not supported"; break; } if (ret >= 0) { encoderStream = audioFilter_->getOutputParams(); - RING_DBG() << "Recorder output: " << encoderStream; + JAMI_DBG() << "Recorder output: " << encoderStream; } else { - RING_ERR() << "Failed to initialize audio filter"; + JAMI_ERR() << "Failed to initialize audio filter"; } return encoderStream; @@ -499,10 +499,10 @@ MediaRecorder::filterAndEncode(MediaFilter* filter, int streamIdx) std::lock_guard<std::mutex> lk(mutex_); encoder_->encode(frame->pointer(), streamIdx); } catch (const MediaEncoderException& e) { - RING_ERR() << "Failed to record frame: " << e.what(); + JAMI_ERR() << "Failed to record frame: " << e.what(); } } } } -} // namespace ring +} // namespace jami diff --git a/src/media/media_recorder.h b/src/media/media_recorder.h index 753a84e18e..9328af6985 100644 --- a/src/media/media_recorder.h +++ b/src/media/media_recorder.h @@ -36,7 +36,7 @@ #include <string> #include <utility> -namespace ring { +namespace jami { class MediaRecorder : public std::enable_shared_from_this<MediaRecorder> { @@ -139,4 +139,4 @@ private: void filterAndEncode(MediaFilter* filter, int streamIdx); }; -}; // namespace ring +}; // namespace jami diff --git a/src/media/media_stream.h b/src/media/media_stream.h index 615f61dc9f..62fc9c2c69 100644 --- a/src/media/media_stream.h +++ b/src/media/media_stream.h @@ -26,7 +26,7 @@ #include <string> -namespace ring { +namespace jami { struct MediaStream { std::string name {}; @@ -161,4 +161,4 @@ inline std::ostream& operator<<(std::ostream& os, const MediaStream& ms) return os; } -}; // namespace ring +}; // namespace jami diff --git a/src/media/recordable.cpp b/src/media/recordable.cpp index cd29930472..6696152053 100644 --- a/src/media/recordable.cpp +++ b/src/media/recordable.cpp @@ -27,7 +27,7 @@ #include <iomanip> -namespace ring { +namespace jami { Recordable::Recordable() { @@ -51,7 +51,7 @@ bool Recordable::toggleRecording() { if (!recorder_) { - RING_ERR("couldn't toggle recording, non existent recorder"); + JAMI_ERR("couldn't toggle recording, non existent recorder"); return false; } @@ -81,13 +81,13 @@ Recordable::startRecording(const std::string& path) { std::lock_guard<std::mutex> lk {apiMutex_}; if (!recorder_) { - RING_ERR("couldn't start recording, non existent recorder"); + JAMI_ERR("couldn't start recording, non existent recorder"); return false; } if (!recording_) { if (path.empty()) { - RING_ERR("couldn't start recording, path is empty"); + JAMI_ERR("couldn't start recording, path is empty"); return false; } @@ -105,12 +105,12 @@ Recordable::stopRecording() { std::lock_guard<std::mutex> lk {apiMutex_}; if (!recorder_) { - RING_WARN("couldn't stop recording, non existent recorder"); + JAMI_WARN("couldn't stop recording, non existent recorder"); return; } if (not recording_) { - RING_WARN("couldn't stop non-running recording"); + JAMI_WARN("couldn't stop non-running recording"); return; } @@ -126,4 +126,4 @@ Recordable::isAudioOnly() const return isAudioOnly_; } -} // namespace ring +} // namespace jami diff --git a/src/media/recordable.h b/src/media/recordable.h index 02e9a905ee..b5c3717675 100644 --- a/src/media/recordable.h +++ b/src/media/recordable.h @@ -28,7 +28,7 @@ #include <memory> #include <mutex> -namespace ring { +namespace jami { class Recordable { public: @@ -74,4 +74,4 @@ protected: bool isAudioOnly_{false}; }; -} // namespace ring +} // namespace jami diff --git a/src/media/rtp_session.h b/src/media/rtp_session.h index 88f9a0840c..66f2d64af3 100644 --- a/src/media/rtp_session.h +++ b/src/media/rtp_session.h @@ -29,7 +29,7 @@ #include <memory> #include <mutex> -namespace ring { +namespace jami { class IceSocket; class MediaRecorder; @@ -73,4 +73,4 @@ protected: } }; -} // namespace ring +} // namespace jami diff --git a/src/media/socket_pair.cpp b/src/media/socket_pair.cpp index b2a3cf4127..2fe7fb0680 100644 --- a/src/media/socket_pair.cpp +++ b/src/media/socket_pair.cpp @@ -59,7 +59,7 @@ extern "C" { #include <fcntl.h> #endif -namespace ring { +namespace jami { static constexpr int NET_POLL_TIMEOUT = 100; /* poll() timeout in ms */ static constexpr int RTP_MAX_PACKET_LENGTH = 2048; @@ -137,22 +137,22 @@ udp_socket_create(int family, int port) #endif if (udp_fd < 0) { - RING_ERR("socket() failed"); + JAMI_ERR("socket() failed"); strErr(); return -1; } auto bind_addr = ip_utils::getAnyHostAddr(family); if (not bind_addr.isIpv4() and not bind_addr.isIpv6()) { - RING_ERR("No IPv4/IPv6 host found for family %u", family); + JAMI_ERR("No IPv4/IPv6 host found for family %u", family); close(udp_fd); return -1; } bind_addr.setPort(port); - RING_DBG("use local address: %s", bind_addr.toString(true, true).c_str()); + JAMI_DBG("use local address: %s", bind_addr.toString(true, true).c_str()); if (::bind(udp_fd, bind_addr, bind_addr.getLength()) < 0) { - RING_ERR("bind() failed"); + JAMI_ERR("bind() failed"); strErr(); close(udp_fd); udp_fd = -1; @@ -280,7 +280,7 @@ SocketPair::openSockets(const char* uri, int local_rtp_port) throw std::runtime_error("Sockets creation failed"); } - RING_WARN("SocketPair: local{%d,%d} / %s{%d,%d}", + JAMI_WARN("SocketPair: local{%d,%d} / %s{%d,%d}", local_rtp_port, local_rtcp_port, hostname, dst_rtp_port, dst_rtcp_port); } @@ -426,7 +426,7 @@ SocketPair::readCallback(uint8_t* buf, int buf_size) if (not fromRTCP and srtpContext_ and srtpContext_->srtp_in.aes) { auto err = ff_srtp_decrypt(&srtpContext_->srtp_in, buf, &len); if (err < 0) - RING_WARN("decrypt error %d", err); + JAMI_WARN("decrypt error %d", err); } if (len != 0) @@ -485,7 +485,7 @@ SocketPair::writeCallback(uint8_t* buf, int buf_size) buf_size, srtpContext_->encryptbuf, sizeof(srtpContext_->encryptbuf)); if (buf_size < 0) { - RING_WARN("encrypt error %d", buf_size); + JAMI_WARN("encrypt error %d", buf_size); return buf_size; } @@ -516,4 +516,4 @@ SocketPair::rtcpPacketLossDetected() const return rtcpPacketLoss_.compare_exchange_strong(b, false); } -} // namespace ring +} // namespace jami diff --git a/src/media/socket_pair.h b/src/media/socket_pair.h index 42b9dff443..f761c270e4 100644 --- a/src/media/socket_pair.h +++ b/src/media/socket_pair.h @@ -47,7 +47,7 @@ using socklen_t = int; #include <condition_variable> -namespace ring { +namespace jami { class IceSocket; class SRTPProtoContext; @@ -147,4 +147,4 @@ class SocketPair { -} // namespace ring +} // namespace jami diff --git a/src/media/system_codec_container.cpp b/src/media/system_codec_container.cpp index 6bae8bf757..7cbd4c42d3 100644 --- a/src/media/system_codec_container.cpp +++ b/src/media/system_codec_container.cpp @@ -31,7 +31,7 @@ #include <TargetConditionals.h> #endif -namespace ring { +namespace jami { decltype(getGlobalInstance<SystemCodecContainer>)& getSystemCodecContainer = getGlobalInstance<SystemCodecContainer>; @@ -48,7 +48,7 @@ SystemCodecContainer::~SystemCodecContainer() void SystemCodecContainer::initCodecConfig() { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO auto minH264 = SystemCodecInfo::DEFAULT_H264_MIN_QUALITY; auto maxH264 = SystemCodecInfo::DEFAULT_H264_MAX_QUALITY; auto minVP8 = SystemCodecInfo::DEFAULT_VP8_MIN_QUALITY; @@ -56,7 +56,7 @@ SystemCodecContainer::initCodecConfig() auto defaultBitrate = SystemCodecInfo::DEFAULT_VIDEO_BITRATE; #endif availableCodecList_ = { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /* Define supported video codec*/ std::make_shared<SystemVideoCodecInfo>(AV_CODEC_ID_H264, "H264", "libx264", @@ -154,8 +154,8 @@ SystemCodecContainer::checkInstalledCodecs() codecIt->codecType = (CodecType)((unsigned)codecType & ~CODEC_DECODER); } } - RING_INFO("Encoders found: %s", enc_ss.str().c_str()); - RING_INFO("Decoders found: %s", dec_ss.str().c_str()); + JAMI_INFO("Encoders found: %s", enc_ss.str().c_str()); + JAMI_INFO("Decoders found: %s", dec_ss.str().c_str()); } std::vector<std::shared_ptr<SystemCodecInfo>> @@ -216,4 +216,4 @@ SystemCodecContainer::searchCodecByPayload(unsigned payload, MediaType mediaType return {}; } -} // namespace ring +} // namespace jami diff --git a/src/media/system_codec_container.h b/src/media/system_codec_container.h index a2f65a3445..34e37ec61a 100644 --- a/src/media/system_codec_container.h +++ b/src/media/system_codec_container.h @@ -28,7 +28,7 @@ #include <vector> #include <memory> -namespace ring { +namespace jami { class SystemCodecContainer; @@ -63,6 +63,6 @@ class SystemCodecContainer void checkInstalledCodecs(); }; -} // namespace ring +} // namespace jami #endif //SYSTEM_CODEC_CONTAINER diff --git a/src/media/video/accel.cpp b/src/media/video/accel.cpp index fd4e7ab320..648b95cc12 100644 --- a/src/media/video/accel.cpp +++ b/src/media/video/accel.cpp @@ -31,7 +31,7 @@ extern "C" { #include "accel.h" #include "config.h" -namespace ring { namespace video { +namespace jami { namespace video { struct HardwareAPI { @@ -51,14 +51,14 @@ getFormatCb(AVCodecContext* codecCtx, const AVPixelFormat* formats) fallback = formats[i]; if (accel && formats[i] == accel->getFormat()) { // found hardware format for codec with api - RING_DBG() << "Found compatible hardware format for " + JAMI_DBG() << "Found compatible hardware format for " << avcodec_get_name(static_cast<AVCodecID>(accel->getCodecId())) << " decoder with " << accel->getName(); return formats[i]; } } - RING_WARN() << "Not using hardware decoding"; + JAMI_WARN() << "Not using hardware decoding"; return fallback; } @@ -98,7 +98,7 @@ HardwareAccel::transfer(const VideoFrame& frame) if (type_ == CODEC_DECODER) { auto input = frame.pointer(); if (input->format != format_) { - RING_ERR() << "Frame format mismatch: expected " + JAMI_ERR() << "Frame format mismatch: expected " << av_get_pix_fmt_name(format_) << ", got " << av_get_pix_fmt_name(static_cast<AVPixelFormat>(input->format)); return nullptr; @@ -108,7 +108,7 @@ HardwareAccel::transfer(const VideoFrame& frame) } else if (type_ == CODEC_ENCODER) { auto input = frame.pointer(); if (input->format != swFormat_) { - RING_ERR() << "Frame format mismatch: expected " + JAMI_ERR() << "Frame format mismatch: expected " << av_get_pix_fmt_name(swFormat_) << ", got " << av_get_pix_fmt_name(static_cast<AVPixelFormat>(input->format)); return nullptr; @@ -118,24 +118,24 @@ HardwareAccel::transfer(const VideoFrame& frame) auto hwFrame = framePtr->pointer(); if ((ret = av_hwframe_get_buffer(framesCtx_, hwFrame, 0)) < 0) { - RING_ERR() << "Failed to allocate hardware buffer: " << libav_utils::getError(ret); + JAMI_ERR() << "Failed to allocate hardware buffer: " << libav_utils::getError(ret); return nullptr; } if (!hwFrame->hw_frames_ctx) { - RING_ERR() << "Failed to allocate hardware buffer: Cannot allocate memory"; + JAMI_ERR() << "Failed to allocate hardware buffer: Cannot allocate memory"; return nullptr; } if ((ret = av_hwframe_transfer_data(hwFrame, input, 0)) < 0) { - RING_ERR() << "Failed to push frame to GPU: " << libav_utils::getError(ret); + JAMI_ERR() << "Failed to push frame to GPU: " << libav_utils::getError(ret); return nullptr; } hwFrame->pts = input->pts; // transfer does not copy timestamp return framePtr; } else { - RING_ERR() << "Invalid hardware accelerator"; + JAMI_ERR() << "Invalid hardware accelerator"; return nullptr; } } @@ -162,7 +162,7 @@ HardwareAccel::initDevice() // default DRM device may not work on multi GPU computers, so check all possible values if (name_ == "vaapi") { const std::string path = "/dev/dri/"; - auto files = ring::fileutils::readDirectory(path); + auto files = jami::fileutils::readDirectory(path); // renderD* is preferred over card* std::sort(files.rbegin(), files.rend()); for (auto& entry : files) { @@ -183,7 +183,7 @@ HardwareAccel::initFrame(int width, int height) { int ret = 0; if (!deviceCtx_) { - RING_ERR() << "Cannot initialize hardware frames without a valid hardware device"; + JAMI_ERR() << "Cannot initialize hardware frames without a valid hardware device"; return false; } @@ -217,7 +217,7 @@ HardwareAccel::linkHardware(AVBufferRef* framesCtx) av_buffer_unref(&framesCtx_); framesCtx_ = av_buffer_ref(framesCtx); if ((linked_ = (framesCtx_ != nullptr))) { - RING_DBG() << "Hardware transcoding pipeline successfully set up for" + JAMI_DBG() << "Hardware transcoding pipeline successfully set up for" << " encoder '" << getCodecName() << "'"; } return linked_; @@ -266,7 +266,7 @@ HardwareAccel::setupDecoder(AVCodecID id, int width, int height) if (std::find(api.supportedCodecs.begin(), api.supportedCodecs.end(), id) != api.supportedCodecs.end()) { auto accel = std::make_unique<HardwareAccel>(id, api.name, api.format, api.swFormat, CODEC_DECODER); if (accel->initDevice() && accel->initFrame(width, height)) { - RING_DBG() << "Attempting to use hardware decoder " << accel->getCodecName() << " with " << api.name; + JAMI_DBG() << "Attempting to use hardware decoder " << accel->getCodecName() << " with " << api.name; return accel; } } @@ -292,15 +292,15 @@ HardwareAccel::setupEncoder(AVCodecID id, int width, int height, AVBufferRef* fr // Set up a fully accelerated pipeline, else fallback to using the main memory if (accel->linkHardware(framesCtx) || (accel->initDevice() && accel->initFrame(width, height))) { - RING_DBG() << "Attempting to use hardware encoder " << codecName; + JAMI_DBG() << "Attempting to use hardware encoder " << codecName; return accel; } } } } - RING_WARN() << "Not using hardware encoding"; + JAMI_WARN() << "Not using hardware encoding"; return nullptr; } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/accel.h b/src/media/video/accel.h index b6f1a7f7c9..9ff29b8c42 100644 --- a/src/media/video/accel.h +++ b/src/media/video/accel.h @@ -27,7 +27,7 @@ #include <string> #include <vector> -namespace ring { namespace video { +namespace jami { namespace video { /** * Provides an abstraction layer to the hardware acceleration APIs in FFmpeg. @@ -140,4 +140,4 @@ private: AVBufferRef* framesCtx_ {nullptr}; }; -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/androidvideo/video_device_impl.cpp b/src/media/video/androidvideo/video_device_impl.cpp index 0453c6246f..89f9515ea6 100644 --- a/src/media/video/androidvideo/video_device_impl.cpp +++ b/src/media/video/androidvideo/video_device_impl.cpp @@ -32,7 +32,7 @@ #include <vector> #include <array> -namespace ring { namespace video { +namespace jami { namespace video { /* * Array to match Android formats. List formats in ascending @@ -96,16 +96,16 @@ VideoDeviceImpl::selectFormat() } } if (f == and_formats.end()) - RING_WARN("AndroidVideo: No format matching %d", fmt); + JAMI_WARN("AndroidVideo: No format matching %d", fmt); } if (best != UINT_MAX) { fmt_ = &and_formats[best]; - RING_DBG("AndroidVideo: picked format %s", fmt_->name.c_str()); + JAMI_DBG("AndroidVideo: picked format %s", fmt_->name.c_str()); } else { fmt_ = &and_formats[0]; - RING_ERR("AndroidVideo: Could not find a known format to use"); + JAMI_ERR("AndroidVideo: Could not find a known format to use"); } } @@ -225,4 +225,4 @@ VideoDevice::getRateList(const std::string& /* channel */, VideoSize /* size */) VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/androidvideo/video_device_monitor_impl.cpp b/src/media/video/androidvideo/video_device_monitor_impl.cpp index 618bbd314f..333168e5d8 100644 --- a/src/media/video/androidvideo/video_device_monitor_impl.cpp +++ b/src/media/video/androidvideo/video_device_monitor_impl.cpp @@ -34,7 +34,7 @@ #include <thread> #include <vector> -namespace ring { namespace video { +namespace jami { namespace video { using std::vector; using std::string; @@ -81,4 +81,4 @@ VideoDeviceMonitor::VideoDeviceMonitor() : VideoDeviceMonitor::~VideoDeviceMonitor() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/filter_transpose.cpp b/src/media/video/filter_transpose.cpp index aece6ffcbe..80b1bb9143 100644 --- a/src/media/video/filter_transpose.cpp +++ b/src/media/video/filter_transpose.cpp @@ -21,13 +21,13 @@ #include "filter_transpose.h" #include "logger.h" -namespace ring { +namespace jami { namespace video { std::unique_ptr<MediaFilter> getTransposeFilter(int rotation, std::string inputName, int width, int height, int format, bool rescale) { - RING_WARN("Rotation set to %d", rotation); + JAMI_WARN("Rotation set to %d", rotation); if (std::isnan(rotation) || !rotation) { return {}; } @@ -67,7 +67,7 @@ getTransposeFilter(int rotation, std::string inputName, int width, int height, i std::unique_ptr<MediaFilter> filter(new MediaFilter); auto ret = filter->initialize(ss.str(), msv); if (ret < 0) { - RING_ERR() << "filter init fail"; + JAMI_ERR() << "filter init fail"; return {}; } return filter; diff --git a/src/media/video/filter_transpose.h b/src/media/video/filter_transpose.h index 152f32c987..d0504f4441 100644 --- a/src/media/video/filter_transpose.h +++ b/src/media/video/filter_transpose.h @@ -22,7 +22,7 @@ #include "../media_filter.h" -namespace ring { +namespace jami { namespace video { std::unique_ptr<MediaFilter> diff --git a/src/media/video/iosvideo/video_device_impl.cpp b/src/media/video/iosvideo/video_device_impl.cpp index 42d9369254..2273be507a 100644 --- a/src/media/video/iosvideo/video_device_impl.cpp +++ b/src/media/video/iosvideo/video_device_impl.cpp @@ -31,7 +31,7 @@ extern "C" { #include "client/ring_signal.h" -namespace ring { namespace video { +namespace jami { namespace video { typedef struct { @@ -91,16 +91,16 @@ VideoDeviceImpl::selectFormat() } } if (f == ios_formats.end()) - RING_WARN("Video: No format matching %s", fmt.c_str()); + JAMI_WARN("Video: No format matching %s", fmt.c_str()); } if (best != UINT_MAX) { fmt_ = &ios_formats[best]; - RING_DBG("Video: picked format %s", fmt_->name.c_str()); + JAMI_DBG("Video: picked format %s", fmt_->name.c_str()); } else { fmt_ = &ios_formats[0]; - RING_ERR("Video: Could not find a known format to use"); + JAMI_ERR("Video: Could not find a known format to use"); } } @@ -216,5 +216,5 @@ VideoDevice::getRateList(const std::string& channel, VideoSize size) const VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/iosvideo/video_device_monitor_impl.cpp b/src/media/video/iosvideo/video_device_monitor_impl.cpp index 28179d85c0..7b1b7116e9 100644 --- a/src/media/video/iosvideo/video_device_monitor_impl.cpp +++ b/src/media/video/iosvideo/video_device_monitor_impl.cpp @@ -26,7 +26,7 @@ #include "logger.h" #include "noncopyable.h" -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceMonitorImpl { @@ -92,5 +92,5 @@ VideoDeviceMonitor::VideoDeviceMonitor() VideoDeviceMonitor::~VideoDeviceMonitor() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/osxvideo/video_device_impl.mm b/src/media/video/osxvideo/video_device_impl.mm index 110c1adc0d..0f4d4d292e 100644 --- a/src/media/video/osxvideo/video_device_impl.mm +++ b/src/media/video/osxvideo/video_device_impl.mm @@ -33,7 +33,7 @@ #import <AVFoundation/AVFoundation.h> -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceImpl { public: @@ -191,4 +191,4 @@ VideoDevice::getRateList(const std::string& channel, VideoSize size) const VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/osxvideo/video_device_monitor_impl.mm b/src/media/video/osxvideo/video_device_monitor_impl.mm index f8ce211c86..0a6dc9cb67 100644 --- a/src/media/video/osxvideo/video_device_monitor_impl.mm +++ b/src/media/video/osxvideo/video_device_monitor_impl.mm @@ -35,7 +35,7 @@ #import <AVFoundation/AVFoundation.h> -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceMonitorImpl { public: @@ -73,7 +73,7 @@ void VideoDeviceMonitorImpl::start() [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]]; if ( [myVideoDevices count] == 0 ) { - RING_ERR("Can't find any suitable video device"); + JAMI_ERR("Can't find any suitable video device"); return; } @@ -89,7 +89,7 @@ void VideoDeviceMonitorImpl::start() try { monitor_->addDevice([[avf_device uniqueID] UTF8String]); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } } @@ -132,4 +132,4 @@ VideoDeviceMonitor::VideoDeviceMonitor() : VideoDeviceMonitor::~VideoDeviceMonitor() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/sinkclient.cpp b/src/media/video/sinkclient.cpp index 0dba86a992..f2d0578dd8 100644 --- a/src/media/video/sinkclient.cpp +++ b/src/media/video/sinkclient.cpp @@ -62,7 +62,7 @@ extern "C" { #include <libavutil/display.h> } -namespace ring { namespace video { +namespace jami { namespace video { const constexpr char FILTER_INPUT_NAME[] = "in"; @@ -106,7 +106,7 @@ class ShmHolder void unMapShmArea() noexcept { if (area_ != MAP_FAILED and ::munmap(area_, areaSize_) < 0) { - RING_ERR("ShmHolder[%s]: munmap(%zu) failed with errno %d", + JAMI_ERR("ShmHolder[%s]: munmap(%zu) failed with errno %d", openedName_.c_str(), areaSize_, errno); } } @@ -158,7 +158,7 @@ ShmHolder::ShmHolder(const std::string& name) if (::sem_init(&area_->frameGenMutex, 1, 0) < 0) shmFailedWithErrno("sem_init(frameGenMutex)"); - RING_DBG("ShmHolder: new holder '%s'", openedName_.c_str()); + JAMI_DBG("ShmHolder: new holder '%s'", openedName_.c_str()); } ShmHolder::~ShmHolder() @@ -191,13 +191,13 @@ ShmHolder::resizeArea(std::size_t frameSize) noexcept // full area size: +15 to take care of maximum padding size const auto areaSize = sizeof(SHMHeader) + 2 * frameSize + 15; - RING_DBG("ShmHolder[%s]: new sizes: f=%zu, a=%zu", openedName_.c_str(), + JAMI_DBG("ShmHolder[%s]: new sizes: f=%zu, a=%zu", openedName_.c_str(), frameSize, areaSize); unMapShmArea(); if (::ftruncate(fd_, areaSize) < 0) { - RING_ERR("ShmHolder[%s]: ftruncate(%zu) failed with errno %d", + JAMI_ERR("ShmHolder[%s]: ftruncate(%zu) failed with errno %d", openedName_.c_str(), areaSize, errno); return false; } @@ -208,7 +208,7 @@ ShmHolder::resizeArea(std::size_t frameSize) noexcept if (area_ == MAP_FAILED) { areaSize_ = 0; - RING_ERR("ShmHolder[%s]: mmap(%zu) failed with errno %d", + JAMI_ERR("ShmHolder[%s]: mmap(%zu) failed with errno %d", openedName_.c_str(), areaSize, errno); return false; } @@ -241,7 +241,7 @@ ShmHolder::renderFrame(const VideoFrame& src) noexcept const auto frameSize = videoFrameSize(format, width, height); if (!resizeArea(frameSize)) { - RING_ERR("ShmHolder[%s]: could not resize area", + JAMI_ERR("ShmHolder[%s]: could not resize area", openedName_.c_str()); return; } @@ -278,7 +278,7 @@ SinkClient::start() noexcept try { shm_ = std::make_shared<ShmHolder>(); } catch (const std::runtime_error& e) { - RING_ERR("SHMHolder ctor failure: %s", e.what()); + JAMI_ERR("SHMHolder ctor failure: %s", e.what()); } } return static_cast<bool>(shm_); @@ -411,16 +411,16 @@ SinkClient::setFrameSize(int width, int height) width_ = width; height_ = height; if (width > 0 and height > 0) { - RING_WARN("Start sink <%s / %s>, size=%dx%d, mixer=%u", + JAMI_WARN("Start sink <%s / %s>, size=%dx%d, mixer=%u", getId().c_str(), openedName().c_str(), width, height, mixer_); emitSignal<DRing::VideoSignal::DecodingStarted>(getId(), openedName(), width, height, mixer_); started_ = true; } else if (started_) { - RING_ERR("Stop sink <%s / %s>, mixer=%u", + JAMI_ERR("Stop sink <%s / %s>, mixer=%u", getId().c_str(), openedName().c_str(), mixer_); emitSignal<DRing::VideoSignal::DecodingStopped>(getId(), openedName(), mixer_); started_ = false; } } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/sinkclient.h b/src/media/video/sinkclient.h index def2e47d6f..2ee2376c1f 100644 --- a/src/media/video/sinkclient.h +++ b/src/media/video/sinkclient.h @@ -35,9 +35,9 @@ #define DEBUG_FPS -namespace ring {class MediaFilter;} +namespace jami {class MediaFilter;} -namespace ring { namespace video { +namespace jami { namespace video { #if HAVE_SHM class ShmHolder; @@ -69,8 +69,8 @@ class SinkClient : public VideoFramePassiveReader } // as VideoFramePassiveReader - void update(Observable<std::shared_ptr<ring::MediaFrame>>*, - const std::shared_ptr<ring::MediaFrame>&) override; + void update(Observable<std::shared_ptr<jami::MediaFrame>>*, + const std::shared_ptr<jami::MediaFrame>&) override; bool start() noexcept; bool stop() noexcept; @@ -109,4 +109,4 @@ class SinkClient : public VideoFramePassiveReader #endif // HAVE_SHM }; -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/uwpvideo/video_device_impl.cpp b/src/media/video/uwpvideo/video_device_impl.cpp index f02e7fc804..8b266eb257 100644 --- a/src/media/video/uwpvideo/video_device_impl.cpp +++ b/src/media/video/uwpvideo/video_device_impl.cpp @@ -32,7 +32,7 @@ extern "C" { //#include <ciso646> -namespace ring { namespace video { +namespace jami { namespace video { typedef struct { @@ -94,16 +94,16 @@ VideoDeviceImpl::selectFormat() } } if (f == uwp_formats.end()) - RING_WARN("Video: No format matching %s", fmt.c_str()); + JAMI_WARN("Video: No format matching %s", fmt.c_str()); } if (best != UINT_MAX) { fmt_ = &uwp_formats[best]; - RING_DBG("Video: picked format %s", fmt_->name.c_str()); + JAMI_DBG("Video: picked format %s", fmt_->name.c_str()); } else { fmt_ = &uwp_formats[0]; - RING_ERR("Video: Could not find a known format to use"); + JAMI_ERR("Video: Could not find a known format to use"); } } @@ -219,4 +219,4 @@ VideoDevice::getRateList(const std::string& channel, VideoSize size) const VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/uwpvideo/video_device_monitor_impl.cpp b/src/media/video/uwpvideo/video_device_monitor_impl.cpp index 27ee836880..29379a59e4 100644 --- a/src/media/video/uwpvideo/video_device_monitor_impl.cpp +++ b/src/media/video/uwpvideo/video_device_monitor_impl.cpp @@ -26,7 +26,7 @@ #include "logger.h" #include "noncopyable.h" -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceMonitorImpl { @@ -92,4 +92,4 @@ VideoDeviceMonitor::VideoDeviceMonitor() VideoDeviceMonitor::~VideoDeviceMonitor() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/v4l2/video_device_impl.cpp b/src/media/video/v4l2/video_device_impl.cpp index c6cc3e88ef..0709087a18 100644 --- a/src/media/video/v4l2/video_device_impl.cpp +++ b/src/media/video/v4l2/video_device_impl.cpp @@ -48,7 +48,7 @@ extern "C" { #define ZEROVAR(x) std::memset(&(x), 0, sizeof(x)) -namespace ring { namespace video { +namespace jami { namespace video { class VideoV4l2Rate { @@ -264,13 +264,13 @@ VideoV4l2Size::readFrameRates(int fd, unsigned int pixel_format) if (ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival)) { addRate(fallback_rate); - RING_ERR("could not query frame interval for size"); + JAMI_ERR("could not query frame interval for size"); return; } if (frmival.type != V4L2_FRMIVAL_TYPE_DISCRETE) { addRate(fallback_rate); - RING_ERR("Continuous and stepwise Frame Intervals are not supported"); + JAMI_ERR("Continuous and stepwise Frame Intervals are not supported"); return; } @@ -351,7 +351,7 @@ VideoV4l2Channel::readSizes(int fd, unsigned int pixelformat) if (frmsize.type != V4L2_FRMSIZE_TYPE_DISCRETE) { // We do not take care of V4L2_FRMSIZE_TYPE_CONTINUOUS or V4L2_FRMSIZE_TYPE_STEPWISE - RING_ERR("Continuous Frame sizes not supported"); + JAMI_ERR("Continuous Frame sizes not supported"); return pixelformat; } @@ -610,4 +610,4 @@ VideoDevice::getRateList(const std::string& channel, VideoSize size) const VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/v4l2/video_device_monitor_impl.cpp b/src/media/video/v4l2/video_device_monitor_impl.cpp index 22694e5dc8..b60774ab2b 100644 --- a/src/media/video/v4l2/video_device_monitor_impl.cpp +++ b/src/media/video/v4l2/video_device_monitor_impl.cpp @@ -43,7 +43,7 @@ extern "C" { #include <sys/types.h> } -namespace ring { namespace video { +namespace jami { namespace video { using std::vector; using std::string; @@ -129,7 +129,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) : try { monitor_->addDevice(string(devpath)); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } } } @@ -141,7 +141,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) : udev_failed: - RING_ERR("udev enumeration failed"); + JAMI_ERR("udev enumeration failed"); if (udev_mon_) udev_monitor_unref(udev_mon_); @@ -157,7 +157,7 @@ udev_failed: try { monitor_->addDevice(ss.str()); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); return; } } @@ -209,14 +209,14 @@ void VideoDeviceMonitorImpl::run() const char *node = udev_device_get_devnode(dev); const char *action = udev_device_get_action(dev); if (!strcmp(action, "add")) { - RING_DBG("udev: adding %s", node); + JAMI_DBG("udev: adding %s", node); try { monitor_->addDevice(node); } catch (const std::runtime_error &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } } else if (!strcmp(action, "remove")) { - RING_DBG("udev: removing %s", node); + JAMI_DBG("udev: removing %s", node); monitor_->removeDevice(string(node)); } udev_device_unref(dev); @@ -226,12 +226,12 @@ void VideoDeviceMonitorImpl::run() case -1: if (errno == EAGAIN) continue; - RING_ERR("udev monitoring thread: select failed (%m)"); + JAMI_ERR("udev monitoring thread: select failed (%m)"); probing_ = false; return; default: - RING_ERR("select() returned %d (%m)", ret); + JAMI_ERR("select() returned %d (%m)", ret); probing_ = false; return; } @@ -248,4 +248,4 @@ VideoDeviceMonitor::VideoDeviceMonitor() : VideoDeviceMonitor::~VideoDeviceMonitor() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_base.cpp b/src/media/video/video_base.cpp index 7a87c1c06a..94c306fa1d 100644 --- a/src/media/video/video_base.cpp +++ b/src/media/video/video_base.cpp @@ -27,7 +27,7 @@ #include <cassert> -namespace ring { namespace video { +namespace jami { namespace video { /*=== VideoGenerator =========================================================*/ @@ -91,12 +91,12 @@ VideoSettings::to_map() const }; } -}} // namespace ring::video +}} // namespace jami::video namespace YAML { Node -convert<ring::video::VideoSettings>::encode(const ring::video::VideoSettings& rhs) { +convert<jami::video::VideoSettings>::encode(const jami::video::VideoSettings& rhs) { Node node; node["name"] = rhs.name; node["video_size"] = rhs.video_size; @@ -106,9 +106,9 @@ convert<ring::video::VideoSettings>::encode(const ring::video::VideoSettings& rh } bool -convert<ring::video::VideoSettings>::decode(const Node& node, ring::video::VideoSettings& rhs) { +convert<jami::video::VideoSettings>::decode(const Node& node, jami::video::VideoSettings& rhs) { if (not node.IsMap()) { - RING_WARN("Can't decode VideoSettings YAML node"); + JAMI_WARN("Can't decode VideoSettings YAML node"); return false; } rhs.name = node["name"].as<std::string>(); @@ -118,8 +118,8 @@ convert<ring::video::VideoSettings>::decode(const Node& node, ring::video::Video return true; } -Emitter& operator << (Emitter& out, const ring::video::VideoSettings& v) { - out << convert<ring::video::VideoSettings>::encode(v); +Emitter& operator << (Emitter& out, const jami::video::VideoSettings& v) { + out << convert<jami::video::VideoSettings>::encode(v); return out; } diff --git a/src/media/video/video_base.h b/src/media/video/video_base.h index f9325e1433..c5a665ad6c 100644 --- a/src/media/video/video_base.h +++ b/src/media/video/video_base.h @@ -53,12 +53,12 @@ class MediaFrame; class VideoFrame; } -namespace ring { +namespace jami { using MediaFrame = DRing::MediaFrame; using VideoFrame = DRing::VideoFrame; } -namespace ring { namespace video { +namespace jami { namespace video { struct VideoFrameActiveWriter: Observable<std::shared_ptr<MediaFrame>> {}; struct VideoFramePassiveReader: Observer<std::shared_ptr<MediaFrame>> {}; @@ -101,15 +101,15 @@ struct VideoSettings std::string framerate {}; }; -}} // namespace ring::video +}} // namespace jami::video namespace YAML { template<> -struct convert<ring::video::VideoSettings> { - static Node encode(const ring::video::VideoSettings& rhs); - static bool decode(const Node& node, ring::video::VideoSettings& rhs); +struct convert<jami::video::VideoSettings> { + static Node encode(const jami::video::VideoSettings& rhs); + static bool decode(const Node& node, jami::video::VideoSettings& rhs); }; -Emitter& operator << (Emitter& out, const ring::video::VideoSettings& v); +Emitter& operator << (Emitter& out, const jami::video::VideoSettings& v); } // namespace YAML diff --git a/src/media/video/video_device.h b/src/media/video/video_device.h index 9b319274d8..16ea85fef8 100644 --- a/src/media/video/video_device.h +++ b/src/media/video/video_device.h @@ -37,7 +37,7 @@ #include "string_utils.h" #include "logger.h" -namespace ring { namespace video { +namespace jami { namespace video { using VideoSize = std::pair<unsigned, unsigned>; using FrameRate = rational<double>; @@ -83,7 +83,7 @@ public: auto rates = getRateList(chan, size); std::vector<std::string> rates_str {rates.size()}; std::transform(rates.begin(), rates.end(), rates_str.begin(), - [](FrameRate r) { return ring::to_string(r.real()); }); + [](FrameRate r) { return jami::to_string(r.real()); }); cap[chan][sz.str()] = std::move(rates_str); } @@ -124,8 +124,8 @@ public: std::stringstream video_size; video_size << max_size.first << "x" << max_size.second; settings.video_size = video_size.str(); - settings.framerate = ring::to_string(max_size_rate.real()); - RING_WARN("Default video settings: %s, %s FPS", settings.video_size.c_str(), + settings.framerate = jami::to_string(max_size_rate.real()); + JAMI_WARN("Default video settings: %s, %s FPS", settings.video_size.c_str(), settings.framerate.c_str()); } @@ -141,7 +141,7 @@ public: settings.name = params.name; settings.channel = params.channel_name; settings.video_size = sizeToString(params.width, params.height); - settings.framerate = ring::to_string(params.framerate.real()); + settings.framerate = jami::to_string(params.framerate.real()); return settings; } @@ -198,9 +198,9 @@ private: FrameRate closest {0}; double rate_val = 0; try { - rate_val = rate.empty() ? 0 : ring::stod(rate); + rate_val = rate.empty() ? 0 : jami::stod(rate); } catch (...) { - RING_WARN("Can't read framerate \"%s\"", rate.c_str()); + JAMI_WARN("Can't read framerate \"%s\"", rate.c_str()); } // fallback to framerate closest to 30 FPS if (rate_val == 0) @@ -236,4 +236,4 @@ private: std::shared_ptr<VideoDeviceImpl> deviceImpl_; }; -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_device_monitor.cpp b/src/media/video/video_device_monitor.cpp index 568cb463f4..97a6b82c7a 100644 --- a/src/media/video/video_device_monitor.cpp +++ b/src/media/video/video_device_monitor.cpp @@ -36,7 +36,7 @@ #include "logger.h" #include "video_device_monitor.h" -namespace ring { namespace video { +namespace jami { namespace video { constexpr const char * const VideoDeviceMonitor::CONFIG_LABEL; @@ -194,7 +194,7 @@ static void notify() { if (!Manager::initialized) { - RING_WARN("Manager not initialized yet"); + JAMI_WARN("Manager not initialized yet"); return; } emitSignal<DRing::VideoSignal::DeviceEvent>(); @@ -231,7 +231,7 @@ VideoDeviceMonitor::addDevice(const string& node, const std::vector<std::map<std devices_.emplace_back(std::move(dev)); } catch (const std::exception& e) { - RING_ERR("Failed to add device %s: %s", node.c_str(), e.what()); + JAMI_ERR("Failed to add device %s: %s", node.c_str(), e.what()); return; } notify(); @@ -347,4 +347,4 @@ VideoDeviceMonitor::unserialize(const YAML::Node &in) defaultDevice_ = first; } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_device_monitor.h b/src/media/video/video_device_monitor.h index 03adfe7eb3..955f1aaad1 100644 --- a/src/media/video/video_device_monitor.h +++ b/src/media/video/video_device_monitor.h @@ -37,7 +37,7 @@ class Emitter; class Node; } -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceMonitorImpl; @@ -101,6 +101,6 @@ class VideoDeviceMonitor : public Serializable constexpr static const char *CONFIG_LABEL = "video"; }; -}} // namespace ring::video +}} // namespace jami::video #endif /* VIDEO_DEVICE_MONITOR_H__ */ diff --git a/src/media/video/video_input.cpp b/src/media/video/video_input.cpp index a3ff2068f2..13aa3fb841 100644 --- a/src/media/video/video_input.cpp +++ b/src/media/video/video_input.cpp @@ -48,7 +48,7 @@ extern "C" { #include <libavutil/display.h> } -namespace ring { namespace video { +namespace jami { namespace video { static constexpr unsigned default_grab_width = 640; static constexpr unsigned default_grab_height = 480; @@ -92,7 +92,7 @@ void VideoInput::process() foundDecOpts(decOpts_); if (switchPending_.exchange(false)) { - RING_DBG("Switching input to '%s'", decOpts_.input.c_str()); + JAMI_DBG("Switching input to '%s'", decOpts_.input.c_str()); if (decOpts_.input.empty()) { loop_.stop(); return; @@ -169,7 +169,7 @@ void VideoInput::cleanup() buffer.status == BUFFER_FULL) { freeOneBuffer(buffer); } else if (buffer.status != BUFFER_NOT_ALLOCATED) { - RING_ERR("Failed to free buffer [%p]", buffer.data); + JAMI_ERR("Failed to free buffer [%p]", buffer.data); } } @@ -195,21 +195,21 @@ VideoInput::cleanup() deleteDecoder(); // do it first to let a chance to last frame to be displayed detach(sink_.get()); sink_->stop(); - RING_DBG("VideoInput closed"); + JAMI_DBG("VideoInput closed"); } #endif bool VideoInput::setup() { if (not attach(sink_.get())) { - RING_ERR("attach sink failed"); + JAMI_ERR("attach sink failed"); return false; } if (!sink_->start()) - RING_ERR("start sink failed"); + JAMI_ERR("start sink failed"); - RING_DBG("VideoInput ready to capture"); + JAMI_DBG("VideoInput ready to capture"); return true; } @@ -245,7 +245,7 @@ bool VideoInput::captureFrame() case MediaDecoder::Status::RestartRequired: createDecoder(); #ifdef RING_ACCEL - RING_WARN("Disabling hardware decoding due to previous failure"); + JAMI_WARN("Disabling hardware decoding due to previous failure"); decoder_->enableAccel(false); #endif return static_cast<bool>(decoder_); @@ -272,17 +272,17 @@ int VideoInput::allocateOneBuffer(struct VideoFrameBuffer& b, int length) if (b.data) { b.status = BUFFER_AVAILABLE; b.length = length; - RING_DBG("Allocated buffer [%p]", b.data); + JAMI_DBG("Allocated buffer [%p]", b.data); return 0; } - RING_DBG("Failed to allocate memory for one buffer"); + JAMI_DBG("Failed to allocate memory for one buffer"); return -ENOMEM; } void VideoInput::freeOneBuffer(struct VideoFrameBuffer& b) { - RING_DBG("Free buffer [%p]", b.data); + JAMI_DBG("Free buffer [%p]", b.data); std::free(b.data); b.data = nullptr; b.length = 0; @@ -325,7 +325,7 @@ VideoInput::obtainFrame(int length) } } - RING_WARN("No buffer found"); + JAMI_WARN("No buffer found"); return nullptr; } @@ -336,7 +336,7 @@ VideoInput::releaseFrame(void *ptr) for(auto& buffer : buffers_) { if (buffer.data == ptr) { if (buffer.status != BUFFER_CAPTURING) - RING_ERR("Released a buffer with status %d, expected %d", + JAMI_ERR("Released a buffer with status %d, expected %d", buffer.status, BUFFER_CAPTURING); if (isCapturing()) { buffer.status = BUFFER_FULL; @@ -373,14 +373,14 @@ VideoInput::createDecoder() this); if (decoder->openInput(decOpts_) < 0) { - RING_ERR("Could not open input \"%s\"", decOpts_.input.c_str()); + JAMI_ERR("Could not open input \"%s\"", decOpts_.input.c_str()); foundDecOpts(decOpts_); return; } /* Data available, finish the decoding */ if (decoder->setupFromVideoData() < 0) { - RING_ERR("decoder IO startup failed"); + JAMI_ERR("decoder IO startup failed"); foundDecOpts(decOpts_); return; } @@ -389,7 +389,7 @@ VideoInput::createDecoder() decOpts_.height = decoder->getHeight(); decOpts_.framerate = decoder->getFps(); - RING_DBG("created decoder with video params : size=%dX%d, fps=%lf", + JAMI_DBG("created decoder with video params : size=%dX%d, fps=%lf", decOpts_.width, decOpts_.height, decOpts_.framerate.real()); decoder_ = std::move(decoder); @@ -411,7 +411,7 @@ VideoInput::deleteDecoder() bool VideoInput::initCamera(const std::string& device) { - decOpts_ = ring::getVideoDeviceMonitor().getDeviceParams(device); + decOpts_ = jami::getVideoDeviceMonitor().getDeviceParams(device); return true; } @@ -510,7 +510,7 @@ VideoInput::initFile(std::string path) /* File exists? */ if (access(path.c_str(), R_OK) != 0) { - RING_ERR("file '%s' unavailable\n", path.c_str()); + JAMI_ERR("file '%s' unavailable\n", path.c_str()); return false; } @@ -521,7 +521,7 @@ VideoInput::initFile(std::string path) p.input = path; auto dec = std::make_unique<MediaDecoder>(); if (dec->openInput(p) < 0 || dec->setupFromVideoData() < 0) { - return initCamera(ring::getVideoDeviceMonitor().getDefaultDevice()); + return initCamera(jami::getVideoDeviceMonitor().getDefaultDevice()); } clearOptions(); @@ -534,7 +534,7 @@ VideoInput::initFile(std::string path) decOpts_.format = "image2"; decOpts_.framerate = 1; } else { - RING_WARN("Guessing file type for %s", path.c_str()); + JAMI_WARN("Guessing file type for %s", path.c_str()); } return false; @@ -546,10 +546,10 @@ VideoInput::switchInput(const std::string& resource) if (resource == currentResource_) return futureDecOpts_; - RING_DBG("MRL: '%s'", resource.c_str()); + JAMI_DBG("MRL: '%s'", resource.c_str()); if (switchPending_) { - RING_ERR("Video switch already requested"); + JAMI_ERR("Video switch already requested"); return {}; } @@ -657,4 +657,4 @@ VideoInput::foundDecOpts(const DeviceParams& params) } } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_input.h b/src/media/video/video_input.h index 2b07d1621c..9c38b0eefc 100644 --- a/src/media/video/video_input.h +++ b/src/media/video/video_input.h @@ -41,11 +41,11 @@ #import "TargetConditionals.h" #endif -namespace ring { +namespace jami { class MediaDecoder; } -namespace ring { namespace video { +namespace jami { namespace video { class SinkClient; @@ -152,6 +152,6 @@ private: #endif }; -}} // namespace ring::video +}} // namespace jami::video #endif // __VIDEO_INPUT_H__ diff --git a/src/media/video/video_mixer.cpp b/src/media/video/video_mixer.cpp index 84e9ce8100..fff6787d49 100644 --- a/src/media/video/video_mixer.cpp +++ b/src/media/video/video_mixer.cpp @@ -33,7 +33,7 @@ #include <cmath> #include <unistd.h> -namespace ring { namespace video { +namespace jami { namespace video { struct VideoMixer::VideoMixerSource { Observable<std::shared_ptr<MediaFrame>>* source = nullptr; @@ -135,7 +135,7 @@ VideoMixer::process() try { output.reserve(AV_PIX_FMT_YUYV422, width_, height_); } catch (const std::bad_alloc& e) { - RING_ERR("VideoFrame::allocBuffer() failed"); + JAMI_ERR("VideoFrame::allocBuffer() failed"); return; } @@ -211,12 +211,12 @@ VideoMixer::start_sink() stop_sink(); if (width_ == 0 or height_ == 0) { - RING_WARN("MX: unable to start with zero-sized output"); + JAMI_WARN("MX: unable to start with zero-sized output"); return; } if (not sink_->start()) { - RING_ERR("MX: sink startup failed"); + JAMI_ERR("MX: sink startup failed"); return; } @@ -243,4 +243,4 @@ AVPixelFormat VideoMixer::getPixelFormat() const { return AV_PIX_FMT_YUYV422; } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_mixer.h b/src/media/video/video_mixer.h index 6f988a9874..43e5534c77 100644 --- a/src/media/video/video_mixer.h +++ b/src/media/video/video_mixer.h @@ -30,7 +30,7 @@ #include <chrono> #include <memory> -namespace ring { namespace video { +namespace jami { namespace video { class SinkClient; @@ -80,4 +80,4 @@ private: ThreadLoop loop_; // as to be last member }; -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_receive_thread.cpp b/src/media/video/video_receive_thread.cpp index 284f19e84d..1df7177708 100644 --- a/src/media/video/video_receive_thread.cpp +++ b/src/media/video/video_receive_thread.cpp @@ -36,7 +36,7 @@ extern "C" { #include <unistd.h> #include <map> -namespace ring { namespace video { +namespace jami { namespace video { using std::string; @@ -98,7 +98,7 @@ bool VideoReceiveThread::setup() args_.sdp_flags = "custom_io"; if (stream_.str().empty()) { - RING_ERR("No SDP loaded"); + JAMI_ERR("No SDP loaded"); return false; } @@ -106,7 +106,7 @@ bool VideoReceiveThread::setup() } if (videoDecoder_->openInput(args_)) { - RING_ERR("Could not open input \"%s\"", args_.input.c_str()); + JAMI_ERR("Could not open input \"%s\"", args_.input.c_str()); return false; } @@ -119,7 +119,7 @@ bool VideoReceiveThread::setup() requestKeyFrameCallback_(); if (videoDecoder_->setupFromVideoData()) { - RING_ERR("decoder IO startup failed"); + JAMI_ERR("decoder IO startup failed"); return false; } @@ -130,7 +130,7 @@ bool VideoReceiveThread::setup() } if (not sink_->start()) { - RING_ERR("RX: sink startup failed"); + JAMI_ERR("RX: sink startup failed"); return false; } @@ -197,13 +197,13 @@ bool VideoReceiveThread::decodeFrame() return true; case MediaDecoder::Status::DecodeError: - RING_WARN("video decoding failure"); + JAMI_WARN("video decoding failure"); if (requestKeyFrameCallback_) requestKeyFrameCallback_(); break; case MediaDecoder::Status::ReadError: - RING_ERR("fatal error, read failed"); + JAMI_ERR("fatal error, read failed"); loop_.stop(); break; @@ -279,4 +279,4 @@ VideoReceiveThread::setRotation(int angle) } } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_receive_thread.h b/src/media/video/video_receive_thread.h index cdee8dbf7d..436ab5496d 100644 --- a/src/media/video/video_receive_thread.h +++ b/src/media/video/video_receive_thread.h @@ -36,12 +36,12 @@ #include <sstream> #include <memory> -namespace ring { +namespace jami { class SocketPair; class MediaDecoder; -} // namespace ring +} // namespace jami -namespace ring { namespace video { +namespace jami { namespace video { class SinkClient; @@ -105,6 +105,6 @@ private: void cleanup(); }; -}} // namespace ring::video +}} // namespace jami::video #endif // _VIDEO_RECEIVE_THREAD_H_ diff --git a/src/media/video/video_rtp_session.cpp b/src/media/video/video_rtp_session.cpp index c8370318b2..d98d13f091 100644 --- a/src/media/video/video_rtp_session.cpp +++ b/src/media/video/video_rtp_session.cpp @@ -41,7 +41,7 @@ #include <thread> #include <chrono> -namespace ring { namespace video { +namespace jami { namespace video { using std::map; using std::string; @@ -91,7 +91,7 @@ void VideoRtpSession::startSender() videoLocal_->detach(sender_.get()); if (videoMixer_) videoMixer_->detach(sender_.get()); - RING_WARN("Restarting video sender"); + JAMI_WARN("Restarting video sender"); } if (not conference_) { @@ -103,16 +103,16 @@ void VideoRtpSession::startSender() newParams.wait_for(NEWPARAMS_TIMEOUT) == std::future_status::ready) { localVideoParams_ = newParams.get(); } else { - RING_ERR("No valid new video parameters."); + JAMI_ERR("No valid new video parameters."); return; } } catch (const std::exception& e) { - RING_ERR("Exception during retrieving video parameters: %s", + JAMI_ERR("Exception during retrieving video parameters: %s", e.what()); return; } } else { - RING_WARN("Can't lock video input"); + JAMI_WARN("Can't lock video input"); return; } } @@ -131,10 +131,10 @@ void VideoRtpSession::startSender() sender_->setChangeOrientationCallback(changeOrientationCallback_); } catch (const MediaEncoderException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); send_.enabled = false; } - auto codecVideo = std::static_pointer_cast<ring::AccountVideoCodecInfo>(send_.codec); + auto codecVideo = std::static_pointer_cast<jami::AccountVideoCodecInfo>(send_.codec); auto autoQuality = codecVideo->isAutoQualityEnabled; if (autoQuality and not rtcpCheckerThread_.isRunning()) rtcpCheckerThread_.start(); @@ -160,7 +160,7 @@ void VideoRtpSession::startReceiver() { if (receive_.enabled and not receive_.holding) { if (receiveThread_) - RING_WARN("Restarting video receiver"); + JAMI_WARN("Restarting video receiver"); receiveThread_.reset( new VideoReceiveThread(callID_, receive_.receiving_sdp, mtu_) ); @@ -171,7 +171,7 @@ void VideoRtpSession::startReceiver() receiveThread_->startLoop(); packetLossThread_.start(); } else { - RING_DBG("Video receiving disabled"); + JAMI_DBG("Video receiving disabled"); if (receiveThread_) receiveThread_->detach(videoMixer_.get()); receiveThread_.reset(); @@ -202,7 +202,7 @@ void VideoRtpSession::start(std::unique_ptr<IceSocket> rtp_sock, send_.crypto.getSrtpKeyInfo().c_str()); } } catch (const std::runtime_error& e) { - RING_ERR("Socket creation failed: %s", e.what()); + JAMI_ERR("Socket creation failed: %s", e.what()); return; } @@ -271,7 +271,7 @@ VideoRtpSession::setupVideoPipeline() void VideoRtpSession::setupConferenceVideoPipeline(Conference& conference) { - RING_DBG("[call:%s] Setup video pipeline on conference %s", callID_.c_str(), + JAMI_DBG("[call:%s] Setup video pipeline on conference %s", callID_.c_str(), conference.getConfID().c_str()); videoMixer_ = conference.getVideoMixer(); @@ -281,13 +281,13 @@ VideoRtpSession::setupConferenceVideoPipeline(Conference& conference) videoLocal_->detach(sender_.get()); videoMixer_->attach(sender_.get()); } else - RING_WARN("[call:%s] no sender", callID_.c_str()); + JAMI_WARN("[call:%s] no sender", callID_.c_str()); if (receiveThread_) { receiveThread_->enterConference(); receiveThread_->attach(videoMixer_.get()); } else - RING_WARN("[call:%s] no receiver", callID_.c_str()); + JAMI_WARN("[call:%s] no receiver", callID_.c_str()); } void @@ -298,7 +298,7 @@ VideoRtpSession::enterConference(Conference* conference) exitConference(); conference_ = conference; - RING_DBG("[call:%s] enterConference (conf: %s)", callID_.c_str(), + JAMI_DBG("[call:%s] enterConference (conf: %s)", callID_.c_str(), conference->getConfID().c_str()); if (send_.enabled or receiveThread_) { @@ -315,7 +315,7 @@ void VideoRtpSession::exitConference() if (!conference_) return; - RING_DBG("[call:%s] exitConference (conf: %s)", callID_.c_str(), + JAMI_DBG("[call:%s] exitConference (conf: %s)", callID_.c_str(), conference_->getConfID().c_str()); if (videoMixer_) { @@ -337,7 +337,7 @@ void VideoRtpSession::exitConference() } bool -VideoRtpSession::useCodec(const ring::AccountVideoCodecInfo* codec) const +VideoRtpSession::useCodec(const jami::AccountVideoCodecInfo* codec) const { return sender_->useCodec(codec); } @@ -499,7 +499,7 @@ VideoRtpSession::adaptQualityAndBitrate() storeVideoBitrateInfo(); const auto& cid = callID_; - RING_WARN("[%u/%u] packetLostRate=%f -> change quality to %d bitrate to %d", + JAMI_WARN("[%u/%u] packetLostRate=%f -> change quality to %d bitrate to %d", videoBitrateInfo_.cptBitrateChecking, videoBitrateInfo_.maxBitrateChecking, packetLostRate, @@ -515,15 +515,15 @@ VideoRtpSession::adaptQualityAndBitrate() void VideoRtpSession::setupVideoBitrateInfo() { - auto codecVideo = std::static_pointer_cast<ring::AccountVideoCodecInfo>(send_.codec); + auto codecVideo = std::static_pointer_cast<jami::AccountVideoCodecInfo>(send_.codec); if (codecVideo) { videoBitrateInfo_ = { - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::BITRATE])), - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MIN_BITRATE])), - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MAX_BITRATE])), - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::QUALITY])), - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MIN_QUALITY])), - (unsigned)(ring::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MAX_QUALITY])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::BITRATE])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MIN_BITRATE])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MAX_BITRATE])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::QUALITY])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MIN_QUALITY])), + (unsigned)(jami::stoi(codecVideo->getCodecSpecifications()[DRing::Account::ConfProperties::CodecInfo::MAX_QUALITY])), videoBitrateInfo_.cptBitrateChecking, videoBitrateInfo_.maxBitrateChecking, videoBitrateInfo_.packetLostThreshold, @@ -537,16 +537,16 @@ VideoRtpSession::setupVideoBitrateInfo() { void VideoRtpSession::storeVideoBitrateInfo() { - auto codecVideo = std::static_pointer_cast<ring::AccountVideoCodecInfo>(send_.codec); + auto codecVideo = std::static_pointer_cast<jami::AccountVideoCodecInfo>(send_.codec); if (codecVideo) { codecVideo->setCodecSpecifications({ - {DRing::Account::ConfProperties::CodecInfo::BITRATE, ring::to_string(videoBitrateInfo_.videoBitrateCurrent)}, - {DRing::Account::ConfProperties::CodecInfo::MIN_BITRATE, ring::to_string(videoBitrateInfo_.videoBitrateMin)}, - {DRing::Account::ConfProperties::CodecInfo::MAX_BITRATE, ring::to_string(videoBitrateInfo_.videoBitrateMax)}, - {DRing::Account::ConfProperties::CodecInfo::QUALITY, ring::to_string(videoBitrateInfo_.videoQualityCurrent)}, - {DRing::Account::ConfProperties::CodecInfo::MIN_QUALITY, ring::to_string(videoBitrateInfo_.videoQualityMin)}, - {DRing::Account::ConfProperties::CodecInfo::MAX_QUALITY, ring::to_string(videoBitrateInfo_.videoQualityMax)} + {DRing::Account::ConfProperties::CodecInfo::BITRATE, jami::to_string(videoBitrateInfo_.videoBitrateCurrent)}, + {DRing::Account::ConfProperties::CodecInfo::MIN_BITRATE, jami::to_string(videoBitrateInfo_.videoBitrateMin)}, + {DRing::Account::ConfProperties::CodecInfo::MAX_BITRATE, jami::to_string(videoBitrateInfo_.videoBitrateMax)}, + {DRing::Account::ConfProperties::CodecInfo::QUALITY, jami::to_string(videoBitrateInfo_.videoQualityCurrent)}, + {DRing::Account::ConfProperties::CodecInfo::MIN_QUALITY, jami::to_string(videoBitrateInfo_.videoQualityMin)}, + {DRing::Account::ConfProperties::CodecInfo::MAX_QUALITY, jami::to_string(videoBitrateInfo_.videoQualityMax)} }); if (histoQuality_.size() > MAX_SIZE_HISTO_QUALITY_) @@ -614,4 +614,4 @@ VideoRtpSession::setChangeOrientationCallback(std::function<void(int)> cb) changeOrientationCallback_ = cb; } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_rtp_session.h b/src/media/video/video_rtp_session.h index b840f4721c..b5a4310530 100644 --- a/src/media/video/video_rtp_session.h +++ b/src/media/video/video_rtp_session.h @@ -31,12 +31,12 @@ #include <string> #include <memory> -namespace ring { +namespace jami { class Conference; class MediaRecorder; -} // namespace ring +} // namespace jami -namespace ring { namespace video { +namespace jami { namespace video { class VideoMixer; class VideoSender; @@ -157,6 +157,6 @@ private: std::function<void(int)> changeOrientationCallback_; }; -}} // namespace ring::video +}} // namespace jami::video #endif // __VIDEO_RTP_SESSION_H__ diff --git a/src/media/video/video_scaler.cpp b/src/media/video/video_scaler.cpp index e2a482b03f..0d45fd94bb 100644 --- a/src/media/video/video_scaler.cpp +++ b/src/media/video/video_scaler.cpp @@ -26,7 +26,7 @@ #include <cassert> -namespace ring { namespace video { +namespace jami { namespace video { VideoScaler::VideoScaler() : ctx_(0), mode_(SWS_FAST_BILINEAR), tmp_data_() @@ -53,7 +53,7 @@ VideoScaler::scale(const VideoFrame& input, VideoFrame& output) mode_, NULL, NULL, NULL); if (!ctx_) { - RING_ERR("Unable to create a scaler context"); + JAMI_ERR("Unable to create a scaler context"); return; } @@ -120,7 +120,7 @@ VideoScaler::scale_and_pad(const VideoFrame& input, VideoFrame& output, mode_, NULL, NULL, NULL); if (!ctx_) { - RING_ERR("Unable to create a scaler context"); + JAMI_ERR("Unable to create a scaler context"); return; } @@ -158,4 +158,4 @@ void VideoScaler::reset() } } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_scaler.h b/src/media/video/video_scaler.h index 78e0abb99a..a6f0ab7d94 100644 --- a/src/media/video/video_scaler.h +++ b/src/media/video/video_scaler.h @@ -27,7 +27,7 @@ struct SwsContext; -namespace ring { namespace video { +namespace jami { namespace video { class VideoScaler { public: @@ -49,6 +49,6 @@ private: uint8_t *tmp_data_[4]; // used by scale_and_pad }; -}} // namespace ring::video +}} // namespace jami::video #endif // __VIDEO_SCALER_H__ diff --git a/src/media/video/video_sender.cpp b/src/media/video/video_sender.cpp index ca47036c9b..80285ef3db 100644 --- a/src/media/video/video_sender.cpp +++ b/src/media/video/video_sender.cpp @@ -39,7 +39,7 @@ extern "C" { #include <libavutil/display.h> } -namespace ring { namespace video { +namespace jami { namespace video { using std::string; @@ -107,7 +107,7 @@ VideoSender::encodeAndSendVideo(VideoFrame& input_frame) } if (videoEncoder_->encode(input_frame, is_keyframe, frameNumber_++) < 0) - RING_ERR("encoding failed"); + JAMI_ERR("encoding failed"); } #ifdef DEBUG_SDP if (frameNumber_ == 1) // video stream is lazy initialized, wait for first frame @@ -125,7 +125,7 @@ VideoSender::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, void VideoSender::forceKeyFrame() { - RING_DBG("Key frame requested"); + JAMI_DBG("Key frame requested"); ++forceKeyFrame_; } @@ -136,7 +136,7 @@ VideoSender::getLastSeqValue() } bool -VideoSender::useCodec(const ring::AccountVideoCodecInfo* codec) const +VideoSender::useCodec(const jami::AccountVideoCodecInfo* codec) const { return videoEncoder_->useCodec(codec); } @@ -147,4 +147,4 @@ VideoSender::setChangeOrientationCallback(std::function<void(int)> cb) changeOrientationCallback_ = cb; } -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/video_sender.h b/src/media/video/video_sender.h index 220365c377..e54fe4231a 100644 --- a/src/media/video/video_sender.h +++ b/src/media/video/video_sender.h @@ -32,13 +32,13 @@ #include <atomic> // Forward declarations -namespace ring { +namespace jami { class SocketPair; struct DeviceParams; struct AccountVideoCodecInfo; } -namespace ring { namespace video { +namespace jami { namespace video { class VideoSender : public VideoFramePassiveReader { @@ -84,6 +84,6 @@ private: int rotation_ = 0; std::function<void(int)> changeOrientationCallback_; }; -}} // namespace ring::video +}} // namespace jami::video #endif // __VIDEO_SENDER_H__ diff --git a/src/media/video/winvideo/capture_graph_interfaces.h b/src/media/video/winvideo/capture_graph_interfaces.h index 86e9873d1e..68a587f8d4 100644 --- a/src/media/video/winvideo/capture_graph_interfaces.h +++ b/src/media/video/winvideo/capture_graph_interfaces.h @@ -23,7 +23,7 @@ #include <dshow.h> -namespace ring { namespace video { +namespace jami { namespace video { class CaptureGraphInterfaces { public: @@ -40,6 +40,6 @@ public: IAMStreamConfig* streamConf_; }; -}} // namespace ring::video +}} // namespace jami::video #endif diff --git a/src/media/video/winvideo/video_device_impl.cpp b/src/media/video/winvideo/video_device_impl.cpp index 5dfeb932a3..4b67435a11 100644 --- a/src/media/video/winvideo/video_device_impl.cpp +++ b/src/media/video/winvideo/video_device_impl.cpp @@ -36,7 +36,7 @@ #include <dshow.h> -namespace ring { namespace video { +namespace jami { namespace video { class VideoDeviceImpl { public: @@ -182,15 +182,15 @@ VideoDeviceImpl::setup() cInterface->streamConf_->GetNumberOfCapabilities(&piCount, &piSize); AM_MEDIA_TYPE *pmt; VIDEO_STREAM_CONFIG_CAPS pSCC; - std::map<std::pair<ring::video::VideoSize, ring::video::FrameRate>, LONG> bitrateList; + std::map<std::pair<jami::video::VideoSize, jami::video::FrameRate>, LONG> bitrateList; for (int i = 0; i < piCount; i++) { cInterface->streamConf_->GetStreamCaps(i, &pmt, (BYTE*)&pSCC); if (pmt->formattype != FORMAT_VideoInfo) { continue; } auto videoInfo = (VIDEOINFOHEADER*) pmt->pbFormat; - auto size = ring::video::VideoSize(videoInfo->bmiHeader.biWidth, videoInfo->bmiHeader.biHeight); - auto rate = ring::video::FrameRate(1e7, videoInfo->AvgTimePerFrame); + auto size = jami::video::VideoSize(videoInfo->bmiHeader.biWidth, videoInfo->bmiHeader.biHeight); + auto rate = jami::video::FrameRate(1e7, videoInfo->AvgTimePerFrame); auto bitrate = videoInfo->dwBitRate; // Only add configurations with positive bitrates. if (bitrate == 0) @@ -217,7 +217,7 @@ VideoDeviceImpl::setup() // Sort rates descending. for (auto& rateList : rateList_) { std::sort(rateList.second.begin(), rateList.second.end(), - [](const ring::video::FrameRate& lhs, const ring::video::FrameRate& rhs) { + [](const jami::video::FrameRate& lhs, const jami::video::FrameRate& rhs) { return lhs.denominator() < rhs.denominator(); }); } @@ -262,7 +262,7 @@ VideoDeviceImpl::setDeviceParams(const DeviceParams& params) if (pmt != nullptr) { ((VIDEOINFOHEADER*) pmt->pbFormat)->AvgTimePerFrame = (FrameRate(1e7) / params.framerate).real(); if (FAILED(cInterface->streamConf_->SetFormat(pmt))) { - RING_ERR("Could not set settings."); + JAMI_ERR("Could not set settings."); } } } @@ -334,4 +334,4 @@ VideoDevice::getRateList(const std::string& channel, VideoSize size) const VideoDevice::~VideoDevice() {} -}} // namespace ring::video +}} // namespace jami::video diff --git a/src/media/video/winvideo/video_device_monitor_impl.cpp b/src/media/video/winvideo/video_device_monitor_impl.cpp index b512909829..fff39876e8 100644 --- a/src/media/video/winvideo/video_device_monitor_impl.cpp +++ b/src/media/video/winvideo/video_device_monitor_impl.cpp @@ -33,7 +33,7 @@ #include <dbt.h> #include <SetupAPI.h> -namespace ring { +namespace jami { namespace video { constexpr GUID guidCamera = { 0xe5323777, 0xf976, 0x4f5b, 0x9b, 0x55, 0xb9, 0x46, 0x99, 0xc4, 0x6e, 0x44 }; @@ -191,7 +191,7 @@ VideoDeviceMonitorImpl::WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pThis)); if (!registerDeviceInterfaceToHwnd(hWnd, &hDeviceNotify)) { - RING_ERR() << "Cannot register for device change notifications"; + JAMI_ERR() << "Cannot register for device change notifications"; SendMessage(hWnd, WM_DESTROY, 0, 0); } } @@ -206,7 +206,7 @@ VideoDeviceMonitorImpl::WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, PDEV_BROADCAST_DEVICEINTERFACE p = (PDEV_BROADCAST_DEVICEINTERFACE)lParam; auto friendlyName = getDeviceFriendlyName(p); if (!friendlyName.empty()) { - RING_DBG() << friendlyName << ((wParam == DBT_DEVICEARRIVAL) ? " plugged" : " unplugged"); + JAMI_DBG() << friendlyName << ((wParam == DBT_DEVICEARRIVAL) ? " plugged" : " unplugged"); if (pThis = reinterpret_cast<VideoDeviceMonitorImpl*>(GetWindowLongPtr(hWnd, GWLP_USERDATA))) { if (wParam == DBT_DEVICEARRIVAL) { pThis->monitor_->addDevice(friendlyName); @@ -307,14 +307,14 @@ VideoDeviceMonitorImpl::enumerateVideoInputDevices() CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum)); if (FAILED(hr)) { - RING_ERR() << "Can't enumerate webcams"; + JAMI_ERR() << "Can't enumerate webcams"; return {}; } IEnumMoniker *pEnum = nullptr; hr = enumerateVideoInputDevices(&pEnum); if (FAILED(hr) || pEnum == nullptr) { - RING_ERR() << "No webcam found"; + JAMI_ERR() << "No webcam found"; return {}; } @@ -368,4 +368,4 @@ VideoDeviceMonitor::~VideoDeviceMonitor() {} } -} // namespace ring::video +} // namespace jami::video diff --git a/src/observer.h b/src/observer.h index b424331422..a4b84a44f7 100644 --- a/src/observer.h +++ b/src/observer.h @@ -30,7 +30,7 @@ #include <mutex> #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { template <typename T> class Observer; template <typename T> class Observable; @@ -96,4 +96,4 @@ public: virtual void detached(Observable<T>*) {}; }; -}; // namespace ring +}; // namespace jami diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index e9f0f979fc..acfd0c24e2 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -48,7 +48,7 @@ #include <sys/time.h> #endif -namespace ring { +namespace jami { using lock = std::lock_guard<std::mutex>; @@ -133,7 +133,7 @@ TlsTurnEndpoint::Impl::onTlsStateChange(tls::TlsSessionState state) void TlsTurnEndpoint::Impl::onTlsRxData(UNUSED std::vector<uint8_t>&& buf) { - RING_ERR() << "[TLS-TURN] rx " << buf.size() << " (but not implemented)"; + JAMI_ERR() << "[TLS-TURN] rx " << buf.size() << " (but not implemented)"; } void @@ -352,7 +352,7 @@ TlsSocketEndpoint::Impl::verifyCertificate(gnutls_session_t session) crt_data.emplace_back(cert_list[i].data, cert_list[i].data + cert_list[i].size); auto crt = dht::crypto::Certificate {crt_data}; if (crt.getPacked() != peerCertificate.getPacked()) { - RING_ERR() << "[TLS-SOCKET] Unexpected peer certificate"; + JAMI_ERR() << "[TLS-SOCKET] Unexpected peer certificate"; return GNUTLS_E_CERTIFICATE_ERROR; } @@ -483,7 +483,7 @@ public: try { eventLoop(); } catch (const std::exception& e) { - RING_ERR() << "[CNX] peer connection event loop failure: " << e.what(); + JAMI_ERR() << "[CNX] peer connection event loop failure: " << e.what(); done(); } })} {} @@ -527,12 +527,12 @@ private: try { if (callable(stream)) return; - RING_DBG() << "EOF on stream #" << stream->getId(); + JAMI_DBG() << "EOF on stream #" << stream->getId(); } catch (const std::system_error& e) { - RING_WARN() << "Stream #" << stream->getId() + JAMI_WARN() << "Stream #" << stream->getId() << " IO failed with code = " << e.code(); } catch (const std::exception& e) { - RING_ERR() << "Unexpected exception during IO with stream #" + JAMI_ERR() << "Unexpected exception during IO with stream #" << stream->getId() << ": " << e.what(); } @@ -544,7 +544,7 @@ private: void PeerConnection::PeerConnectionImpl::eventLoop() { - RING_DBG() << "[CNX] Peer connection to " << peer_uri << " ready"; + JAMI_DBG() << "[CNX] Peer connection to " << peer_uri << " ready"; while (true) { // Process ctrl orders first while (true) { @@ -556,7 +556,7 @@ PeerConnection::PeerConnectionImpl::eventLoop() std::error_code ec; if (endpoint_->waitForData(100, ec) > 0) { std::vector<uint8_t> buf(IO_BUFFER_SIZE); - RING_DBG("A good buffer arrived before any input or output attachment"); + JAMI_DBG("A good buffer arrived before any input or output attachment"); auto size = endpoint_->read(buf, ec); if (ec) throw std::system_error(ec); @@ -590,7 +590,7 @@ PeerConnection::PeerConnectionImpl::eventLoop() case CtrlMsgType::STOP: return; - default: RING_ERR("BUG: got unhandled control msg!"); break; + default: JAMI_ERR("BUG: got unhandled control msg!"); break; } } @@ -701,4 +701,4 @@ PeerConnection::getPeerUri() const return pimpl_->peer_uri; } -} // namespace ring +} // namespace jami diff --git a/src/peer_connection.h b/src/peer_connection.h index acc27a3bf6..f67b4e9408 100644 --- a/src/peer_connection.h +++ b/src/peer_connection.h @@ -39,7 +39,7 @@ struct PrivateKey; struct Certificate; }} -namespace ring { +namespace jami { class Account; class TurnTransport; @@ -198,4 +198,4 @@ private: std::unique_ptr<PeerConnectionImpl> pimpl_; }; -} // namespace ring +} // namespace jami diff --git a/src/preferences.cpp b/src/preferences.cpp index d523aee903..33b36f44d1 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -52,7 +52,7 @@ #endif #endif /* HAVE_OPENSL */ -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "client/videomanager.h" #endif @@ -70,7 +70,7 @@ #include "fileutils.h" #include "string_utils.h" -namespace ring { +namespace jami { using yaml_utils::parseValue; @@ -134,7 +134,7 @@ static constexpr const char* POPUP_SHORT_KEY {"popupWindow"}; static constexpr const char* TOGGLE_HOLD_SHORT_KEY {"toggleHold"}; static constexpr const char* TOGGLE_PICKUP_HANGUP_SHORT_KEY {"togglePickupHangup"}; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // video preferences constexpr const char * const VideoPreferences::CONFIG_LABEL; static constexpr const char* DECODING_ACCELERATED_KEY {"decodingAccelerated"}; @@ -174,7 +174,7 @@ void Preferences::verifyAccountOrder(const std::vector<std::string> &accountIDs) if (find(accountIDs.begin(), accountIDs.end(), token) != accountIDs.end()) tokens.push_back(token); else { - RING_DBG("Dropping nonexistent account %s", token.c_str()); + JAMI_DBG("Dropping nonexistent account %s", token.c_str()); drop = true; } token.clear(); @@ -348,7 +348,7 @@ static void checkSoundCard(int &card, DeviceType type) { if (not AlsaLayer::soundCardIndexExists(card, type)) { - RING_WARN(" Card with index %d doesn't exist or is unusable.", card); + JAMI_WARN(" Card with index %d doesn't exist or is unusable.", card); card = ALSA_DFT_CARD_ID; } } @@ -368,7 +368,7 @@ AudioPreference::createAudioLayer() throw std::runtime_error("Error running jack_lsp: " + to_string(ret)); return new JackLayer(*this); } catch (const std::runtime_error& e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); #if HAVE_PULSE audioApi_ = PULSEAUDIO_API_STR; #elif HAVE_ALSA @@ -390,7 +390,7 @@ AudioPreference::createAudioLayer() try { return new PulseLayer(*this); } catch (const std::runtime_error &e) { - RING_WARN("Could not create pulseaudio layer, falling back to ALSA"); + JAMI_WARN("Could not create pulseaudio layer, falling back to ALSA"); } } @@ -411,7 +411,7 @@ AudioPreference::createAudioLayer() try { return new CoreLayer(*this); } catch (const std::runtime_error &e) { - RING_WARN("Could not create coreaudio layer. There will be no sound."); + JAMI_WARN("Could not create coreaudio layer. There will be no sound."); } return NULL; #endif @@ -421,13 +421,13 @@ AudioPreference::createAudioLayer() try { return new PortAudioLayer(*this); } catch (const std::runtime_error &e) { - RING_WARN("Could not create PortAudio layer. There will be no sound."); + JAMI_WARN("Could not create PortAudio layer. There will be no sound."); } return nullptr; #endif #endif // __ANDROID__ - RING_WARN("No audio layer provided"); + JAMI_WARN("No audio layer provided"); return nullptr; } @@ -474,7 +474,7 @@ AudioPreference::setRecordPath(const std::string &r) recordpath_ = path; return true; } else { - RING_ERR("%s is not writable, cannot be the recording path", path.c_str()); + JAMI_ERR("%s is not writable, cannot be the recording path", path.c_str()); return false; } } @@ -560,7 +560,7 @@ void ShortcutPreferences::unserialize(const YAML::Node &in) parseValue(node, TOGGLE_PICKUP_HANGUP_SHORT_KEY, togglePickupHangup_); } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO VideoPreferences::VideoPreferences() : decodingAccelerated_(true) , encodingAccelerated_(false) @@ -593,6 +593,6 @@ void VideoPreferences::unserialize(const YAML::Node &in) #endif getVideoDeviceMonitor().unserialize(in); } -#endif // RING_VIDEO +#endif // ENABLE_VIDEO -} // namespace ring +} // namespace jami diff --git a/src/preferences.h b/src/preferences.h index 4e6b170e37..0b6cb61f45 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -34,7 +34,7 @@ namespace YAML { struct pjsip_msg; -namespace ring { +namespace jami { class AudioLayer; @@ -449,7 +449,7 @@ class ShortcutPreferences : public Serializable { constexpr static const char * const CONFIG_LABEL = "shortcuts"; }; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO class VideoPreferences : public Serializable { public: VideoPreferences(); @@ -480,8 +480,8 @@ class VideoPreferences : public Serializable { bool encodingAccelerated_; constexpr static const char* const CONFIG_LABEL = "video"; }; -#endif // RING_VIDEO +#endif // ENABLE_VIDEO -} // namespace ring +} // namespace jami #endif diff --git a/src/rational.h b/src/rational.h index 167a0f7f0c..c3318adab2 100644 --- a/src/rational.h +++ b/src/rational.h @@ -31,7 +31,7 @@ extern "C" { #include <libavutil/rational.h> // specify conversions for AVRational } -namespace ring { +namespace jami { /** * Naive implementation of the boost::rational interface, described here: diff --git a/src/registration_states.h b/src/registration_states.h index dc46160074..7dbf03e36d 100644 --- a/src/registration_states.h +++ b/src/registration_states.h @@ -26,7 +26,7 @@ #undef REGISTERED #endif -namespace ring { +namespace jami { /** Contains all the Registration states for an account can be in */ enum class RegistrationState { @@ -44,6 +44,6 @@ enum class RegistrationState { INITIALIZING }; -} // namespace ring +} // namespace jami #endif // REGISTRATION_STATES_H_ diff --git a/src/ring_api.cpp b/src/ring_api.cpp index 9a1310a1bc..9230a2e3c1 100644 --- a/src/ring_api.cpp +++ b/src/ring_api.cpp @@ -35,9 +35,9 @@ #include "presencemanager_interface.h" #include "client/ring_signal.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "client/videomanager.h" -#endif // RING_VIDEO +#endif // ENABLE_VIDEO namespace DRing { @@ -50,11 +50,11 @@ init(enum InitFlag flags) noexcept // Following function create a local static variable inside // This var must have the same live as Manager. // So we call it now to create this var. - ring::getSignalHandlers(); + jami::getSignalHandlers(); try { // current implementation use static variable - auto& manager = ring::Manager::instance(); + auto& manager = jami::Manager::instance(); manager.setAutoAnswer(flags & DRING_FLAG_AUTOANSWER); return true; } catch (...) { @@ -66,7 +66,7 @@ bool start(const std::string& config_file) noexcept { try { - ring::Manager::instance().init(config_file); + jami::Manager::instance().init(config_file); } catch (...) { return false; } @@ -76,7 +76,7 @@ start(const std::string& config_file) noexcept void fini() noexcept { - ring::Manager::instance().finish(); + jami::Manager::instance().finish(); } } // namespace DRing diff --git a/src/ring_types.h b/src/ring_types.h index 41f9eadab8..61825c88b1 100644 --- a/src/ring_types.h +++ b/src/ring_types.h @@ -29,7 +29,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { typedef int16_t AudioSample; @@ -76,6 +76,6 @@ getGlobalInstance() return wlink.lock(); } -} // namespace ring +} // namespace jami #endif // RING_TYPES_H_ diff --git a/src/ringdht/accountarchive.cpp b/src/ringdht/accountarchive.cpp index a09eb9cef7..0db1a067b1 100644 --- a/src/ringdht/accountarchive.cpp +++ b/src/ringdht/accountarchive.cpp @@ -23,12 +23,12 @@ #include "base64.h" #include "logger.h" -namespace ring { +namespace jami { void AccountArchive::deserialize(const std::vector<uint8_t>& dat) { - RING_DBG("Loading account archive (%lu bytes)", dat.size()); + JAMI_DBG("Loading account archive (%lu bytes)", dat.size()); // Decode string auto* char_data = reinterpret_cast<const char*>(&dat[0]); @@ -37,7 +37,7 @@ AccountArchive::deserialize(const std::vector<uint8_t>& dat) Json::CharReaderBuilder rbuilder; auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); if (!reader->parse(char_data, char_data + dat.size(), &value, &err)) { - RING_ERR() << "Archive JSON parsing error: " << err; + JAMI_ERR() << "Archive JSON parsing error: " << err; throw std::runtime_error("failed to parse JSON"); } @@ -71,11 +71,11 @@ AccountArchive::deserialize(const std::vector<uint8_t>& dat) } else config[key] = itr->asString(); } catch (const std::exception& ex) { - RING_ERR("Can't parse JSON entry with value of type %d: %s", (unsigned)itr->type(), ex.what()); + JAMI_ERR("Can't parse JSON entry with value of type %d: %s", (unsigned)itr->type(), ex.what()); } } } catch (const std::exception& ex) { - RING_ERR("Can't parse JSON: %s", ex.what()); + JAMI_ERR("Can't parse JSON: %s", ex.what()); } } diff --git a/src/ringdht/accountarchive.h b/src/ringdht/accountarchive.h index 73a10e3c0a..b0d88992ad 100644 --- a/src/ringdht/accountarchive.h +++ b/src/ringdht/accountarchive.h @@ -26,7 +26,7 @@ #include <map> #include <string> -namespace ring { +namespace jami { /** * Crypto material contained in the archive, diff --git a/src/ringdht/configkeys.h b/src/ringdht/configkeys.h index 0a043ab521..ba670f1b57 100644 --- a/src/ringdht/configkeys.h +++ b/src/ringdht/configkeys.h @@ -17,7 +17,7 @@ */ #pragma once -namespace ring { +namespace jami { namespace Conf { constexpr const char* const DHT_PORT_KEY = "dhtPort"; diff --git a/src/ringdht/namedirectory.cpp b/src/ringdht/namedirectory.cpp index c4dd81bec5..632fa1e3e1 100644 --- a/src/ringdht/namedirectory.cpp +++ b/src/ringdht/namedirectory.cpp @@ -35,7 +35,7 @@ #include <regex> #include <fstream> -namespace ring { +namespace jami { constexpr const char* const QUERY_NAME {"/name/"}; constexpr const char* const QUERY_ADDR {"/addr/"}; @@ -67,7 +67,7 @@ NameDirectory::lookupUri(const std::string& uri, const std::string& default_serv return; } } - RING_ERR("Can't parse URI: %s", uri.c_str()); + JAMI_ERR("Can't parse URI: %s", uri.c_str()); cb("", Response::invalidResponse); } @@ -119,7 +119,7 @@ void NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb) req->set_header("Accept", "*/*"); req->set_header("Host", serverHost_); - RING_DBG("Address lookup for %s: %s", addr.c_str(), uri.to_string().c_str()); + JAMI_DBG("Address lookup for %s: %s", addr.c_str(), uri.to_string().c_str()); auto ret = restbed::Http::async(req, [this,cb,addr](const std::shared_ptr<restbed::Request>&, const std::shared_ptr<restbed::Response>& reply) { @@ -138,13 +138,13 @@ void NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb) Json::CharReaderBuilder rbuilder; auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); if (!reader->parse(&body[0], &body[body.size()], &json, nullptr)) { - RING_ERR("Address lookup for %s: can't parse server response: %s", addr.c_str(), body.c_str()); + JAMI_ERR("Address lookup for %s: can't parse server response: %s", addr.c_str(), body.c_str()); cb("", Response::error); return; } auto name = json["name"].asString(); if (not name.empty()) { - RING_DBG("Found name for %s: %s", addr.c_str(), name.c_str()); + JAMI_DBG("Found name for %s: %s", addr.c_str(), name.c_str()); { std::lock_guard<std::mutex> l(lock_); addrCache_.emplace(name, addr); @@ -165,7 +165,7 @@ void NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb) // avoid blocking on future destruction ThreadPool::instance().run([ret](){ ret.get(); }); } catch (const std::exception& e) { - RING_ERR("Error when performing address lookup: %s", e.what()); + JAMI_ERR("Error when performing address lookup: %s", e.what()); cb("", Response::error); } } @@ -193,7 +193,7 @@ void NameDirectory::lookupName(const std::string& n, LookupCallback cb) } restbed::Uri uri(HTTPS_PROTO + serverHost_ + QUERY_NAME + name); - RING_DBG("Name lookup for %s: %s", name.c_str(), uri.to_string().c_str()); + JAMI_DBG("Name lookup for %s: %s", name.c_str(), uri.to_string().c_str()); auto request = std::make_shared<restbed::Request>(std::move(uri)); request->set_header("Accept", "*/*"); @@ -203,7 +203,7 @@ void NameDirectory::lookupName(const std::string& n, LookupCallback cb) const std::shared_ptr<restbed::Response>& reply) { auto code = reply->get_status_code(); if (code != 200) - RING_DBG("Name lookup for %s: got reply code %d", name.c_str(), code); + JAMI_DBG("Name lookup for %s: got reply code %d", name.c_str(), code); if (code >= 200 && code < 300) { size_t length = getContentLength(*reply); if (length > MAX_RESPONSE_SIZE) { @@ -218,7 +218,7 @@ void NameDirectory::lookupName(const std::string& n, LookupCallback cb) Json::CharReaderBuilder rbuilder; auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); if (!reader->parse(&body[0], &body[body.size()], &json, nullptr)) { - RING_ERR("Name lookup for %s: can't parse server response: %s", name.c_str(), body.c_str()); + JAMI_ERR("Name lookup for %s: can't parse server response: %s", name.c_str(), body.c_str()); cb("", Response::error); return; } @@ -246,7 +246,7 @@ void NameDirectory::lookupName(const std::string& n, LookupCallback cb) } } - RING_DBG("Found address for %s: %s", name.c_str(), addr.c_str()); + JAMI_DBG("Found address for %s: %s", name.c_str(), addr.c_str()); { std::lock_guard<std::mutex> l(lock_); addrCache_.emplace(name, addr); @@ -264,7 +264,7 @@ void NameDirectory::lookupName(const std::string& n, LookupCallback cb) // avoid blocking on future destruction ThreadPool::instance().run([ret](){ ret.get(); }); } catch (const std::exception& e) { - RING_ERR("Error when performing name lookup: %s", e.what()); + JAMI_ERR("Error when performing name lookup: %s", e.what()); cb("", Response::error); } } @@ -301,23 +301,23 @@ void NameDirectory::registerName(const std::string& addr, const std::string& n, { std::stringstream ss; ss << "{\"addr\":\"" << addr << "\",\"owner\":\"" << owner << - "\",\"signature\":\"" << signedname << "\",\"publickey\":\"" << base64::encode(ring::Blob(publickey.begin(), publickey.end())) << "\"}"; + "\",\"signature\":\"" << signedname << "\",\"publickey\":\"" << base64::encode(jami::Blob(publickey.begin(), publickey.end())) << "\"}"; body = ss.str(); } request->set_body(body); - request->set_header("Content-Length", ring::to_string(body.size())); + request->set_header("Content-Length", jami::to_string(body.size())); auto params = std::make_shared<restbed::Settings>(); params->set_connection_timeout(std::chrono::seconds(120)); - RING_WARN("registerName: sending request %s %s", addr.c_str(), name.c_str()); + JAMI_WARN("registerName: sending request %s %s", addr.c_str(), name.c_str()); auto ret = restbed::Http::async(request, [this,cb,addr,name](const std::shared_ptr<restbed::Request>&, const std::shared_ptr<restbed::Response>& reply) { auto code = reply->get_status_code(); - RING_DBG("Got reply for registration of %s -> %s: code %d", name.c_str(), addr.c_str(), code); + JAMI_DBG("Got reply for registration of %s -> %s: code %d", name.c_str(), addr.c_str(), code); if (code >= 200 && code < 300) { size_t length = getContentLength(*reply); if (length > MAX_RESPONSE_SIZE) { @@ -336,7 +336,7 @@ void NameDirectory::registerName(const std::string& addr, const std::string& n, return; } auto success = json["success"].asBool(); - RING_DBG("Got reply for registration of %s -> %s: %s", name.c_str(), addr.c_str(), success ? "success" : "failure"); + JAMI_DBG("Got reply for registration of %s -> %s: %s", name.c_str(), addr.c_str(), success ? "success" : "failure"); if (success) { std::lock_guard<std::mutex> l(lock_); addrCache_.emplace(name, addr); @@ -345,29 +345,29 @@ void NameDirectory::registerName(const std::string& addr, const std::string& n, cb(success ? RegistrationResponse::success : RegistrationResponse::error); } else if(code == 400){ cb(RegistrationResponse::incompleteRequest); - RING_ERR("RegistrationResponse::incompleteRequest"); + JAMI_ERR("RegistrationResponse::incompleteRequest"); } else if(code == 401){ cb(RegistrationResponse::signatureVerificationFailed); - RING_ERR("RegistrationResponse::signatureVerificationFailed"); + JAMI_ERR("RegistrationResponse::signatureVerificationFailed"); } else if (code == 403) { cb(RegistrationResponse::alreadyTaken); - RING_ERR("RegistrationResponse::alreadyTaken"); + JAMI_ERR("RegistrationResponse::alreadyTaken"); } else if (code == 409) { cb(RegistrationResponse::alreadyTaken); - RING_ERR("RegistrationResponse::alreadyTaken"); + JAMI_ERR("RegistrationResponse::alreadyTaken"); } else if (code > 400 && code < 500) { cb(RegistrationResponse::alreadyTaken); - RING_ERR("RegistrationResponse::alreadyTaken"); + JAMI_ERR("RegistrationResponse::alreadyTaken"); } else { cb(RegistrationResponse::error); - RING_ERR("RegistrationResponse::error"); + JAMI_ERR("RegistrationResponse::error"); } }, params).share(); // avoid blocking on future destruction ThreadPool::instance().run([ret](){ ret.get(); }); } catch (const std::exception& e) { - RING_ERR("Error when performing name registration: %s", e.what()); + JAMI_ERR("Error when performing name registration: %s", e.what()); cb(RegistrationResponse::error); } } @@ -382,7 +382,7 @@ NameDirectory::saveCache() std::lock_guard<std::mutex> l(lock_); msgpack::pack(file, nameCache_); } - RING_DBG("Saved %lu name-address mappings", (long unsigned)nameCache_.size()); + JAMI_DBG("Saved %lu name-address mappings", (long unsigned)nameCache_.size()); } void @@ -395,7 +395,7 @@ NameDirectory::loadCache() std::lock_guard<std::mutex> lock(fileutils::getFileLock(cachePath_)); std::ifstream file(cachePath_); if (!file.is_open()) { - RING_DBG("Could not load %s", cachePath_.c_str()); + JAMI_DBG("Could not load %s", cachePath_.c_str()); return; } std::string line; @@ -413,7 +413,7 @@ NameDirectory::loadCache() oh.get().convert(nameCache_); for (const auto& m : nameCache_) addrCache_.emplace(m.second, m.first); - RING_DBG("Loaded %lu name-address mappings", (long unsigned)nameCache_.size()); + JAMI_DBG("Loaded %lu name-address mappings", (long unsigned)nameCache_.size()); } } diff --git a/src/ringdht/namedirectory.h b/src/ringdht/namedirectory.h index 0d24332d2d..09c872df42 100644 --- a/src/ringdht/namedirectory.h +++ b/src/ringdht/namedirectory.h @@ -30,7 +30,7 @@ struct PublicKey; } } -namespace ring { +namespace jami { class NameDirectory { diff --git a/src/ringdht/p2p.cpp b/src/ringdht/p2p.cpp index 800d8e89a8..810930f61f 100644 --- a/src/ringdht/p2p.cpp +++ b/src/ringdht/p2p.cpp @@ -40,7 +40,7 @@ #include <algorithm> #include <type_traits> -namespace ring { +namespace jami { static constexpr auto DHT_MSG_TIMEOUT = std::chrono::seconds(20); static constexpr auto NET_CONNECTION_TIMEOUT = std::chrono::seconds(10); @@ -273,7 +273,7 @@ public: [this] { try { process(); } catch (const std::exception& e) { - RING_ERR() << "[CNX] exception during client processing: " << e.what(); + JAMI_ERR() << "[CNX] exception during client processing: " << e.what(); cancel(); } }); @@ -316,7 +316,7 @@ private: request.id = ValueIdDist()(parent_.account.rand); /* Random id for the message unicity */ // Send connection request through DHT - RING_DBG() << parent_.account << "[CNX] request connection to " << peer_; + JAMI_DBG() << parent_.account << "[CNX] request connection to " << peer_; parent_.account.dht().putEncrypted( dht::InfoHash::get(PeerConnectionMsg::key_prefix + peer_.toString()), peer_, request); @@ -325,7 +325,7 @@ private: dhtMsgTimeout.start(); while (!responseReceived_) { if (dhtMsgTimeout) { - RING_ERR("no response from DHT to E2E request. Cancel transfer"); + JAMI_ERR("no response from DHT to E2E request. Cancel transfer"); cancel(); return; } @@ -345,30 +345,30 @@ private: throw std::runtime_error("invalid connection reply"); try { // Connect to TURN peer using a raw socket - RING_DBG() << parent_.account << "[CNX] connecting to TURN relay " + JAMI_DBG() << parent_.account << "[CNX] connecting to TURN relay " << relay_addr.toString(true, true); peer_ep = std::make_unique<TcpSocketEndpoint>(relay_addr); try { peer_ep->connect(SOCK_TIMEOUT); } catch (const std::logic_error& e) { // In case of a timeout - RING_WARN() << "TcpSocketEndpoint timeout for addr " << relay_addr.toString(true, true) << ": " << e.what(); + JAMI_WARN() << "TcpSocketEndpoint timeout for addr " << relay_addr.toString(true, true) << ": " << e.what(); cancel(); return; } catch (...) { - RING_WARN() << "TcpSocketEndpoint failure for addr " << relay_addr.toString(true, true); + JAMI_WARN() << "TcpSocketEndpoint failure for addr " << relay_addr.toString(true, true); cancel(); return; } break; } catch (std::system_error&) { - RING_DBG() << parent_.account << "[CNX] Failed to connect to TURN relay " + JAMI_DBG() << parent_.account << "[CNX] Failed to connect to TURN relay " << relay_addr.toString(true, true); } } // Negotiate a TLS session - RING_DBG() << parent_.account << "[CNX] start TLS session"; + JAMI_DBG() << parent_.account << "[CNX] start TLS session"; auto tls_ep = std::make_unique<TlsSocketEndpoint>(*peer_ep, parent_.account.identity(), parent_.account.dhParams(), @@ -378,11 +378,11 @@ private: tls_ep->waitForReady(SOCK_TIMEOUT); } catch (const std::logic_error& e) { // In case of a timeout - RING_WARN() << "TLS connection timeout from peer " << peer_.toString() << ": " << e.what(); + JAMI_WARN() << "TLS connection timeout from peer " << peer_.toString() << ": " << e.what(); cancel(); return; } catch (...) { - RING_WARN() << "TLS connection failure from peer " << peer_.toString(); + JAMI_WARN() << "TLS connection failure from peer " << peer_.toString(); cancel(); return; } @@ -497,7 +497,7 @@ DhtPeerConnector::Impl::validatePeerCertificate(const dht::crypto::Certificate& void DhtPeerConnector::Impl::onTurnPeerConnection(const IpAddr& peer_addr) { - RING_DBG() << account << "[CNX] TURN connection attempt from " + JAMI_DBG() << account << "[CNX] TURN connection attempt from " << peer_addr.toString(true, true); auto turn_ep = std::unique_ptr<ConnectedTurnTransport>(nullptr); @@ -506,7 +506,7 @@ DhtPeerConnector::Impl::onTurnPeerConnection(const IpAddr& peer_addr) else turn_ep = std::make_unique<ConnectedTurnTransport>(*turnAuthv6_, peer_addr); - RING_DBG() << account << "[CNX] start TLS session over TURN socket"; + JAMI_DBG() << account << "[CNX] start TLS session over TURN socket"; dht::InfoHash peer_h; auto tls_ep = std::make_unique<TlsTurnEndpoint>( *turn_ep, account.identity(), account.dhParams(), @@ -517,14 +517,14 @@ DhtPeerConnector::Impl::onTurnPeerConnection(const IpAddr& peer_addr) tls_ep->waitForReady(SOCK_TIMEOUT); } catch (const std::logic_error& e) { // In case of a timeout - RING_WARN() << "TLS connection timeout from peer " << peer_addr.toString(true, true) << ": " << e.what(); + JAMI_WARN() << "TLS connection timeout from peer " << peer_addr.toString(true, true) << ": " << e.what(); return; } catch (...) { - RING_WARN() << "[CNX] TLS connection failure from peer " << peer_addr.toString(true, true); + JAMI_WARN() << "[CNX] TLS connection failure from peer " << peer_addr.toString(true, true); return; } - RING_DBG() << account << "[CNX] Accepted TLS-TURN connection from RingID " << peer_h; + JAMI_DBG() << account << "[CNX] Accepted TLS-TURN connection from RingID " << peer_h; connectedPeers_.emplace(peer_addr, tls_ep->peerCertificate().getId()); auto connection = std::make_unique<PeerConnection>([] {}, account, peer_addr.toString(), std::move(tls_ep)); @@ -542,7 +542,7 @@ DhtPeerConnector::Impl::onTurnPeerDisconnection(const IpAddr& peer_addr) [&peer_addr](const auto& element) { return element.first.second == peer_addr;}); if (it == servers_.end()) return; - RING_WARN() << account << "[CNX] disconnection from peer " << peer_addr.toString(true, true); + JAMI_WARN() << account << "[CNX] disconnection from peer " << peer_addr.toString(true, true); servers_.erase(it); connectedPeers_.erase(peer_addr); turnEndpoints_.erase(peer_addr); @@ -551,7 +551,7 @@ DhtPeerConnector::Impl::onTurnPeerDisconnection(const IpAddr& peer_addr) void DhtPeerConnector::Impl::onRequestMsg(PeerConnectionMsg&& request) { - RING_DBG() << account << "[CNX] rx DHT request from " << request.from; + JAMI_DBG() << account << "[CNX] rx DHT request from " << request.from; // Asynch certificate checking -> trig onTrustedRequestMsg when trusted certificate is found account.findCertificate( @@ -561,7 +561,7 @@ DhtPeerConnector::Impl::onRequestMsg(PeerConnectionMsg&& request) if (account.foundPeerDevice(cert, peer_h)) onTrustedRequestMsg(std::move(request), cert, peer_h); else - RING_WARN() << account << "[CNX] rejected untrusted connection request from " + JAMI_WARN() << account << "[CNX] rejected untrusted connection request from " << request.from; }); } @@ -583,16 +583,16 @@ DhtPeerConnector::Impl::onTrustedRequestMsg(PeerConnectionMsg&& request, if (IpAddr(ip).isIpv4()) { sendRelayV4 = true; turnAuthv4_->permitPeer(ip); - RING_DBG() << account << "[CNX] authorized peer connection from " << ip; + JAMI_DBG() << account << "[CNX] authorized peer connection from " << ip; } else if (IpAddr(ip).isIpv6()) { sendRelayV6 = true; turnAuthv6_->permitPeer(ip); - RING_DBG() << account << "[CNX] authorized peer connection from " << ip; + JAMI_DBG() << account << "[CNX] authorized peer connection from " << ip; } else { - RING_DBG() << account << "Unknown family type: " << ip; + JAMI_DBG() << account << "Unknown family type: " << ip; } } catch (const std::exception& e) { - RING_WARN() << account << "[CNX] ignored peer connection '" << ip << "', " << e.what(); + JAMI_WARN() << account << "[CNX] ignored peer connection '" << ip << "', " << e.what(); } } @@ -604,10 +604,10 @@ DhtPeerConnector::Impl::onTrustedRequestMsg(PeerConnectionMsg&& request, if (sendRelayV6 && relayIpv6) addresses.emplace_back(relayIpv6.toString(true, true)); if (addresses.empty()) { - RING_DBG() << account << "[CNX] connection aborted, no family address found"; + JAMI_DBG() << account << "[CNX] connection aborted, no family address found"; return; } - RING_DBG() << account << "[CNX] connection accepted, DHT reply to " << request.from; + JAMI_DBG() << account << "[CNX] connection accepted, DHT reply to " << request.from; account.dht().putEncrypted( dht::InfoHash::get(PeerConnectionMsg::key_prefix + request.from.toString()), request.from, request.respond(addresses)); @@ -618,7 +618,7 @@ DhtPeerConnector::Impl::onTrustedRequestMsg(PeerConnectionMsg&& request, void DhtPeerConnector::Impl::onResponseMsg(PeerConnectionMsg&& response) { - RING_DBG() << account << "[CNX] rx DHT reply from " << response.from; + JAMI_DBG() << account << "[CNX] rx DHT reply from " << response.from; std::lock_guard<std::mutex> lock(clientsMutex_); for (auto& client: clients_) { // NOTE We can receives multiple files from one peer. So fill unanswered clients. @@ -705,7 +705,7 @@ DhtPeerConnector::Impl::eventLoop() ctrlMsgData<CtrlMsgType::ADD_DEVICE, 4>(*msg)); break; - default: RING_ERR("BUG: got unhandled control msg!"); break; + default: JAMI_ERR("BUG: got unhandled control msg!"); break; } } } @@ -768,7 +768,7 @@ DhtPeerConnector::requestConnection(const std::string& peer_id, [this, addresses, connect_cb, tid](const std::shared_ptr<RingAccount>& account, const dht::InfoHash& dev_h) { if (dev_h == account->dht().getId()) { - RING_ERR() << account << "[CNX] no connection to yourself, bad person!"; + JAMI_ERR() << account << "[CNX] no connection to yourself, bad person!"; return; } @@ -781,7 +781,7 @@ DhtPeerConnector::requestConnection(const std::string& peer_id, [peer_h, connect_cb](const std::shared_ptr<RingAccount>& account, bool found) { if (!found) { - RING_WARN() << account << "[CNX] aborted, no devices for " << peer_h; + JAMI_WARN() << account << "[CNX] aborted, no devices for " << peer_h; connect_cb(nullptr); } }); @@ -805,7 +805,7 @@ DhtPeerConnector::closeConnection(const std::string& peer_id, const DRing::DataT [this, tid](const std::shared_ptr<RingAccount>& account, const dht::InfoHash& dev_h) { if (dev_h == account->dht().getId()) { - RING_ERR() << account << "[CNX] no connection to yourself, bad person!"; + JAMI_ERR() << account << "[CNX] no connection to yourself, bad person!"; return; } pimpl_->ctrl << makeMsg<CtrlMsgType::CANCEL>(dev_h, tid); @@ -813,9 +813,9 @@ DhtPeerConnector::closeConnection(const std::string& peer_id, const DRing::DataT [peer_h](const std::shared_ptr<RingAccount>& account, bool found) { if (!found) { - RING_WARN() << account << "[CNX] aborted, no devices for " << peer_h; + JAMI_WARN() << account << "[CNX] aborted, no devices for " << peer_h; } }); } -} // namespace ring +} // namespace jami diff --git a/src/ringdht/p2p.h b/src/ringdht/p2p.h index c080df26c5..d1d5e4d46c 100644 --- a/src/ringdht/p2p.h +++ b/src/ringdht/p2p.h @@ -25,7 +25,7 @@ #include <functional> #include "dring/datatransfer_interface.h" -namespace ring { +namespace jami { class RingAccount; class PeerConnection; diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 0c14d83163..f4532f6bcc 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -56,7 +56,7 @@ #include "manager.h" #include "utf8_utils.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "libav_utils.h" #endif #include "fileutils.h" @@ -86,7 +86,7 @@ #include <string> #include <system_error> -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -118,7 +118,7 @@ setState (const std::string& accountID, mapStateNumberToString(migrationState)); } -} // namespace ring::Migration +} // namespace jami::Migration struct RingAccount::BuddyInfo { @@ -326,12 +326,12 @@ RingAccount::newIncomingCall(const std::string& from, const std::map<std::string while (call_it != pendingSipCalls_.end()) { auto call = call_it->call.lock(); if (not call) { - RING_WARN("newIncomingCall: discarding deleted call"); + JAMI_WARN("newIncomingCall: discarding deleted call"); call_it = pendingSipCalls_.erase(call_it); } else if (call->getPeerNumber() == from || (call_it->from_cert and call_it->from_cert->issuer and call_it->from_cert->issuer->getId().toString() == from)) { - RING_DBG("newIncomingCall: found matching call for %s", from.c_str()); + JAMI_DBG("newIncomingCall: found matching call for %s", from.c_str()); pendingSipCalls_.erase(call_it); call->updateDetails(details); return call; @@ -339,7 +339,7 @@ RingAccount::newIncomingCall(const std::string& from, const std::map<std::string ++call_it; } } - RING_ERR("newIncomingCall: can't find matching call for %s", from.c_str()); + JAMI_ERR("newIncomingCall: can't find matching call for %s", from.c_str()); return nullptr; } @@ -349,7 +349,7 @@ RingAccount::newOutgoingCall(const std::string& toUrl, const std::map<std::string, std::string>& volatileCallDetails) { auto suffix = stripPrefix(toUrl); - RING_DBG() << *this << "Calling DHT peer " << suffix; + JAMI_DBG() << *this << "Calling DHT peer " << suffix; auto& manager = Manager::instance(); auto call = manager.callFactory.newCall<SIPCall, RingAccount>(*this, manager.getNewCallID(), Call::CallType::OUTGOING, @@ -418,7 +418,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: { auto call = wCall.lock(); if (not call) return; - RING_DBG("[call %s] calling device %s", call->getCallId().c_str(), dev.toString().c_str()); + JAMI_DBG("[call %s] calling device %s", call->getCallId().c_str(), dev.toString().c_str()); auto& manager = Manager::instance(); auto dev_call = manager.callFactory.newCall<SIPCall, RingAccount>(*sthis, manager.getNewCallID(), @@ -430,7 +430,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: auto ice = sthis->createIceTransport(("sip:" + dev_call->getCallId()).c_str(), ICE_COMPONENTS, true, sthis->getIceOptions()); if (not ice) { - RING_WARN("Can't create ICE"); + JAMI_WARN("Can't create ICE"); dev_call->removeCall(); return; } @@ -445,7 +445,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: return false; if (ice->isFailed()) { - RING_ERR("[call:%s] ice init failed", call->getCallId().c_str()); + JAMI_ERR("[call:%s] ice init failed", call->getCallId().c_str()); call->onFailure(EIO); return false; } @@ -468,11 +468,11 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: std::move(val), [=](bool ok) { // Put complete callback if (!ok) { - RING_WARN("Can't put ICE descriptor on DHT"); + JAMI_WARN("Can't put ICE descriptor on DHT"); if (auto call = weak_dev_call.lock()) call->onFailure(); } else - RING_DBG("Successfully put ICE descriptor on DHT"); + JAMI_DBG("Successfully put ICE descriptor on DHT"); } ); @@ -486,7 +486,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: iceData.erase(std::remove_if(iceData.begin(), iceData.end(), [](unsigned char c){ return !std::isprint(c) && !std::isspace(c); } ), iceData.end()); - RING_WARN("ICE request replied from DHT peer %s\nData: %s", dev.toString().c_str(), iceData.c_str()); + JAMI_WARN("ICE request replied from DHT peer %s\nData: %s", dev.toString().c_str(), iceData.c_str()); if (auto call = weak_dev_call.lock()) { call->setState(Call::ConnectionState::PROGRESSING); if (!ice->start(msg.ice_data)) { @@ -514,7 +514,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: }, [wCall](const std::shared_ptr<RingAccount>&, bool ok){ if (not ok) { if (auto call = wCall.lock()) { - RING_WARN("[call:%s] no devices found", call->getCallId().c_str()); + JAMI_WARN("[call:%s] no devices found", call->getCallId().c_str()); call->onFailure(static_cast<int>(std::errc::no_such_device_or_address)); } } @@ -524,7 +524,7 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:: void RingAccount::onConnectedOutgoingCall(SIPCall& call, const std::string& to_id, IpAddr target) { - RING_DBG("[call:%s] outgoing call connected to %s", call.getCallId().c_str(), to_id.c_str()); + JAMI_DBG("[call:%s] outgoing call connected to %s", call.getCallId().c_str(), to_id.c_str()); call.initIceMediaTransport(true); call.setIPToIP(true); @@ -548,7 +548,7 @@ RingAccount::onConnectedOutgoingCall(SIPCall& call, const std::string& to_id, Ip // Initialize the session using ULAW as default codec in case of early media // The session should be ready to receive media once the first INVITE is sent, before // the session initialization is completed - if (!getSystemCodecContainer()->searchCodecByName("PCMA", ring::MEDIA_AUDIO)) + if (!getSystemCodecContainer()->searchCodecByName("PCMA", jami::MEDIA_AUDIO)) throw VoipLinkException("Could not instantiate codec for early media"); // Building the local SDP offer @@ -593,7 +593,7 @@ RingAccount::SIPStartCall(SIPCall& call, IpAddr target) pjContact = getContactHeader(transport ? transport->get() : nullptr); } - RING_DBG("contact header: %.*s / %s -> %s / %.*s", + JAMI_DBG("contact header: %.*s / %s -> %s / %.*s", (int)pjContact.slen, pjContact.ptr, from.c_str(), toUri.c_str(), (int)pjTarget.slen, pjTarget.ptr); @@ -616,20 +616,20 @@ RingAccount::SIPStartCall(SIPCall& call, IpAddr target) pjsip_tx_data *tdata; if (pjsip_inv_invite(call.inv.get(), &tdata) != PJ_SUCCESS) { - RING_ERR("Could not initialize invite messager for this call"); + JAMI_ERR("Could not initialize invite messager for this call"); return false; } //const pjsip_tpselector tp_sel = getTransportSelector(); const pjsip_tpselector tp_sel = {PJSIP_TPSELECTOR_TRANSPORT, {call.getTransport()->get()}}; if (pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) { - RING_ERR("Unable to associate transport for invite session dialog"); + JAMI_ERR("Unable to associate transport for invite session dialog"); return false; } - RING_DBG("[call:%s] Sending SIP invite", call.getCallId().c_str()); + JAMI_DBG("[call:%s] Sending SIP invite", call.getCallId().c_str()); if (pjsip_inv_send_msg(call.inv.get(), tdata) != PJ_SUCCESS) { - RING_ERR("Unable to send invite message for this call"); + JAMI_ERR("Unable to send invite message for this call"); return false; } @@ -704,13 +704,13 @@ void RingAccount::unserialize(const YAML::Node &node) try { parseValue(node, DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_); } catch (const std::exception& e) { - RING_WARN("can't read device name: %s", e.what()); + JAMI_WARN("can't read device name: %s", e.what()); } if (registeredName_.empty()) { try { parseValue(node, DRing::Account::VolatileProperties::REGISTERED_NAME, registeredName_); } catch (const std::exception& e) { - RING_WARN("can't read registered name: %s", e.what()); + JAMI_WARN("can't read registered name: %s", e.what()); } } @@ -718,7 +718,7 @@ void RingAccount::unserialize(const YAML::Node &node) parsePath(node, DRing::Account::ConfProperties::ARCHIVE_PATH, archivePath_, idPath_); parseValue(node, DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD, archiveHasPassword_); } catch (const std::exception& e) { - RING_WARN("can't read archive path: %s", e.what()); + JAMI_WARN("can't read archive path: %s", e.what()); archiveHasPassword_ = true; } @@ -727,7 +727,7 @@ void RingAccount::unserialize(const YAML::Node &node) auto receipt_sig = node[Conf::RING_ACCOUNT_RECEIPT_SIG].as<YAML::Binary>(); receiptSignature_ = {receipt_sig.data(), receipt_sig.data()+receipt_sig.size()}; } catch (const std::exception& e) { - RING_WARN("can't read receipt: %s", e.what()); + JAMI_WARN("can't read receipt: %s", e.what()); } if (not dhtPort_) @@ -738,7 +738,7 @@ void RingAccount::unserialize(const YAML::Node &node) try { parseValue(node, DRing::Account::ConfProperties::RingNS::URI, nameServer_); } catch (const std::exception& e) { - RING_WARN("can't read name server: %s", e.what()); + JAMI_WARN("can't read name server: %s", e.what()); } nameDir_ = NameDirectory::instance(nameServer_); #endif @@ -752,7 +752,7 @@ void RingAccount::createRingDevice(const dht::crypto::Identity& id) { if (not id.second->isCA()) { - RING_ERR("[Account %s] trying to sign a certificate with a non-CA.", getAccountID().c_str()); + JAMI_ERR("[Account %s] trying to sign a certificate with a non-CA.", getAccountID().c_str()); } auto dev_id = dht::crypto::generateIdentity("Ring device", id); if (!dev_id.first || !dev_id.second) { @@ -776,14 +776,14 @@ RingAccount::createRingDevice(const dht::crypto::Identity& id) receipt_ = makeReceipt(id); receiptSignature_ = id.first->sign({receipt_.begin(), receipt_.end()}); - RING_WARN("[Account %s] created new device: %s (%s)", + JAMI_WARN("[Account %s] created new device: %s (%s)", getAccountID().c_str(), ringDeviceId_.c_str(), ringDeviceName_.c_str()); } void RingAccount::initRingDevice(const AccountArchive& a) { - RING_WARN("[Account %s] creating new device from archive", getAccountID().c_str()); + JAMI_WARN("[Account %s] creating new device from archive", getAccountID().c_str()); SIPAccountBase::setAccountDetails(a.config); parseInt(a.config, Conf::CONFIG_DHT_PORT, dhtPort_); parseBool(a.config, Conf::CONFIG_DHT_PUBLIC_IN_CALLS, dhtPublicInCalls_); @@ -801,7 +801,7 @@ RingAccount::initRingDevice(const AccountArchive& a) std::string RingAccount::makeReceipt(const dht::crypto::Identity& id) { - RING_DBG("[Account %s] signing device receipt", getAccountID().c_str()); + JAMI_DBG("[Account %s] signing device receipt", getAccountID().c_str()); DeviceAnnouncement announcement; announcement.dev = identity_.second->getId(); dht::Value ann_val {announcement}; @@ -824,13 +824,13 @@ RingAccount::useIdentity(const dht::crypto::Identity& identity) return false; if (not identity.first or not identity.second) { - RING_ERR("[Account %s] no identity provided", getAccountID().c_str()); + JAMI_ERR("[Account %s] no identity provided", getAccountID().c_str()); return false; } auto accountCertificate = identity.second->issuer; if (not accountCertificate) { - RING_ERR("[Account %s] device certificate must be issued by the account certificate", getAccountID().c_str()); + JAMI_ERR("[Account %s] device certificate must be issued by the account certificate", getAccountID().c_str()); return false; } @@ -838,14 +838,14 @@ RingAccount::useIdentity(const dht::crypto::Identity& identity) dht::crypto::TrustList account_trust; account_trust.add(*accountCertificate); if (not account_trust.verify(*identity.second)) { - RING_ERR("[Account %s] can't use identity: device certificate chain can't be verified", getAccountID().c_str()); + JAMI_ERR("[Account %s] can't use identity: device certificate chain can't be verified", getAccountID().c_str()); return false; } auto pk = accountCertificate->getPublicKey(); - RING_DBG("[Account %s] checking device receipt for %s", getAccountID().c_str(), pk.getId().toString().c_str()); + JAMI_DBG("[Account %s] checking device receipt for %s", getAccountID().c_str(), pk.getId().toString().c_str()); if (!pk.checkSignature({receipt_.begin(), receipt_.end()}, receiptSignature_)) { - RING_ERR("[Account %s] device receipt signature check failed", getAccountID().c_str()); + JAMI_ERR("[Account %s] device receipt signature check failed", getAccountID().c_str()); return false; } @@ -853,18 +853,18 @@ RingAccount::useIdentity(const dht::crypto::Identity& identity) Json::CharReaderBuilder rbuilder; auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); if (!reader->parse(&receipt_[0], &receipt_[receipt_.size()], &root, nullptr)) { - RING_ERR() << this << " device receipt parsing error"; + JAMI_ERR() << this << " device receipt parsing error"; return false; } auto dev_id = root["dev"].asString(); if (dev_id != identity.second->getId().toString()) { - RING_ERR("[Account %s] device ID mismatch between receipt and certificate", getAccountID().c_str()); + JAMI_ERR("[Account %s] device ID mismatch between receipt and certificate", getAccountID().c_str()); return false; } auto id = root["id"].asString(); if (id != pk.getId().toString()) { - RING_ERR("[Account %s] account ID mismatch between receipt and certificate", getAccountID().c_str()); + JAMI_ERR("[Account %s] account ID mismatch between receipt and certificate", getAccountID().c_str()); return false; } @@ -875,17 +875,17 @@ RingAccount::useIdentity(const dht::crypto::Identity& identity) //dht::Value announce_val (announce_msg.get()); announce_val.msgpack_unpack(announce_msg.get()); if (not announce_val.checkSignature()) { - RING_ERR("[Account %s] announce signature check failed", getAccountID().c_str()); + JAMI_ERR("[Account %s] announce signature check failed", getAccountID().c_str()); return false; } DeviceAnnouncement da; da.unpackValue(announce_val); if (da.from.toString() != id or da.dev.toString() != dev_id) { - RING_ERR("[Account %s] device ID mismatch in announce", getAccountID().c_str()); + JAMI_ERR("[Account %s] device ID mismatch in announce", getAccountID().c_str()); return false; } } catch (const std::exception& e) { - RING_ERR("[Account %s] can't read announce: %s", getAccountID().c_str(), e.what()); + JAMI_ERR("[Account %s] can't read announce: %s", getAccountID().c_str(), e.what()); return false; } @@ -898,14 +898,14 @@ RingAccount::useIdentity(const dht::crypto::Identity& identity) announce_ = std::make_shared<dht::Value>(std::move(announce_val)); ethAccount_ = root["eth"].asString(); - RING_DBG("[Account %s] ring:%s device %s receipt checked successfully", getAccountID().c_str(), id.c_str(), ringDeviceId_.c_str()); + JAMI_DBG("[Account %s] ring:%s device %s receipt checked successfully", getAccountID().c_str(), id.c_str(), ringDeviceId_.c_str()); return true; } dht::crypto::Identity RingAccount::loadIdentity(const std::string& crt_path, const std::string& key_path, const std::string& key_pwd) const { - RING_DBG("[Account %s] loading identity: %s %s", getAccountID().c_str(), crt_path.c_str(), key_path.c_str()); + JAMI_DBG("[Account %s] loading identity: %s %s", getAccountID().c_str(), crt_path.c_str(), key_path.c_str()); dht::crypto::Identity id; try { dht::crypto::Certificate dht_cert(fileutils::loadFile(crt_path, idPath_)); @@ -915,7 +915,7 @@ RingAccount::loadIdentity(const std::string& crt_path, const std::string& key_pa return {}; if (not dht_cert.issuer) { - RING_ERR("[Account %s] device certificate %s has no issuer", getAccountID().c_str(), dht_cert.getId().toString().c_str()); + JAMI_ERR("[Account %s] device certificate %s has no issuer", getAccountID().c_str(), dht_cert.getId().toString().c_str()); return {}; } // load revocation lists for device authority (account certificate). @@ -927,7 +927,7 @@ RingAccount::loadIdentity(const std::string& crt_path, const std::string& key_pa }; } catch (const std::exception& e) { - RING_ERR("Error loading identity: %s", e.what()); + JAMI_ERR("Error loading identity: %s", e.what()); } return id; @@ -936,7 +936,7 @@ RingAccount::loadIdentity(const std::string& crt_path, const std::string& key_pa AccountArchive RingAccount::readArchive(const std::string& pwd) const { - RING_DBG("[Account %s] reading account archive", getAccountID().c_str()); + JAMI_DBG("[Account %s] reading account archive", getAccountID().c_str()); return AccountArchive(fileutils::getFullPath(idPath_, archivePath_), pwd); } @@ -958,7 +958,7 @@ RingAccount::updateArchive(AccountArchive& archive) const TLS::CERTIFICATE_FILE, TLS::PRIVATE_KEY_FILE }; - RING_DBG("[Account %s] building account archive", getAccountID().c_str()); + JAMI_DBG("[Account %s] building account archive", getAccountID().c_str()); for (const auto& it : getAccountDetails()) { // filter-out? if (std::any_of(std::begin(filtered_keys), std::end(filtered_keys), @@ -987,7 +987,7 @@ RingAccount::saveArchive(AccountArchive& archive, const std::string& pwd) archive.save(fileutils::getFullPath(idPath_, archivePath_), pwd); archiveHasPassword_ = not pwd.empty(); } catch (const std::runtime_error& ex) { - RING_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); + JAMI_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); return; } } @@ -1000,7 +1000,7 @@ RingAccount::changeArchivePassword(const std::string& password_old, const std::s AccountArchive(path, password_old).save(path, password_new); archiveHasPassword_ = not password_new.empty(); } catch (const std::exception& ex) { - RING_ERR("[Account %s] Can't change archive password: %s", getAccountID().c_str(), ex.what()); + JAMI_ERR("[Account %s] Can't change archive password: %s", getAccountID().c_str(), ex.what()); return false; } return true; @@ -1054,7 +1054,7 @@ RingAccount::addDevice(const std::string& password) std::string pin_str; AccountArchive a; try { - RING_DBG("[Account %s] exporting account", this_->getAccountID().c_str()); + JAMI_DBG("[Account %s] exporting account", this_->getAccountID().c_str()); a = this_->readArchive(password); @@ -1063,7 +1063,7 @@ RingAccount::addDevice(const std::string& password) std::tie(key, loc) = computeKeys(password, pin_str); } catch (const std::exception& e) { - RING_ERR("[Account %s] can't export account: %s", this_->getAccountID().c_str(), e.what()); + JAMI_ERR("[Account %s] can't export account: %s", this_->getAccountID().c_str(), e.what()); emitSignal<DRing::ConfigurationSignal::ExportOnRingEnded>(this_->getAccountID(), 1, ""); return; } @@ -1075,15 +1075,15 @@ RingAccount::addDevice(const std::string& password) if (not this_->dht_.isRunning()) throw std::runtime_error("DHT is not running.."); this_->dht_.put(loc, encrypted, [this_,pin_str](bool ok) { - RING_DBG("[Account %s] account archive published: %s", this_->getAccountID().c_str(), ok ? "success" : "failure"); + JAMI_DBG("[Account %s] account archive published: %s", this_->getAccountID().c_str(), ok ? "success" : "failure"); if (ok) emitSignal<DRing::ConfigurationSignal::ExportOnRingEnded>(this_->getAccountID(), 0, pin_str); else emitSignal<DRing::ConfigurationSignal::ExportOnRingEnded>(this_->getAccountID(), 2, ""); }); - RING_WARN("[Account %s] exporting account with PIN: %s at %s (size %zu)", this_->getAccountID().c_str(), pin_str.c_str(), loc.toString().c_str(), encrypted.size()); + JAMI_WARN("[Account %s] exporting account with PIN: %s at %s (size %zu)", this_->getAccountID().c_str(), pin_str.c_str(), loc.toString().c_str(), encrypted.size()); } catch (const std::exception& e) { - RING_ERR("[Account %s] can't export account: %s", this_->getAccountID().c_str(), e.what()); + JAMI_ERR("[Account %s] can't export account: %s", this_->getAccountID().c_str(), e.what()); emitSignal<DRing::ConfigurationSignal::ExportOnRingEnded>(this_->getAccountID(), 2, ""); return; } @@ -1108,10 +1108,10 @@ RingAccount::exportArchive(const std::string& destinationPath, const std::string std::ofstream dst(destinationPath, std::ios::out | std::ios::binary); dst << src.rdbuf(); } catch (const std::runtime_error& ex) { - RING_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); + JAMI_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); return false; } catch (...) { - RING_ERR("[Account %s] Can't export archive: can't read archive", getAccountID().c_str()); + JAMI_ERR("[Account %s] Can't export archive: can't read archive", getAccountID().c_str()); return false; } return true; @@ -1187,7 +1187,7 @@ RingAccount::loadAccountFromFile(const std::string& archive_path, const std::str try { archive = AccountArchive(archive_path, archive_password); } catch (const std::exception& ex) { - RING_WARN("[Account %s] can't read file: %s", accountId.c_str(), ex.what()); + JAMI_WARN("[Account %s] can't read file: %s", accountId.c_str(), ex.what()); runOnMainThread([w, accountId]() { if (auto this_ = w.lock()) this_->setRegistrationState(RegistrationState::ERROR_GENERIC); @@ -1209,11 +1209,11 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: // launch dedicated dht instance if (dht_.isRunning()) { - RING_ERR("DHT already running (stopping it first)."); + JAMI_ERR("DHT already running (stopping it first)."); dht_.join(); } dht_.setOnStatusChanged([](dht::NodeStatus s4, dht::NodeStatus s6) { - RING_WARN("Dht status : IPv4 %s; IPv6 %s", dhtStatusStr(s4), dhtStatusStr(s6)); + JAMI_WARN("Dht status : IPv4 %s; IPv6 %s", dhtStatusStr(s4), dhtStatusStr(s6)); }); dht_.run((in_port_t)dhtPortUsed_, {}, true); dht_.bootstrap(loadNodes()); @@ -1232,7 +1232,7 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: if (state_old->first && state_new->first) { bool network_error = !state_old->second && !state_new->second; if (auto this_ = w.lock()) { - RING_WARN("[Account %s] failure looking for archive on DHT: %s", this_->getAccountID().c_str(), network_error ? "network error" : "not found"); + JAMI_WARN("[Account %s] failure looking for archive on DHT: %s", this_->getAccountID().c_str(), network_error ? "network error" : "not found"); this_->setRegistrationState(network_error ? RegistrationState::ERROR_NETWORK : RegistrationState::ERROR_GENERIC); runOnMainThread([=]() { Manager::instance().removeAccount(this_->getAccountID()); @@ -1249,7 +1249,7 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: try { std::tie(key, loc) = computeKeys(archive_password, archive_pin, previous); if (auto this_ = w.lock()) { - RING_DBG("[Account %s] trying to load account from DHT with %s at %s", this_->getAccountID().c_str(), archive_pin.c_str(), loc.toString().c_str()); + JAMI_DBG("[Account %s] trying to load account from DHT with %s at %s", this_->getAccountID().c_str(), archive_pin.c_str(), loc.toString().c_str()); this_->dht_.get(loc, [w,key,found,archive_password](const std::shared_ptr<dht::Value>& val) { std::vector<uint8_t> decrypted; try { @@ -1257,14 +1257,14 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: } catch (const std::exception& ex) { return true; } - RING_DBG("Found archive on the DHT"); + JAMI_DBG("Found archive on the DHT"); runOnMainThread([=]() { if (auto this_ = w.lock()) { try { *found = true; this_->loadAccountFromArchive(AccountArchive(decrypted), archive_password); } catch (const std::exception& e) { - RING_WARN("[Account %s] error reading archive: %s", this_->getAccountID().c_str(), e.what()); + JAMI_WARN("[Account %s] error reading archive: %s", this_->getAccountID().c_str(), e.what()); this_->setRegistrationState(RegistrationState::ERROR_GENERIC); Manager::instance().removeAccount(this_->getAccountID()); } @@ -1272,14 +1272,14 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: }); return not *found; }, [=](bool ok) { - RING_DBG("[Account %s] DHT archive search ended at %s", this_->getAccountID().c_str(), loc.toString().c_str()); + JAMI_DBG("[Account %s] DHT archive search ended at %s", this_->getAccountID().c_str(), loc.toString().c_str()); state->first = true; state->second = ok; searchEnded(); }); } } catch (const std::exception& e) { - RING_ERR("Error computing keys: %s", e.what()); + JAMI_ERR("Error computing keys: %s", e.what()); state->first = true; state->second = true; searchEnded(); @@ -1294,7 +1294,7 @@ RingAccount::loadAccountFromDHT(const std::string& archive_password, const std:: void RingAccount::createAccount(const std::string& archive_password, dht::crypto::Identity&& migrate) { - RING_WARN("[Account %s] creating new account", getAccountID().c_str()); + JAMI_WARN("[Account %s] creating new account", getAccountID().c_str()); setRegistrationState(RegistrationState::INITIALIZING); auto sthis = std::static_pointer_cast<RingAccount>(shared_from_this()); ThreadPool::instance().run([sthis,archive_password,migrate]() mutable { @@ -1304,7 +1304,7 @@ RingAccount::createAccount(const std::string& archive_password, dht::crypto::Ide auto future_keypair = ThreadPool::instance().get<dev::KeyPair>(std::bind(&dev::KeyPair::create)); try { if (migrate.first and migrate.second) { - RING_WARN("[Account %s] converting certificate from old ring account %s", + JAMI_WARN("[Account %s] converting certificate from old ring account %s", this_.getAccountID().c_str(), migrate.first->getPublicKey().getId().toString().c_str()); a.id = std::move(migrate); try { @@ -1320,7 +1320,7 @@ RingAccount::createAccount(const std::string& archive_password, dht::crypto::Ide if (!a.id.first || !a.id.second) { throw VoipLinkException("Can't generate identity for this account."); } - RING_WARN("[Account %s] new account: CA: %s, RingID: %s", + JAMI_WARN("[Account %s] new account: CA: %s, RingID: %s", this_.getAccountID().c_str(), ca.second->getId().toString().c_str(), a.id.second->getId().toString().c_str()); a.ca_key = ca.first; @@ -1339,7 +1339,7 @@ RingAccount::createAccount(const std::string& archive_password, dht::crypto::Ide Manager::instance().removeAccount(sthis->getAccountID()); }); } - RING_DBG("[Account %s] Account creation ended, saving configuration", this_.getAccountID().c_str()); + JAMI_DBG("[Account %s] Account creation ended, saving configuration", this_.getAccountID().c_str()); this_.setRegistrationState(RegistrationState::UNREGISTERED); Manager::instance().saveConfig(); this_.doRegister(); @@ -1354,11 +1354,11 @@ RingAccount::needsMigration(const dht::crypto::Identity& id) auto cert = id.second->issuer; while (cert) { if (not cert->isCA()){ - RING_WARN("certificate %s is not a CA, needs update.", cert->getId().toString().c_str()); + JAMI_WARN("certificate %s is not a CA, needs update.", cert->getId().toString().c_str()); return true; } if (cert->getExpiration() < clock::now()) { - RING_WARN("certificate %s is expired, needs update.", cert->getId().toString().c_str()); + JAMI_WARN("certificate %s is expired, needs update.", cert->getId().toString().c_str()); return true; } cert = cert->issuer; @@ -1369,7 +1369,7 @@ RingAccount::needsMigration(const dht::crypto::Identity& id) bool RingAccount::updateCertificates(AccountArchive& archive, dht::crypto::Identity& device) { - RING_WARN("Updating certificates"); + JAMI_WARN("Updating certificates"); using Certificate = dht::crypto::Certificate; // We need the CA key to resign certificates @@ -1389,20 +1389,20 @@ RingAccount::updateCertificates(AccountArchive& archive, dht::crypto::Identity& if (not ca or (not ca->issuer and (not ca->isCA() or ca->getExpiration() < clock::now()))) { ca = std::make_shared<Certificate>(Certificate::generate(*archive.ca_key, "Ring CA", {}, true)); updated = true; - RING_DBG("CA CRT re-generated"); + JAMI_DBG("CA CRT re-generated"); } // Update certificate if (updated or not cert->isCA() or cert->getExpiration() < clock::now()) { cert = std::make_shared<Certificate>(Certificate::generate(*archive.id.first, "Ring", dht::crypto::Identity{archive.ca_key, ca}, true)); updated = true; - RING_DBG("ring CRT re-generated"); + JAMI_DBG("ring CRT re-generated"); } if (updated and device.first and *device.first) { // update device certificate device.second = std::make_shared<Certificate>(Certificate::generate(*device.first, "Ring device", archive.id)); - RING_DBG("device CRT re-generated"); + JAMI_DBG("device CRT re-generated"); } return updated; @@ -1415,7 +1415,7 @@ RingAccount::migrateAccount(const std::string& pwd, dht::crypto::Identity& devic try { archive = readArchive(pwd); } catch (...) { - RING_DBG("[Account %s] Can't load archive", getAccountID().c_str()); + JAMI_DBG("[Account %s] Can't load archive", getAccountID().c_str()); Migration::setState(accountID_, Migration::State::INVALID); setRegistrationState(RegistrationState::ERROR_NEED_MIGRATION); return; @@ -1436,7 +1436,7 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string& if (registrationState_ == RegistrationState::INITIALIZING) return; - RING_DBG("[Account %s] loading account", getAccountID().c_str()); + JAMI_DBG("[Account %s] loading account", getAccountID().c_str()); try { auto id = loadIdentity(tlsCertificateFile_, tlsPrivateKeyFile_, tlsPassword_); bool hasArchive = not archivePath_.empty() @@ -1447,7 +1447,7 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string& loadContacts(); loadTrustRequests(); if (not hasArchive) - RING_WARN("[Account %s] account archive not found, won't be able to add new devices", getAccountID().c_str()); + JAMI_WARN("[Account %s] account archive not found, won't be able to add new devices", getAccountID().c_str()); if (not isEnabled()) { setRegistrationState(RegistrationState::UNREGISTERED); } @@ -1455,11 +1455,11 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string& else if (isEnabled()) { if (hasArchive) { if (needsMigration(id)) { - RING_WARN("[Account %s] account certificate needs update", getAccountID().c_str()); + JAMI_WARN("[Account %s] account certificate needs update", getAccountID().c_str()); migrateAccount(archive_password, id); } else { - RING_WARN("[Account %s] archive present but no valid receipt: creating new device", getAccountID().c_str()); + JAMI_WARN("[Account %s] archive present but no valid receipt: creating new device", getAccountID().c_str()); try { initRingDevice(readArchive(archive_password)); } @@ -1492,7 +1492,7 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string& } } catch (const std::exception& e) { - RING_WARN("[Account %s] error loading account: %s", getAccountID().c_str(), e.what()); + JAMI_WARN("[Account %s] error loading account: %s", getAccountID().c_str(), e.what()); identity_ = dht::crypto::Identity{}; setRegistrationState(RegistrationState::ERROR_GENERIC); } @@ -1541,7 +1541,7 @@ RingAccount::setAccountDetails(const std::map<std::string, std::string>& details && proxyServerCached_.empty())) proxyServer_ = DHT_DEFAULT_PROXY; if (proxyServer_ != oldProxyServer) { - RING_DBG("DHT Proxy configuration changed, resetting cache"); + JAMI_DBG("DHT Proxy configuration changed, resetting cache"); proxyServerCached_ = {}; auto proxyCachePath = cachePath_ + DIR_SEPARATOR_STR "dhtproxy"; std::remove(proxyCachePath.c_str()); @@ -1569,7 +1569,7 @@ RingAccount::getAccountDetails() const { std::lock_guard<std::mutex> lock(configurationMutex_); std::map<std::string, std::string> a = SIPAccountBase::getAccountDetails(); - a.emplace(Conf::CONFIG_DHT_PORT, ring::to_string(dhtPort_)); + a.emplace(Conf::CONFIG_DHT_PORT, jami::to_string(dhtPort_)); a.emplace(Conf::CONFIG_DHT_PUBLIC_IN_CALLS, dhtPublicInCalls_ ? TRUE_STR : FALSE_STR); a.emplace(DRing::Account::ConfProperties::RING_DEVICE_ID, ringDeviceId_); a.emplace(DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_); @@ -1684,7 +1684,7 @@ RingAccount::handlePendingCallList() try { handled = handlePendingCall(*pc_iter, incoming); } catch (const std::exception& e) { - RING_ERR("[DHT] exception during pending call handling: %s", e.what()); + JAMI_ERR("[DHT] exception during pending call handling: %s", e.what()); handled = true; // drop from pending list } @@ -1714,11 +1714,11 @@ RingAccount::checkPeerTlsCertificate(dht::InfoHash from, std::shared_ptr<dht::crypto::Certificate>& cert_out) { if (cert_num == 0) { - RING_ERR("[peer:%s] No certificate", from.toString().c_str()); + JAMI_ERR("[peer:%s] No certificate", from.toString().c_str()); return PJ_SSL_CERT_EUNKNOWN; } if (status & GNUTLS_CERT_EXPIRED or status & GNUTLS_CERT_NOT_ACTIVATED) { - RING_ERR("[peer:%s] Expired certificate", from.toString().c_str()); + JAMI_ERR("[peer:%s] Expired certificate", from.toString().c_str()); return PJ_SSL_CERT_EVALIDITY_PERIOD; } @@ -1732,26 +1732,26 @@ RingAccount::checkPeerTlsCertificate(dht::InfoHash from, // Check expected peer identity dht::InfoHash tls_account_id; if (not foundPeerDevice(crt, tls_account_id)) { - RING_ERR("[peer:%s] Discarding message from invalid peer certificate.", from.toString().c_str()); + JAMI_ERR("[peer:%s] Discarding message from invalid peer certificate.", from.toString().c_str()); return PJ_SSL_CERT_EUNKNOWN; } if (from_account != tls_account_id) { - RING_ERR("[peer:%s] Discarding message from wrong peer account %s.", from.toString().c_str(), tls_account_id.toString().c_str()); + JAMI_ERR("[peer:%s] Discarding message from wrong peer account %s.", from.toString().c_str(), tls_account_id.toString().c_str()); return PJ_SSL_CERT_EUNTRUSTED; } const auto tls_id = crt->getId(); if (crt->getUID() != tls_id.toString()) { - RING_ERR("[peer:%s] Certificate UID must be the public key ID", from.toString().c_str()); + JAMI_ERR("[peer:%s] Certificate UID must be the public key ID", from.toString().c_str()); return PJ_SSL_CERT_EUNTRUSTED; } if (tls_id != from) { - RING_ERR("[peer:%s] Certificate public key ID doesn't match (%s)", + JAMI_ERR("[peer:%s] Certificate public key ID doesn't match (%s)", from.toString().c_str(), tls_id.toString().c_str()); return PJ_SSL_CERT_EUNTRUSTED; } - RING_DBG("[peer:%s] Certificate verified", from.toString().c_str()); + JAMI_DBG("[peer:%s] Certificate verified", from.toString().c_str()); cert_out = std::move(crt); return PJ_SUCCESS; } @@ -1765,7 +1765,7 @@ RingAccount::handlePendingCall(PendingCall& pc, bool incoming) auto ice = pc.ice_sp.get(); if (not ice or ice->isFailed()) { - RING_ERR("[call:%s] Null or failed ICE transport", call->getCallId().c_str()); + JAMI_ERR("[call:%s] Null or failed ICE transport", call->getCallId().c_str()); call->onFailure(); return true; } @@ -1773,7 +1773,7 @@ RingAccount::handlePendingCall(PendingCall& pc, bool incoming) // Return to pending list if not negotiated yet and not in timeout if (not ice->isRunning()) { if ((std::chrono::steady_clock::now() - pc.start) >= ICE_NEGOTIATION_TIMEOUT) { - RING_WARN("[call:%s] Timeout on ICE negotiation", call->getCallId().c_str()); + JAMI_WARN("[call:%s] Timeout on ICE negotiation", call->getCallId().c_str()); call->onFailure(); return true; } @@ -1810,7 +1810,7 @@ RingAccount::handlePendingCall(PendingCall& pc, bool incoming) for (auto& pscall : this_.pendingSipCalls_) { if (auto pcall = pscall.call.lock()) { if (pcall == call and not pscall.from_cert) { - RING_DBG("[call:%s] got peer certificate from TLS negotiation", call->getCallId().c_str()); + JAMI_DBG("[call:%s] got peer certificate from TLS negotiation", call->getCallId().c_str()); tls::CertificateStore::instance().pinCertificate(peer_cert); pscall.from_cert = peer_cert; break; @@ -1823,7 +1823,7 @@ RingAccount::handlePendingCall(PendingCall& pc, bool incoming) } return PJ_SSL_CERT_EUNTRUSTED; } catch (const std::exception& e) { - RING_ERR("[peer:%s] TLS certificate check exception: %s", + JAMI_ERR("[peer:%s] TLS certificate check exception: %s", remote_device.toString().c_str(), e.what()); return PJ_SSL_CERT_EUNKNOWN; } @@ -1889,10 +1889,10 @@ RingAccount::mapPortUPnP() uint16_t port_used; std::lock_guard<std::mutex> lock(upnp_mtx); upnp_->removeMappings(); - added = upnp_->addAnyMapping(dhtPort_, ring::upnp::PortType::UDP, false, &port_used); + added = upnp_->addAnyMapping(dhtPort_, jami::upnp::PortType::UDP, false, &port_used); if (added) { if (port_used != dhtPort_) - RING_DBG("UPnP could not map port %u for DHT, using %u instead", dhtPort_, port_used); + JAMI_DBG("UPnP could not map port %u for DHT, using %u instead", dhtPort_, port_used); dhtPortUsed_ = port_used; } } @@ -1909,7 +1909,7 @@ RingAccount::doRegister() { std::unique_lock<std::mutex> lock(configurationMutex_); if (not isUsable()) { - RING_WARN("Account must be enabled and active to register, ignoring"); + JAMI_WARN("Account must be enabled and active to register, ignoring"); return; } @@ -1926,13 +1926,13 @@ RingAccount::doRegister() /* if UPnP is enabled, then wait for IGD to complete registration */ if (upnp_) { - RING_DBG("UPnP: waiting for IGD to register RING account"); + JAMI_DBG("UPnP: waiting for IGD to register RING account"); lock.unlock(); setRegistrationState(RegistrationState::TRYING); std::thread{ [w=weak()] { if (auto acc = w.lock()) { if (not acc->mapPortUPnP()) - RING_WARN("UPnP: Could not successfully map DHT port with UPnP, continuing with account registration anyways."); + JAMI_WARN("UPnP: Could not successfully map DHT port with UPnP, continuing with account registration anyways."); acc->doRegister_(); } }}.detach(); @@ -1969,7 +1969,7 @@ RingAccount::loadBootstrap() const } } for (const auto& ip : bootstrap) - RING_DBG("Bootstrap node: %s", ip.toString().c_str()); + JAMI_DBG("Bootstrap node: %s", ip.toString().c_str()); } return bootstrap; } @@ -1983,7 +1983,7 @@ RingAccount::trackBuddyPresence(const std::string& buddy_id, bool track) buddyUri = parseRingUri(buddy_id); } catch (...) { - RING_ERR("[Account %s] Failed to track a buddy due to an invalid URI %s", getAccountID().c_str(), buddy_id.c_str()); + JAMI_ERR("[Account %s] Failed to track a buddy due to an invalid URI %s", getAccountID().c_str(), buddy_id.c_str()); return; } auto h = dht::InfoHash(buddyUri); @@ -2030,7 +2030,7 @@ RingAccount::trackPresence(const dht::InfoHash& h, BuddyInfo& buddy) } return true; }); - // RING_DBG("[Account %s] tracking buddy %s", getAccountID().c_str(), h.to_c_str()); + // JAMI_DBG("[Account %s] tracking buddy %s", getAccountID().c_str(), h.to_c_str()); } std::map<std::string, bool> @@ -2046,7 +2046,7 @@ RingAccount::getTrackedBuddyPresence() void RingAccount::onTrackedBuddyOnline(const dht::InfoHash& contactId) { - RING_DBG("Buddy %s online", contactId.toString().c_str()); + JAMI_DBG("Buddy %s online", contactId.toString().c_str()); std::string id(contactId.toString()); emitSignal<DRing::PresenceSignal::NewBuddyNotification>(getAccountID(), id, 1, ""); messageEngine_.onPeerOnline(id); @@ -2055,7 +2055,7 @@ RingAccount::onTrackedBuddyOnline(const dht::InfoHash& contactId) void RingAccount::onTrackedBuddyOffline(const dht::InfoHash& contactId) { - RING_DBG("Buddy %s offline", contactId.toString().c_str()); + JAMI_DBG("Buddy %s offline", contactId.toString().c_str()); emitSignal<DRing::PresenceSignal::NewBuddyNotification>(getAccountID(), contactId.toString(), 0, ""); } @@ -2071,7 +2071,7 @@ RingAccount::doRegister_() loadTreatedCalls(); loadTreatedMessages(); if (dht_.isRunning()) { - RING_ERR("[Account %s] DHT already running (stopping it first).", getAccountID().c_str()); + JAMI_ERR("[Account %s] DHT already running (stopping it first).", getAccountID().c_str()); dht_.join(); } @@ -2096,22 +2096,22 @@ RingAccount::doRegister_() auto currentDhtStatus = std::make_shared<dht::NodeStatus>(dht::NodeStatus::Disconnected); dht_.setOnStatusChanged([this, currentDhtStatus](dht::NodeStatus s4, dht::NodeStatus s6) { - RING_DBG("[Account %s] Dht status : IPv4 %s; IPv6 %s", getAccountID().c_str(), dhtStatusStr(s4), dhtStatusStr(s6)); + JAMI_DBG("[Account %s] Dht status : IPv4 %s; IPv6 %s", getAccountID().c_str(), dhtStatusStr(s4), dhtStatusStr(s6)); RegistrationState state; auto newStatus = std::max(s4, s6); if (newStatus == *currentDhtStatus) return; switch (newStatus) { case dht::NodeStatus::Connecting: - RING_WARN("[Account %s] connecting to the DHT network...", getAccountID().c_str()); + JAMI_WARN("[Account %s] connecting to the DHT network...", getAccountID().c_str()); state = RegistrationState::TRYING; break; case dht::NodeStatus::Connected: - RING_WARN("[Account %s] connected to the DHT network", getAccountID().c_str()); + JAMI_WARN("[Account %s] connected to the DHT network", getAccountID().c_str()); state = RegistrationState::REGISTERED; break; case dht::NodeStatus::Disconnected: - RING_WARN("[Account %s] disconnected from the DHT network", getAccountID().c_str()); + JAMI_WARN("[Account %s] disconnected from the DHT network", getAccountID().c_str()); state = RegistrationState::UNREGISTERED; break; default: @@ -2130,10 +2130,10 @@ RingAccount::doRegister_() config.push_node_id = getAccountID(); config.threaded = true; if (not config.proxy_server.empty()) - RING_WARN("[Account %s] using proxy server %s", getAccountID().c_str(), config.proxy_server.c_str()); + JAMI_WARN("[Account %s] using proxy server %s", getAccountID().c_str(), config.proxy_server.c_str()); if (not deviceKey_.empty()) { - RING_WARN("[Account %s] using push notifications", getAccountID().c_str()); + JAMI_WARN("[Account %s] using push notifications", getAccountID().c_str()); dht_.setPushNotificationToken(deviceKey_); } @@ -2143,7 +2143,7 @@ RingAccount::doRegister_() std::vector<std::shared_ptr<dht::crypto::Certificate>> ret; if (auto cert = tls::CertificateStore::instance().getCertificate(pk_id.toString())) ret.emplace_back(std::move(cert)); - RING_DBG("Query for local certificate store: %s: %zu found.", pk_id.toString().c_str(), ret.size()); + JAMI_DBG("Query for local certificate store: %s: %zu found.", pk_id.toString().c_str(), ret.size()); return ret; }); @@ -2163,7 +2163,7 @@ RingAccount::doRegister_() char tmp[2048]; vsprintf(tmp, m, args); auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count(); - ring::emitSignal<DRing::DebugSignal::MessageSend>(std::to_string(now) + " " + std::string(tmp)); + jami::emitSignal<DRing::DebugSignal::MessageSend>(std::to_string(now) + " " + std::string(tmp)); }; dht_.setLoggers(log_all, log_all, silent); #else @@ -2189,7 +2189,7 @@ RingAccount::doRegister_() // Put device annoucement if (announce_) { auto h = dht::InfoHash(ringAccountId_); - RING_DBG("[Account %s] announcing device at %s", getAccountID().c_str(), h.toString().c_str()); + JAMI_DBG("[Account %s] announcing device at %s", getAccountID().c_str(), h.toString().c_str()); dht_.put(h, announce_, dht::DoneCallback{}, {}, true); for (const auto& crl : identity_.second->issuer->getRevocationLists()) dht_.put(h, crl, dht::DoneCallback{}, {}, true); @@ -2201,7 +2201,7 @@ RingAccount::doRegister_() }); dht_.listen<dht::crypto::RevocationList>(h, [this](dht::crypto::RevocationList&& crl) { if (crl.isSignedBy(*identity_.second->issuer)) { - RING_DBG("[Account %s] found CRL for account.", getAccountID().c_str()); + JAMI_DBG("[Account %s] found CRL for account.", getAccountID().c_str()); tls::CertificateStore::instance().pinRevocationList( ringAccountId_, std::make_shared<dht::crypto::RevocationList>(std::move(crl))); @@ -2210,12 +2210,12 @@ RingAccount::doRegister_() }); syncDevices(); } else { - RING_WARN("[Account %s] can't announce device: no annoucement...", getAccountID().c_str()); + JAMI_WARN("[Account %s] can't announce device: no annoucement...", getAccountID().c_str()); } // Listen for incoming calls callKey_ = dht::InfoHash::get("callto:"+ringDeviceId_); - RING_DBG("[Account %s] Listening on callto:%s : %s", getAccountID().c_str(), ringDeviceId_.c_str(), callKey_.toString().c_str()); + JAMI_DBG("[Account %s] Listening on callto:%s : %s", getAccountID().c_str(), ringDeviceId_.c_str(), callKey_.toString().c_str()); dht_.listen<dht::IceCandidates>( callKey_, [this] (dht::IceCandidates&& msg) { @@ -2229,7 +2229,7 @@ RingAccount::doRegister_() if (!res.second) return true; - RING_WARN("[Account %s] ICE candidate from %s.", getAccountID().c_str(), from.toString().c_str()); + JAMI_WARN("[Account %s] ICE candidate from %s.", getAccountID().c_str(), from.toString().c_str()); onPeerMessage(from, [this, msg=std::move(msg)](const std::shared_ptr<dht::crypto::Certificate>& cert, const dht::InfoHash& account) mutable @@ -2254,7 +2254,7 @@ RingAccount::doRegister_() return; } - RING_WARN("Got trust request from: %s / %s", peer_account.toString().c_str(), v.from.toString().c_str()); + JAMI_WARN("Got trust request from: %s / %s", peer_account.toString().c_str(), v.from.toString().c_str()); onTrustRequest(peer_account, v.from, time(nullptr), v.confirm, std::move(v.payload)); }); return true; @@ -2269,7 +2269,7 @@ RingAccount::doRegister_() // check device certificate findCertificate(sync.from, [this,sync](const std::shared_ptr<dht::crypto::Certificate>& cert) mutable { if (!cert or cert->getId() != sync.from) { - RING_WARN("Can't find certificate for device %s", sync.from.toString().c_str()); + JAMI_WARN("Can't find certificate for device %s", sync.from.toString().c_str()); return; } if (not foundAccountDevice(cert)) @@ -2303,7 +2303,7 @@ RingAccount::doRegister_() std::map<std::string, std::string> payloads = {{datatype, utf8_make_valid(v.msg)}}; onTextMessage(peer_account.toString(), payloads); - RING_DBG() << "Sending message confirmation " << v.id; + JAMI_DBG() << "Sending message confirmation " << v.id; dht_.putEncrypted(inboxDeviceKey, v.from, dht::ImMessage(v.id, std::string(), now)); @@ -2320,7 +2320,7 @@ RingAccount::doRegister_() } } catch (const std::exception& e) { - RING_ERR("Error registering DHT account: %s", e.what()); + JAMI_ERR("Error registering DHT account: %s", e.what()); setRegistrationState(RegistrationState::ERROR_GENERIC); } } @@ -2358,7 +2358,7 @@ RingAccount::onTrustRequest(const dht::InfoHash& peer_account, const dht::InfoHa req->second.received = received; req->second.payload = std::move(payload); } else { - RING_DBG("[Account %s] Ignoring outdated trust request from %s", getAccountID().c_str(), peer_account.toString().c_str()); + JAMI_DBG("[Account %s] Ignoring outdated trust request from %s", getAccountID().c_str(), peer_account.toString().c_str()); } } saveTrustRequests(); @@ -2377,7 +2377,7 @@ RingAccount::onPeerMessage(const dht::InfoHash& peer_device, std::function<void( // quick check in case we already explicilty banned this device auto trustStatus = trust_.getCertificateStatus(peer_device.toString()); if (trustStatus == tls::TrustStore::PermissionStatus::BANNED) { - RING_WARN("[Account %s] Discarding message from banned device %s", getAccountID().c_str(), peer_device.toString().c_str()); + JAMI_WARN("[Account %s] Discarding message from banned device %s", getAccountID().c_str(), peer_device.toString().c_str()); return; } @@ -2385,12 +2385,12 @@ RingAccount::onPeerMessage(const dht::InfoHash& peer_device, std::function<void( [this, peer_device, cb=std::move(cb)](const std::shared_ptr<dht::crypto::Certificate>& cert) { dht::InfoHash peer_account_id; if (not foundPeerDevice(cert, peer_account_id)) { - RING_WARN("[Account %s] Discarding message from invalid peer certificate %s.", getAccountID().c_str(), peer_device.toString().c_str()); + JAMI_WARN("[Account %s] Discarding message from invalid peer certificate %s.", getAccountID().c_str(), peer_device.toString().c_str()); return; } if (not trust_.isAllowed(*cert, dhtPublicInCalls_)) { - RING_WARN("[Account %s] Discarding message from unauthorized peer %s.", getAccountID().c_str(), peer_device.toString().c_str()); + JAMI_WARN("[Account %s] Discarding message from unauthorized peer %s.", getAccountID().c_str(), peer_device.toString().c_str()); return; } @@ -2413,7 +2413,7 @@ RingAccount::incomingCall(dht::IceCandidates&& msg, const std::shared_ptr<dht::c return false; if (ice->isFailed()) { - RING_ERR("[call:%s] ice init failed", call->getCallId().c_str()); + JAMI_ERR("[call:%s] ice init failed", call->getCallId().c_str()); call->onFailure(EIO); return false; } @@ -2437,14 +2437,14 @@ RingAccount::foundAccountDevice(const std::shared_ptr<dht::crypto::Certificate>& // match certificate chain if (not accountTrust_.verify(*crt)) { - RING_WARN("[Account %s] Found invalid account device: %s", getAccountID().c_str(), crt->getId().toString().c_str()); + JAMI_WARN("[Account %s] Found invalid account device: %s", getAccountID().c_str(), crt->getId().toString().c_str()); return false; } // insert device auto it = knownDevices_.emplace(crt->getId(), KnownDevice{crt, name, updated}); if (it.second) { - RING_DBG("[Account %s] Found account device: %s %s", getAccountID().c_str(), + JAMI_DBG("[Account %s] Found account device: %s %s", getAccountID().c_str(), name.c_str(), crt->getId().toString().c_str()); tls::CertificateStore::instance().pinCertificate(crt); @@ -2453,7 +2453,7 @@ RingAccount::foundAccountDevice(const std::shared_ptr<dht::crypto::Certificate>& } else { // update device name if (not name.empty() and it.first->second.name != name) { - RING_DBG("[Account %s] updating device name: %s %s", getAccountID().c_str(), + JAMI_DBG("[Account %s] updating device name: %s %s", getAccountID().c_str(), name.c_str(), crt->getId().toString().c_str()); it.first->second.name = name; @@ -2476,7 +2476,7 @@ RingAccount::foundPeerDevice(const std::shared_ptr<dht::crypto::Certificate>& cr // Device certificate can't be self-signed if (top_issuer == crt) { - RING_WARN("Found invalid peer device: %s", crt->getId().toString().c_str()); + JAMI_WARN("Found invalid peer device: %s", crt->getId().toString().c_str()); return false; } @@ -2485,12 +2485,12 @@ RingAccount::foundPeerDevice(const std::shared_ptr<dht::crypto::Certificate>& cr dht::crypto::TrustList peer_trust; peer_trust.add(*top_issuer); if (not peer_trust.verify(*crt)) { - RING_WARN("Found invalid peer device: %s", crt->getId().toString().c_str()); + JAMI_WARN("Found invalid peer device: %s", crt->getId().toString().c_str()); return false; } account_id = crt->issuer->getId(); - RING_WARN("Found peer device: %s account:%s CA:%s", crt->getId().toString().c_str(), account_id.toString().c_str(), top_issuer->getId().toString().c_str()); + JAMI_WARN("Found peer device: %s account:%s CA:%s", crt->getId().toString().c_str(), account_id.toString().c_str(), top_issuer->getId().toString().c_str()); return true; } @@ -2523,11 +2523,11 @@ RingAccount::replyToIncomingIceMsg(const std::shared_ptr<SIPCall>& call, dht::Value {dht::IceCandidates(peer_ice_msg.id, ice->packIceMsg())}, [wcall](bool ok) { if (!ok) { - RING_WARN("Can't put ICE descriptor reply on DHT"); + JAMI_WARN("Can't put ICE descriptor reply on DHT"); if (auto call = wcall.lock()) call->onFailure(); } else - RING_DBG("Successfully put ICE descriptor reply on DHT"); + JAMI_DBG("Successfully put ICE descriptor reply on DHT"); }); auto started_time = std::chrono::steady_clock::now(); @@ -2568,7 +2568,7 @@ RingAccount::doUnregister(std::function<void(bool)> released_cb) return; } - RING_WARN("[Account %s] unregistering account %p", getAccountID().c_str(), this); + JAMI_WARN("[Account %s] unregistering account %p", getAccountID().c_str(), this); { std::lock_guard<std::mutex> lock(callsMutex_); pendingCalls_.clear(); @@ -2595,7 +2595,7 @@ RingAccount::doUnregister(std::function<void(bool)> released_cb) void RingAccount::connectivityChanged() { - RING_WARN("connectivityChanged"); + JAMI_WARN("connectivityChanged"); if (not isUsable()) { // nothing to do return; @@ -2633,7 +2633,7 @@ bool RingAccount::setCertificateStatus(const std::string& cert_id, tls::TrustStore::PermissionStatus status) { if (contacts_.find(dht::InfoHash(cert_id)) != contacts_.end()) { - RING_DBG("Can't set certificate status for existing contacts %s", cert_id.c_str()); + JAMI_DBG("Can't set certificate status for existing contacts %s", cert_id.c_str()); return false; } findCertificate(cert_id); @@ -2656,7 +2656,7 @@ loadIdList(const std::string& path) std::set<ID> ids; std::ifstream file(path); if (!file.is_open()) { - RING_DBG("Could not load %s", path.c_str()); + JAMI_DBG("Could not load %s", path.c_str()); return ids; } std::string line; @@ -2675,7 +2675,7 @@ saveIdList(const std::string& path, const std::set<ID>& ids) { std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { - RING_ERR("Could not save to %s", path.c_str()); + JAMI_ERR("Could not save to %s", path.c_str()); return; } for (auto& c : ids) @@ -2738,20 +2738,20 @@ RingAccount::loadKnownDevices() msgpack::object_handle oh = msgpack::unpack((const char*)file.data(), file.size()); oh.get().convert(knownDevices); } catch (const std::exception& e) { - RING_WARN("[Account %s] error loading devices: %s", getAccountID().c_str(), e.what()); + JAMI_WARN("[Account %s] error loading devices: %s", getAccountID().c_str(), e.what()); return; } for (const auto& d : knownDevices) { - RING_DBG("[Account %s] loading known account device %s %s", getAccountID().c_str(), + JAMI_DBG("[Account %s] loading known account device %s %s", getAccountID().c_str(), d.second.first.c_str(), d.first.toString().c_str()); if (auto crt = tls::CertificateStore::instance().getCertificate(d.first.toString())) { if (not foundAccountDevice(crt, d.second.first, clock::from_time_t(d.second.second))) - RING_WARN("[Account %s] can't add device %s", getAccountID().c_str(), d.first.toString().c_str()); + JAMI_WARN("[Account %s] can't add device %s", getAccountID().c_str(), d.first.toString().c_str()); } else { - RING_WARN("[Account %s] can't find certificate for device %s", getAccountID().c_str(), d.first.toString().c_str()); + JAMI_WARN("[Account %s] can't find certificate for device %s", getAccountID().c_str(), d.first.toString().c_str()); } } } @@ -2791,7 +2791,7 @@ RingAccount::saveNodes(const std::vector<dht::NodeExport>& nodes) const std::lock_guard<std::mutex> lock(fileutils::getFileLock(nodesPath)); std::ofstream file(nodesPath, std::ios::trunc | std::ios::binary); if (!file.is_open()) { - RING_ERR("Could not save nodes to %s", nodesPath.c_str()); + JAMI_ERR("Could not save nodes to %s", nodesPath.c_str()); return; } for (auto& n : nodes) @@ -2820,7 +2820,7 @@ RingAccount::loadNodes() const std::lock_guard<std::mutex> lock(fileutils::getFileLock(nodesPath)); std::ifstream file(nodesPath); if (!file.is_open()) { - RING_DBG("Could not load nodes from %s", nodesPath.c_str()); + JAMI_DBG("Could not load nodes from %s", nodesPath.c_str()); return nodes; } std::string line; @@ -2850,11 +2850,11 @@ RingAccount::loadValues() const std::istreambuf_iterator<char> begin(ifs), end; values.emplace_back(dht::ValuesExport{dht::InfoHash(fname), std::vector<uint8_t>{begin, end}}); } catch (const std::exception& e) { - RING_ERR("[Account %s] error reading value from cache : %s", getAccountID().c_str(), e.what()); + JAMI_ERR("[Account %s] error reading value from cache : %s", getAccountID().c_str(), e.what()); } fileutils::remove(file); } - RING_DBG("[Account %s] loaded %zu values", getAccountID().c_str(), values.size()); + JAMI_DBG("[Account %s] loaded %zu values", getAccountID().c_str(), values.size()); return values; } @@ -2867,20 +2867,20 @@ RingAccount::loadDhParams(const std::string path) if (duration >= std::chrono::hours(24 * 3)) // file is valid only 3 days throw std::runtime_error("file too old"); - RING_DBG("Loading DhParams from file '%s'", path.c_str()); + JAMI_DBG("Loading DhParams from file '%s'", path.c_str()); return {fileutils::loadFile(path)}; } catch (const std::exception& e) { - RING_DBG("Failed to load DhParams file '%s': %s", path.c_str(), e.what()); + JAMI_DBG("Failed to load DhParams file '%s': %s", path.c_str(), e.what()); if (auto params = tls::DhParams::generate()) { try { fileutils::saveFile(path, params.serialize(), 0600); - RING_DBG("Saved DhParams to file '%s'", path.c_str()); + JAMI_DBG("Saved DhParams to file '%s'", path.c_str()); } catch (const std::exception& ex) { - RING_WARN("Failed to save DhParams in file '%s': %s", path.c_str(), ex.what()); + JAMI_WARN("Failed to save DhParams in file '%s': %s", path.c_str(), ex.what()); } return params; } - RING_ERR("Can't generate DH params."); + JAMI_ERR("Can't generate DH params."); return {}; } } @@ -2902,7 +2902,7 @@ RingAccount::getDhtProxyServer() proxys.emplace_back(match[1].str() + match[2].str() + ":" + std::to_string(p)); } catch (...) { - RING_WARN("Malformed proxy, ignore it"); + JAMI_WARN("Malformed proxy, ignore it"); continue; } } else { @@ -2919,11 +2919,11 @@ RingAccount::getDhtProxyServer() fileutils::check_dir(cachePath_.c_str(), 0700); std::string proxyCachePath = cachePath_ + DIR_SEPARATOR_STR "dhtproxy"; std::ofstream file(proxyCachePath); - RING_DBG("Cache DHT proxy server: %s", proxyServerCached_.c_str()); + JAMI_DBG("Cache DHT proxy server: %s", proxyServerCached_.c_str()); if (file.is_open()) file << proxyServerCached_; else - RING_WARN("Cannot write into %s", proxyCachePath.c_str()); + JAMI_WARN("Cannot write into %s", proxyCachePath.c_str()); return proxyServerCached_; } return proxyServerCached_; @@ -2941,7 +2941,7 @@ MatchRank RingAccount::matches(const std::string &userName, const std::string &server) const { if (userName == ringAccountId_ || server == ringAccountId_ || userName == ringDeviceId_) { - RING_DBG("Matching account id in request with username %s", userName.c_str()); + JAMI_DBG("Matching account id in request with username %s", userName.c_str()); return MatchRank::FULL; } else { return MatchRank::NONE; @@ -2978,7 +2978,7 @@ RingAccount::getContactHeader(pjsip_transport* t) (address.empty() ? "" : "@"), address.c_str()); } else { - RING_ERR("getContactHeader: no SIP transport provided"); + JAMI_ERR("getContactHeader: no SIP transport provided"); contact_.slen = pj_ansi_snprintf(contact_.ptr, PJSIP_MAX_URL_SIZE, "%s<sips:%s@ring.dht>", quotedDisplayName.c_str(), @@ -2994,7 +2994,7 @@ RingAccount::addContact(const std::string& uri, bool confirmed) { dht::InfoHash h (uri); if (not h) { - RING_ERR("[Account %s] addContact: invalid contact URI", getAccountID().c_str()); + JAMI_ERR("[Account %s] addContact: invalid contact URI", getAccountID().c_str()); return; } addContact(h, confirmed); @@ -3003,7 +3003,7 @@ RingAccount::addContact(const std::string& uri, bool confirmed) void RingAccount::addContact(const dht::InfoHash& h, bool confirmed) { - RING_WARN("[Account %s] addContact: %s", getAccountID().c_str(), h.to_c_str()); + JAMI_WARN("[Account %s] addContact: %s", getAccountID().c_str(), h.to_c_str()); auto c = contacts_.find(h); if (c == contacts_.end()) c = contacts_.emplace(h, Contact{}).first; @@ -3021,7 +3021,7 @@ RingAccount::addContact(const dht::InfoHash& h, bool confirmed) void RingAccount::removeContact(const std::string& uri, bool ban) { - RING_WARN("[Account %s] removeContact: %s", getAccountID().c_str(), uri.c_str()); + JAMI_WARN("[Account %s] removeContact: %s", getAccountID().c_str(), uri.c_str()); dht::InfoHash h (uri); auto c = contacts_.find(h); if (c == contacts_.end()) @@ -3046,7 +3046,7 @@ RingAccount::getContactDetails(const std::string& uri) const const auto c = contacts_.find(h); if (c == std::end(contacts_)) { - RING_WARN("[dht] contact '%s' not found", uri.c_str()); + JAMI_WARN("[dht] contact '%s' not found", uri.c_str()); return {}; } @@ -3077,17 +3077,17 @@ void RingAccount::updateContact(const dht::InfoHash& id, const Contact& contact) { if (not id) { - RING_ERR("[Account %s] updateContact: invalid contact ID", getAccountID().c_str()); + JAMI_ERR("[Account %s] updateContact: invalid contact ID", getAccountID().c_str()); return; } bool stateChanged {false}; auto c = contacts_.find(id); if (c == contacts_.end()) { - RING_DBG("[Account %s] new contact: %s", getAccountID().c_str(), id.toString().c_str()); + JAMI_DBG("[Account %s] new contact: %s", getAccountID().c_str(), id.toString().c_str()); c = contacts_.emplace(id, contact).first; stateChanged = c->second.isActive() or c->second.isBanned(); } else { - RING_DBG("[Account %s] updated contact: %s", getAccountID().c_str(), id.toString().c_str()); + JAMI_DBG("[Account %s] updated contact: %s", getAccountID().c_str(), id.toString().c_str()); stateChanged = c->second.update(contact); } if (stateChanged) { @@ -3113,7 +3113,7 @@ RingAccount::loadContacts() msgpack::object_handle oh = msgpack::unpack((const char*)file.data(), file.size()); oh.get().convert(contacts); } catch (const std::exception& e) { - RING_WARN("[Account %s] error loading contacts: %s", getAccountID().c_str(), e.what()); + JAMI_WARN("[Account %s] error loading contacts: %s", getAccountID().c_str(), e.what()); return; } @@ -3186,13 +3186,13 @@ RingAccount::sendTrustRequest(const std::string& to, const std::vector<uint8_t>& { auto toH = dht::InfoHash(to); if (not toH) { - RING_ERR("[Account %s] can't send trust request to invalid hash: %s", getAccountID().c_str(), to.c_str()); + JAMI_ERR("[Account %s] can't send trust request to invalid hash: %s", getAccountID().c_str(), to.c_str()); return; } addContact(toH); forEachDevice(toH, [toH,payload](const std::shared_ptr<RingAccount>& shared, const dht::InfoHash& dev) { - RING_WARN("[Account %s] sending trust request to: %s / %s", shared->getAccountID().c_str(), toH.toString().c_str(), dev.toString().c_str()); + JAMI_WARN("[Account %s] sending trust request to: %s / %s", shared->getAccountID().c_str(), toH.toString().c_str(), dev.toString().c_str()); shared->dht_.putEncrypted(dht::InfoHash::get("inbox:"+dev.toString()), dev, dht::TrustRequest(DHT_TYPE_NS, payload)); @@ -3206,7 +3206,7 @@ RingAccount::sendTrustRequestConfirm(const dht::InfoHash& to) answer.confirm = true; forEachDevice(to, [to,answer](const std::shared_ptr<RingAccount>& shared, const dht::InfoHash& dev) { - RING_WARN("[Account %s] sending trust request reply: %s / %s", shared->getAccountID().c_str(), to.toString().c_str(), dev.toString().c_str()); + JAMI_WARN("[Account %s] sending trust request reply: %s / %s", shared->getAccountID().c_str(), to.toString().c_str(), dev.toString().c_str()); shared->dht_.putEncrypted(dht::InfoHash::get("inbox:"+dev.toString()), dev, answer); }); } @@ -3229,7 +3229,7 @@ RingAccount::loadTrustRequests() msgpack::object_handle oh = msgpack::unpack((const char*)file.data(), file.size()); oh.get().convert(requests); } catch (const std::exception& e) { - RING_WARN("[Account %s] error loading trust requests: %s", getAccountID().c_str(), e.what()); + JAMI_WARN("[Account %s] error loading trust requests: %s", getAccountID().c_str(), e.what()); return; } @@ -3242,7 +3242,7 @@ RingAccount::loadTrustRequests() void RingAccount::syncDevices() { - RING_DBG("[Account %s] building device sync from %s %s", getAccountID().c_str(), ringDeviceName_.c_str(), ringDeviceId_.c_str()); + JAMI_DBG("[Account %s] building device sync from %s %s", getAccountID().c_str(), ringDeviceName_.c_str(), ringDeviceId_.c_str()); DeviceSync sync_data; sync_data.date = clock::now().time_since_epoch().count(); sync_data.device_name = ringDeviceName_; @@ -3273,7 +3273,7 @@ RingAccount::syncDevices() // don't send sync data to ourself if (dev.first.toString() == ringDeviceId_) continue; - RING_DBG("[Account %s] sending device sync to %s %s", getAccountID().c_str(), dev.second.name.c_str(), dev.first.toString().c_str()); + JAMI_DBG("[Account %s] sending device sync to %s %s", getAccountID().c_str(), dev.second.name.c_str(), dev.first.toString().c_str()); auto syncDeviceKey = dht::InfoHash::get("inbox:"+dev.first.toString()); dht_.putEncrypted(syncDeviceKey, dev.first, sync_data); } @@ -3284,17 +3284,17 @@ RingAccount::onReceiveDeviceSync(DeviceSync&& sync) { auto it = knownDevices_.find(sync.from); if (it == knownDevices_.end()) { - RING_WARN("[Account %s] dropping sync data from unknown device", getAccountID().c_str()); + JAMI_WARN("[Account %s] dropping sync data from unknown device", getAccountID().c_str()); return; } auto sync_date = clock::time_point(clock::duration(sync.date)); if (it->second.last_sync >= sync_date) { - RING_DBG("[Account %s] dropping outdated sync data", getAccountID().c_str()); + JAMI_DBG("[Account %s] dropping outdated sync data", getAccountID().c_str()); return; } // Sync known devices - RING_DBG("[Account %s] received device sync data (%lu devices, %lu contacts)", getAccountID().c_str(), sync.devices_known.size(), sync.peers.size()); + JAMI_DBG("[Account %s] received device sync data (%lu devices, %lu contacts)", getAccountID().c_str(), sync.devices_known.size(), sync.peers.size()); for (const auto& d : sync.devices_known) { findCertificate(d.first, [this,d](const std::shared_ptr<dht::crypto::Certificate>& crt) { if (not crt) @@ -3327,10 +3327,10 @@ RingAccount::igdChanged() auto& this_ = *shared.get(); auto oldPort = static_cast<in_port_t>(this_.dhtPortUsed_); if (not this_.mapPortUPnP()) - RING_WARN("UPnP: Could not map DHT port"); + JAMI_WARN("UPnP: Could not map DHT port"); auto newPort = static_cast<in_port_t>(this_.dhtPortUsed_); if (oldPort != newPort) { - RING_WARN("DHT port changed: restarting network"); + JAMI_WARN("DHT port changed: restarting network"); this_.doRegister_(); } else this_.dht_.connectivityChanged(); @@ -3357,7 +3357,7 @@ RingAccount::forEachDevice(const dht::InfoHash& to, op(shared, dev.dev); return true; }, [=, end=std::move(end)](bool /*ok*/){ - RING_DBG("[Account %s] found %lu devices for %s", + JAMI_DBG("[Account %s] found %lu devices for %s", getAccountID().c_str(), treatedDevices->size(), to.to_c_str()); if (end) end(shared, not treatedDevices->empty()); }); @@ -3370,11 +3370,11 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, try { toUri = parseRingUri(to); } catch (...) { - RING_ERR("Failed to send a text message due to an invalid URI %s", to.c_str()); + JAMI_ERR("Failed to send a text message due to an invalid URI %s", to.c_str()); return 0; } if (payloads.size() != 1) { - RING_ERR("Multi-part im is not supported yet by RingAccount"); + JAMI_ERR("Multi-part im is not supported yet by RingAccount"); return 0; } return SIPAccountBase::sendTextMessage(toUri, payloads); @@ -3387,14 +3387,14 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, try { toUri = parseRingUri(to); } catch (...) { - RING_ERR("Failed to send a text message due to an invalid URI %s", to.c_str()); + JAMI_ERR("Failed to send a text message due to an invalid URI %s", to.c_str()); messageEngine_.onMessageSent(to, token, false); return; } if (payloads.size() != 1) { // Multi-part message // TODO: not supported yet - RING_ERR("Multi-part im is not supported yet by RingAccount"); + JAMI_ERR("Multi-part im is not supported yet by RingAccount"); messageEngine_.onMessageSent(toUri, token, false); return; } @@ -3430,11 +3430,11 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, std::lock_guard<std::mutex> lock(this_.messageMutex_); auto e = this_.sentMessages_.find(msg.id); if (e == this_.sentMessages_.end() or e->second.to != msg.from) { - RING_DBG() << "[Account " << this_.getAccountID() << "] [message " << token << "] Message not found"; + JAMI_DBG() << "[Account " << this_.getAccountID() << "] [message " << token << "] Message not found"; return true; } this_.sentMessages_.erase(e); - RING_DBG() << "[Account " << this_.getAccountID() << "] [message " << token << "] Received text message reply"; + JAMI_DBG() << "[Account " << this_.getAccountID() << "] [message " << token << "] Received text message reply"; // add treated message auto res = this_.treatedMessages_.insert(msg.id); @@ -3457,7 +3457,7 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, dht::ImMessage(token, std::string(payloads.begin()->first), std::string(payloads.begin()->second), now), [w,to,token,confirm,h](bool ok) { if (auto this_ = w.lock()) { - RING_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Put encrypted " << (ok ? "ok" : "failed"); + JAMI_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Put encrypted " << (ok ? "ok" : "failed"); if (not ok) { auto lt = confirm->listenTokens.find(h); if (lt != confirm->listenTokens.end()) { @@ -3470,7 +3470,7 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, } }); - RING_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Sending message for device " << dev.toString(); + JAMI_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Sending message for device " << dev.toString(); }, [to, token](const std::shared_ptr<RingAccount>& shared, bool ok) { if (not ok) { shared->messageEngine_.onMessageSent(to, token, false); @@ -3481,7 +3481,7 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string, Manager::instance().scheduleTask([w=weak(), confirm, to, token]() { if (not confirm->replied) { if (auto this_ = w.lock()) { - RING_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Timeout"; + JAMI_DBG() << "[Account " << this_->getAccountID() << "] [message " << token << "] Timeout"; for (auto& t : confirm->listenTokens) this_->dht_.cancelListen(t.first, t.second.get()); confirm->listenTokens.clear(); @@ -3496,7 +3496,7 @@ void RingAccount::registerDhtAddress(IceTransport& ice) { const auto reg_addr = [&](IceTransport& ice, const IpAddr& ip) { - RING_DBG("[Account %s] using public IP: %s", getAccountID().c_str(), ip.toString().c_str()); + JAMI_DBG("[Account %s] using public IP: %s", getAccountID().c_str(), ip.toString().c_str()); for (unsigned compId = 1; compId <= ice.getComponentCount(); ++compId) ice.registerPublicIP(compId, ip); return ip; @@ -3550,13 +3550,13 @@ RingAccount::closePeerConnection(const std::string& peer, const DRing::DataTrans void RingAccount::enableProxyClient(bool enable) { - RING_WARN("[Account %s] DHT proxy client: %s", getAccountID().c_str(), enable ? "enable" : "disable"); + JAMI_WARN("[Account %s] DHT proxy client: %s", getAccountID().c_str(), enable ? "enable" : "disable"); dht_.enableProxy(enable); } void RingAccount::setPushNotificationToken(const std::string& token) { - RING_WARN("[Account %s] setPushNotificationToken: %s", getAccountID().c_str(), token.c_str()); + JAMI_WARN("[Account %s] setPushNotificationToken: %s", getAccountID().c_str(), token.c_str()); deviceKey_ = token; dht_.setPushNotificationToken(deviceKey_); } @@ -3566,7 +3566,7 @@ void RingAccount::setPushNotificationToken(const std::string& token) */ void RingAccount::pushNotificationReceived(const std::string& from, const std::map<std::string, std::string>& data) { - RING_WARN("[Account %s] pushNotificationReceived: %s", getAccountID().c_str(), from.c_str()); + JAMI_WARN("[Account %s] pushNotificationReceived: %s", getAccountID().c_str(), from.c_str()); dht_.pushNotificationReceived(data); } @@ -3604,4 +3604,4 @@ RingAccount::checkPendingCallsTask() } } -} // namespace ring +} // namespace jami diff --git a/src/ringdht/ringaccount.h b/src/ringdht/ringaccount.h index f73e4ad24b..24ff1ccd49 100644 --- a/src/ringdht/ringaccount.h +++ b/src/ringdht/ringaccount.h @@ -70,7 +70,7 @@ namespace dev using Address = h160; } -namespace ring { +namespace jami { class IceTransport; struct Contact; @@ -688,4 +688,4 @@ static inline std::ostream& operator<< (std::ostream& os, const RingAccount& acc return os; } -} // namespace ring +} // namespace jami diff --git a/src/ringdht/ringcontact.h b/src/ringdht/ringcontact.h index afde3f1d56..2ed9a3a08a 100644 --- a/src/ringdht/ringcontact.h +++ b/src/ringdht/ringcontact.h @@ -27,7 +27,7 @@ #include <ctime> #include <ciso646> -namespace ring { +namespace jami { struct Contact { diff --git a/src/ringdht/sips_transport_ice.cpp b/src/ringdht/sips_transport_ice.cpp index 12361a3420..963d193c97 100644 --- a/src/ringdht/sips_transport_ice.cpp +++ b/src/ringdht/sips_transport_ice.cpp @@ -43,7 +43,7 @@ #include <system_error> #include <cstring> // std::memset -namespace ring { namespace tls { +namespace jami { namespace tls { static constexpr int POOL_TP_INIT {512}; static constexpr int POOL_TP_INC {512}; @@ -138,7 +138,7 @@ tls_status_from_err(int err) SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, int tp_type, const TlsParams& param, - const std::shared_ptr<ring::IceTransport>& ice, + const std::shared_ptr<jami::IceTransport>& ice, int comp_id) : ice_ (ice) , comp_id_ (comp_id) @@ -147,7 +147,7 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, , pool_ {nullptr, pj_pool_release} , rxPool_ (nullptr, pj_pool_release) { - RING_DBG("SipIceTransport@%p {tr=%p}", this, &trData_.base); + JAMI_DBG("SipIceTransport@%p {tr=%p}", this, &trData_.base); if (not ice or not ice->isRunning()) throw std::logic_error("ICE transport must exist and negotiation completed"); @@ -203,7 +203,7 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, }; base.do_shutdown = [](pjsip_transport *transport) -> pj_status_t { auto& this_ = reinterpret_cast<TransportData*>(transport)->self; - RING_DBG("SipsIceTransport@%p {tr=%p {rc=%ld}}: shutdown", this_, + JAMI_DBG("SipsIceTransport@%p {tr=%p {rc=%ld}}: shutdown", this_, transport, pj_atomic_get(transport->ref_cnt)); // Nothing to do here, tls session is not shutdown as some messages could be pending // and application can continue to do IO (if they already own the transport) @@ -211,7 +211,7 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, }; base.destroy = [](pjsip_transport *transport) -> pj_status_t { auto& this_ = reinterpret_cast<TransportData*>(transport)->self; - RING_DBG("SipsIceTransport@%p: destroying", this_); + JAMI_DBG("SipsIceTransport@%p: destroying", this_); delete this_; return PJ_SUCCESS; }; @@ -253,7 +253,7 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, SipsIceTransport::~SipsIceTransport() { - RING_DBG("~SipIceTransport@%p {tr=%p}", this, &trData_.base); + JAMI_DBG("~SipIceTransport@%p {tr=%p}", this, &trData_.base); // Flush send queue with ENOTCONN error for (auto tdata : txQueue_) { @@ -274,7 +274,7 @@ SipsIceTransport::~SipsIceTransport() pj_lock_destroy(base->lock); pj_atomic_destroy(base->ref_cnt); - RING_DBG("~SipIceTransport@%p {tr=%p} bye", this, &trData_.base); + JAMI_DBG("~SipIceTransport@%p {tr=%p} bye", this, &trData_.base); } void @@ -302,7 +302,7 @@ SipsIceTransport::handleEvents() if (evdata.state != PJSIP_TP_STATE_DISCONNECTED) { (*state_cb)(&trData_.base, evdata.state, &evdata.state_info); } else { - RING_WARN("[SIPS] got disconnected event!"); + JAMI_WARN("[SIPS] got disconnected event!"); disconnectedEvent = std::move(evdata); disconnected = true; break; @@ -330,7 +330,7 @@ SipsIceTransport::handleEvents() if (ec) { status = tls_status_from_err(ec.value()); if (gnutls_error_is_fatal(ec.value())) { - RING_ERR("[TLS] fatal error during sending: %s", gnutls_strerror(ec.value())); + JAMI_ERR("[TLS] fatal error during sending: %s", gnutls_strerror(ec.value())); tls_->shutdown(); fatal = true; } @@ -382,7 +382,7 @@ SipsIceTransport::handleEvents() // Time to deliver disconnected event if exists if (disconnected and state_cb) { - RING_WARN("[SIPS] process disconnect event"); + JAMI_WARN("[SIPS] process disconnect event"); (*state_cb)(&trData_.base, disconnectedEvent.state, &disconnectedEvent.state_info); } } @@ -509,9 +509,9 @@ SipsIceTransport::getInfo(pj_ssl_sock_info* info, bool established) std::array<uint8_t, 2> cs_id; if (auto cipher_name = tls_->currentCipherSuiteId(cs_id)) { info->cipher = static_cast<pj_ssl_cipher>((cs_id[0] << 8) | cs_id[1]); - RING_DBG("[TLS] using cipher %s (0x%02X%02X)", cipher_name, cs_id[0], cs_id[1]); + JAMI_DBG("[TLS] using cipher %s (0x%02X%02X)", cipher_name, cs_id[0], cs_id[1]); } else - RING_ERR("[TLS] Can't find info on used cipher"); + JAMI_ERR("[TLS] Can't find info on used cipher"); info->local_cert_info = &localCertInfo_; info->remote_cert_info = &remoteCertInfo_; @@ -685,7 +685,7 @@ SipsIceTransport::send(pjsip_tx_data* tdata, const pj_sockaddr_t* rem_addr, // Shutdown on fatal error, else ignore it if (ec and gnutls_error_is_fatal(ec.value())) { - RING_ERR("[TLS] fatal error during sending: %s", gnutls_strerror(ec.value())); + JAMI_ERR("[TLS] fatal error during sending: %s", gnutls_strerror(ec.value())); tls_->shutdown(); return tls_status_from_err(ec.value()); } @@ -708,4 +708,4 @@ SipsIceTransport::getTlsSessionMtu() return tls_->maxPayload(); } -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/ringdht/sips_transport_ice.h b/src/ringdht/sips_transport_ice.h index 59c53fda0a..8af70f6969 100644 --- a/src/ringdht/sips_transport_ice.h +++ b/src/ringdht/sips_transport_ice.h @@ -42,12 +42,12 @@ #include <utility> #include <vector> -namespace ring { +namespace jami { class IceTransport; class IceSocketTransport; -} // namespace ring +} // namespace jami -namespace ring { namespace tls { +namespace jami { namespace tls { /** * SipsIceTransport @@ -140,4 +140,4 @@ private: int verifyCertificate(gnutls_session_t); }; -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/rw_mutex.h b/src/rw_mutex.h index cbe81b851d..5c895138e9 100644 --- a/src/rw_mutex.h +++ b/src/rw_mutex.h @@ -29,7 +29,7 @@ #include <string> #include <sstream> -namespace ring { +namespace jami { /** * rw_mutex is a shared mutex meant to protect @@ -110,6 +110,6 @@ class rw_mutex { bool writing; }; -} // namespace ring +} // namespace jami #endif diff --git a/src/scheduled_executor.cpp b/src/scheduled_executor.cpp index c8e32576e8..bc18bb0c6d 100644 --- a/src/scheduled_executor.cpp +++ b/src/scheduled_executor.cpp @@ -20,7 +20,7 @@ #include "scheduled_executor.h" #include "logger.h" -namespace ring { +namespace jami { ScheduledExecutor::ScheduledExecutor() : thread_([this]{ while (running_.load()) @@ -121,7 +121,7 @@ ScheduledExecutor::loop() try { job(); } catch (const std::exception& e) { - RING_ERR("Exception running job: %s", e.what()); + JAMI_ERR("Exception running job: %s", e.what()); } } } diff --git a/src/scheduled_executor.h b/src/scheduled_executor.h index 1326318929..81eaedaf22 100644 --- a/src/scheduled_executor.h +++ b/src/scheduled_executor.h @@ -32,7 +32,7 @@ #include "noncopyable.h" -namespace ring { +namespace jami { /** * A runnable function diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp index c83cf3449c..26340197a3 100644 --- a/src/security/certstore.cpp +++ b/src/security/certstore.cpp @@ -29,7 +29,7 @@ #include <thread> #include <sstream> -namespace ring { namespace tls { +namespace jami { namespace tls { CertificateStore& CertificateStore::instance() @@ -72,7 +72,7 @@ CertificateStore::loadLocalCertificates() remove((certPath_+DIR_SEPARATOR_CH+f).c_str()); } } - RING_DBG("CertificateStore: loaded %u local certificates.", n); + JAMI_DBG("CertificateStore: loaded %u local certificates.", n); return n; } @@ -85,7 +85,7 @@ CertificateStore::loadRevocations(crypto::Certificate& crt) try { crt.addRevocationList(std::make_shared<crypto::RevocationList>(fileutils::loadFile(dir+DIR_SEPARATOR_CH+crl))); } catch (const std::exception& e) { - RING_WARN("Can't load revocation list: %s", e.what()); + JAMI_WARN("Can't load revocation list: %s", e.what()); } } } @@ -162,7 +162,7 @@ CertificateStore::findIssuer(const std::shared_ptr<crypto::Certificate>& crt) co unsigned verify_out = 0; int err = gnutls_x509_crt_verify(crt->cert, &ret->cert, 1, 0, &verify_out); if (err != GNUTLS_E_SUCCESS) { - RING_WARN("gnutls_x509_crt_verify failed: %s", gnutls_strerror(err)); + JAMI_WARN("gnutls_x509_crt_verify failed: %s", gnutls_strerror(err)); return {}; } if (verify_out & GNUTLS_CERT_INVALID) @@ -216,7 +216,7 @@ CertificateStore::pinCertificatePath(const std::string& path, std::function<void } paths_.emplace(path, std::move(scerts)); } - RING_DBG("CertificateStore: loaded %zu certificates from %s.", + JAMI_DBG("CertificateStore: loaded %zu certificates from %s.", certs.size(), path.c_str()); if (cb) cb(ids); @@ -341,7 +341,7 @@ CertificateStore::pinRevocationList(const std::string& id, const std::shared_ptr c->addRevocationList(crl); pinRevocationList(id, *crl); } catch (...) { - RING_WARN("Can't add revocation list"); + JAMI_WARN("Can't add revocation list"); } } @@ -513,7 +513,7 @@ TrustStore::isAllowed(const crypto::Certificate& crt, bool allowPublic) auto ret = allowed_.verify(crt); // Unknown issuer (only that) are accepted if allowPublic is true if (not ret and !(allowPublic and ret.result == (GNUTLS_CERT_INVALID|GNUTLS_CERT_SIGNER_NOT_FOUND))) { - RING_WARN("%s", ret.toString().c_str()); + JAMI_WARN("%s", ret.toString().c_str()); return false; } @@ -551,4 +551,4 @@ TrustStore::rebuildTrust() setStoreCertStatus(*c.second.first, c.second.second.allowed); } -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/certstore.h b/src/security/certstore.h index 75d50f1ab7..81aaa6891b 100644 --- a/src/security/certstore.h +++ b/src/security/certstore.h @@ -34,7 +34,7 @@ namespace crypto = ::dht::crypto; -namespace ring { namespace tls { +namespace jami { namespace tls { enum class TrustStatus { UNTRUSTED = 0, @@ -163,4 +163,4 @@ private: dht::crypto::TrustList allowed_; }; -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/diffie-hellman.cpp b/src/security/diffie-hellman.cpp index 9130e74c49..c36cd1885d 100644 --- a/src/security/diffie-hellman.cpp +++ b/src/security/diffie-hellman.cpp @@ -24,7 +24,7 @@ #include <chrono> #include <ciso646> -namespace ring { namespace tls { +namespace jami { namespace tls { DhParams::DhParams(const std::vector<uint8_t>& data) { @@ -62,7 +62,7 @@ std::vector<uint8_t> DhParams::serialize() const { if (!params_) { - RING_WARN("serialize() called on an empty DhParams"); + JAMI_WARN("serialize() called on an empty DhParams"); return {}; } gnutls_datum_t out; @@ -79,26 +79,26 @@ DhParams::generate() using clock = std::chrono::high_resolution_clock; auto bits = gnutls_sec_param_to_pk_bits(GNUTLS_PK_DH, /* GNUTLS_SEC_PARAM_HIGH */ GNUTLS_SEC_PARAM_HIGH); - RING_DBG("Generating DH params with %u bits", bits); + JAMI_DBG("Generating DH params with %u bits", bits); auto start = clock::now(); gnutls_dh_params_t new_params_; int ret = gnutls_dh_params_init(&new_params_); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("Error initializing DH params: %s", gnutls_strerror(ret)); + JAMI_ERR("Error initializing DH params: %s", gnutls_strerror(ret)); return {}; } DhParams params {new_params_}; ret = gnutls_dh_params_generate2(params.get(), bits); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("Error generating DH params: %s", gnutls_strerror(ret)); + JAMI_ERR("Error generating DH params: %s", gnutls_strerror(ret)); return {}; } std::chrono::duration<double> time_span = clock::now() - start; - RING_DBG("Generated DH params with %u bits in %lfs", bits, time_span.count()); + JAMI_DBG("Generated DH params with %u bits in %lfs", bits, time_span.count()); return params; } -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/diffie-hellman.h b/src/security/diffie-hellman.h index 2a2ead7267..4e004d5e12 100644 --- a/src/security/diffie-hellman.h +++ b/src/security/diffie-hellman.h @@ -26,7 +26,7 @@ #include <memory> #include <cstdint> -namespace ring { namespace tls { +namespace jami { namespace tls { class DhParams { public: @@ -68,4 +68,4 @@ private: std::unique_ptr<gnutls_dh_params_int, decltype(gnutls_dh_params_deinit)*> params_ {nullptr, gnutls_dh_params_deinit}; }; -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/memory.cpp b/src/security/memory.cpp index 50edcb6dd1..1a0b0cf121 100644 --- a/src/security/memory.cpp +++ b/src/security/memory.cpp @@ -27,7 +27,7 @@ #include <algorithm> -namespace ring { namespace secure { +namespace jami { namespace secure { void memzero(void* ptr, std::size_t length) @@ -45,5 +45,5 @@ memzero(void* ptr, std::size_t length) extern "C" void ring_secure_memzero(void* ptr, size_t length) { - ring::secure::memzero(ptr, length); + jami::secure::memzero(ptr, length); } diff --git a/src/security/memory.h b/src/security/memory.h index de28074dc8..1ffe7e96a9 100644 --- a/src/security/memory.h +++ b/src/security/memory.h @@ -36,7 +36,7 @@ void ring_secure_memzero(void* ptr, size_t length); #ifdef __cplusplus }; } -namespace ring { namespace secure { +namespace jami { namespace secure { /// Erase with \a size '0' the given memory starting at \a ptr pointer. void memzero(void* ptr, std::size_t length); diff --git a/src/security/tls_session.cpp b/src/security/tls_session.cpp index cd84f27b4d..a0a99d3e85 100644 --- a/src/security/tls_session.cpp +++ b/src/security/tls_session.cpp @@ -51,7 +51,7 @@ #include <cstdlib> #include <unistd.h> -namespace ring { namespace tls { +namespace jami { namespace tls { static constexpr const char* DTLS_CERT_PRIORITY_STRING {"SECURE192:-VERS-TLS-ALL:+VERS-DTLS-ALL:-RSA:%SERVER_PRECEDENCE:%SAFE_RENEGOTIATION"}; static constexpr const char* DTLS_FULL_PRIORITY_STRING {"SECURE192:-KX-ALL:+ANON-ECDH:+ANON-DH:+SECURE192:-VERS-TLS-ALL:+VERS-DTLS-ALL:-RSA:%SERVER_PRECEDENCE:%SAFE_RENEGOTIATION"}; @@ -100,7 +100,7 @@ public: TlsCertificateCredendials() { int ret = gnutls_certificate_allocate_credentials(&creds_); if (ret < 0) { - RING_ERR("gnutls_certificate_allocate_credentials() failed with ret=%d", ret); + JAMI_ERR("gnutls_certificate_allocate_credentials() failed with ret=%d", ret); throw std::bad_alloc(); } } @@ -123,7 +123,7 @@ public: TlsAnonymousClientCredendials() { int ret = gnutls_anon_allocate_client_credentials(&creds_); if (ret < 0) { - RING_ERR("gnutls_anon_allocate_client_credentials() failed with ret=%d", ret); + JAMI_ERR("gnutls_anon_allocate_client_credentials() failed with ret=%d", ret); throw std::bad_alloc(); } } @@ -146,7 +146,7 @@ public: TlsAnonymousServerCredendials() { int ret = gnutls_anon_allocate_server_credentials(&creds_); if (ret < 0) { - RING_ERR("gnutls_anon_allocate_server_credentials() failed with ret=%d", ret); + JAMI_ERR("gnutls_anon_allocate_server_credentials() failed with ret=%d", ret); throw std::bad_alloc(); } } @@ -314,7 +314,7 @@ TlsSession::TlsSessionImpl::typeName() const void TlsSession::TlsSessionImpl::dump_io_stats() const { - RING_DBG("[TLS] RxRawPkt=%zu (%zu bytes) - TxRawPkt=%zu (%zu bytes)", + JAMI_DBG("[TLS] RxRawPkt=%zu (%zu bytes) - TxRawPkt=%zu (%zu bytes)", stRxRawPacketCnt_.load(), stRxRawBytesCnt_.load(), stTxRawPacketCnt_.load(), stTxRawBytesCnt_.load()); } @@ -327,14 +327,14 @@ TlsSession::TlsSessionImpl::setupClient() if (not transport_.isReliable()) { ret = gnutls_init(&session_, GNUTLS_CLIENT | GNUTLS_DATAGRAM); // uncoment to reactivate PMTUD - // RING_DBG("[TLS] set heartbeat reception for retrocompatibility check on server"); + // JAMI_DBG("[TLS] set heartbeat reception for retrocompatibility check on server"); // gnutls_heartbeat_enable(session_,GNUTLS_HB_PEER_ALLOWED_TO_SEND); } else { ret = gnutls_init(&session_, GNUTLS_CLIENT); } if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] session init failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] session init failed: %s", gnutls_strerror(ret)); return TlsSessionState::SHUTDOWN; } @@ -354,7 +354,7 @@ TlsSession::TlsSessionImpl::setupServer() ret = gnutls_init(&session_, GNUTLS_SERVER | GNUTLS_DATAGRAM); // uncoment to reactivate PMTUD - // RING_DBG("[TLS] set heartbeat reception"); + // JAMI_DBG("[TLS] set heartbeat reception"); // gnutls_heartbeat_enable(session_, GNUTLS_HB_PEER_ALLOWED_TO_SEND); gnutls_dtls_prestate_set(session_, &prestate_); @@ -363,7 +363,7 @@ TlsSession::TlsSessionImpl::setupServer() } if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] session init failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] session init failed: %s", gnutls_strerror(ret)); return TlsSessionState::SHUTDOWN; } @@ -389,7 +389,7 @@ TlsSession::TlsSessionImpl::initAnonymous() if (const auto& dh_params = params_.dh_params.get().get()) gnutls_anon_set_server_dh_params(*sacred_, dh_params); else - RING_WARN("[TLS] DH params unavailable"); // YOMGUI: need to stop? + JAMI_WARN("[TLS] DH params unavailable"); // YOMGUI: need to stop? } } @@ -421,14 +421,14 @@ TlsSession::TlsSessionImpl::initCredentials() throw std::runtime_error("can't load CA " + params_.ca_list + ": " + std::string(gnutls_strerror(ret))); - RING_DBG("[TLS] CA list %s loadev", params_.ca_list.c_str()); + JAMI_DBG("[TLS] CA list %s loadev", params_.ca_list.c_str()); } if (params_.peer_ca) { auto chain = params_.peer_ca->getChainWithRevocations(); auto ret = gnutls_certificate_set_x509_trust(*xcred_, chain.first.data(), chain.first.size()); if (not chain.second.empty()) gnutls_certificate_set_x509_crl(*xcred_, chain.second.data(), chain.second.size()); - RING_DBG("[TLS] Peer CA list %lu (%lu CRLs): %d", chain.first.size(), chain.second.size(), ret); + JAMI_DBG("[TLS] Peer CA list %lu (%lu CRLs): %d", chain.first.size(), chain.second.size(), ret); } // Load user-given identity (key and passwd) @@ -446,7 +446,7 @@ TlsSession::TlsSessionImpl::initCredentials() throw std::runtime_error("can't load certificate: " + std::string(gnutls_strerror(ret))); - RING_DBG("[TLS] User identity loaded"); + JAMI_DBG("[TLS] User identity loaded"); } // Setup DH-params (server only, may block on dh_params.get()) @@ -454,7 +454,7 @@ TlsSession::TlsSessionImpl::initCredentials() if (const auto& dh_params = params_.dh_params.get().get()) gnutls_certificate_set_dh_params(*xcred_, dh_params); else - RING_WARN("[TLS] DH params unavailable"); // YOMGUI: need to stop? + JAMI_WARN("[TLS] DH params unavailable"); // YOMGUI: need to stop? } } @@ -469,7 +469,7 @@ TlsSession::TlsSessionImpl::commonSessionInit() transport_.isReliable() ? TLS_FULL_PRIORITY_STRING : DTLS_FULL_PRIORITY_STRING, nullptr); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] TLS priority set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] TLS priority set failed: %s", gnutls_strerror(ret)); return false; } @@ -480,7 +480,7 @@ TlsSession::TlsSessionImpl::commonSessionInit() ret = gnutls_credentials_set(session_, GNUTLS_CRD_ANON, *cacred_); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] anonymous credential set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] anonymous credential set failed: %s", gnutls_strerror(ret)); return false; } } else { @@ -489,7 +489,7 @@ TlsSession::TlsSessionImpl::commonSessionInit() transport_.isReliable() ? TLS_CERT_PRIORITY_STRING : DTLS_CERT_PRIORITY_STRING, nullptr); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] TLS priority set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] TLS priority set failed: %s", gnutls_strerror(ret)); return false; } } @@ -497,7 +497,7 @@ TlsSession::TlsSessionImpl::commonSessionInit() // Add certificate credentials ret = gnutls_credentials_set(session_, GNUTLS_CRD_CERTIFICATE, *xcred_); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] certificate credential set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] certificate credential set failed: %s", gnutls_strerror(ret)); return false; } gnutls_certificate_send_x509_rdn_sequence(session_, 0); @@ -564,7 +564,7 @@ TlsSession::TlsSessionImpl::send(const ValueType* tx_data, std::size_t tx_size, * state has not changed, so we have to ask for more data first. * We will just try again later, although this should never happen. */ - RING_ERR() << "[TLS] send failed (only " << total_written << " bytes sent): " + JAMI_ERR() << "[TLS] send failed (only " << total_written << " bytes sent): " << gnutls_strerror(nwritten); ec = std::error_code(nwritten, std::system_category()); return 0; @@ -594,10 +594,10 @@ TlsSession::TlsSessionImpl::sendRaw(const void* buf, size_t size) } if (ec.value() == EAGAIN) { - RING_WARN() << "[TLS] EAGAIN from transport, retry#" << ++retry_count; + JAMI_WARN() << "[TLS] EAGAIN from transport, retry#" << ++retry_count; std::this_thread::sleep_for(std::chrono::milliseconds(10)); if (retry_count == 100) { - RING_ERR() << "[TLS] excessive retry detected, aborting"; + JAMI_ERR() << "[TLS] excessive retry detected, aborting"; ec.assign(EIO, std::system_category()); } } @@ -605,7 +605,7 @@ TlsSession::TlsSessionImpl::sendRaw(const void* buf, size_t size) // Must be called to pass errno value to GnuTLS on Windows (cf. GnuTLS doc) gnutls_transport_set_errno(session_, ec.value()); - RING_ERR() << "[TLS] transport failure on tx: errno = " << ec.value(); + JAMI_ERR() << "[TLS] transport failure on tx: errno = " << ec.value(); return -1; } @@ -681,7 +681,7 @@ TlsSession::TlsSessionImpl::waitForRawData(unsigned timeout) return -1; } if (rxQueue_.empty()) { - RING_ERR("[TLS] waitForRawData: timeout after %u ms", timeout); + JAMI_ERR("[TLS] waitForRawData: timeout after %u ms", timeout); return 0; } return 1; @@ -692,14 +692,14 @@ TlsSession::TlsSessionImpl::initFromRecordState(int offset) { std::array<uint8_t, 8> seq; if (gnutls_record_get_state(session_, 1, nullptr, nullptr, nullptr, &seq[0]) != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] Fatal-error Unable to read initial state"); + JAMI_ERR("[TLS] Fatal-error Unable to read initial state"); return false; } baseSeq_ = array2uint(seq) + offset; gapOffset_ = baseSeq_; lastRxSeq_ = baseSeq_ - 1; - RING_DBG("[TLS] Initial sequence number: %lx", baseSeq_); + JAMI_DBG("[TLS] Initial sequence number: %lx", baseSeq_); return true; } @@ -739,14 +739,14 @@ TlsSession::TlsSessionImpl::cleanup() TlsSessionState TlsSession::TlsSessionImpl::handleStateSetup(UNUSED TlsSessionState state) { - RING_DBG("[TLS] Start %s session", typeName()); + JAMI_DBG("[TLS] Start %s session", typeName()); try { if (anonymous_) initAnonymous(); initCredentials(); } catch (const std::exception& e) { - RING_ERR("[TLS] authentifications init failed: %s", e.what()); + JAMI_ERR("[TLS] authentifications init failed: %s", e.what()); return TlsSessionState::SHUTDOWN; } @@ -764,7 +764,7 @@ TlsSession::TlsSessionImpl::handleStateSetup(UNUSED TlsSessionState state) TlsSessionState TlsSession::TlsSessionImpl::handleStateCookie(TlsSessionState state) { - RING_DBG("[TLS] SYN cookie"); + JAMI_DBG("[TLS] SYN cookie"); std::size_t count; { @@ -773,7 +773,7 @@ TlsSession::TlsSessionImpl::handleStateCookie(TlsSessionState state) if (!rxCv_.wait_for(lk, COOKIE_TIMEOUT, [this]{ return !rxQueue_.empty() or state_ == TlsSessionState::SHUTDOWN; })) { - RING_ERR("[TLS] SYN cookie failed: timeout"); + JAMI_ERR("[TLS] SYN cookie failed: timeout"); return TlsSessionState::SHUTDOWN; } // Shutdown state? @@ -815,7 +815,7 @@ TlsSession::TlsSessionImpl::handleStateCookie(TlsSessionState state) // So we retry until we get a valid cookie. // To protect against a flood attack we delay each retry after FLOOD_THRESHOLD rx bytes. if (cookie_count_ >= FLOOD_THRESHOLD) { - RING_WARN("[TLS] flood threshold reach (retry in %zds)", + JAMI_WARN("[TLS] flood threshold reach (retry in %zds)", std::chrono::duration_cast<std::chrono::seconds>(FLOOD_PAUSE).count()); dump_io_stats(); std::this_thread::sleep_for(FLOOD_PAUSE); // flood attack protection @@ -823,7 +823,7 @@ TlsSession::TlsSessionImpl::handleStateCookie(TlsSessionState state) return state; } - RING_DBG("[TLS] cookie ok"); + JAMI_DBG("[TLS] cookie ok"); return setupServer(); } @@ -834,7 +834,7 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) int ret; size_t retry_count = 0; do { - RING_DBG("[TLS] handshake"); + JAMI_DBG("[TLS] handshake"); ret = gnutls_handshake(session_); } while ((ret == GNUTLS_E_INTERRUPTED or ret == GNUTLS_E_AGAIN ) and @@ -842,7 +842,7 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) // Stop on fatal error if (gnutls_error_is_fatal(ret)) { - RING_ERR("[TLS] handshake failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] handshake failed: %s", gnutls_strerror(ret)); return TlsSessionState::SHUTDOWN; } @@ -850,7 +850,7 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) if (ret != GNUTLS_E_SUCCESS) { // TODO: handle GNUTLS_E_LARGE_PACKET (MTU must be lowered) if (ret != GNUTLS_E_AGAIN) - RING_DBG("[TLS] non-fatal handshake error: %s", gnutls_strerror(ret)); + JAMI_DBG("[TLS] non-fatal handshake error: %s", gnutls_strerror(ret)); return state; } @@ -863,7 +863,7 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) if (!isTLS1_3 || (isTLS1_3 && isServer_)) { #endif if (!gnutls_safe_renegotiation_status(session_)) { - RING_ERR("[TLS] server identity changed! MiM attack?"); + JAMI_ERR("[TLS] server identity changed! MiM attack?"); return TlsSessionState::SHUTDOWN; } #if GNUTLS_VERSION_NUMBER >= 0x030605 @@ -871,20 +871,20 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) #endif auto desc = gnutls_session_get_desc(session_); - RING_DBG("[TLS] session established: %s", desc); + JAMI_DBG("[TLS] session established: %s", desc); gnutls_free(desc); // Anonymous connection? rehandshake immediately with certificate authentification forced auto cred = gnutls_auth_get_type(session_); if (cred == GNUTLS_CRD_ANON) { - RING_DBG("[TLS] renogotiate with certificate authentification"); + JAMI_DBG("[TLS] renogotiate with certificate authentification"); // Re-setup TLS algorithms priority list with only certificate based cipher suites ret = gnutls_priority_set_direct(session_, transport_.isReliable() ? TLS_CERT_PRIORITY_STRING : DTLS_CERT_PRIORITY_STRING, nullptr); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] session TLS cert-only priority set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] session TLS cert-only priority set failed: %s", gnutls_strerror(ret)); return TlsSessionState::SHUTDOWN; } @@ -892,14 +892,14 @@ TlsSession::TlsSessionImpl::handleStateHandshake(TlsSessionState state) gnutls_credentials_clear(session_); ret = gnutls_credentials_set(session_, GNUTLS_CRD_CERTIFICATE, *xcred_); if (ret != GNUTLS_E_SUCCESS) { - RING_ERR("[TLS] session credential set failed: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] session credential set failed: %s", gnutls_strerror(ret)); return TlsSessionState::SHUTDOWN; } return state; // handshake } else if (cred != GNUTLS_CRD_CERTIFICATE) { - RING_ERR("[TLS] spurious session credential (%u)", cred); + JAMI_ERR("[TLS] spurious session credential (%u)", cred); return TlsSessionState::SHUTDOWN; } @@ -926,13 +926,13 @@ TlsSession::TlsSessionImpl::handleStateMtuDiscovery(UNUSED TlsSessionState state if (!isServer_) { pathMtuHeartbeat(); if (state_ == TlsSessionState::SHUTDOWN) { - RING_ERR("[TLS] session destroyed while performing PMTUD, shuting down"); + JAMI_ERR("[TLS] session destroyed while performing PMTUD, shuting down"); return TlsSessionState::SHUTDOWN; } pmtudOver_ = true; } } else { - RING_ERR() << "[TLS] PEER HEARTBEAT DISABLED: using transport MTU value " << mtuProbe_; + JAMI_ERR() << "[TLS] PEER HEARTBEAT DISABLED: using transport MTU value " << mtuProbe_; pmtudOver_ = true; } @@ -940,7 +940,7 @@ TlsSession::TlsSessionImpl::handleStateMtuDiscovery(UNUSED TlsSessionState state maxPayload_ = gnutls_dtls_get_data_mtu(session_); if (pmtudOver_) { - RING_DBG() << "[TLS] maxPayload: " << maxPayload_.load(); + JAMI_DBG() << "[TLS] maxPayload: " << maxPayload_.load(); if (!initFromRecordState()) return TlsSessionState::SHUTDOWN; } @@ -960,7 +960,7 @@ TlsSession::TlsSessionImpl::handleStateMtuDiscovery(UNUSED TlsSessionState state void TlsSession::TlsSessionImpl::pathMtuHeartbeat() { - RING_DBG() << "[TLS] PMTUD: starting probing with " << HEARTBEAT_RETRANS_TIMEOUT.count() + JAMI_DBG() << "[TLS] PMTUD: starting probing with " << HEARTBEAT_RETRANS_TIMEOUT.count() << "ms of retransmission timeout"; gnutls_heartbeat_set_timeouts(session_, @@ -975,7 +975,7 @@ TlsSession::TlsSessionImpl::pathMtuHeartbeat() // Hence we have to signal to the TLS session to reduce the MTU on client size accordingly. if (transport_.localAddr().isIpv4() and transport_.remoteAddr().isIpv6()) { mtuOffset = ASYMETRIC_TRANSPORT_MTU_OFFSET; - RING_WARN() << "[TLS] local/remote IP protocol version not alike, use an MTU offset of " + JAMI_WARN() << "[TLS] local/remote IP protocol version not alike, use an MTU offset of " << ASYMETRIC_TRANSPORT_MTU_OFFSET << " bytes to compensate"; } @@ -984,7 +984,7 @@ TlsSession::TlsSessionImpl::pathMtuHeartbeat() for (auto mtu: MTUS_) { gnutls_dtls_set_mtu(session_, mtu); auto data_mtu = gnutls_dtls_get_data_mtu(session_); - RING_DBG() << "[TLS] PMTUD: mtu " << mtu + JAMI_DBG() << "[TLS] PMTUD: mtu " << mtu << ", payload " << data_mtu; auto bytesToSend = data_mtu - mtuOffset - 3; // want to know why -3? ask gnutls! @@ -993,27 +993,27 @@ TlsSession::TlsSessionImpl::pathMtuHeartbeat() } while (errno_send == GNUTLS_E_AGAIN || (errno_send == GNUTLS_E_INTERRUPTED && state_ != TlsSessionState::SHUTDOWN)); if (errno_send != GNUTLS_E_SUCCESS) { - RING_DBG() << "[TLS] PMTUD: mtu " << mtu << " [FAILED]"; + JAMI_DBG() << "[TLS] PMTUD: mtu " << mtu << " [FAILED]"; break; } mtuProbe_ = mtu; - RING_DBG() << "[TLS] PMTUD: mtu " << mtu << " [OK]"; + JAMI_DBG() << "[TLS] PMTUD: mtu " << mtu << " [OK]"; } if (errno_send == GNUTLS_E_TIMEDOUT) { // timeout is considered as a packet loss, then the good mtu is the precedent if (mtuProbe_ == MTUS_[0]) { - RING_WARN() << "[TLS] PMTUD: no response on first ping, using minimal MTU value " + JAMI_WARN() << "[TLS] PMTUD: no response on first ping, using minimal MTU value " << mtuProbe_; } else { - RING_WARN() << "[TLS] PMTUD: timed out, using last working mtu " + JAMI_WARN() << "[TLS] PMTUD: timed out, using last working mtu " << mtuProbe_; } } else if (errno_send != GNUTLS_E_SUCCESS) { - RING_ERR() << "[TLS] PMTUD: failed with gnutls error '" + JAMI_ERR() << "[TLS] PMTUD: failed with gnutls error '" << gnutls_strerror(errno_send) << '\''; } else { - RING_DBG() << "[TLS] PMTUD: reached maximal value"; + JAMI_DBG() << "[TLS] PMTUD: reached maximal value"; } } @@ -1027,14 +1027,14 @@ TlsSession::TlsSessionImpl::handleDataPacket(std::vector<ValueType>&& buf, uint6 } else { // too old? if (seq_delta <= -MISS_ORDERING_LIMIT) { - RING_WARN("[TLS] drop old pkt: 0x%lx", pkt_seq); + JAMI_WARN("[TLS] drop old pkt: 0x%lx", pkt_seq); return; } // No duplicate check as DTLS prevents that for us (replay protection) // accept Out-Of-Order pkt - will be reordered by queue flush operation - RING_WARN("[TLS] OOO pkt: 0x%lx", pkt_seq); + JAMI_WARN("[TLS] OOO pkt: 0x%lx", pkt_seq); } { @@ -1085,9 +1085,9 @@ TlsSession::TlsSessionImpl::flushRxQueue() if ((now - lastReadTime_) >= RX_OOO_TIMEOUT) { // OOO packet timeout - consider waited packets as lost if (auto lost = next_offset - gapOffset_) - RING_WARN("[TLS] %lu lost since 0x%lx", lost, gapOffset_); + JAMI_WARN("[TLS] %lu lost since 0x%lx", lost, gapOffset_); else - RING_WARN("[TLS] slow flush"); + JAMI_WARN("[TLS] slow flush"); } else if (next_offset != gapOffset_) return; @@ -1144,7 +1144,7 @@ TlsSession::TlsSessionImpl::handleStateEstablished(TlsSessionState state) gnutls_dtls_set_mtu(session_, mtuProbe_); maxPayload_ = gnutls_dtls_get_data_mtu(session_); pmtudOver_ = true; - RING_DBG() << "[TLS] maxPayload: " << maxPayload_.load(); + JAMI_DBG() << "[TLS] maxPayload: " << maxPayload_.load(); if (!initFromRecordState(-1)) return TlsSessionState::SHUTDOWN; @@ -1154,24 +1154,24 @@ TlsSession::TlsSessionImpl::handleStateEstablished(TlsSessionState state) handleDataPacket(std::move(rawPktBuf_), array2uint(seq)); // no state change } else if (ret == GNUTLS_E_HEARTBEAT_PING_RECEIVED) { - RING_DBG("[TLS] PMTUD: ping received sending pong"); + JAMI_DBG("[TLS] PMTUD: ping received sending pong"); auto errno_send = gnutls_heartbeat_pong(session_, 0); if (errno_send != GNUTLS_E_SUCCESS){ - RING_ERR("[TLS] PMTUD: failed on pong with error %d: %s", errno_send, + JAMI_ERR("[TLS] PMTUD: failed on pong with error %d: %s", errno_send, gnutls_strerror(errno_send)); } else { ++hbPingRecved_; } // no state change } else if (ret == 0) { - RING_DBG("[TLS] eof"); + JAMI_DBG("[TLS] eof"); state = TlsSessionState::SHUTDOWN; } else if (ret == GNUTLS_E_REHANDSHAKE) { - RING_DBG("[TLS] re-handshake"); + JAMI_DBG("[TLS] re-handshake"); state = TlsSessionState::HANDSHAKE; } else if (gnutls_error_is_fatal(ret)) { - RING_ERR("[TLS] fatal error in recv: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] fatal error in recv: %s", gnutls_strerror(ret)); state = TlsSessionState::SHUTDOWN; } // else non-fatal error... let's continue @@ -1181,7 +1181,7 @@ TlsSession::TlsSessionImpl::handleStateEstablished(TlsSessionState state) TlsSessionState TlsSession::TlsSessionImpl::handleStateShutdown(TlsSessionState state) { - RING_DBG("[TLS] shutdown"); + JAMI_DBG("[TLS] shutdown"); // Stop ourself thread_.stop(); @@ -1257,7 +1257,7 @@ TlsSession::currentCipherSuiteId(std::array<uint8_t, 2>& cs_id) const } auto name = gnutls_cipher_get_name(s_cipher); - RING_WARN("[TLS] No Cipher Suite Id found for cipher %s", name ? name : "<null>"); + JAMI_WARN("[TLS] No Cipher Suite Id found for cipher %s", name ? name : "<null>"); return {}; } @@ -1300,17 +1300,17 @@ TlsSession::read(ValueType* data, std::size_t size, std::error_code& ec) } if (ret == 0) { - RING_DBG("[TLS] eof"); + JAMI_DBG("[TLS] eof"); shutdown(); error = std::errc::broken_pipe; break; } else if (ret == GNUTLS_E_REHANDSHAKE) { - RING_DBG("[TLS] re-handshake"); + JAMI_DBG("[TLS] re-handshake"); pimpl_->state_ = TlsSessionState::HANDSHAKE; pimpl_->rxCv_.notify_one(); // unblock waiting FSM pimpl_->stateCondition_.notify_all(); } else if (gnutls_error_is_fatal(ret)) { - RING_ERR("[TLS] fatal error in recv: %s", gnutls_strerror(ret)); + JAMI_ERR("[TLS] fatal error in recv: %s", gnutls_strerror(ret)); shutdown(); error = std::errc::io_error; break; @@ -1346,4 +1346,4 @@ TlsSession::waitForData(unsigned ms_timeout, std::error_code& ec) const return 1; } -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/tls_session.h b/src/security/tls_session.h index baa4ca2b51..1f09dfa604 100644 --- a/src/security/tls_session.h +++ b/src/security/tls_session.h @@ -39,7 +39,7 @@ struct Certificate; struct PrivateKey; }} // namespace dht::crypto -namespace ring { namespace tls { +namespace jami { namespace tls { class DhParams; @@ -145,4 +145,4 @@ private: std::unique_ptr<TlsSessionImpl> pimpl_; }; -}} // namespace ring::tls +}} // namespace jami::tls diff --git a/src/security/tlsvalidator.cpp b/src/security/tlsvalidator.cpp index e63b095bc7..52740785e7 100644 --- a/src/security/tlsvalidator.cpp +++ b/src/security/tlsvalidator.cpp @@ -66,7 +66,7 @@ #include "windirent.h" #endif -namespace ring { namespace tls { +namespace jami { namespace tls { //Map the internal ring Enum class of the exported names @@ -252,11 +252,11 @@ TlsValidator::TlsValidator(const std::string& certificate, } catch (const dht::crypto::DecryptError& d) { // If we encounter a DecryptError, it means the private key exists and is encrypted, // otherwise we would get some other exception. - RING_WARN("decryption error: %s", d.what()); + JAMI_WARN("decryption error: %s", d.what()); privateKeyFound_ = true; privateKeyPassword_ = true; } catch (const std::exception& e) { - RING_WARN("creation failed: %s", e.what()); + JAMI_WARN("creation failed: %s", e.what()); } } @@ -328,7 +328,7 @@ bool TlsValidator::isValid(bool verbose) if (enforcedCheckType[check] == CheckValuesType::BOOLEAN) { if (((this->*(checkCallback[check]))()).first == CheckValues::FAILED) { if (verbose) - RING_WARN("Check failed: %s", CertificateCheckNames[check]); + JAMI_WARN("Check failed: %s", CertificateCheckNames[check]); return false; } } @@ -454,7 +454,7 @@ unsigned int TlsValidator::compareToCa() auto root_cas = CertificateStore::instance().getTrustedCertificates(); auto err = gnutls_x509_trust_list_add_cas(trust, root_cas.data(), root_cas.size(), 0); if (err) - RING_WARN("gnutls_x509_trust_list_add_cas failed: %s", gnutls_strerror(err)); + JAMI_WARN("gnutls_x509_trust_list_add_cas failed: %s", gnutls_strerror(err)); if (not caListPath_.empty()) { if (fileutils::isDirectory(caListPath_)) @@ -475,7 +475,7 @@ unsigned int TlsValidator::compareToCa() gnutls_x509_trust_list_deinit(trust, true); if (err) { - RING_WARN("gnutls_x509_trust_list_verify_crt2 failed: %s", gnutls_strerror(err)); + JAMI_WARN("gnutls_x509_trust_list_verify_crt2 failed: %s", gnutls_strerror(err)); return GNUTLS_CERT_SIGNER_NOT_FOUND; } @@ -512,14 +512,14 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 struct timeval tv; if (!host.size() || !port) { - RING_ERR("Wrong parameters used - host %s, port %d.", host.c_str(), port); + JAMI_ERR("Wrong parameters used - host %s, port %d.", host.c_str(), port); return res; } /* Create the socket. */ sockfd = socket (PF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - RING_ERR("Could not create socket."); + JAMI_ERR("Could not create socket."); return res; } /* Set non-blocking so we can dected timeouts. */ @@ -536,7 +536,7 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 name.sin_port = htons(port); hostinfo = gethostbyname(host.c_str()); if (hostinfo == nullptr) { - RING_ERR("Unknown host %s.", host.c_str()); + JAMI_ERR("Unknown host %s.", host.c_str()); goto out; } name.sin_addr = *(struct in_addr *)hostinfo->h_addr; @@ -552,7 +552,7 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 tv.tv_usec = 0; err = select(sockfd + 1, nullptr, &fdset, nullptr, &tv); if (err < 0 && errno != EINTR) { - RING_ERR("Could not connect to hostname %s at port %d", + JAMI_ERR("Could not connect to hostname %s at port %d", host.c_str(), port); goto out; } else if (err > 0) { @@ -562,17 +562,17 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &so_error, &len); if (so_error) { - RING_ERR("Connection delayed."); + JAMI_ERR("Connection delayed."); goto out; } break; // exit do-while loop } else { - RING_ERR("Connection timeout."); + JAMI_ERR("Connection timeout."); goto out; } } while(1); } else { - RING_ERR("Could not connect to hostname %s at port %d", host.c_str(), port); + JAMI_ERR("Could not connect to hostname %s at port %d", host.c_str(), port); goto out; } } @@ -587,7 +587,7 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 /* Disable Nagle algorithm that slows down the SSL handshake. */ err = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); if (err < 0) { - RING_ERR("Could not set TCP_NODELAY."); + JAMI_ERR("Could not set TCP_NODELAY."); goto out; } @@ -595,33 +595,33 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 /* Load the trusted CA certificates. */ err = gnutls_certificate_allocate_credentials(&cred); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not allocate credentials - %s", gnutls_strerror(err)); + JAMI_ERR("Could not allocate credentials - %s", gnutls_strerror(err)); goto out; } err = gnutls_certificate_set_x509_system_trust(cred); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not load credentials."); + JAMI_ERR("Could not load credentials."); goto out; } /* Create the session object. */ err = gnutls_init(&session, GNUTLS_CLIENT); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not init session -%s\n", gnutls_strerror(err)); + JAMI_ERR("Could not init session -%s\n", gnutls_strerror(err)); goto out; } /* Configure the cipher preferences. The default set should be good enough. */ err = gnutls_priority_set_direct(session, "NORMAL", &errptr); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not set up ciphers - %s (%s)", gnutls_strerror(err), errptr); + JAMI_ERR("Could not set up ciphers - %s (%s)", gnutls_strerror(err), errptr); goto out; } /* Install the trusted certificates. */ err = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not set up credentials - %s", gnutls_strerror(err)); + JAMI_ERR("Could not set up credentials - %s", gnutls_strerror(err)); goto out; } @@ -629,28 +629,28 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) (uintptr_t) sockfd); err = gnutls_server_name_set(session, GNUTLS_NAME_DNS, host.c_str(), host.size()); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not set server name - %s", gnutls_strerror(err)); + JAMI_ERR("Could not set server name - %s", gnutls_strerror(err)); goto out; } /* Establish the connection. */ err = gnutls_handshake(session); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Handshake failed - %s", gnutls_strerror(err)); + JAMI_ERR("Handshake failed - %s", gnutls_strerror(err)); goto out; } /* Obtain the server certificate chain. The server certificate * itself is stored in the first element of the array. */ certs = gnutls_certificate_get_peers(session, &certslen); if (certs == nullptr || certslen == 0) { - RING_ERR("Could not obtain peer certificate - %s", gnutls_strerror(err)); + JAMI_ERR("Could not obtain peer certificate - %s", gnutls_strerror(err)); goto out; } /* Validate the certificate chain. */ err = gnutls_certificate_verify_peers2(session, &status); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not verify the certificate chain - %s", gnutls_strerror(err)); + JAMI_ERR("Could not verify the certificate chain - %s", gnutls_strerror(err)); goto out; } if (status != 0) { @@ -662,11 +662,11 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 err = -1; #endif if (err == 0) { - RING_ERR("Certificate validation failed - %s\n", msg.data); + JAMI_ERR("Certificate validation failed - %s\n", msg.data); gnutls_free(msg.data); goto out; } else { - RING_ERR("Certificate validation failed with code 0x%x.", status); + JAMI_ERR("Certificate validation failed with code 0x%x.", status); goto out; } } @@ -678,7 +678,7 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 err = gnutls_x509_crt_init(&cert); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not init certificate - %s", gnutls_strerror(err)); + JAMI_ERR("Could not init certificate - %s", gnutls_strerror(err)); goto out; } @@ -687,13 +687,13 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 if (err != GNUTLS_E_SUCCESS) err = gnutls_x509_crt_import(cert, certs, GNUTLS_X509_FMT_DER); if (err != GNUTLS_E_SUCCESS) { - RING_ERR("Could not read peer certificate - %s", gnutls_strerror(err)); + JAMI_ERR("Could not read peer certificate - %s", gnutls_strerror(err)); goto out; } /* Finally check if the hostnames match. */ err = gnutls_x509_crt_check_hostname(cert, host.c_str()); if (err == 0) { - RING_ERR("Hostname %s does not match certificate.", host.c_str()); + JAMI_ERR("Hostname %s does not match certificate.", host.c_str()); goto out; } @@ -701,16 +701,16 @@ int TlsValidator::verifyHostnameCertificate(const std::string& host, const uint1 snprintf(buf, sizeof(buf), "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", host.c_str()); err = gnutls_record_send(session, buf, strlen(buf)); if (err < 0) { - RING_ERR("Send failed - %s", gnutls_strerror(err)); + JAMI_ERR("Send failed - %s", gnutls_strerror(err)); goto out; } err = gnutls_record_recv(session, buf, sizeof(buf)); if (err < 0) { - RING_ERR("Recv failed - %s", gnutls_strerror(err)); + JAMI_ERR("Recv failed - %s", gnutls_strerror(err)); goto out; } - RING_DBG("Hostname %s seems to point to a valid server.", host.c_str()); + JAMI_DBG("Hostname %s seems to point to a valid server.", host.c_str()); res = 0; out: if (session) { @@ -740,7 +740,7 @@ TlsValidator::CheckResult TlsValidator::hasPrivateKey() return CheckResult(CheckValues::FAILED, e.what()); } - RING_DBG("Key from %s seems valid.", certificatePath_.c_str()); + JAMI_DBG("Key from %s seems valid.", certificatePath_.c_str()); return CheckResult(CheckValues::PASSED, ""); } @@ -1248,4 +1248,4 @@ TlsValidator::CheckResult TlsValidator::isCA() } -}} //namespace ring +}} //namespace jami diff --git a/src/security/tlsvalidator.h b/src/security/tlsvalidator.h index fa32e29110..5ba50a59dc 100644 --- a/src/security/tlsvalidator.h +++ b/src/security/tlsvalidator.h @@ -35,7 +35,7 @@ namespace dht { namespace crypto { struct Certificate; }} // namespace dht::crypto -namespace ring { namespace tls { +namespace jami { namespace tls { #if !defined (S_IRWXG) #define S_IRWXG 00070 @@ -313,6 +313,6 @@ public: }; // TlsValidator -}} // namespace ring::tls +}} // namespace jami::tls #endif diff --git a/src/sip/pres_sub_client.cpp b/src/sip/pres_sub_client.cpp index 682f93b0db..34b0bdf31a 100644 --- a/src/sip/pres_sub_client.cpp +++ b/src/sip/pres_sub_client.cpp @@ -46,7 +46,7 @@ #define PRES_TIMER 300 // 5min -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -56,7 +56,7 @@ void PresSubClient::pres_client_timer_cb(pj_timer_heap_t * /*th*/, pj_timer_entry *entry) { PresSubClient *c = (PresSubClient *) entry->user_data; - RING_DBG("timeout for %s", c->getURI().c_str()); + JAMI_DBG("timeout for %s", c->getURI().c_str()); } /* Callback called when *client* subscription state has changed. */ @@ -69,11 +69,11 @@ PresSubClient::pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event) /* No need to pres->lock() here since the client has a locked dialog*/ if (!pres_client) { - RING_WARN("pres_client not found"); + JAMI_WARN("pres_client not found"); return; } - RING_DBG("Subscription for pres_client '%s' is '%s'", pres_client->getURI().c_str(), + JAMI_DBG("Subscription for pres_client '%s' is '%s'", pres_client->getURI().c_str(), pjsip_evsub_get_state_name(sub) ? pjsip_evsub_get_state_name(sub) : "null"); pjsip_evsub_state state = pjsip_evsub_get_state(sub); @@ -248,7 +248,7 @@ PresSubClient::pres_client_evsub_on_tsx_state(pjsip_evsub *sub, pjsip_transactio /* No need to pres->lock() here since the client has a locked dialog*/ if (!pres_client) { - RING_WARN("Couldn't find pres_client."); + JAMI_WARN("Couldn't find pres_client."); return; } @@ -291,7 +291,7 @@ PresSubClient::pres_client_evsub_on_rx_notify(pjsip_evsub *sub, pjsip_rx_data *r PresSubClient *pres_client = (PresSubClient *) pjsip_evsub_get_mod_data(sub, modId_); if (!pres_client) { - RING_WARN("Couldn't find pres_client from ev_sub."); + JAMI_WARN("Couldn't find pres_client from ev_sub."); return; } /* No need to pres->lock() here since the client has a locked dialog*/ @@ -336,7 +336,7 @@ PresSubClient::PresSubClient(const std::string& uri, SIPPresence *pres) : PresSubClient::~PresSubClient() { - RING_DBG("Destroying pres_client object with uri %.*s", (int)uri_.slen, uri_.ptr); + JAMI_DBG("Destroying pres_client object with uri %.*s", (int)uri_.slen, uri_.ptr); rescheduleTimer(PJ_FALSE, 0); unsubscribe(); pj_pool_release(pool_); @@ -384,7 +384,7 @@ void PresSubClient::rescheduleTimer(bool reschedule, unsigned msec) if (reschedule) { pj_time_val delay; - RING_WARN("pres_client %.*s will resubscribe in %u ms (reason: %.*s)", + JAMI_WARN("pres_client %.*s will resubscribe in %u ms (reason: %.*s)", (int)uri_.slen, uri_.ptr, msec, (int)term_reason_.slen, term_reason_.ptr); pj_timer_entry_init(&timer_, 0, this, &pres_client_timer_cb); delay.sec = 0; @@ -399,7 +399,7 @@ void PresSubClient::rescheduleTimer(bool reschedule, unsigned msec) void PresSubClient::enable(bool flag) { - RING_DBG("pres_client %s is %s monitored.",getURI().c_str(), flag? "":"NOT"); + JAMI_DBG("pres_client %s is %s monitored.",getURI().c_str(), flag? "":"NOT"); if (flag and not monitored_) pres_->addPresSubClient(this); monitored_ = flag; @@ -443,7 +443,7 @@ bool PresSubClient::lock() if (lock_flag_ == 0) { - RING_DBG("pres_client failed to lock : timeout"); + JAMI_DBG("pres_client failed to lock : timeout"); return false; } return true; @@ -469,20 +469,20 @@ bool PresSubClient::unsubscribe() pj_status_t retStatus; if (sub_ == NULL or dlg_ == NULL) { - RING_WARN("PresSubClient already unsubscribed."); + JAMI_WARN("PresSubClient already unsubscribed."); unlock(); return false; } if (pjsip_evsub_get_state(sub_) == PJSIP_EVSUB_STATE_TERMINATED) { - RING_WARN("pres_client already unsubscribed sub=TERMINATED."); + JAMI_WARN("pres_client already unsubscribed sub=TERMINATED."); sub_ = NULL; unlock(); return false; } /* Unsubscribe means send a subscribe with timeout=0s*/ - RING_WARN("pres_client %.*s: unsubscribing..", (int)uri_.slen, uri_.ptr); + JAMI_WARN("pres_client %.*s: unsubscribing..", (int)uri_.slen, uri_.ptr); retStatus = pjsip_pres_initiate(sub_, 0, &tdata); if (retStatus == PJ_SUCCESS) { @@ -493,7 +493,7 @@ bool PresSubClient::unsubscribe() if (retStatus != PJ_SUCCESS and sub_) { pjsip_pres_terminate(sub_, PJ_FALSE); sub_ = NULL; - RING_WARN("Unable to unsubscribe presence (%d)", retStatus); + JAMI_WARN("Unable to unsubscribe presence (%d)", retStatus); unlock(); return false; } @@ -510,7 +510,7 @@ bool PresSubClient::subscribe() if (sub_ and dlg_) { //do not bother if already subscribed pjsip_evsub_terminate(sub_, PJ_FALSE); - RING_DBG("PreseSubClient %.*s: already subscribed. Refresh it.", (int)uri_.slen, uri_.ptr); + JAMI_DBG("PreseSubClient %.*s: already subscribed. Refresh it.", (int)uri_.slen, uri_.ptr); } //subscribe @@ -525,7 +525,7 @@ bool PresSubClient::subscribe() pres_callback.on_rx_notify = &pres_client_evsub_on_rx_notify; SIPAccount * acc = pres_->getAccount(); - RING_DBG("PresSubClient %.*s: subscribing ", (int)uri_.slen, uri_.ptr); + JAMI_DBG("PresSubClient %.*s: subscribing ", (int)uri_.slen, uri_.ptr); /* Create UAC dialog */ @@ -533,13 +533,13 @@ bool PresSubClient::subscribe() status = pjsip_dlg_create_uac(pjsip_ua_instance(), &from, &contact_, &uri_, NULL, &dlg_); if (status != PJ_SUCCESS) { - RING_ERR("Unable to create dialog \n"); + JAMI_ERR("Unable to create dialog \n"); return false; } /* Add credential for auth. */ if (acc->hasCredentials() and pjsip_auth_clt_set_credentials(&dlg_->auth_sess, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) { - RING_ERR("Could not initialize credentials for subscribe session authentication"); + JAMI_ERR("Could not initialize credentials for subscribe session authentication"); } /* Increment the dialog's lock otherwise when presence session creation @@ -551,7 +551,7 @@ bool PresSubClient::subscribe() if (status != PJ_SUCCESS) { sub_ = NULL; - RING_WARN("Unable to create presence client (%d)", status); + JAMI_WARN("Unable to create presence client (%d)", status); /* This should destroy the dialog since there's no session * referencing it @@ -565,7 +565,7 @@ bool PresSubClient::subscribe() /* Add credential for authentication */ if (acc->hasCredentials() and pjsip_auth_clt_set_credentials(&dlg_->auth_sess, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) { - RING_ERR("Could not initialize credentials for invite session authentication"); + JAMI_ERR("Could not initialize credentials for invite session authentication"); return false; } @@ -584,7 +584,7 @@ bool PresSubClient::subscribe() if (sub_) pjsip_pres_terminate(sub_, PJ_FALSE); sub_ = NULL; - RING_WARN("Unable to create initial SUBSCRIBE (%d)", status); + JAMI_WARN("Unable to create initial SUBSCRIBE (%d)", status); return false; } @@ -598,7 +598,7 @@ bool PresSubClient::subscribe() if (sub_) pjsip_pres_terminate(sub_, PJ_FALSE); sub_ = NULL; - RING_WARN("Unable to send initial SUBSCRIBE (%d)", status); + JAMI_WARN("Unable to send initial SUBSCRIBE (%d)", status); return false; } @@ -611,4 +611,4 @@ bool PresSubClient::match(PresSubClient *b) return (b->getURI() == getURI()); } -} // namespace ring +} // namespace jami diff --git a/src/sip/pres_sub_client.h b/src/sip/pres_sub_client.h index 1daf1b1306..318fb8446a 100644 --- a/src/sip/pres_sub_client.h +++ b/src/sip/pres_sub_client.h @@ -32,7 +32,7 @@ #include <pjsip/sip_transport.h> #include "noncopyable.h" -namespace ring { +namespace jami { class SIPPresence; @@ -174,6 +174,6 @@ class PresSubClient { static int modId_; // used to extract data structure from event_subscription }; -} // namespace ring +} // namespace jami #endif /* PRES_SUB_CLIENT_H */ diff --git a/src/sip/pres_sub_server.cpp b/src/sip/pres_sub_server.cpp index e1c01a0211..c2e894abf9 100644 --- a/src/sip/pres_sub_server.cpp +++ b/src/sip/pres_sub_server.cpp @@ -31,7 +31,7 @@ #include "sip_utils.h" #include "compiler_intrinsics.h" -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -39,28 +39,28 @@ using sip_utils::CONST_PJ_STR; void PresSubServer::pres_evsub_on_srv_state(UNUSED pjsip_evsub *sub, UNUSED pjsip_event *event) { - RING_ERR("PresSubServer::pres_evsub_on_srv_state() is deprecated and does nothing"); + JAMI_ERR("PresSubServer::pres_evsub_on_srv_state() is deprecated and does nothing"); return; #if 0 // DISABLED: removed IP2IP support, tuleap: #448 pjsip_rx_data *rdata = event->body.rx_msg.rdata; if (!rdata) { - RING_DBG("Presence_subscription_server estate has changed but no rdata."); + JAMI_DBG("Presence_subscription_server estate has changed but no rdata."); return; } auto account = Manager::instance().getIP2IPAccount(); auto sipaccount = static_cast<SIPAccount *>(account.get()); if (!sipaccount) { - RING_ERR("Could not find account IP2IP"); + JAMI_ERR("Could not find account IP2IP"); return; } auto pres = sipaccount->getPresence(); if (!pres) { - RING_ERR("Presence not initialized"); + JAMI_ERR("Presence not initialized"); return; } @@ -68,7 +68,7 @@ PresSubServer::pres_evsub_on_srv_state(UNUSED pjsip_evsub *sub, UNUSED pjsip_eve PresSubServer *presSubServer = static_cast<PresSubServer *>(pjsip_evsub_get_mod_data(sub, pres->getModId())); if (presSubServer) { - RING_DBG("Presence_subscription_server to %s is %s", + JAMI_DBG("Presence_subscription_server to %s is %s", presSubServer->remote_, pjsip_evsub_get_state_name(sub)); pjsip_evsub_state state; @@ -111,14 +111,14 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, pjsip_get_subscribe_method()) != 0) return PJ_FALSE; - RING_ERR("PresSubServer::pres_evsub_on_srv_state() is deprecated and does nothing"); + JAMI_ERR("PresSubServer::pres_evsub_on_srv_state() is deprecated and does nothing"); return PJ_FALSE; #if 0 // DISABLED: removed IP2IP support, tuleap: #448 /* debug msg */ std::string name(rdata->msg_info.to->name.ptr, rdata->msg_info.to->name.slen); std::string server(rdata->msg_info.from->name.ptr, rdata->msg_info.from->name.slen); - RING_DBG("Incoming pres_on_rx_subscribe_request for %s, name:%s, server:%s." + JAMI_DBG("Incoming pres_on_rx_subscribe_request for %s, name:%s, server:%s." , request.c_str() , name.c_str() , server.c_str()); @@ -127,7 +127,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) auto account = Manager::instance().getIP2IPAccount(); auto sipaccount = static_cast<SIPAccount *>(account.get()); if (!sipaccount) { - RING_ERR("Could not find account IP2IP"); + JAMI_ERR("Could not find account IP2IP"); return PJ_FALSE; } @@ -142,7 +142,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) if (status != PJ_SUCCESS) { char errmsg[PJ_ERR_MSG_SIZE]; pj_strerror(status, errmsg, sizeof(errmsg)); - RING_WARN("Unable to create UAS dialog for subscription: %s [status=%d]", errmsg, status); + JAMI_WARN("Unable to create UAS dialog for subscription: %s [status=%d]", errmsg, status); pres->unlock(); pjsip_endpt_respond_stateless(endpt, rdata, 400, NULL, NULL, NULL); return PJ_TRUE; @@ -159,7 +159,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) int code = PJSIP_ERRNO_TO_SIP_STATUS(status); pjsip_tx_data *tdata; - RING_WARN("Unable to create server subscription %d", status); + JAMI_WARN("Unable to create server subscription %d", status); if (code == 599 || code > 699 || code < 300) { code = 400; @@ -212,7 +212,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) status = pjsip_pres_accept(sub, rdata, st_code, &msg_data.hdr_list); if (status != PJ_SUCCESS) { - RING_WARN("Unable to accept presence subscription %d", status); + JAMI_WARN("Unable to accept presence subscription %d", status); pjsip_pres_terminate(sub, PJ_FALSE); pres->unlock(); return PJ_FALSE; @@ -257,7 +257,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata) } if (status != PJ_SUCCESS) { - RING_WARN("Unable to create/send NOTIFY %d", status); + JAMI_WARN("Unable to create/send NOTIFY %d", status); pjsip_pres_terminate(sub, PJ_FALSE); pres->unlock(); return status; @@ -320,7 +320,7 @@ bool PresSubServer::matches(const char *s) const void PresSubServer::approve(bool flag) { approved_ = flag; - RING_DBG("Approve Presence_subscription_server for %s: %s.", remote_, flag ? "true" : "false"); + JAMI_DBG("Approve Presence_subscription_server for %s: %s.", remote_, flag ? "true" : "false"); // attach the real status data pjsip_pres_set_status(sub_, pres_->getStatus()); } @@ -335,7 +335,7 @@ void PresSubServer::notify() * the user accepted the request. */ if ((pjsip_evsub_get_state(sub_) == PJSIP_EVSUB_STATE_ACTIVE) && (approved_)) { - RING_DBG("Notifying %s.", remote_); + JAMI_DBG("Notifying %s.", remote_); pjsip_tx_data *tdata; pjsip_pres_set_status(sub_, pres_->getStatus()); @@ -345,10 +345,10 @@ void PresSubServer::notify() pres_->fillDoc(tdata, NULL); pjsip_pres_send_request(sub_, tdata); } else { - RING_WARN("Unable to create/send NOTIFY"); + JAMI_WARN("Unable to create/send NOTIFY"); pjsip_pres_terminate(sub_, PJ_FALSE); } } } -} // namespace ring +} // namespace jami diff --git a/src/sip/pres_sub_server.h b/src/sip/pres_sub_server.h index 1cb99b0871..685e32d0a4 100644 --- a/src/sip/pres_sub_server.h +++ b/src/sip/pres_sub_server.h @@ -31,7 +31,7 @@ #include "noncopyable.h" #include "array_size.h" -namespace ring { +namespace jami { extern pj_bool_t pres_on_rx_subscribe_request(pjsip_rx_data *rdata); @@ -79,6 +79,6 @@ class PresSubServer { bool approved_; }; -} // namespace ring +} // namespace jami #endif /* SERVERPRESENCESUB_H */ diff --git a/src/sip/sdes_negotiator.cpp b/src/sip/sdes_negotiator.cpp index 76d0f73981..9869213c65 100644 --- a/src/sip/sdes_negotiator.cpp +++ b/src/sip/sdes_negotiator.cpp @@ -31,7 +31,7 @@ #include <cstdio> -namespace ring { +namespace jami { SdesNegotiator::SdesNegotiator(const std::vector<CryptoSuiteDefinition>& localCapabilites) : localCapabilities_(localCapabilites) @@ -164,5 +164,5 @@ SdesNegotiator::negotiate(const std::vector<std::string>& attributes) const return {}; } -} // namespace ring +} // namespace jami diff --git a/src/sip/sdes_negotiator.h b/src/sip/sdes_negotiator.h index 1df1d683fe..40d017cca5 100644 --- a/src/sip/sdes_negotiator.h +++ b/src/sip/sdes_negotiator.h @@ -27,7 +27,7 @@ #include <string> #include <vector> -namespace ring { +namespace jami { /** * General exception object that is thrown when @@ -118,4 +118,4 @@ private: std::vector<CryptoSuiteDefinition> localCapabilities_; }; -} // namespace ring +} // namespace jami diff --git a/src/sip/sdp.cpp b/src/sip/sdp.cpp index b439887ad5..86072d18fe 100644 --- a/src/sip/sdp.cpp +++ b/src/sip/sdp.cpp @@ -47,7 +47,7 @@ using random_device = dht::crypto::random_device; #include <algorithm> #include <cassert> -namespace ring { +namespace jami { using std::string; using std::map; @@ -75,7 +75,7 @@ Sdp::Sdp(const std::string& id) Sdp::~Sdp() { SIPAccount::releasePort(localAudioDataPort_); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO SIPAccount::releasePort(localVideoDataPort_); #endif } @@ -139,7 +139,7 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp) { if (!sdp) { - RING_ERR("Remote sdp is NULL"); + JAMI_ERR("Remote sdp is NULL"); return; } @@ -151,14 +151,14 @@ Sdp::generateSdesAttribute() { static constexpr const unsigned cryptoSuite = 0; std::vector<uint8_t> keyAndSalt; - keyAndSalt.resize(ring::CryptoSuites[cryptoSuite].masterKeyLength / 8 - + ring::CryptoSuites[cryptoSuite].masterSaltLength/ 8); + keyAndSalt.resize(jami::CryptoSuites[cryptoSuite].masterKeyLength / 8 + + jami::CryptoSuites[cryptoSuite].masterSaltLength/ 8); // generate keys randomFill(keyAndSalt); std::string tag = "1"; std::string crypto_attr = tag + " " - + ring::CryptoSuites[cryptoSuite].name + + jami::CryptoSuites[cryptoSuite].name + " inline:" + base64::encode(keyAndSalt); pj_str_t val { (char*) crypto_attr.c_str(), static_cast<pj_ssize_t>(crypto_attr.size()) }; @@ -196,7 +196,7 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro enc_name = accountAudioCodec->systemCodecInfo.name; if (accountAudioCodec->audioformat.nb_channels > 1) { - channels = ring::to_string(accountAudioCodec->audioformat.nb_channels); + channels = jami::to_string(accountAudioCodec->audioformat.nb_channels); rtpmap.param.ptr = (char *) channels.c_str(); rtpmap.param.slen = strlen(channels.c_str()); // don't include NULL terminator } @@ -228,7 +228,7 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro pjmedia_sdp_rtpmap_to_attr(memPool_.get(), &rtpmap, &attr); med->attr[med->attr_count++] = attr; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (enc_name == "H264") { // FIXME: this should not be hardcoded, it will determine what profile and level // our peer will send us @@ -281,7 +281,7 @@ Sdp::setPublishedIP(const std::string &addr, pj_uint16_t addr_type) localSession_->origin.addr = pj_str((char*) publishedIpAddr_.c_str()); localSession_->conn->addr = localSession_->origin.addr; if (pjmedia_sdp_validate(localSession_) != PJ_SUCCESS) - RING_ERR("Could not validate SDP"); + JAMI_ERR("Could not validate SDP"); } } @@ -313,7 +313,7 @@ void Sdp::setTelephoneEventRtpmap(pjmedia_sdp_media *med) void Sdp::setLocalMediaVideoCapabilities(const std::vector<std::shared_ptr<AccountCodecInfo>>& selectedCodecs) { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO video_codec_list_ = selectedCodecs; #else (void) selectedCodecs; @@ -337,7 +337,7 @@ Sdp::printSession(const pjmedia_sdp_session *session, const char* header) auto cloned_session = pjmedia_sdp_session_clone(tmpPool_.get(), session); if (!cloned_session) { - RING_ERR("Could not clone SDP for printing"); + JAMI_ERR("Could not clone SDP for printing"); return; } @@ -349,11 +349,11 @@ Sdp::printSession(const pjmedia_sdp_session *session, const char* header) std::array<char, BUF_SZ+1> buffer; auto size = pjmedia_sdp_print(cloned_session, buffer.data(), BUF_SZ); if (size < 0) { - RING_ERR("%sSDP too big for dump", header); + JAMI_ERR("%sSDP too big for dump", header); return; } buffer[size] = '\0'; - RING_DBG("%s%s", header, &buffer[0]); + JAMI_DBG("%s%s", header, &buffer[0]); } int Sdp::createLocalSession(const std::vector<std::shared_ptr<AccountCodecInfo>>& selectedAudioCodecs, @@ -413,12 +413,12 @@ Sdp::createOffer(const std::vector<std::shared_ptr<AccountCodecInfo>>& selectedA bool holding) { if (createLocalSession(selectedAudioCodecs, selectedVideoCodecs, security, holding) != PJ_SUCCESS) { - RING_ERR("Failed to create initial offer"); + JAMI_ERR("Failed to create initial offer"); return false; } if (pjmedia_sdp_neg_create_w_local_offer(memPool_.get(), localSession_, &negotiator_) != PJ_SUCCESS) { - RING_ERR("Failed to create an initial SDP negotiator"); + JAMI_ERR("Failed to create an initial SDP negotiator"); return false; } @@ -432,7 +432,7 @@ void Sdp::receiveOffer(const pjmedia_sdp_session* remote, bool holding) { if (!remote) { - RING_ERR("Remote session is NULL"); + JAMI_ERR("Remote session is NULL"); return; } @@ -440,7 +440,7 @@ void Sdp::receiveOffer(const pjmedia_sdp_session* remote, if (not localSession_ and createLocalSession(selectedAudioCodecs, selectedVideoCodecs, kx, holding) != PJ_SUCCESS) { - RING_ERR("Failed to create initial offer"); + JAMI_ERR("Failed to create initial offer"); return; } @@ -448,13 +448,13 @@ void Sdp::receiveOffer(const pjmedia_sdp_session* remote, if (pjmedia_sdp_neg_create_w_remote_offer(memPool_.get(), localSession_, remoteSession_, &negotiator_) != PJ_SUCCESS) - RING_ERR("Failed to initialize negotiator"); + JAMI_ERR("Failed to initialize negotiator"); } void Sdp::startNegotiation() { if (negotiator_ == NULL) { - RING_ERR("Can't start negotiation with invalid negotiator"); + JAMI_ERR("Can't start negotiation with invalid negotiator"); return; } @@ -462,7 +462,7 @@ void Sdp::startNegotiation() const pjmedia_sdp_session *active_remote; if (pjmedia_sdp_neg_get_state(negotiator_) != PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) { - RING_WARN("Negotiator not in right state for negotiation"); + JAMI_WARN("Negotiator not in right state for negotiation"); return; } @@ -470,12 +470,12 @@ void Sdp::startNegotiation() return; if (pjmedia_sdp_neg_get_active_local(negotiator_, &active_local) != PJ_SUCCESS) - RING_ERR("Could not retrieve local active session"); + JAMI_ERR("Could not retrieve local active session"); else setActiveLocalSdpSession(active_local); if (pjmedia_sdp_neg_get_active_remote(negotiator_, &active_remote) != PJ_SUCCESS) - RING_ERR("Could not retrieve remote active session"); + JAMI_ERR("Could not retrieve remote active session"); else setActiveRemoteSdpSession(active_remote); } @@ -493,7 +493,7 @@ Sdp::getFilteredSdp(const pjmedia_sdp_session* session, unsigned media_keep, uns ); auto cloned = pjmedia_sdp_session_clone(tmpPool_.get(), session); if (!cloned) { - RING_ERR("Could not clone SDP"); + JAMI_ERR("Could not clone SDP"); return ""; } @@ -502,13 +502,13 @@ Sdp::getFilteredSdp(const pjmedia_sdp_session* session, unsigned media_keep, uns for (unsigned i = 0; i < cloned->media_count; i++) if (i != media_keep) { if (pjmedia_sdp_media_deactivate(tmpPool_.get(), cloned->media[i]) != PJ_SUCCESS) - RING_ERR("Could not deactivate media"); + JAMI_ERR("Could not deactivate media"); } else { hasKeep = true; } if (not hasKeep) { - RING_DBG("No media to keep present in SDP"); + JAMI_DBG("No media to keep present in SDP"); return ""; } @@ -584,7 +584,7 @@ Sdp::getMediaSlots(const pjmedia_sdp_session* session, bool remote) const // get connection info pjmedia_sdp_conn* conn = media->conn ? media->conn : session->conn; if (not conn) { - RING_ERR("Could not find connection information for media"); + JAMI_ERR("Could not find connection information for media"); continue; } descr.addr = std::string(conn->addr.ptr, conn->addr.slen); @@ -597,7 +597,7 @@ Sdp::getMediaSlots(const pjmedia_sdp_session* session, bool remote) const for (unsigned j = 0; j<media->desc.fmt_count; j++) { const auto rtpMapAttribute = pjmedia_sdp_media_find_attr(media, &STR_RTPMAP, &media->desc.fmt[j]); if (!rtpMapAttribute) { - RING_ERR("Could not find rtpmap attribute"); + JAMI_ERR("Could not find rtpmap attribute"); descr.enabled = false; continue; } @@ -605,7 +605,7 @@ Sdp::getMediaSlots(const pjmedia_sdp_session* session, bool remote) const if (pjmedia_sdp_attr_get_rtpmap(rtpMapAttribute, &rtpmap) != PJ_SUCCESS || rtpmap.enc_name.slen == 0) { - RING_ERR("Could not find payload type %.*s in SDP", + JAMI_ERR("Could not find payload type %.*s in SDP", (int)media->desc.fmt[j].slen, media->desc.fmt[j].ptr); descr.enabled = false; continue; @@ -614,7 +614,7 @@ Sdp::getMediaSlots(const pjmedia_sdp_session* session, bool remote) const descr.rtp_clockrate = rtpmap.clock_rate; descr.codec = findCodecBySpec(codec_raw, rtpmap.clock_rate); if (not descr.codec) { - RING_ERR("Could not find codec %s", codec_raw.c_str()); + JAMI_ERR("Could not find codec %s", codec_raw.c_str()); descr.enabled = false; continue; } @@ -664,7 +664,7 @@ void Sdp::addIceCandidates(unsigned media_index, const std::vector<std::string>& cands) { if (media_index >= localSession_->media_count) { - RING_ERR("addIceCandidates failed: cannot access media#%u (may be deactivated)", media_index); + JAMI_ERR("addIceCandidates failed: cannot access media#%u (may be deactivated)", media_index); return; } @@ -685,17 +685,17 @@ Sdp::getIceCandidates(unsigned media_index) const auto session = activeRemoteSession_ ? activeRemoteSession_ : remoteSession_; auto localSession = activeLocalSession_ ? activeLocalSession_ : localSession_; if (not session) { - RING_ERR("getIceCandidates failed: no remote session"); + JAMI_ERR("getIceCandidates failed: no remote session"); return {}; } if (media_index >= session->media_count || media_index >= localSession->media_count) { - RING_ERR("getIceCandidates failed: cannot access media#%u (may be deactivated)", media_index); + JAMI_ERR("getIceCandidates failed: cannot access media#%u (may be deactivated)", media_index); return {}; } auto media = session->media[media_index]; auto localMedia = localSession->media[media_index]; if (media->desc.port == 0 || localMedia->desc.port == 0) { - RING_ERR("getIceCandidates failed: media#%u is disabled", media_index); + JAMI_ERR("getIceCandidates failed: media#%u is disabled", media_index); return {}; } @@ -773,4 +773,4 @@ Sdp::clearIce(pjmedia_sdp_session* session) } } -} // namespace ring +} // namespace jami diff --git a/src/sip/sdp.h b/src/sip/sdp.h index 7f90490b0d..a0934f51d4 100644 --- a/src/sip/sdp.h +++ b/src/sip/sdp.h @@ -44,7 +44,7 @@ #include <string> #include <stdexcept> -namespace ring { +namespace jami { namespace test { class SDPTest; @@ -324,4 +324,4 @@ class Sdp { std::shared_ptr<AccountCodecInfo> findCodecBySpec(const std::string &codecName, const unsigned clockrate=0) const; }; -} // namespace ring +} // namespace jami diff --git a/src/sip/sip_utils.cpp b/src/sip/sip_utils.cpp index 5ac0ae1c7b..5a5b800e27 100644 --- a/src/sip/sip_utils.cpp +++ b/src/sip/sip_utils.cpp @@ -42,7 +42,7 @@ #include <vector> #include <algorithm> -namespace ring { namespace sip_utils { +namespace jami { namespace sip_utils { std::string PjsipErrorCategory::message( int condition ) const @@ -93,7 +93,7 @@ createRouteSet(const std::string &route, pj_pool_t *hdr_pool) pj_strdup2(hdr_pool, &url->host, host.c_str()); url->port = port; - RING_DBG("Adding route %s", host.c_str()); + JAMI_DBG("Adding route %s", host.c_str()); pj_list_push_back(route_set, pjsip_hdr_clone(hdr_pool, routing)); return route_set; @@ -200,8 +200,8 @@ register_thread() static __thread pj_thread_t *this_thread; #endif pj_thread_register(NULL, desc, &this_thread); - RING_DBG("Registered thread %p (0x%X)", this_thread, pj_getpid()); + JAMI_DBG("Registered thread %p (0x%X)", this_thread, pj_getpid()); } } -}} // namespace ring::sip_utils +}} // namespace jami::sip_utils diff --git a/src/sip/sip_utils.h b/src/sip/sip_utils.h index f9885c709e..1514f56481 100644 --- a/src/sip/sip_utils.h +++ b/src/sip/sip_utils.h @@ -40,7 +40,7 @@ struct pjsip_msg; struct pjsip_dialog; -namespace ring { namespace sip_utils { +namespace jami { namespace sip_utils { static constexpr int DEFAULT_SIP_PORT {5060}; static constexpr int DEFAULT_SIP_TLS_PORT {5061}; @@ -141,6 +141,6 @@ smart_alloc_pool(pjsip_endpoint* endpt, const char* const name, pj_size_t initia return std::unique_ptr<pj_pool_t, decltype(pj_pool_release)&>(pool, pj_pool_release); } -}} // namespace ring::sip_utils +}} // namespace jami::sip_utils #endif // SIP_UTILS_H_ diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 35fec8ddf5..70af6d6d87 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -50,7 +50,7 @@ #include "client/ring_signal.h" #include "dring/account_const.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "libav_utils.h" #endif @@ -79,7 +79,7 @@ #include <pwd.h> #endif -namespace ring { +namespace jami { using yaml_utils::parseValue; using yaml_utils::parseVectorMap; @@ -97,13 +97,13 @@ static void registration_cb(pjsip_regc_cbparam *param) { if (!param) { - RING_ERR("registration callback parameter is null"); + JAMI_ERR("registration callback parameter is null"); return; } auto account = static_cast<SIPAccount *>(param->token); if (!account) { - RING_ERR("account doesn't exist in registration callback"); + JAMI_ERR("account doesn't exist in registration callback"); return; } @@ -176,7 +176,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl, std::string to; int family; - RING_DBG() << *this << "Calling SIP peer " << toUrl; + JAMI_DBG() << *this << "Calling SIP peer " << toUrl; auto& manager = Manager::instance(); auto call = manager.callFactory.newCall<SIPCall, SIPAccount>(*this, manager.getNewCallID(), @@ -199,7 +199,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl, setTransport(t); call->setTransport(t); - RING_DBG("New %s IP to IP call to %s", ipv6?"IPv6":"IPv4", to.c_str()); + JAMI_DBG("New %s IP to IP call to %s", ipv6?"IPv6":"IPv4", to.c_str()); } else { to = toUrl; @@ -207,7 +207,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl, // FIXME : for now, use the same address family as the SIP transport family = pjsip_transport_type_get_af(getTransportType()); - RING_DBG("UserAgent: New registered account call to %s", toUrl.c_str()); + JAMI_DBG("UserAgent: New registered account call to %s", toUrl.c_str()); } auto toUri = getToUri(to); @@ -250,7 +250,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl, manager.scheduler().run([this, weak_call] { if (auto call = weak_call.lock()) { if (not SIPStartCall(call)) { - RING_ERR("Could not send outgoing INVITE request for new call"); + JAMI_ERR("Could not send outgoing INVITE request for new call"); call->onFailure(); } } @@ -267,12 +267,12 @@ void SIPAccount::onTransportStateChanged(pjsip_transport_state state, const pjsip_transport_state_info *info) { pj_status_t currentStatus = transportStatus_; - RING_DBG("Transport state changed to %s for account %s !", SipTransport::stateToStr(state), accountID_.c_str()); + JAMI_DBG("Transport state changed to %s for account %s !", SipTransport::stateToStr(state), accountID_.c_str()); if (!SipTransport::isAlive(transport_, state)) { if (info) { transportStatus_ = info->status; transportError_ = sip_utils::sip_strerror(info->status); - RING_ERR("Transport disconnected: %s", transportError_.c_str()); + JAMI_ERR("Transport disconnected: %s", transportError_.c_str()); } else { // This is already the generic error used by pjsip. @@ -299,7 +299,7 @@ SIPAccount::setTransport(const std::shared_ptr<SipTransport>& t) if (t == transport_) return; if (transport_) { - RING_DBG("Removing transport from account"); + JAMI_DBG("Removing transport from account"); if (regc_) pjsip_regc_release_transport(regc_); transport_->removeStateListener(reinterpret_cast<uintptr_t>(this)); @@ -340,12 +340,12 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call) auto transport = call->getTransport(); if (!transport) { - RING_ERR("Unable to start call without transport"); + JAMI_ERR("Unable to start call without transport"); return false; } pj_str_t pjContact = getContactHeader(transport->get()); - RING_DBG("contact header: %.*s / %s -> %s", + JAMI_DBG("contact header: %.*s / %s -> %s", (int)pjContact.slen, pjContact.ptr, from.c_str(), toUri.c_str()); auto local_sdp = call->getSDP().getLocalSdpSession(); @@ -363,25 +363,25 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call) pjsip_dlg_set_route_set(dialog, sip_utils::createRouteSet(getServiceRoute(), call->inv->pool)); if (hasCredentials() and pjsip_auth_clt_set_credentials(&dialog->auth_sess, getCredentialCount(), getCredInfo()) != PJ_SUCCESS) { - RING_ERR("Could not initialize credentials for invite session authentication"); + JAMI_ERR("Could not initialize credentials for invite session authentication"); return false; } pjsip_tx_data *tdata; if (pjsip_inv_invite(call->inv.get(), &tdata) != PJ_SUCCESS) { - RING_ERR("Could not initialize invite messager for this call"); + JAMI_ERR("Could not initialize invite messager for this call"); return false; } const pjsip_tpselector tp_sel = link_->getTransportSelector(transport->get()); if (pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) { - RING_ERR("Unable to associate transport for invite session dialog"); + JAMI_ERR("Unable to associate transport for invite session dialog"); return false; } if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) { - RING_ERR("Unable to send invite message for this call"); + JAMI_ERR("Unable to send invite message for this call"); return false; } @@ -459,7 +459,7 @@ validate(std::string &member, const std::string ¶m, const T& valid) if (find(begin, end, param) != end) member = param; else - RING_ERR("Invalid parameter \"%s\"", param.c_str()); + JAMI_ERR("Invalid parameter \"%s\"", param.c_str()); } void SIPAccount::unserialize(const YAML::Node &node) @@ -594,7 +594,7 @@ void SIPAccount::setAccountDetails(const std::map<std::string, std::string> &det srtpKeyExchange_ = sip_utils::getKeyExchangeProtocol(iter->second.c_str()); if (credentials_.empty()) { // credentials not set, construct 1 entry - RING_WARN("No credentials set, inferring them..."); + JAMI_WARN("No credentials set, inferring them..."); std::vector<std::map<std::string, std::string> > v; std::map<std::string, std::string> map; map[Conf::CONFIG_ACCOUNT_USERNAME] = username_; @@ -622,9 +622,9 @@ SIPAccount::getAccountDetails() const } a.emplace(Conf::CONFIG_ACCOUNT_PASSWORD, std::move(password)); - a.emplace(Conf::CONFIG_LOCAL_PORT, ring::to_string(localPort_)); + a.emplace(Conf::CONFIG_LOCAL_PORT, jami::to_string(localPort_)); a.emplace(Conf::CONFIG_ACCOUNT_ROUTESET, serviceRoute_); - a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_EXPIRE, ring::to_string(registrationExpire_)); + a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_EXPIRE, jami::to_string(registrationExpire_)); a.emplace(Conf::CONFIG_KEEP_ALIVE_ENABLED, keepAliveEnabled_ ? TRUE_STR : FALSE_STR); a.emplace(Conf::CONFIG_PRESENCE_ENABLED, presence_ and presence_->isEnabled()? TRUE_STR : FALSE_STR); @@ -645,7 +645,7 @@ std::map<std::string, std::string> SIPAccount::getVolatileAccountDetails() const { auto a = SIPAccountBase::getVolatileAccountDetails(); - a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, ring::to_string(registrationStateDetailed_.first)); + a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_STATE_CODE, jami::to_string(registrationStateDetailed_.first)); a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_STATE_DESC, registrationStateDetailed_.second); a.emplace(DRing::Account::VolatileProperties::InstantMessaging::OFF_CALL, TRUE_STR); @@ -658,7 +658,7 @@ SIPAccount::getVolatileAccountDetails() const const auto& tlsInfos = transport_->getTlsInfos(); auto cipher = pj_ssl_cipher_name(tlsInfos.cipher); if (tlsInfos.cipher and not cipher) - RING_WARN("Unknown cipher: %d", tlsInfos.cipher); + JAMI_WARN("Unknown cipher: %d", tlsInfos.cipher); a.emplace(DRing::TlsTransport::TLS_CIPHER, cipher ? cipher : ""); a.emplace(DRing::TlsTransport::TLS_PEER_CERT, tlsInfos.peerCert->toString()); auto ca = tlsInfos.peerCert->issuer; @@ -669,7 +669,7 @@ SIPAccount::getVolatileAccountDetails() const a.emplace(name_str.str(), ca->toString()); ca = ca->issuer; } - a.emplace(DRing::TlsTransport::TLS_PEER_CA_NUM, ring::to_string(n)); + a.emplace(DRing::TlsTransport::TLS_PEER_CA_NUM, jami::to_string(n)); } return a; @@ -689,10 +689,10 @@ bool SIPAccount::mapPortUPnP() * a different port, if succesfull, then we have to use that port for SIP */ uint16_t port_used; - bool added = upnp_->addAnyMapping(publishedPort_, localPort_, ring::upnp::PortType::UDP, false, false, &port_used); + bool added = upnp_->addAnyMapping(publishedPort_, localPort_, jami::upnp::PortType::UDP, false, false, &port_used); if (added) { if (port_used != publishedPort_) - RING_DBG("UPnP could not map published port %u for SIP, using %u instead", publishedPort_, port_used); + JAMI_DBG("UPnP could not map published port %u for SIP, using %u instead", publishedPort_, port_used); publishedPortUsed_ = port_used; } } @@ -709,22 +709,22 @@ void SIPAccount::doRegister() { std::unique_lock<std::mutex> lock(configurationMutex_); if (not isUsable()) { - RING_WARN("Account must be enabled and active to register, ignoring"); + JAMI_WARN("Account must be enabled and active to register, ignoring"); return; } - RING_DBG("doRegister %s", hostname_.c_str()); + JAMI_DBG("doRegister %s", hostname_.c_str()); /* if UPnP is enabled, then wait for IGD to complete registration */ if (upnp_) { - RING_DBG("UPnP: waiting for IGD to register SIP account"); + JAMI_DBG("UPnP: waiting for IGD to register SIP account"); lock.unlock(); setRegistrationState(RegistrationState::TRYING); std::thread{ [w=weak()] { if (auto acc = w.lock()) { sip_utils::register_thread(); if (not acc->mapPortUPnP()) - RING_WARN("UPnP: Could not successfully map SIP port with UPnP, continuing with account registration anyways."); + JAMI_WARN("UPnP: Could not successfully map SIP port with UPnP, continuing with account registration anyways."); acc->doRegister1_(); } }}.detach(); @@ -751,7 +751,7 @@ void SIPAccount::doRegister1_() if (auto acc = w.lock()) { std::lock_guard<std::mutex> lock(acc->configurationMutex_); if (host_ips.empty()) { - RING_ERR("Can't resolve hostname for registration."); + JAMI_ERR("Can't resolve hostname for registration."); acc->setRegistrationState(RegistrationState::ERROR_GENERIC, PJSIP_SC_NOT_FOUND); return; } @@ -766,13 +766,13 @@ void SIPAccount::doRegister2_() { bool ipv6 = false; if (isIP2IP()) { - RING_DBG("doRegister isIP2IP."); + JAMI_DBG("doRegister isIP2IP."); #if HAVE_IPV6 ipv6 = ip_utils::getInterfaceAddr(interface_).isIpv6(); #endif } else if (!hostIp_) { setRegistrationState(RegistrationState::ERROR_GENERIC, PJSIP_SC_NOT_FOUND); - RING_ERR("Hostname not resolved."); + JAMI_ERR("Hostname not resolved."); return; } #if HAVE_IPV6 @@ -782,7 +782,7 @@ void SIPAccount::doRegister2_() // Init TLS settings if the user wants to use TLS if (tlsEnable_) { - RING_DBG("TLS is enabled for account %s", accountID_.c_str()); + JAMI_DBG("TLS is enabled for account %s", accountID_.c_str()); // Dropping current calls already using the transport is currently required // with TLS. @@ -797,7 +797,7 @@ void SIPAccount::doRegister2_() getTlsSetting()); if (!tlsListener_) { setRegistrationState(RegistrationState::ERROR_GENERIC); - RING_ERR("Error creating TLS listener."); + JAMI_ERR("Error creating TLS listener."); return; } } @@ -825,7 +825,7 @@ void SIPAccount::doRegister2_() } try { - RING_WARN("Creating transport"); + JAMI_WARN("Creating transport"); transport_.reset(); if (isTlsEnabled()) { setTransport(link_->sipTransportBroker->getTlsTransport(tlsListener_, hostIp_, tlsServerName_.empty() ? hostname_ : tlsServerName_)); @@ -839,7 +839,7 @@ void SIPAccount::doRegister2_() sendRegister(); } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); setRegistrationState(RegistrationState::ERROR_GENERIC); return; } @@ -862,7 +862,7 @@ void SIPAccount::doUnregister(std::function<void(bool)> released_cb) try { sendUnregister(); } catch (const VoipLinkException& e) { - RING_ERR("doUnregister %s", e.what()); + JAMI_ERR("doUnregister %s", e.what()); } } @@ -901,7 +901,7 @@ void SIPAccount::startKeepAliveTimer() if (keepAliveTimerActive_) return; - RING_DBG("Start keep alive timer for account %s", getAccountID().c_str()); + JAMI_DBG("Start keep alive timer for account %s", getAccountID().c_str()); // make sure here we have an entirely new timer memset(&keepAliveTimer_, 0, sizeof(pj_timer_entry)); @@ -913,10 +913,10 @@ void SIPAccount::startKeepAliveTimer() // expiration may be undetermined during the first registration request if (registrationExpire_ == 0) { - RING_DBG("Registration Expire: 0, taking 60 instead"); + JAMI_DBG("Registration Expire: 0, taking 60 instead"); keepAliveDelay_.sec = 3600; } else { - RING_DBG("Registration Expire: %d", registrationExpire_); + JAMI_DBG("Registration Expire: %d", registrationExpire_); keepAliveDelay_.sec = registrationExpire_ + MIN_REGISTRATION_TIME; } @@ -930,7 +930,7 @@ void SIPAccount::startKeepAliveTimer() void SIPAccount::stopKeepAliveTimer() { if (keepAliveTimerActive_) { - RING_DBG("Stop keep alive timer %d for account %s", keepAliveTimer_.id, getAccountID().c_str()); + JAMI_DBG("Stop keep alive timer %d for account %s", keepAliveTimer_.id, getAccountID().c_str()); keepAliveTimerActive_ = false; link_->cancelKeepAliveTimer(keepAliveTimer_); } @@ -940,7 +940,7 @@ void SIPAccount::sendRegister() { if (not isUsable()) { - RING_WARN("Account must be enabled and active to register, ignoring"); + JAMI_WARN("Account must be enabled and active to register, ignoring"); return; } @@ -967,7 +967,7 @@ SIPAccount::sendRegister() if (transport_) { if (getUPnPActive() or not getPublishedSameasLocal() or (not received.empty() and received != getPublishedAddress())) { pjsip_host_port *via = getViaAddr(); - RING_DBG("Setting VIA sent-by to %.*s:%d", (int)via->host.slen, via->host.ptr, via->port); + JAMI_DBG("Setting VIA sent-by to %.*s:%d", (int)via->host.slen, via->host.ptr, via->port); if (pjsip_regc_set_via_sent_by(regc, via, transport_->get()) != PJ_SUCCESS) throw VoipLinkException("Unable to set the \"sent-by\" field"); @@ -979,9 +979,9 @@ SIPAccount::sendRegister() pj_status_t status; - //RING_DBG("pjsip_regc_init from:%s, srv:%s, contact:%s", from.c_str(), srvUri.c_str(), std::string(pj_strbuf(&pjContact), pj_strlen(&pjContact)).c_str()); + //JAMI_DBG("pjsip_regc_init from:%s, srv:%s, contact:%s", from.c_str(), srvUri.c_str(), std::string(pj_strbuf(&pjContact), pj_strlen(&pjContact)).c_str()); if ((status = pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, getRegistrationExpire())) != PJ_SUCCESS) { - RING_ERR("pjsip_regc_init failed with error %d: %s", status, + JAMI_ERR("pjsip_regc_init failed with error %d: %s", status, sip_utils::sip_strerror(status).c_str()); throw VoipLinkException("Unable to initialize account registration structure"); } @@ -1021,7 +1021,7 @@ SIPAccount::sendRegister() // pjsip_regc_send increment the transport ref count by one, if ((status = pjsip_regc_send(regc, tdata)) != PJ_SUCCESS) { - RING_ERR("pjsip_regc_init failed with error %d: %s", status, + JAMI_ERR("pjsip_regc_init failed with error %d: %s", status, sip_utils::sip_strerror(status).c_str()); throw VoipLinkException("Unable to send account registration request"); } @@ -1036,12 +1036,12 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param) return; if (param->status != PJ_SUCCESS) { - RING_ERR("SIP registration error %d", param->status); + JAMI_ERR("SIP registration error %d", param->status); destroyRegistrationInfo(); stopKeepAliveTimer(); setRegistrationState(RegistrationState::ERROR_GENERIC, param->code); } else if (param->code < 0 || param->code >= 300) { - RING_ERR("SIP registration failed, status=%d (%.*s)", + JAMI_ERR("SIP registration failed, status=%d (%.*s)", param->code, (int)param->reason.slen, param->reason.ptr); destroyRegistrationInfo(); stopKeepAliveTimer(); @@ -1070,7 +1070,7 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param) destroyRegistrationInfo(); /* Stop keep-alive timer if any. */ stopKeepAliveTimer(); - RING_DBG("Unregistration success"); + JAMI_DBG("Unregistration success"); setRegistrationState(RegistrationState::UNREGISTERED, param->code); } else { /* TODO Check and update SIP outbound status first, since the result @@ -1079,7 +1079,7 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param) // update_rfc5626_status(acc, param->rdata); if (checkNATAddress(param, link_->getPool())) - RING_WARN("Contact overwritten"); + JAMI_WARN("Contact overwritten"); /* TODO Check and update Service-Route header */ if (hasServiceRoute()) @@ -1138,7 +1138,7 @@ SIPAccount::sendUnregister() pj_status_t status; if ((status = pjsip_regc_send(regc, tdata)) != PJ_SUCCESS) { - RING_ERR("pjsip_regc_send failed with error %d: %s", status, + JAMI_ERR("pjsip_regc_send failed with error %d: %s", status, sip_utils::sip_strerror(status).c_str()); throw VoipLinkException("Unable to send request to unregister sip account"); } @@ -1184,7 +1184,7 @@ void SIPAccount::initTlsConfiguration() CipherArray avail_ciphers(256); unsigned cipherNum = avail_ciphers.size(); if (pj_ssl_cipher_get_availables(&avail_ciphers.front(), &cipherNum) != PJ_SUCCESS) - RING_ERR("Could not determine cipher list on this system"); + JAMI_ERR("Could not determine cipher list on this system"); avail_ciphers.resize(cipherNum); ciphers_.clear(); @@ -1196,11 +1196,11 @@ void SIPAccount::initTlsConfiguration() if (item.empty()) continue; auto item_cid = pj_ssl_cipher_id(item.c_str()); if (item_cid != PJ_TLS_UNKNOWN_CIPHER) { - RING_WARN("Valid cipher: %s", item.c_str()); + JAMI_WARN("Valid cipher: %s", item.c_str()); ciphers_.push_back(item_cid); } else - RING_ERR("Invalid cipher: %s", item.c_str()); + JAMI_ERR("Invalid cipher: %s", item.c_str()); } } #endif @@ -1215,7 +1215,7 @@ void SIPAccount::initTlsConfiguration() pj_cstr(&tlsSetting_.privkey_file, tlsPrivateKeyFile_.c_str()); pj_cstr(&tlsSetting_.password, tlsPassword_.c_str()); - RING_DBG("Using %zu ciphers", ciphers_.size()); + JAMI_DBG("Using %zu ciphers", ciphers_.size()); tlsSetting_.ciphers_num = ciphers_.size(); tlsSetting_.ciphers = &ciphers_.front(); @@ -1414,7 +1414,7 @@ SIPAccount::getContactHeader(pjsip_transport* t) if (!t && transport_) t = transport_->get(); if (!t) { - RING_ERR("Transport not created yet"); + JAMI_ERR("Transport not created yet"); return {nullptr, 0}; } @@ -1438,11 +1438,11 @@ SIPAccount::getContactHeader(pjsip_transport* t) address = getUPnPIpAddress().toString(); port = publishedPortUsed_; useUPnPAddressPortInVIA(); - RING_DBG("Using UPnP address %s and port %d", address.c_str(), port); + JAMI_DBG("Using UPnP address %s and port %d", address.c_str(), port); } else if (not publishedSameasLocal_) { address = publishedIpAddress_; port = publishedPort_; - RING_DBG("Using published address %s and port %d", address.c_str(), port); + JAMI_DBG("Using published address %s and port %d", address.c_str(), port); } else if (stunEnabled_) { auto success = link_->findLocalAddressFromSTUN(t, &stunServerName_, stunPort_, address, port); @@ -1454,12 +1454,12 @@ SIPAccount::getContactHeader(pjsip_transport* t) } else { if (!receivedParameter_.empty()) { address = receivedParameter_; - RING_DBG("Using received address %s", address.c_str()); + JAMI_DBG("Using received address %s", address.c_str()); } if (rPort_ != -1 and rPort_ != 0) { port = rPort_; - RING_DBG("Using received port %d", port); + JAMI_DBG("Using received port %d", port); } } @@ -1520,7 +1520,7 @@ SIPAccount::getSupportedTlsCiphers() unsigned cipherNum = 256; CipherArray avail_ciphers(cipherNum); if (pj_ssl_cipher_get_availables(&avail_ciphers.front(), &cipherNum) != PJ_SUCCESS) - RING_ERR("Could not determine cipher list on this system"); + JAMI_ERR("Could not determine cipher list on this system"); avail_ciphers.resize(cipherNum); availCiphers.reserve(cipherNum); for (const auto &item : avail_ciphers) { @@ -1543,11 +1543,11 @@ void SIPAccount::keepAliveRegistrationCb(UNUSED pj_timer_heap_t *th, pj_timer_en SIPAccount *sipAccount = static_cast<SIPAccount *>(te->user_data); if (sipAccount == nullptr) { - RING_ERR("SIP account is nullptr while registering a new keep alive timer"); + JAMI_ERR("SIP account is nullptr while registering a new keep alive timer"); return; } - RING_ERR("Keep alive registration callback for account %s", sipAccount->getAccountID().c_str()); + JAMI_ERR("Keep alive registration callback for account %s", sipAccount->getAccountID().c_str()); // IP2IP default does not require keep-alive if (sipAccount->isIP2IP()) @@ -1593,7 +1593,7 @@ SIPAccount::Credentials::computePasswordHash() void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::string> >& creds) { if (creds.empty()) { - RING_ERR("Cannot authenticate with empty credentials list"); + JAMI_ERR("Cannot authenticate with empty credentials list"); return; } credentials_.clear(); @@ -1668,7 +1668,7 @@ SIPAccount::getTlsSettings() const { return { {Conf::CONFIG_TLS_ENABLE, tlsEnable_ ? TRUE_STR : FALSE_STR}, - {Conf::CONFIG_TLS_LISTENER_PORT, ring::to_string(tlsListenerPort_)}, + {Conf::CONFIG_TLS_LISTENER_PORT, jami::to_string(tlsListenerPort_)}, {Conf::CONFIG_TLS_CA_LIST_FILE, tlsCaListFile_}, {Conf::CONFIG_TLS_CERTIFICATE_FILE, tlsCertificateFile_}, {Conf::CONFIG_TLS_PRIVATE_KEY_FILE, tlsPrivateKeyFile_}, @@ -1700,11 +1700,11 @@ void SIPAccount::enablePresence(const bool& enabled) { if (!presence_) { - RING_ERR("Presence not initialized"); + JAMI_ERR("Presence not initialized"); return; } - RING_DBG("Presence enabled for %s : %s.", + JAMI_DBG("Presence enabled for %s : %s.", accountID_.c_str(), enabled? TRUE_STR : FALSE_STR); @@ -1719,14 +1719,14 @@ void SIPAccount::supportPresence(int function, bool enabled) { if (!presence_) { - RING_ERR("Presence not initialized"); + JAMI_ERR("Presence not initialized"); return; } if (presence_->isSupported(function) == enabled) return; - RING_DBG("Presence support for %s (%s: %s).", accountID_.c_str(), + JAMI_DBG("Presence support for %s (%s: %s).", accountID_.c_str(), function == PRESENCE_FUNCTION_PUBLISH ? "publish" : "subscribe", enabled ? TRUE_STR : FALSE_STR); presence_->support(function, enabled); @@ -1745,16 +1745,16 @@ MatchRank SIPAccount::matches(const std::string &userName, const std::string &server) const { if (fullMatch(userName, server)) { - RING_DBG("Matching account id in request is a fullmatch %s@%s", userName.c_str(), server.c_str()); + JAMI_DBG("Matching account id in request is a fullmatch %s@%s", userName.c_str(), server.c_str()); return MatchRank::FULL; } else if (hostnameMatch(server)) { - RING_DBG("Matching account id in request with hostname %s", server.c_str()); + JAMI_DBG("Matching account id in request with hostname %s", server.c_str()); return MatchRank::PARTIAL; } else if (userMatch(userName)) { - RING_DBG("Matching account id in request with username %s", userName.c_str()); + JAMI_DBG("Matching account id in request with username %s", userName.c_str()); return MatchRank::PARTIAL; } else if (proxyMatch(server)) { - RING_DBG("Matching account id in request with proxy %s", server.c_str()); + JAMI_DBG("Matching account id in request with proxy %s", server.c_str()); return MatchRank::PARTIAL; } else { return MatchRank::NONE; @@ -1893,7 +1893,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool) via_addrstr = IpAddr(via_addrstr).toString(false, true); #endif - RING_WARN("IP address change detected for account %s " + JAMI_WARN("IP address change detected for account %s " "(%.*s:%d --> %s:%d). Updating registration " "(using method %d)", accountID_.c_str(), @@ -1936,7 +1936,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool) rport, transport_param); if (len < 1) { - RING_ERR("URI too long"); + JAMI_ERR("URI too long"); return false; } @@ -1952,7 +1952,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool) tmp_tp = transport_; sendUnregister(); } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } // sendUnregister may failed and cause regc_ to be reset to nullptr @@ -1965,7 +1965,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool) try { sendRegister(); } catch (const VoipLinkException &e) { - RING_ERR("%s", e.what()); + JAMI_ERR("%s", e.what()); } } @@ -1988,7 +1988,7 @@ SIPAccount::autoReregTimerCb() try { sendRegister(); } catch (const VoipLinkException& e) { - RING_ERR("Exception during SIP registration: %s", e.what()); + JAMI_ERR("Exception during SIP registration: %s", e.what()); scheduleReregistration(); } } @@ -2033,7 +2033,7 @@ SIPAccount::scheduleReregistration() pj_time_val_normalize(&delay); - RING_WARN("Scheduling re-registration retry in %ld seconds..", delay.sec); + JAMI_WARN("Scheduling re-registration retry in %ld seconds..", delay.sec); auto_rereg_.timer.id = PJ_TRUE; if (pjsip_endpt_schedule_timer(link_->getEndpoint(), &auto_rereg_.timer, &delay) != PJ_SUCCESS) auto_rereg_.timer.id = PJ_FALSE; @@ -2067,7 +2067,7 @@ void SIPAccount::sendTextMessage(const std::string& to, const std::map<std::string, std::string>& payloads, uint64_t id) { if (to.empty() or payloads.empty()) { - RING_WARN("No sender or payload"); + JAMI_WARN("No sender or payload"); messageEngine_.onMessageSent(to, id, false); return; } @@ -2085,7 +2085,7 @@ SIPAccount::sendTextMessage(const std::string& to, const std::map<std::string, s &pjTo, &pjFrom, &pjTo, nullptr, nullptr, -1, nullptr, &tdata); if (status != PJ_SUCCESS) { - RING_ERR("Unable to create request: %s", sip_utils::sip_strerror(status).c_str()); + JAMI_ERR("Unable to create request: %s", sip_utils::sip_strerror(status).c_str()); messageEngine_.onMessageSent(to, id, false); return; } @@ -2114,13 +2114,13 @@ SIPAccount::sendTextMessage(const std::string& to, const std::map<std::string, s && e->body.tsx_state.tsx->status_code == PJSIP_SC_OK); } } catch (const std::exception& e) { - RING_ERR("Error calling message callback: %s", e.what()); + JAMI_ERR("Error calling message callback: %s", e.what()); } delete c; }); if (status != PJ_SUCCESS) { - RING_ERR("Unable to send request: %s", sip_utils::sip_strerror(status).c_str()); + JAMI_ERR("Unable to send request: %s", sip_utils::sip_strerror(status).c_str()); return; } } @@ -2131,4 +2131,4 @@ SIPAccount::getUserUri() const return getFromUri(); } -} // namespace ring +} // namespace jami diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index b8f9a81121..7e18ba6175 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -45,7 +45,7 @@ namespace YAML { class Emitter; } -namespace ring { +namespace jami { namespace Conf { const char *const KEEP_ALIVE_ENABLED = "keepAlive"; @@ -775,6 +775,6 @@ class SIPAccount : public SIPAccountBase { pj_uint16_t publishedPortUsed_ {sip_utils::DEFAULT_SIP_PORT}; }; -} // namespace ring +} // namespace jami #endif diff --git a/src/sip/sipaccountbase.cpp b/src/sip/sipaccountbase.cpp index 32d0cc482d..a6904ed3b5 100644 --- a/src/sip/sipaccountbase.cpp +++ b/src/sip/sipaccountbase.cpp @@ -22,7 +22,7 @@ #include "sipaccountbase.h" #include "sipvoiplink.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "libav_utils.h" #endif @@ -45,7 +45,7 @@ #include <ctime> #include <type_traits> -namespace ring { +namespace jami { SIPAccountBase::SIPAccountBase(const std::string& accountID) : Account(accountID), @@ -65,7 +65,7 @@ SIPAccountBase::CreateClientDialogAndInvite(const pj_str_t* from, pjsip_inv_session** inv) { if (pjsip_dlg_create_uac(pjsip_ua_instance(), from, contact, to, target, dlg) != PJ_SUCCESS) { - RING_ERR("Unable to create SIP dialogs for user agent client when calling %s", to->ptr); + JAMI_ERR("Unable to create SIP dialogs for user agent client when calling %s", to->ptr); return false; } @@ -84,7 +84,7 @@ SIPAccountBase::CreateClientDialogAndInvite(const pj_str_t* from, pj_list_push_back(&dialog->inv_hdr, subj_hdr); if (pjsip_inv_create_uac(dialog, local_sdp, 0, inv) != PJ_SUCCESS) { - RING_ERR("Unable to create invite session for user agent client"); + JAMI_ERR("Unable to create invite session for user agent client"); return false; } } @@ -110,7 +110,7 @@ validate(std::string &member, const std::string ¶m, const T& valid) if (find(begin, end, param) != end) member = param; else - RING_ERR("Invalid parameter \"%s\"", param.c_str()); + JAMI_ERR("Invalid parameter \"%s\"", param.c_str()); } static void @@ -137,8 +137,8 @@ addRangeToDetails(std::map<std::string, std::string> &a, const char *minKey, const char *maxKey, const std::pair<uint16_t, uint16_t> &range) { - a.emplace(minKey, ring::to_string(range.first)); - a.emplace(maxKey, ring::to_string(range.second)); + a.emplace(minKey, jami::to_string(range.first)); + a.emplace(maxKey, jami::to_string(range.second)); } void SIPAccountBase::serialize(YAML::Emitter &out) @@ -231,7 +231,7 @@ void SIPAccountBase::setAccountDetails(const std::map<std::string, std::string> int tmpMax = -1; parseInt(details, Conf::CONFIG_ACCOUNT_AUDIO_PORT_MAX, tmpMax); updateRange(tmpMin, tmpMax, audioPortRange_); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO tmpMin = -1; parseInt(details, Conf::CONFIG_ACCOUNT_VIDEO_PORT_MIN, tmpMin); tmpMax = -1; @@ -258,13 +258,13 @@ SIPAccountBase::getAccountDetails() const a.emplace(Conf::CONFIG_VIDEO_ENABLED, videoEnabled_ ? TRUE_STR : FALSE_STR); addRangeToDetails(a, Conf::CONFIG_ACCOUNT_AUDIO_PORT_MIN, Conf::CONFIG_ACCOUNT_AUDIO_PORT_MAX, audioPortRange_); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO addRangeToDetails(a, Conf::CONFIG_ACCOUNT_VIDEO_PORT_MIN, Conf::CONFIG_ACCOUNT_VIDEO_PORT_MAX, videoPortRange_); #endif a.emplace(Conf::CONFIG_ACCOUNT_DTMF_TYPE, dtmfType_); a.emplace(Conf::CONFIG_LOCAL_INTERFACE, interface_); - a.emplace(Conf::CONFIG_PUBLISHED_PORT, ring::to_string(publishedPort_)); + a.emplace(Conf::CONFIG_PUBLISHED_PORT, jami::to_string(publishedPort_)); a.emplace(Conf::CONFIG_PUBLISHED_SAMEAS_LOCAL, publishedSameasLocal_ ? TRUE_STR : FALSE_STR); a.emplace(Conf::CONFIG_PUBLISHED_ADDRESS, publishedIpAddress_); @@ -288,7 +288,7 @@ SIPAccountBase::getVolatileAccountDetails() const if (isIP2IP()) a[Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS] = "READY"; - a.emplace(Conf::CONFIG_TRANSPORT_STATE_CODE, ring::to_string(transportStatus_)); + a.emplace(Conf::CONFIG_TRANSPORT_STATE_CODE, jami::to_string(transportStatus_)); a.emplace(Conf::CONFIG_TRANSPORT_STATE_DESC, transportError_); return a; } @@ -356,7 +356,7 @@ SIPAccountBase::generateAudioPort() const return acquireRandomEvenPort(audioPortRange_); } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO uint16_t SIPAccountBase::generateVideoPort() const { @@ -385,7 +385,7 @@ void SIPAccountBase::onTextMessage(const std::string& from, const std::map<std::string, std::string>& payloads) { - RING_DBG("Text message received from %s, %zu part(s)", from.c_str(), payloads.size()); + JAMI_DBG("Text message received from %s, %zu part(s)", from.c_str(), payloads.size()); emitSignal<DRing::ConfigurationSignal::IncomingAccountMessage>(accountID_, from, payloads); DRing::Message message; message.from = from; @@ -403,8 +403,8 @@ SIPAccountBase::setPublishedAddress(const IpAddr& ip_addr) { publishedIp_ = ip_addr; publishedIpAddress_ = ip_addr.toString(); - RING_DBG("[Account %s] Using public address %s", getAccountID().c_str(), + JAMI_DBG("[Account %s] Using public address %s", getAccountID().c_str(), publishedIpAddress_.c_str()); } -} // namespace ring +} // namespace jami diff --git a/src/sip/sipaccountbase.h b/src/sip/sipaccountbase.h index 2ebcdbe8e0..6c8c8e7154 100644 --- a/src/sip/sipaccountbase.h +++ b/src/sip/sipaccountbase.h @@ -50,7 +50,7 @@ struct pjsip_dialog; struct pjsip_inv_session; struct pjmedia_sdp_session; -namespace ring { +namespace jami { namespace Conf { // SIP specific configuration keys @@ -237,7 +237,7 @@ public: * releasePort(). */ uint16_t generateAudioPort() const; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO uint16_t generateVideoPort() const; #endif static void releasePort(uint16_t port) noexcept; @@ -449,4 +449,4 @@ private: }; -} // namespace ring +} // namespace jami diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 360f72c5f8..1a50513eab 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -42,7 +42,7 @@ #include "ice_transport.h" #include "thread_pool.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "client/videomanager.h" #include "video/video_rtp_session.h" #include "dring/videomanager_interface.h" @@ -53,15 +53,15 @@ #include <opendht/crypto.h> -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO static DeviceParams getVideoSettings() { - const auto& videomon = ring::getVideoDeviceMonitor(); + const auto& videomon = jami::getVideoDeviceMonitor(); return videomon.getDeviceParams(videomon.getDefaultDevice()); } #endif @@ -85,7 +85,7 @@ SIPCall::SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType const std::map<std::string, std::string>& details) : Call(account, id, type, details) , avformatrtp_(new AudioRtpSession(id)) -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // The ID is used to associate video streams to calls , videortp_(new video::VideoRtpSession(id, getVideoSettings())) , mediaInput_(Manager::instance().getVideoManager().videoDeviceMonitor.getMRLForDefaultDevice()) @@ -115,7 +115,7 @@ void SIPCall::setCallMediaLocal() { if (localAudioPort_ == 0 -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO || localVideoPort_ == 0 #endif ) @@ -135,7 +135,7 @@ SIPCall::generateMediaPorts() localAudioPort_ = callLocalAudioPort; sdp_->setLocalPublishedAudioPort(callLocalAudioPort); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // https://projects.savoirfairelinux.com/issues/17498 const unsigned int callLocalVideoPort = account.generateVideoPort(); if (localVideoPort_ != 0) @@ -156,7 +156,7 @@ void SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) { if (isSecure() and t and not t->isSecure()) { - RING_ERR("Can't set unsecure transport to secure call."); + JAMI_ERR("Can't set unsecure transport to secure call."); return; } @@ -175,7 +175,7 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) if (auto this_ = wthis_.lock()) { // end the call if the SIP transport is shut down if (not SipTransport::isAlive(this_->transport_, state) and this_->getConnectionState() != ConnectionState::DISCONNECTED) { - RING_WARN("[call:%s] Ending call because underlying SIP transport was closed", + JAMI_WARN("[call:%s] Ending call because underlying SIP transport was closed", this_->getCallId().c_str()); this_->onFailure(ECONNRESET); } @@ -197,7 +197,7 @@ SIPCall::SIPSessionReinvite() if (not inv or inv->invite_tsx) return PJ_SUCCESS; - RING_DBG("[call:%s] Processing reINVITE (state=%s)", getCallId().c_str(), + JAMI_DBG("[call:%s] Processing reINVITE (state=%s)", getCallId().c_str(), pjsip_inv_state_name(inv->state)); // Generate new ports to receive the new media stream @@ -224,12 +224,12 @@ SIPCall::SIPSessionReinvite() result = pjsip_inv_send_msg(inv.get(), tdata); if (result == PJ_SUCCESS) return PJ_SUCCESS; - RING_ERR("[call:%s] Failed to send REINVITE msg (pjsip: %s)", getCallId().c_str(), + JAMI_ERR("[call:%s] Failed to send REINVITE msg (pjsip: %s)", getCallId().c_str(), sip_utils::sip_strerror(result).c_str()); // Canceling internals without sending (anyways the send has just failed!) pjsip_inv_cancel_reinvite(inv.get(), &tdata); } else - RING_ERR("[call:%s] Failed to create REINVITE msg (pjsip: %s)", getCallId().c_str(), + JAMI_ERR("[call:%s] Failed to create REINVITE msg (pjsip: %s)", getCallId().c_str(), sip_utils::sip_strerror(result).c_str()); return !PJ_SUCCESS; @@ -252,7 +252,7 @@ SIPCall::sendSIPInfo(const char *const body, const char *const subtype) pjsip_tx_data *tdata; if (pjsip_dlg_create_request(inv->dlg, &method, -1, &tdata) != PJ_SUCCESS) { - RING_ERR("[call:%s] Could not create dialog", getCallId().c_str()); + JAMI_ERR("[call:%s] Could not create dialog", getCallId().c_str()); return; } @@ -277,24 +277,24 @@ SIPCall::requestKeyframe() "<picture_fast_update/>" "</to_encoder></vc_primitive></media_control>"; - RING_DBG("Sending video keyframe request via SIP INFO"); + JAMI_DBG("Sending video keyframe request via SIP INFO"); try { sendSIPInfo(BODY, "media_control+xml"); } catch (const std::exception& e) { - RING_ERR("Error sending video keyframe request: %s", e.what()); + JAMI_ERR("Error sending video keyframe request: %s", e.what()); } } void SIPCall::updateSDPFromSTUN() { - RING_WARN("[call:%s] SIPCall::updateSDPFromSTUN() not implemented", getCallId().c_str()); + JAMI_WARN("[call:%s] SIPCall::updateSDPFromSTUN() not implemented", getCallId().c_str()); } void SIPCall::terminateSipSession(int status) { - RING_DBG("[call:%s] Terminate SIP session", getCallId().c_str()); + JAMI_DBG("[call:%s] Terminate SIP session", getCallId().c_str()); std::lock_guard<std::recursive_mutex> lk {callMutex_}; if (inv and inv->state != PJSIP_INV_STATE_DISCONNECTED) { pjsip_tx_data* tdata = nullptr; @@ -305,11 +305,11 @@ SIPCall::terminateSipSession(int status) sip_utils::addContactHeader(&contact, tdata); ret = pjsip_inv_send_msg(inv.get(), tdata); if (ret != PJ_SUCCESS) - RING_ERR("[call:%s] failed to send terminate msg, SIP error (%s)", + JAMI_ERR("[call:%s] failed to send terminate msg, SIP error (%s)", getCallId().c_str(), sip_utils::sip_strerror(ret).c_str()); } } else - RING_ERR("[call:%s] failed to terminate INVITE@%p, SIP error (%s)", + JAMI_ERR("[call:%s] failed to terminate INVITE@%p, SIP error (%s)", getCallId().c_str(), inv.get(), sip_utils::sip_strerror(ret).c_str()); } @@ -326,7 +326,7 @@ SIPCall::answer() throw VoipLinkException("[call:" + getCallId() + "] answer: no invite session for this call"); if (!inv->neg) { - RING_WARN("[call:%s] Negotiator is NULL, we've received an INVITE without an SDP", + JAMI_WARN("[call:%s] Negotiator is NULL, we've received an INVITE without an SDP", getCallId().c_str()); pjmedia_sdp_session *dummy = 0; getSIPVoIPLink()->createSDPOffer(inv.get(), &dummy); @@ -348,7 +348,7 @@ SIPCall::answer() // contactStr must stay in scope as long as tdata if (contactHeader_.slen) { - RING_DBG("[call:%s] Answering with contact header: %.*s", + JAMI_DBG("[call:%s] Answering with contact header: %.*s", getCallId().c_str(), (int)contactHeader_.slen, contactHeader_.ptr); sip_utils::addContactHeader(&contactHeader_, tdata); } @@ -372,7 +372,7 @@ SIPCall::hangup(int reason) int printed = pjsip_hdr_print_on(route, buf, sizeof(buf)); if (printed >= 0) { buf[printed] = '\0'; - RING_DBG("[call:%s] Route header %s", getCallId().c_str(), buf); + JAMI_DBG("[call:%s] Route header %s", getCallId().c_str(), buf); } route = route->next; } @@ -409,7 +409,7 @@ transfer_client_cb(pjsip_evsub *sub, pjsip_event *event) { auto link = getSIPVoIPLink(); if (not link) { - RING_ERR("no more VoIP link"); + JAMI_ERR("no more VoIP link"); return; } @@ -534,7 +534,7 @@ SIPCall::transfer(const std::string& to) toUri = account.getToUri(to); pj_cstr(&dst, toUri.c_str()); - RING_DBG("[call:%s] Transferring to %.*s", getCallId().c_str(), (int)dst.slen, dst.ptr); + JAMI_DBG("[call:%s] Transferring to %.*s", getCallId().c_str(), (int)dst.slen, dst.ptr); if (!transferCommon(&dst)) throw VoipLinkException("Couldn't transfer"); @@ -588,7 +588,7 @@ SIPCall::onhold() if (getConnectionState() == ConnectionState::CONNECTED) { if (SIPSessionReinvite() != PJ_SUCCESS) { - RING_WARN("[call:%s] Reinvite failed", getCallId().c_str()); + JAMI_WARN("[call:%s] Reinvite failed", getCallId().c_str()); return true; } } @@ -617,7 +617,7 @@ SIPCall::offhold() success = internalOffHold([] {}); } catch (const SdpException &e) { - RING_ERR("[call:%s] %s", getCallId().c_str(), e.what()); + JAMI_ERR("[call:%s] %s", getCallId().c_str(), e.what()); throw VoipLinkException("SDP issue in offhold"); } @@ -636,7 +636,7 @@ SIPCall::internalOffHold(const std::function<void()>& sdp_cb) if (getConnectionState() == ConnectionState::CONNECTED) { if (SIPSessionReinvite() != PJ_SUCCESS) { - RING_WARN("[call:%s] resuming hold", getCallId().c_str()); + JAMI_WARN("[call:%s] resuming hold", getCallId().c_str()); onhold(); return false; } @@ -667,7 +667,7 @@ SIPCall::peerHungup() if (inv) terminateSipSession(PJSIP_SC_NOT_FOUND); else - RING_ERR("[call:%s] peerHungup: no invite session for this call", getCallId().c_str()); + JAMI_ERR("[call:%s] peerHungup: no invite session for this call", getCallId().c_str()); Call::peerHungup(); } @@ -688,7 +688,7 @@ SIPCall::carryingDTMFdigits(char code) try { sendSIPInfo(dtmf_body, "dtmf-relay"); } catch (const std::exception& e) { - RING_ERR("Error sending DTMF: %s", e.what()); + JAMI_ERR("Error sending DTMF: %s", e.what()); } } @@ -701,7 +701,7 @@ SIPCall::setVideoOrientation(int rotation) "<device_orientation=" + std::to_string(rotation) + "/>" "</to_encoder></vc_primitive></media_control>"; - RING_DBG("Sending device orientation via SIP INFO"); + JAMI_DBG("Sending device orientation via SIP INFO"); sendSIPInfo(sip_body.c_str(), "media_control+xml"); } @@ -724,7 +724,7 @@ SIPCall::sendTextMessage(const std::map<std::string, std::string>& messages, } catch (...) {} } else { pendingOutMessages_.emplace_back(messages, from); - RING_ERR("[call:%s] sendTextMessage: no invite session for this call", getCallId().c_str()); + JAMI_ERR("[call:%s] sendTextMessage: no invite session for this call", getCallId().c_str()); } } } @@ -733,7 +733,7 @@ void SIPCall::removeCall() { std::lock_guard<std::recursive_mutex> lk {callMutex_}; - RING_WARN("[call:%s] removeCall()", getCallId().c_str()); + JAMI_WARN("[call:%s] removeCall()", getCallId().c_str()); Call::removeCall(); mediaTransport_.reset(); inv.reset(); @@ -786,7 +786,7 @@ SIPCall::onClosed() void SIPCall::onAnswered() { - RING_WARN("[call:%s] onAnswered()", getCallId().c_str()); + JAMI_WARN("[call:%s] onAnswered()", getCallId().c_str()); if (getConnectionState() != ConnectionState::CONNECTED) { setState(CallState::ACTIVE, ConnectionState::CONNECTED); if (not isSubcall()) { @@ -802,10 +802,10 @@ SIPCall::onAnswered() void SIPCall::sendKeyframe() { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO ThreadPool::instance().run([w = weak()] { if (auto sthis = w.lock()) { - RING_DBG("handling picture fast update request"); + JAMI_DBG("handling picture fast update request"); sthis->getVideoRtp().forceKeyFrame(); } }); @@ -824,13 +824,13 @@ SIPCall::setupLocalSDPFromIce() auto media_tr = getIceMediaTransport(); if (not media_tr) { - RING_WARN("[call:%s] no media ICE transport, SDP not changed", getCallId().c_str()); + JAMI_WARN("[call:%s] no media ICE transport, SDP not changed", getCallId().c_str()); return; } // we need an initialized ICE to progress further if (media_tr->waitForInitialization(DEFAULT_ICE_INIT_TIMEOUT) <= 0) { - RING_ERR("[call:%s] Medias' ICE init failed", getCallId().c_str()); + JAMI_ERR("[call:%s] Medias' ICE init failed", getCallId().c_str()); return; } @@ -839,13 +839,13 @@ SIPCall::setupLocalSDPFromIce() media_tr->registerPublicIP(compId, ip); } - RING_WARN("[call:%s] fill SDP with ICE transport %p", getCallId().c_str(), media_tr); + JAMI_WARN("[call:%s] fill SDP with ICE transport %p", getCallId().c_str(), media_tr); sdp_->addIceAttributes(media_tr->getLocalAttributes()); // Add video and audio channels sdp_->addIceCandidates(SDP_AUDIO_MEDIA_ID, media_tr->getLocalCandidates(ICE_AUDIO_RTP_COMPID)); sdp_->addIceCandidates(SDP_AUDIO_MEDIA_ID, media_tr->getLocalCandidates(ICE_AUDIO_RTCP_COMPID)); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO sdp_->addIceCandidates(SDP_VIDEO_MEDIA_ID, media_tr->getLocalCandidates(ICE_VIDEO_RTP_COMPID)); sdp_->addIceCandidates(SDP_VIDEO_MEDIA_ID, media_tr->getLocalCandidates(ICE_VIDEO_RTCP_COMPID)); #endif @@ -862,14 +862,14 @@ SIPCall::getAllRemoteCandidates() IceCandidate cand; for (auto& line : sdp_->getIceCandidates(sdpMediaId)) { if (media_tr->getCandidateFromSDP(line, cand)) { - RING_DBG("[call:%s] add remote ICE candidate: %s", getCallId().c_str(), line.c_str()); + JAMI_DBG("[call:%s] add remote ICE candidate: %s", getCallId().c_str(), line.c_str()); out.emplace_back(cand); } } }; addSDPCandidates(SDP_AUDIO_MEDIA_ID, rem_candidates); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO addSDPCandidates(SDP_VIDEO_MEDIA_ID, rem_candidates); #endif @@ -879,7 +879,7 @@ SIPCall::getAllRemoteCandidates() bool SIPCall::useVideoCodec(const AccountVideoCodecInfo* codec) const { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (videortp_->isSending()) return videortp_->useCodec(codec); #endif @@ -889,9 +889,9 @@ SIPCall::useVideoCodec(const AccountVideoCodecInfo* codec) const void SIPCall::startAllMedia() { - RING_WARN("[call:%s] startAllMedia()", getCallId().c_str()); + JAMI_WARN("[call:%s] startAllMedia()", getCallId().c_str()); if (isSecure() && not transport_->isSecure()) { - RING_ERR("[call:%s] Can't perform secure call over insecure SIP transport", + JAMI_ERR("[call:%s] Can't perform secure call over insecure SIP transport", getCallId().c_str()); onFailure(EPROTONOSUPPORT); return; @@ -901,7 +901,7 @@ SIPCall::startAllMedia() bool peer_holding {true}; int slotN = -1; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videortp_->setRequestKeyFrameCallback([wthis = weak()] { runOnMainThread([wthis] { if (auto this_ = wthis.lock()) @@ -922,14 +922,14 @@ SIPCall::startAllMedia() const auto& remote = slot.second; if (local.type != remote.type) { - RING_ERR("[call:%s] [SDP:slot#%u] Inconsistent media types between local and remote", + JAMI_ERR("[call:%s] [SDP:slot#%u] Inconsistent media types between local and remote", getCallId().c_str(), slotN); continue; } RtpSession* rtp = local.type == MEDIA_AUDIO ? static_cast<RtpSession*>(avformatrtp_.get()) -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO : static_cast<RtpSession*>(videortp_.get()); #else : nullptr; @@ -939,12 +939,12 @@ SIPCall::startAllMedia() continue; if (!local.codec) { - RING_WARN("[call:%s] [SDP:slot#%u] Missing local codec", getCallId().c_str(), + JAMI_WARN("[call:%s] [SDP:slot#%u] Missing local codec", getCallId().c_str(), slotN); continue; } if (!remote.codec) { - RING_WARN("[call:%s] [SDP:slot#%u] Missing remote codec", getCallId().c_str(), + JAMI_WARN("[call:%s] [SDP:slot#%u] Missing remote codec", getCallId().c_str(), slotN); continue; } @@ -952,7 +952,7 @@ SIPCall::startAllMedia() peer_holding &= remote.holding; if (isSecure() && (not local.crypto || not remote.crypto)) { - RING_ERR("[call:%s] [SDP:slot#%u] Can't perform secure call over insecure RTP transport", + JAMI_ERR("[call:%s] [SDP:slot#%u] Can't perform secure call over insecure RTP transport", getCallId().c_str(), slotN); continue; } @@ -962,7 +962,7 @@ SIPCall::startAllMedia() avformatrtp_->switchInput(mediaInput_); avformatrtp_->setMtu(new_mtu); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (local.type & MEDIA_VIDEO) videortp_->switchInput(mediaInput_); videortp_->setMtu(new_mtu); @@ -981,7 +981,7 @@ SIPCall::startAllMedia() } switch (local.type) { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO case MEDIA_VIDEO: isVideoMuted_ = mediaInput_.empty(); break; @@ -1021,9 +1021,9 @@ SIPCall::startAllMedia() void SIPCall::restartMediaSender() { - RING_DBG("[call:%s] restarting TX media streams", getCallId().c_str()); + JAMI_DBG("[call:%s] restarting TX media streams", getCallId().c_str()); avformatrtp_->restartSender(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videortp_->restartSender(); #endif } @@ -1031,11 +1031,11 @@ SIPCall::restartMediaSender() void SIPCall::stopAllMedia() { - RING_DBG("[call:%s] stopping all medias", getCallId().c_str()); + JAMI_DBG("[call:%s] stopping all medias", getCallId().c_str()); if (Recordable::isRecording()) Recordable::stopRecording(); // if call stops, finish recording avformatrtp_->stop(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO videortp_->stop(); #endif } @@ -1044,9 +1044,9 @@ void SIPCall::muteMedia(const std::string& mediaType, bool mute) { if (mediaType.compare(DRing::Media::Details::MEDIA_TYPE_VIDEO) == 0) { -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (mute == isVideoMuted_) return; - RING_WARN("[call:%s] video muting %s", getCallId().c_str(), bool_to_str(mute)); + JAMI_WARN("[call:%s] video muting %s", getCallId().c_str(), bool_to_str(mute)); isVideoMuted_ = mute; mediaInput_ = isVideoMuted_ ? "" : Manager::instance().getVideoManager().videoDeviceMonitor.getMRLForDefaultDevice(); DRing::switchInput(getCallId(), mediaInput_); @@ -1055,7 +1055,7 @@ SIPCall::muteMedia(const std::string& mediaType, bool mute) #endif } else if (mediaType.compare(DRing::Media::Details::MEDIA_TYPE_AUDIO) == 0) { if (mute == isAudioMuted_) return; - RING_WARN("[call:%s] audio muting %s", getCallId().c_str(), bool_to_str(mute)); + JAMI_WARN("[call:%s] audio muting %s", getCallId().c_str(), bool_to_str(mute)); isAudioMuted_ = mute; avformatrtp_->setMuted(isAudioMuted_); if (not isSubcall()) @@ -1072,12 +1072,12 @@ SIPCall::muteMedia(const std::string& mediaType, bool mute) void SIPCall::onMediaUpdate() { - RING_WARN("[call:%s] medias changed", getCallId().c_str()); + JAMI_WARN("[call:%s] medias changed", getCallId().c_str()); // If ICE is not used, start medias now auto rem_ice_attrs = sdp_->getIceAttributes(); if (rem_ice_attrs.ufrag.empty() or rem_ice_attrs.pwd.empty()) { - RING_WARN("[call:%s] no remote ICE for medias", getCallId().c_str()); + JAMI_WARN("[call:%s] no remote ICE for medias", getCallId().c_str()); stopAllMedia(); startAllMedia(); return; @@ -1100,7 +1100,7 @@ SIPCall::waitForIceAndStartMedia() auto ice = call->getIceMediaTransport(); if (ice->isFailed()) { - RING_ERR("[call:%s] Media ICE init failed", call->getCallId().c_str()); + JAMI_ERR("[call:%s] Media ICE init failed", call->getCallId().c_str()); call->onFailure(EIO); return false; } @@ -1111,12 +1111,12 @@ SIPCall::waitForIceAndStartMedia() // Start transport on SDP data and wait for negotiation auto rem_ice_attrs = call->sdp_->getIceAttributes(); if (rem_ice_attrs.ufrag.empty() or rem_ice_attrs.pwd.empty()) { - RING_ERR("[call:%s] Media ICE attributes empty", call->getCallId().c_str()); + JAMI_ERR("[call:%s] Media ICE attributes empty", call->getCallId().c_str()); call->onFailure(EIO); return false; } if (not ice->start(rem_ice_attrs, call->getAllRemoteCandidates())) { - RING_ERR("[call:%s] Media ICE start failed", call->getCallId().c_str()); + JAMI_ERR("[call:%s] Media ICE start failed", call->getCallId().c_str()); call->onFailure(EIO); return false; } @@ -1127,7 +1127,7 @@ SIPCall::waitForIceAndStartMedia() auto ice = call->getIceMediaTransport(); if (ice->isFailed()) { - RING_ERR("[call:%s] Media ICE negotiation failed", call->getCallId().c_str()); + JAMI_ERR("[call:%s] Media ICE negotiation failed", call->getCallId().c_str()); call->onFailure(EIO); return false; } @@ -1179,7 +1179,7 @@ SIPCall::openPortsUPnP() * the newly selected port should possibly be checked against the list of used ports and marked * as used, the old port should be "released" */ - RING_DBG("[call:%s] opening ports via UPNP for SDP session", getCallId().c_str()); + JAMI_DBG("[call:%s] opening ports via UPNP for SDP session", getCallId().c_str()); uint16_t audio_port_used; if (upnp_->addAnyMapping(sdp_->getLocalAudioPort(), upnp::PortType::UDP, true, &audio_port_used)) { uint16_t control_port_used; @@ -1187,7 +1187,7 @@ SIPCall::openPortsUPnP() sdp_->setLocalPublishedAudioPorts(audio_port_used, control_port_used); } } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO uint16_t video_port_used; if (upnp_->addAnyMapping(sdp_->getLocalVideoPort(), upnp::PortType::UDP, true, &video_port_used)) { uint16_t control_port_used; @@ -1208,7 +1208,7 @@ SIPCall::getDetails() const auto& acc = getSIPAccount(); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO // If Video is not enabled return an empty string details.emplace(DRing::Call::Details::VIDEO_SOURCE, acc.isVideoEnabled() ? mediaInput_ : ""); #endif @@ -1234,7 +1234,7 @@ SIPCall::getDetails() const ca = ca->issuer; } details.emplace(DRing::TlsTransport::TLS_PEER_CA_NUM, - ring::to_string(n)); + jami::to_string(n)); } else { details.emplace(DRing::TlsTransport::TLS_PEER_CERT, ""); details.emplace(DRing::TlsTransport::TLS_PEER_CA_NUM, ""); @@ -1254,14 +1254,14 @@ SIPCall::toggleRecording() recorder_->setMetadata(ss.str(), ""); // use default description if (avformatrtp_) avformatrtp_->initRecorder(recorder_); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (!isAudioOnly_ && videortp_) videortp_->initRecorder(recorder_); #endif } else { if (avformatrtp_) avformatrtp_->deinitRecorder(recorder_); -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO if (!isAudioOnly_ && videortp_) videortp_->deinitRecorder(recorder_); #endif @@ -1284,14 +1284,14 @@ void SIPCall::InvSessionDeleter::operator ()(pjsip_inv_session* inv) const noexcept { // prevent this from getting accessed in callbacks - // RING_WARN: this is not thread-safe! + // JAMI_WARN: this is not thread-safe! inv->mod_data[getSIPVoIPLink()->getModId()] = nullptr; } bool SIPCall::initIceMediaTransport(bool master, unsigned channel_num) { - RING_DBG("[call:%s] create media ICE transport", getCallId().c_str()); + JAMI_DBG("[call:%s] create media ICE transport", getCallId().c_str()); auto& iceTransportFactory = Manager::instance().getIceTransportFactory(); tmpMediaTransport_ = iceTransportFactory.createTransport(getCallId().c_str(), @@ -1303,7 +1303,7 @@ SIPCall::initIceMediaTransport(bool master, unsigned channel_num) void SIPCall::merge(Call& call) { - RING_DBG("[sipcall:%s] merge subcall %s", getCallId().c_str(), call.getCallId().c_str()); + JAMI_DBG("[sipcall:%s] merge subcall %s", getCallId().c_str(), call.getCallId().c_str()); // This static cast is safe as this method is private and overload Call::merge auto& subcall = static_cast<SIPCall&>(call); @@ -1335,7 +1335,7 @@ SIPCall::setRemoteSdp(const pjmedia_sdp_session* sdp) // If ICE is not used, start medias now auto rem_ice_attrs = sdp_->getIceAttributes(); if (rem_ice_attrs.ufrag.empty() or rem_ice_attrs.pwd.empty()) { - RING_WARN("[call:%s] no ICE data in remote SDP", getCallId().c_str()); + JAMI_WARN("[call:%s] no ICE data in remote SDP", getCallId().c_str()); return; } @@ -1363,4 +1363,4 @@ SIPCall::newIceSocket(unsigned compId) return std::unique_ptr<IceSocket> {new IceSocket(mediaTransport_, compId)}; } -} // namespace ring +} // namespace jami diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index afbdc60f93..6e9a468120 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -30,7 +30,7 @@ #include "call.h" #include "sip_utils.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "media/video/video_rtp_session.h" #endif @@ -45,7 +45,7 @@ struct pjsip_inv_session; struct pjmedia_sdp_session; struct pj_ice_sess_cand; -namespace ring { +namespace jami { class Sdp; class SIPAccountBase; @@ -200,7 +200,7 @@ public: // NOT SIP RELATED (good candidates to be moved elsewhere) return *avformatrtp_; } -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /** * Returns a pointer to the VideoRtp object */ @@ -274,7 +274,7 @@ private: std::unique_ptr<AudioRtpSession> avformatrtp_; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO /** * Video Rtp Session factory */ @@ -312,7 +312,7 @@ private: char contactBuffer_[PJSIP_MAX_URL_SIZE] {}; pj_str_t contactHeader_ {contactBuffer_, 0}; - std::unique_ptr<ring::upnp::Controller> upnp_; + std::unique_ptr<jami::upnp::Controller> upnp_; /** Local audio port, as seen by me. */ unsigned int localAudioPort_ {0}; @@ -339,4 +339,4 @@ inline std::shared_ptr<SIPCall> getPtr(SIPCall& call) return std::static_pointer_cast<SIPCall>(call.shared_from_this()); } -} // namespace ring +} // namespace jami diff --git a/src/sip/sippresence.cpp b/src/sip/sippresence.cpp index adda994975..f2b9c72246 100644 --- a/src/sip/sippresence.cpp +++ b/src/sip/sippresence.cpp @@ -38,7 +38,7 @@ #define MAX_N_SUB_SERVER 50 #define MAX_N_SUB_CLIENT 50 -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -142,7 +142,7 @@ void SIPPresence::updateStatus(bool status, const std::string ¬e) rpid.activity = PJRPID_ACTIVITY_BUSY; /* else // TODO: is there any other possibilities - RING_DBG("Presence : no activity"); + JAMI_DBG("Presence : no activity"); */ pj_bzero(&status_data_, sizeof(status_data_)); @@ -178,7 +178,7 @@ void SIPPresence::reportPresSubClientNotification(const std::string& uri, pjsip_ const std::string acc_ID = acc_->getAccountID(); const std::string basic(status->info[0].basic_open ? "open" : "closed"); const std::string note(status->info[0].rpid.note.ptr, status->info[0].rpid.note.slen); - RING_DBG(" Received status of PresSubClient %s(acc:%s): status=%s note=%s", uri.c_str(), acc_ID.c_str(), basic.c_str(), note.c_str()); + JAMI_DBG(" Received status of PresSubClient %s(acc:%s): status=%s note=%s", uri.c_str(), acc_ID.c_str(), basic.c_str(), note.c_str()); if (uri == acc_->getFromUri()) { // save the status of our own account @@ -204,7 +204,7 @@ void SIPPresence::subscribeClient(const std::string& uri, bool flag) /* Check if the buddy was already subscribed */ for (const auto & c : sub_client_list_) { if (c->getURI() == uri) { - //RING_DBG("-PresSubClient:%s exists in the list. Replace it.", uri.c_str()); + //JAMI_DBG("-PresSubClient:%s exists in the list. Replace it.", uri.c_str()); if (flag) c->subscribe(); else @@ -214,14 +214,14 @@ void SIPPresence::subscribeClient(const std::string& uri, bool flag) } if (sub_client_list_.size() >= MAX_N_SUB_CLIENT) { - RING_WARN("Can't add PresSubClient, max number reached."); + JAMI_WARN("Can't add PresSubClient, max number reached."); return; } if (flag) { PresSubClient *c = new PresSubClient(uri, this); if (!(c->subscribe())) { - RING_WARN("Failed send subscribe."); + JAMI_WARN("Failed send subscribe."); delete c; } // the buddy has to be accepted before being added in the list @@ -232,16 +232,16 @@ void SIPPresence::addPresSubClient(PresSubClient *c) { if (sub_client_list_.size() < MAX_N_SUB_CLIENT) { sub_client_list_.push_back(c); - RING_DBG("New Presence_subscription_client added (list[%zu]).", sub_client_list_.size()); + JAMI_DBG("New Presence_subscription_client added (list[%zu]).", sub_client_list_.size()); } else { - RING_WARN("Max Presence_subscription_client is reach."); + JAMI_WARN("Max Presence_subscription_client is reach."); // let the client alive //delete c; } } void SIPPresence::removePresSubClient(PresSubClient *c) { - RING_DBG("Remove Presence_subscription_client from the buddy list."); + JAMI_DBG("Remove Presence_subscription_client from the buddy list."); sub_client_list_.remove(c); } @@ -261,7 +261,7 @@ void SIPPresence::addPresSubServer(PresSubServer *s) if (sub_server_list_.size() < MAX_N_SUB_SERVER) { sub_server_list_.push_back(s); } else { - RING_WARN("Max Presence_subscription_server is reach."); + JAMI_WARN("Max Presence_subscription_server is reach."); // let de server alive // delete s; } } @@ -269,12 +269,12 @@ void SIPPresence::addPresSubServer(PresSubServer *s) void SIPPresence::removePresSubServer(PresSubServer *s) { sub_server_list_.remove(s); - RING_DBG("Presence_subscription_server removed"); + JAMI_DBG("Presence_subscription_server removed"); } void SIPPresence::notifyPresSubServer() { - RING_DBG("Iterating through IP2IP Presence_subscription_server:"); + JAMI_DBG("Iterating through IP2IP Presence_subscription_server:"); for (const auto & s : sub_server_list_) s->notify(); @@ -315,7 +315,7 @@ void SIPPresence::fillDoc(pjsip_tx_data *tdata, const pres_msg_data *msg_data) while (hdr && hdr != &msg_data->hdr_list) { pjsip_hdr *new_hdr; new_hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, hdr); - RING_DBG("adding header %p", new_hdr->name.ptr); + JAMI_DBG("adding header %p", new_hdr->name.ptr); pjsip_msg_add_hdr(tdata->msg, new_hdr); hdr = hdr->next; } @@ -350,7 +350,7 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param) if (param->status != PJ_SUCCESS) { char errmsg[PJ_ERR_MSG_SIZE]; pj_strerror(param->status, errmsg, sizeof(errmsg)); - RING_ERR("Client (PUBLISH) failed, status=%d, msg=%s", param->status, errmsg); + JAMI_ERR("Client (PUBLISH) failed, status=%d, msg=%s", param->status, errmsg); emitSignal<DRing::PresenceSignal::ServerError>( pres->getAccount()->getAccountID(), error, @@ -360,10 +360,10 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param) /* 412 (Conditional Request Failed) * The PUBLISH refresh has failed, retry with new one. */ - RING_WARN("Publish retry."); + JAMI_WARN("Publish retry."); publish(pres); } else if ((param->code == PJSIP_SC_BAD_EVENT) || (param->code == PJSIP_SC_NOT_IMPLEMENTED)){ //489 or 501 - RING_WARN("Client (PUBLISH) failed (%s)",error.c_str()); + JAMI_WARN("Client (PUBLISH) failed (%s)",error.c_str()); emitSignal<DRing::PresenceSignal::ServerError>( pres->getAccount()->getAccountID(), @@ -395,7 +395,7 @@ SIPPresence::send_publish(SIPPresence * pres) pjsip_tx_data *tdata; pj_status_t status; - RING_DBG("Send PUBLISH (%s).", pres->getAccount()->getAccountID().c_str()); + JAMI_DBG("Send PUBLISH (%s).", pres->getAccount()->getAccountID().c_str()); SIPAccount * acc = pres->getAccount(); std::string contactWithAngles = acc->getFromUri(); @@ -413,7 +413,7 @@ SIPPresence::send_publish(SIPPresence * pres) pj_str_t from = pj_strdup3(pres->pool_, acc->getFromUri().c_str()); if (status != PJ_SUCCESS) { - RING_ERR("Error creating PUBLISH request %d", status); + JAMI_ERR("Error creating PUBLISH request %d", status); goto on_error; } @@ -421,7 +421,7 @@ SIPPresence::send_publish(SIPPresence * pres) char *epos = pj_strchr(&from, '>'); if (epos - bpos < 2) { - RING_ERR("Unexpected invalid URI"); + JAMI_ERR("Unexpected invalid URI"); status = PJSIP_EINVALIDURI; goto on_error; } @@ -439,7 +439,7 @@ SIPPresence::send_publish(SIPPresence * pres) pres_msg_data msg_data; if (status != PJ_SUCCESS) { - RING_ERR("Error creating PIDF for PUBLISH request"); + JAMI_ERR("Error creating PIDF for PUBLISH request"); pjsip_tx_data_dec_ref(tdata); goto on_error; } @@ -455,9 +455,9 @@ SIPPresence::send_publish(SIPPresence * pres) status = pjsip_publishc_send(pres->publish_sess_, tdata); if (status == PJ_EPENDING) { - RING_WARN("Previous request is in progress, "); + JAMI_WARN("Previous request is in progress, "); } else if (status != PJ_SUCCESS) { - RING_ERR("Error sending PUBLISH request"); + JAMI_ERR("Error sending PUBLISH request"); goto on_error; } @@ -492,7 +492,7 @@ SIPPresence::publish(SIPPresence *pres) if (status != PJ_SUCCESS) { pres->publish_sess_ = NULL; - RING_ERR("Failed to create a publish seesion."); + JAMI_ERR("Failed to create a publish seesion."); return status; } @@ -501,14 +501,14 @@ SIPPresence::publish(SIPPresence *pres) status = pjsip_publishc_init(pres->publish_sess_, &STR_PRESENCE, &from, &from, &from, 0xFFFF); if (status != PJ_SUCCESS) { - RING_ERR("Failed to init a publish session"); + JAMI_ERR("Failed to init a publish session"); pres->publish_sess_ = NULL; return status; } /* Add credential for authentication */ if (acc->hasCredentials() and pjsip_publishc_set_credentials(pres->publish_sess_, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) { - RING_ERR("Could not initialize credentials for invite session authentication"); + JAMI_ERR("Could not initialize credentials for invite session authentication"); return status; } @@ -527,4 +527,4 @@ SIPPresence::publish(SIPPresence *pres) return PJ_SUCCESS; } -} // namespace ring +} // namespace jami diff --git a/src/sip/sippresence.h b/src/sip/sippresence.h index 8b27a1926a..19f9ac23c8 100644 --- a/src/sip/sippresence.h +++ b/src/sip/sippresence.h @@ -44,7 +44,7 @@ */ struct pj_caching_pool; -namespace ring { +namespace jami { struct pres_msg_data { /** @@ -242,6 +242,6 @@ class SIPPresence { pj_pool_t *pool_; }; -} // namespace ring +} // namespace jami #endif diff --git a/src/sip/siptransport.cpp b/src/sip/siptransport.cpp index 53838eba7f..8883983e64 100644 --- a/src/sip/siptransport.cpp +++ b/src/sip/siptransport.cpp @@ -46,9 +46,9 @@ #include <sstream> #include <algorithm> -#define RETURN_IF_FAIL(A, VAL, ...) if (!(A)) { RING_ERR(__VA_ARGS__); return (VAL); } +#define RETURN_IF_FAIL(A, VAL, ...) if (!(A)) { JAMI_ERR(__VA_ARGS__); return (VAL); } -namespace ring { +namespace jami { constexpr const char* TRANSPORT_STATE_STR[] = { "CONNECTED", "DISCONNECTED", "SHUTDOWN", "DESTROY", "UNKNOWN STATE" @@ -78,7 +78,7 @@ SipTransport::SipTransport(pjsip_transport* t) // Set pointer here, right after the successful pjsip_transport_add_ref transport_.reset(t); - RING_DBG("SipTransport@%p {tr=%p {rc=%ld}}", + JAMI_DBG("SipTransport@%p {tr=%p {rc=%ld}}", this, transport_.get(), pj_atomic_get(transport_->ref_cnt)); } @@ -91,7 +91,7 @@ SipTransport::SipTransport(pjsip_transport* t, SipTransport::~SipTransport() { - RING_DBG("~SipTransport@%p {tr=%p {rc=%ld}}", + JAMI_DBG("~SipTransport@%p {tr=%p {rc=%ld}}", this, transport_.get(), pj_atomic_get(transport_->ref_cnt)); } @@ -198,19 +198,19 @@ cp_(cp), pool_(pool), endpt_(endpt) pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP), &ice_pj_transport_type_); */ - RING_DBG("SipTransportBroker@%p", this); + JAMI_DBG("SipTransportBroker@%p", this); } SipTransportBroker::~SipTransportBroker() { - RING_DBG("~SipTransportBroker@%p", this); + JAMI_DBG("~SipTransportBroker@%p", this); shutdown(); udpTransports_.clear(); transports_.clear(); - RING_DBG("destroying SipTransportBroker@%p", this); + JAMI_DBG("destroying SipTransportBroker@%p", this); } void @@ -218,7 +218,7 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp, pjsip_transport_state state, const pjsip_transport_state_info* info) { - RING_DBG("pjsip transport@%p %s -> %s", + JAMI_DBG("pjsip transport@%p %s -> %s", tp, tp->info, SipTransport::stateToStr(state)); // First make sure that this transport is handled by us @@ -230,7 +230,7 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp, std::lock_guard<std::mutex> lock(transportMapMutex_); auto key = transports_.find(tp); if (key == transports_.end()) { - RING_WARN("spurious pjsip transport state change"); + JAMI_WARN("spurious pjsip transport state change"); return; } @@ -244,7 +244,7 @@ SipTransportBroker::transportStateChanged(pjsip_transport* tp, // maps cleanup if (destroyed) { - RING_DBG("unmap pjsip transport@%p {SipTransport@%p}", + JAMI_DBG("unmap pjsip transport@%p {SipTransport@%p}", tp, sipTransport.get()); transports_.erase(key); @@ -311,18 +311,18 @@ SipTransportBroker::getUdpTransport(const SipTransportDescr& descr) auto it = transports_.find(itp->second); if (it != transports_.end()) { if (auto spt = it->second.lock()) { - RING_DBG("Reusing transport %s", descr.toString().c_str()); + JAMI_DBG("Reusing transport %s", descr.toString().c_str()); return spt; } else { // Transport still exists but have not been destroyed yet. - RING_WARN("Recycling transport %s", descr.toString().c_str()); + JAMI_WARN("Recycling transport %s", descr.toString().c_str()); auto ret = std::make_shared<SipTransport>(itp->second); it->second = ret; return ret; } } else { - RING_WARN("Cleaning up UDP transport %s", descr.toString().c_str()); + JAMI_WARN("Cleaning up UDP transport %s", descr.toString().c_str()); udpTransports_.erase(itp); } } @@ -351,15 +351,15 @@ SipTransportBroker::createUdpTransport(const SipTransportDescr& d) pj_cfg.bind_addr = listeningAddress; pjsip_transport *transport = nullptr; if (pj_status_t status = pjsip_udp_transport_start2(endpt_, &pj_cfg, &transport)) { - RING_ERR("pjsip_udp_transport_start2 failed with error %d: %s", status, + JAMI_ERR("pjsip_udp_transport_start2 failed with error %d: %s", status, sip_utils::sip_strerror(status).c_str()); - RING_ERR("UDP IPv%s Transport did not start on %s", + JAMI_ERR("UDP IPv%s Transport did not start on %s", listeningAddress.isIpv4() ? "4" : "6", listeningAddress.toString(true).c_str()); return nullptr; } - RING_DBG("Created UDP transport on %s : %s", d.interface.c_str(), listeningAddress.toString(true).c_str()); + JAMI_DBG("Created UDP transport on %s : %s", d.interface.c_str(), listeningAddress.toString(true).c_str()); return std::make_shared<SipTransport>(transport); } @@ -375,19 +375,19 @@ SipTransportBroker::getTlsListener(const SipTransportDescr& d, const pjsip_tls_s listeningAddress.setPort(d.listenerPort); RETURN_IF_FAIL(listeningAddress, nullptr, "Could not determine IP address for this transport"); - RING_DBG("Creating TLS listener %s on %s...", d.toString().c_str(), listeningAddress.toString(true).c_str()); + JAMI_DBG("Creating TLS listener %s on %s...", d.toString().c_str(), listeningAddress.toString(true).c_str()); #if 0 - RING_DBG(" ca_list_file : %s", settings->ca_list_file.ptr); - RING_DBG(" cert_file : %s", settings->cert_file.ptr); - RING_DBG(" ciphers_num : %d", settings->ciphers_num); - RING_DBG(" verify server %d client %d client_cert %d", settings->verify_server, settings->verify_client, settings->require_client_cert); - RING_DBG(" reuse_addr : %d", settings->reuse_addr); + JAMI_DBG(" ca_list_file : %s", settings->ca_list_file.ptr); + JAMI_DBG(" cert_file : %s", settings->cert_file.ptr); + JAMI_DBG(" ciphers_num : %d", settings->ciphers_num); + JAMI_DBG(" verify server %d client %d client_cert %d", settings->verify_server, settings->verify_client, settings->require_client_cert); + JAMI_DBG(" reuse_addr : %d", settings->reuse_addr); #endif pjsip_tpfactory *listener = nullptr; const pj_status_t status = pjsip_tls_transport_start2(endpt_, settings, listeningAddress.pjPtr(), nullptr, 1, &listener); if (status != PJ_SUCCESS) { - RING_ERR("TLS listener did not start: %s", sip_utils::sip_strerror(status).c_str()); + JAMI_ERR("TLS listener did not start: %s", sip_utils::sip_strerror(status).c_str()); return nullptr; } return std::make_shared<TlsListener>(listener); @@ -402,7 +402,7 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const if (remoteAddr.getPort() == 0) remoteAddr.setPort(pjsip_transport_get_default_port_for_type(l->get()->type)); - RING_DBG("Get new TLS transport to %s", remoteAddr.toString(true).c_str()); + JAMI_DBG("Get new TLS transport to %s", remoteAddr.toString(true).c_str()); pjsip_tpselector sel; sel.type = PJSIP_TPSELECTOR_LISTENER; sel.u.listener = l->get(); @@ -421,7 +421,7 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const &transport); if (!transport || status != PJ_SUCCESS) { - RING_ERR("Could not get new TLS transport: %s", sip_utils::sip_strerror(status).c_str()); + JAMI_ERR("Could not get new TLS transport: %s", sip_utils::sip_strerror(status).c_str()); return nullptr; } auto ret = std::make_shared<SipTransport>(transport, l); @@ -434,7 +434,7 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const } std::shared_ptr<SipTransport> -SipTransportBroker::getTlsIceTransport(const std::shared_ptr<ring::IceTransport>& ice, +SipTransportBroker::getTlsIceTransport(const std::shared_ptr<jami::IceTransport>& ice, unsigned comp_id, const tls::TlsParams& params) { @@ -456,4 +456,4 @@ SipTransportBroker::getTlsIceTransport(const std::shared_ptr<ring::IceTransport> return sip_tr; } -} // namespace ring +} // namespace jami diff --git a/src/sip/siptransport.h b/src/sip/siptransport.h index d61451e402..3be21163ed 100644 --- a/src/sip/siptransport.h +++ b/src/sip/siptransport.h @@ -48,7 +48,7 @@ namespace dht { namespace crypto { struct Certificate; }} // namespace dht::crypto -namespace ring { +namespace jami { struct SipTransportDescr { @@ -86,7 +86,7 @@ struct TlsListener TlsListener() {} TlsListener(pjsip_tpfactory* f) : listener(f) {} virtual ~TlsListener() { - RING_DBG("Destroying listener"); + JAMI_DBG("Destroying listener"); listener->destroy(listener); } pjsip_tpfactory* get() { @@ -230,6 +230,6 @@ private: }; -} // namespace ring +} // namespace jami #endif // SIPTRANSPORT_H_ diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index 5987422400..79ba2ee8ad 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -40,7 +40,7 @@ #include "system_codec_container.h" #include "audio/audio_rtp_session.h" -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include "video/video_rtp_session.h" #include "client/videomanager.h" #endif @@ -63,7 +63,7 @@ #include <algorithm> #include <regex> -namespace ring { +namespace jami { using sip_utils::CONST_PJ_STR; @@ -152,7 +152,7 @@ try_respond_stateless(pjsip_endpoint *endpt, pjsip_rx_data *rdata, int st_code, if (!pjsip_rdata_get_tsx(rdata)) return pjsip_endpt_respond_stateless(endpt, rdata, st_code, st_text, hdr_list, body); else - RING_ERR("Transaction has been created for this request, send response " + JAMI_ERR("Transaction has been created for this request, send response " "statefully instead"); return !PJ_SUCCESS; @@ -162,14 +162,14 @@ static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) { if (!rdata or !rdata->msg_info.msg) { - RING_ERR("rx_data is NULL"); + JAMI_ERR("rx_data is NULL"); return PJ_FALSE; } pjsip_method *method = &rdata->msg_info.msg->line.req.method; if (!method) { - RING_ERR("method is NULL"); + JAMI_ERR("method is NULL"); return PJ_FALSE; } @@ -177,7 +177,7 @@ transaction_request_cb(pjsip_rx_data *rdata) return PJ_FALSE; if (!rdata->msg_info.to or !rdata->msg_info.from or !rdata->msg_info.via) { - RING_ERR("Missing From, To or Via fields"); + JAMI_ERR("Missing From, To or Via fields"); return PJ_FALSE; } @@ -186,7 +186,7 @@ transaction_request_cb(pjsip_rx_data *rdata) const pjsip_host_port& sip_via = rdata->msg_info.via->sent_by; if (!sip_to_uri or !sip_from_uri or !sip_via.host.ptr) { - RING_ERR("NULL uri"); + JAMI_ERR("NULL uri"); return PJ_FALSE; } @@ -204,13 +204,13 @@ transaction_request_cb(pjsip_rx_data *rdata) auto link = getSIPVoIPLink(); if (not link) { - RING_ERR("no more VoIP link"); + JAMI_ERR("no more VoIP link"); return PJ_FALSE; } auto account(link->guessAccount(toUsername, viaHostname, remote_hostname)); if (!account) { - RING_ERR("NULL account"); + JAMI_ERR("NULL account"); return PJ_FALSE; } @@ -285,18 +285,18 @@ transaction_request_cb(pjsip_rx_data *rdata) return PJ_FALSE; } - // RING_DBG("transaction_request_cb viaHostname %s toUsername %s addrToUse %s addrSdp %s peerNumber: %s" , + // JAMI_DBG("transaction_request_cb viaHostname %s toUsername %s addrToUse %s addrSdp %s peerNumber: %s" , // viaHostname.c_str(), toUsername.c_str(), addrToUse.toString().c_str(), addrSdp.toString().c_str(), peerNumber.c_str()); // Append PJSIP transport to the broker's SipTransport list auto transport = link->sipTransportBroker->addTransport(rdata->tp_info.transport); if (!transport) { if (not ::strcmp(account->getAccountType(), SIPAccount::ACCOUNT_TYPE)) { - RING_WARN("Using transport from account."); + JAMI_WARN("Using transport from account."); transport = std::static_pointer_cast<SIPAccount>(account)->getTransport(); } if (!transport) { - RING_ERR("No suitable transport to answer this call."); + JAMI_ERR("No suitable transport to answer this call."); return PJ_FALSE; } } @@ -346,7 +346,7 @@ transaction_request_cb(pjsip_rx_data *rdata) pjsip_dialog *dialog = nullptr; if (pjsip_dlg_create_uas_and_inc_lock(pjsip_ua_instance(), rdata, nullptr, &dialog) != PJ_SUCCESS) { - RING_ERR("Could not create uas"); + JAMI_ERR("Could not create uas"); call.reset(); try_respond_stateless(endpt_, rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, nullptr, nullptr, nullptr); return PJ_FALSE; @@ -354,7 +354,7 @@ transaction_request_cb(pjsip_rx_data *rdata) pjsip_tpselector tp_sel = SIPVoIPLink::getTransportSelector(transport->get()); if (!dialog or pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) { - RING_ERR("Could not set transport for dialog"); + JAMI_ERR("Could not set transport for dialog"); if (dialog) pjsip_dlg_dec_lock(dialog); return PJ_FALSE; } @@ -362,7 +362,7 @@ transaction_request_cb(pjsip_rx_data *rdata) pjsip_inv_session* inv = nullptr; pjsip_inv_create_uas(dialog, rdata, call->getSDP().getLocalSdpSession(), PJSIP_INV_SUPPORT_ICE, &inv); if (!inv) { - RING_ERR("Call invite is not initialized"); + JAMI_ERR("Call invite is not initialized"); pjsip_dlg_dec_lock(dialog); return PJ_FALSE; } @@ -378,7 +378,7 @@ transaction_request_cb(pjsip_rx_data *rdata) pjsip_tx_data *response; if (pjsip_replaces_verify_request(rdata, &replaced_dlg, PJ_FALSE, &response) != PJ_SUCCESS) { - RING_ERR("Something wrong with Replaces request."); + JAMI_ERR("Something wrong with Replaces request."); call.reset(); // Something wrong with the Replaces header. @@ -398,19 +398,19 @@ transaction_request_cb(pjsip_rx_data *rdata) pjsip_tx_data *tdata = 0; if (pjsip_inv_initial_answer(call->inv.get(), rdata, PJSIP_SC_TRYING, NULL, NULL, &tdata) != PJ_SUCCESS) { - RING_ERR("Could not create answer TRYING"); + JAMI_ERR("Could not create answer TRYING"); return PJ_FALSE; } if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) { - RING_ERR("Could not send msg TRYING"); + JAMI_ERR("Could not send msg TRYING"); return PJ_FALSE; } call->setState(Call::ConnectionState::TRYING); if (pjsip_inv_answer(call->inv.get(), PJSIP_SC_RINGING, NULL, NULL, &tdata) != PJ_SUCCESS) { - RING_ERR("Could not create answer RINGING"); + JAMI_ERR("Could not create answer RINGING"); return PJ_FALSE; } @@ -419,7 +419,7 @@ transaction_request_cb(pjsip_rx_data *rdata) sip_utils::addContactHeader(&contactStr, tdata); if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) { - RING_ERR("Could not send msg RINGING"); + JAMI_ERR("Could not send msg RINGING"); return PJ_FALSE; } @@ -455,9 +455,9 @@ tp_state_callback(pjsip_transport* tp, pjsip_transport_state state, if (auto& broker = sipLink->sipTransportBroker) broker->transportStateChanged(tp, state, info); else - RING_ERR("SIPVoIPLink with invalid SipTransportBroker"); + JAMI_ERR("SIPVoIPLink with invalid SipTransportBroker"); } else - RING_ERR("no more VoIP link"); + JAMI_ERR("no more VoIP link"); } /*************************************************************************************************/ @@ -506,22 +506,22 @@ SIPVoIPLink::SIPVoIPLink() : pool_(nullptr, pj_pool_release) for (unsigned i=0, n=ns.size(); i<n; i++) { char hbuf[NI_MAXHOST]; if (auto ret = getnameinfo((sockaddr*)&ns[i], ns[i].getLength(), hbuf, sizeof(hbuf), nullptr, 0, NI_NUMERICHOST)) { - RING_WARN("Error printing SIP nameserver: %s", strerror(ret)); + JAMI_WARN("Error printing SIP nameserver: %s", strerror(ret)); } else { - RING_DBG("Using SIP nameserver: %s", hbuf); + JAMI_DBG("Using SIP nameserver: %s", hbuf); pj_strdup2(pool_.get(), &dns_nameservers[i], hbuf); dns_ports[i] = ns[i].getPort(); } } pj_dns_resolver* resv; if (auto ret = pjsip_endpt_create_resolver(endpt_, &resv)) { - RING_WARN("Error creating SIP DNS resolver: %s", sip_utils::sip_strerror(ret).c_str()); + JAMI_WARN("Error creating SIP DNS resolver: %s", sip_utils::sip_strerror(ret).c_str()); } else { if (auto ret = pj_dns_resolver_set_ns(resv, dns_nameservers.size(), dns_nameservers.data(), dns_ports.data())) { - RING_WARN("Error setting SIP DNS servers: %s", sip_utils::sip_strerror(ret).c_str()); + JAMI_WARN("Error setting SIP DNS servers: %s", sip_utils::sip_strerror(ret).c_str()); } else { if (auto ret = pjsip_endpt_set_resolver(endpt_, resv)) { - RING_WARN("Error setting pjsip DNS resolver: %s", sip_utils::sip_strerror(ret).c_str()); + JAMI_WARN("Error setting pjsip DNS resolver: %s", sip_utils::sip_strerror(ret).c_str()); } } } @@ -532,7 +532,7 @@ SIPVoIPLink::SIPVoIPLink() : pool_(nullptr, pj_pool_release) auto status = pjsip_tpmgr_set_state_cb(pjsip_endpt_get_tpmgr(endpt_), tp_state_callback); if (status != PJ_SUCCESS) - RING_ERR("Can't set transport callback: %s", sip_utils::sip_strerror(status).c_str()); + JAMI_ERR("Can't set transport callback: %s", sip_utils::sip_strerror(status).c_str()); if (!ip_utils::getLocalAddr()) throw VoipLinkException("UserAgent: Unable to determine network capabilities"); @@ -602,12 +602,12 @@ SIPVoIPLink::SIPVoIPLink() : pool_(nullptr, pj_pool_release) handleEvents(); }); - RING_DBG("SIPVoIPLink@%p", this); + JAMI_DBG("SIPVoIPLink@%p", this); } SIPVoIPLink::~SIPVoIPLink() { - RING_DBG("~SIPVoIPLink@%p", this); + JAMI_DBG("~SIPVoIPLink@%p", this); running_ = false; @@ -615,7 +615,7 @@ SIPVoIPLink::~SIPVoIPLink() // may be called and another instance of SIPVoIPLink can be re-created! if (not Manager::instance().callFactory.empty<SIPCall>()) - RING_ERR("%zu SIP calls remains!", + JAMI_ERR("%zu SIP calls remains!", Manager::instance().callFactory.callCount<SIPCall>()); sipTransportBroker->shutdown(); @@ -635,7 +635,7 @@ SIPVoIPLink::~SIPVoIPLink() pj_caching_pool_destroy(&cp_); sipThread_.join(); - RING_DBG("destroying SIPVoIPLink@%p", this); + JAMI_DBG("destroying SIPVoIPLink@%p", this); } std::shared_ptr<SIPAccountBase> @@ -643,7 +643,7 @@ SIPVoIPLink::guessAccount(const std::string& userName, const std::string& server, const std::string& fromUri) const { - RING_DBG("username = %s, server = %s, from = %s", userName.c_str(), server.c_str(), fromUri.c_str()); + JAMI_DBG("username = %s, server = %s, from = %s", userName.c_str(), server.c_str(), fromUri.c_str()); // Try to find the account id from username and server name by full match std::shared_ptr<SIPAccountBase> result; @@ -692,31 +692,31 @@ SIPVoIPLink::handleEvents() { const pj_time_val timeout = {1, 0}; if (auto ret = pjsip_endpt_handle_events(endpt_, &timeout)) - RING_ERR("pjsip_endpt_handle_events failed with error %s", + JAMI_ERR("pjsip_endpt_handle_events failed with error %s", sip_utils::sip_strerror(ret).c_str()); } void SIPVoIPLink::registerKeepAliveTimer(pj_timer_entry &timer, pj_time_val &delay) { - RING_DBG("Register new keep alive timer %d with delay %ld", timer.id, delay.sec); + JAMI_DBG("Register new keep alive timer %d with delay %ld", timer.id, delay.sec); if (timer.id == -1) - RING_WARN("Timer already scheduled"); + JAMI_WARN("Timer already scheduled"); switch (pjsip_endpt_schedule_timer(endpt_, &timer, &delay)) { case PJ_SUCCESS: break; default: - RING_ERR("Could not schedule new timer in pjsip endpoint"); + JAMI_ERR("Could not schedule new timer in pjsip endpoint"); /* fallthrough */ case PJ_EINVAL: - RING_ERR("Invalid timer or delay entry"); + JAMI_ERR("Invalid timer or delay entry"); break; case PJ_EINVALIDOP: - RING_ERR("Invalid timer entry, maybe already scheduled"); + JAMI_ERR("Invalid timer entry, maybe already scheduled"); break; } } @@ -746,7 +746,7 @@ invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev) return; if (ev->type != PJSIP_EVENT_TSX_STATE and ev->type != PJSIP_EVENT_TX_MSG) { - RING_WARN("[call:%s] INVITE@%p state changed to %d (%s): unwaited event type %d", + JAMI_WARN("[call:%s] INVITE@%p state changed to %d (%s): unwaited event type %d", call->getCallId().c_str(), inv, inv->state, pjsip_inv_state_name(inv->state), ev->type); return; @@ -759,12 +759,12 @@ invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev) status_code = tsx ? tsx->status_code : PJSIP_SC_NOT_FOUND; const pj_str_t* description = pjsip_get_status_text(status_code); - RING_DBG("[call:%s] INVITE@%p state changed to %d (%s): cause=%d, tsx@%p status %d (%.*s)", + JAMI_DBG("[call:%s] INVITE@%p state changed to %d (%s): cause=%d, tsx@%p status %d (%.*s)", call->getCallId().c_str(), inv, inv->state, pjsip_inv_state_name(inv->state), inv->cause, tsx, status_code, (int)description->slen, description->ptr); } else { status_code = 0; - RING_DBG("[call:%s] INVITE@%p state changed to %d (%s): cause=%d (TX_MSG)", + JAMI_DBG("[call:%s] INVITE@%p state changed to %d (%s): cause=%d (TX_MSG)", call->getCallId().c_str(), inv, inv->state, pjsip_inv_state_name(inv->state), inv->cause); } @@ -871,12 +871,12 @@ get_active_remote_sdp(pjsip_inv_session *inv) const pjmedia_sdp_session* sdp_session {}; if (pjmedia_sdp_neg_get_active_remote(inv->neg, &sdp_session) != PJ_SUCCESS) { - RING_ERR("Active remote not present"); + JAMI_ERR("Active remote not present"); return nullptr; } if (pjmedia_sdp_validate(sdp_session) != PJ_SUCCESS) { - RING_ERR("Invalid remote SDP session"); + JAMI_ERR("Invalid remote SDP session"); return nullptr; } @@ -890,12 +890,12 @@ get_active_local_sdp(pjsip_inv_session *inv) const pjmedia_sdp_session* sdp_session {}; if (pjmedia_sdp_neg_get_active_local(inv->neg, &sdp_session) != PJ_SUCCESS) { - RING_ERR("Active local not present"); + JAMI_ERR("Active local not present"); return nullptr; } if (pjmedia_sdp_validate(sdp_session) != PJ_SUCCESS) { - RING_ERR("Invalid local SDP session"); + JAMI_ERR("Invalid local SDP session"); return nullptr; } @@ -911,7 +911,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status) if (not call) return; - RING_DBG("[call:%s] INVITE@%p media update: status %d", + JAMI_DBG("[call:%s] INVITE@%p media update: status %d", call->getCallId().c_str(), inv, status); if (status != PJ_SUCCESS) { @@ -919,7 +919,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status) inv->state != PJSIP_INV_STATE_CONFIRMED ? PJSIP_SC_UNSUPPORTED_MEDIA_TYPE : 0; - RING_WARN("[call:%s] SDP offer failed, reason %d", call->getCallId().c_str(), reason); + JAMI_WARN("[call:%s] SDP offer failed, reason %d", call->getCallId().c_str(), reason); call->hangup(reason); return; } @@ -971,7 +971,7 @@ handleMediaControl(SIPCall& call, pjsip_msg_body* body) if (matched_pattern.ready() && !matched_pattern.empty() && matched_pattern[1].matched) { rotation = std::stoi(matched_pattern[1]); - RING_WARN("Rotate video %d deg.", rotation); + JAMI_WARN("Rotate video %d deg.", rotation); call.getVideoRtp().setRotation(rotation); @@ -990,12 +990,12 @@ static bool transferCall(SIPCall& call, const std::string& refer_to) { const auto& callId = call.getCallId(); - RING_WARN("[call:%s] Trying to transfer to %s", callId.c_str(), refer_to.c_str()); + JAMI_WARN("[call:%s] Trying to transfer to %s", callId.c_str(), refer_to.c_str()); try { Manager::instance().newOutgoingCall(refer_to, call.getAccountId()); Manager::instance().hangupCall(callId); } catch (const std::exception& e) { - RING_ERR("[call:%s] SIP transfer failed: %s", callId.c_str(), e.what()); + JAMI_ERR("[call:%s] SIP transfer failed: %s", callId.c_str(), e.what()); return false; } return true; @@ -1006,7 +1006,7 @@ replyToRequest(pjsip_inv_session* inv, pjsip_rx_data* rdata, int status_code) { const auto ret = pjsip_dlg_respond(inv->dlg, rdata, status_code, nullptr, nullptr, nullptr); if (ret != PJ_SUCCESS) - RING_WARN("SIP: failed to reply %d to request", status_code); + JAMI_WARN("SIP: failed to reply %d to request", status_code); } static void @@ -1026,9 +1026,9 @@ onRequestRefer(pjsip_inv_session* inv, pjsip_rx_data* rdata, pjsip_msg* msg, SIP // But your current design doesn't permit that return; } else - RING_ERR("[call:%s] REFER: too many Refer-To headers", call.getCallId().c_str()); + JAMI_ERR("[call:%s] REFER: too many Refer-To headers", call.getCallId().c_str()); } else - RING_ERR("[call:%s] REFER: no Refer-To header", call.getCallId().c_str()); + JAMI_ERR("[call:%s] REFER: no Refer-To header", call.getCallId().c_str()); replyToRequest(inv, rdata, PJSIP_SC_BAD_REQUEST); } @@ -1047,7 +1047,7 @@ onRequestNotify(pjsip_inv_session* /*inv*/, pjsip_rx_data* /*rdata*/, pjsip_msg* return; const std::string bodyText {static_cast<char *>(msg->body->data), msg->body->len}; - RING_DBG("[call:%s] NOTIFY body start - %p\n%s\n[call:%s] NOTIFY body end - %p", + JAMI_DBG("[call:%s] NOTIFY body start - %p\n%s\n[call:%s] NOTIFY body end - %p", call.getCallId().c_str(), msg->body, bodyText.c_str(), call.getCallId().c_str(), msg->body); @@ -1071,24 +1071,24 @@ transaction_state_changed_cb(pjsip_inv_session* inv, pjsip_transaction* tsx, pjs const auto rdata = event->body.tsx_state.src.rdata; if (!rdata) { - RING_ERR("[INVITE:%p] SIP RX request without rx data", inv); + JAMI_ERR("[INVITE:%p] SIP RX request without rx data", inv); return; } const auto msg = rdata->msg_info.msg; if (msg->type != PJSIP_REQUEST_MSG) { - RING_ERR("[INVITE:%p] SIP RX request without msg", inv); + JAMI_ERR("[INVITE:%p] SIP RX request without msg", inv); return; } // Using method name to dispatch const std::string methodName {msg->line.req.method.name.ptr, (unsigned)msg->line.req.method.name.slen}; - RING_DBG("[INVITE:%p] RX SIP method %d (%s)", inv, msg->line.req.method.id, methodName.c_str()); + JAMI_DBG("[INVITE:%p] RX SIP method %d (%s)", inv, msg->line.req.method.id, methodName.c_str()); #ifdef DEBUG_SIP_REQUEST_MSG char msgbuf[1000]; pjsip_msg_print(msg, msgbuf, sizeof msgbuf); - RING_DBG("%s", msgbuf); + JAMI_DBG("%s", msgbuf); #endif // DEBUG_SIP_MESSAGE if (methodName == "REFER") @@ -1163,7 +1163,7 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type // So we just choose a security marge enough for most cases, preventing a crash later // in the call of pjsip_endpt_resolve(). if (name.length() > (PJ_MAX_HOSTNAME - 12)) { - RING_ERR("Hostname is too long"); + JAMI_ERR("Hostname is too long"); cb({}); return; } @@ -1179,7 +1179,7 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type port = 0; name_size = name.size(); } - RING_DBG("try to resolve '%s' (port: %u)", name.c_str(), port); + JAMI_DBG("try to resolve '%s' (port: %u)", name.c_str(), port); pjsip_host_info host_info { /*.flag = */0, @@ -1192,7 +1192,7 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type [=,cb=std::move(cb)](pj_status_t s, const pjsip_server_addresses* r) { try { if (s != PJ_SUCCESS || !r) { - RING_WARN("Can't resolve \"%s\" using pjsip_endpt_resolve, trying getaddrinfo.", name.c_str()); + JAMI_WARN("Can't resolve \"%s\" using pjsip_endpt_resolve, trying getaddrinfo.", name.c_str()); std::thread([=,cb=std::move(cb)](){ auto ips = ip_utils::getAddrList(name.c_str()); runOnMainThread(std::bind(cb, ips.empty() ? std::vector<IpAddr>{} : std::move(ips))); @@ -1205,7 +1205,7 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type cb(ips); } } catch (const std::exception& e) { - RING_ERR("Error resolving address: %s", e.what()); + JAMI_ERR("Error resolving address: %s", e.what()); cb({}); } }); @@ -1214,10 +1214,10 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type } #define RETURN_IF_NULL(A, ...) \ - if ((A) == NULL) { RING_WARN(__VA_ARGS__); return; } + if ((A) == NULL) { JAMI_WARN(__VA_ARGS__); return; } #define RETURN_FALSE_IF_NULL(A, ...) \ - if ((A) == NULL) { RING_WARN(__VA_ARGS__); return false; } + if ((A) == NULL) { JAMI_WARN(__VA_ARGS__); return false; } void SIPVoIPLink::findLocalAddressFromTransport(pjsip_transport* transport, @@ -1251,7 +1251,7 @@ SIPVoIPLink::findLocalAddressFromTransport(pjsip_transport* transport, pjsip_tpmgr_fla2_param param = { transportType, &tp_sel, pjstring, PJ_FALSE, {nullptr, 0}, 0, nullptr }; if (pjsip_tpmgr_find_local_addr2(tpmgr, pool_.get(), ¶m) != PJ_SUCCESS) { - RING_WARN("Could not retrieve local address and port from transport, using %s :%d", + JAMI_WARN("Could not retrieve local address and port from transport, using %s :%d", addr.c_str(), port); return; } @@ -1280,7 +1280,7 @@ SIPVoIPLink::findLocalAddressFromSTUN(pjsip_transport* transport, // Get Local IP address auto localIp = ip_utils::getLocalAddr(pj_AF_INET()); if (not localIp) { - RING_WARN("Failed to find local IP"); + JAMI_WARN("Failed to find local IP"); return false; } @@ -1291,7 +1291,7 @@ SIPVoIPLink::findLocalAddressFromSTUN(pjsip_transport* transport, "Transport is NULL in findLocalAddress, using local address %s:%u", addr.c_str(), port); - RING_DBG("STUN mapping of '%s:%u'", addr.c_str(), port); + JAMI_DBG("STUN mapping of '%s:%u'", addr.c_str(), port); pj_sockaddr_in mapped_addr; pj_sock_t sipSocket = pjsip_udp_transport_get_socket(transport); @@ -1308,28 +1308,28 @@ SIPVoIPLink::findLocalAddressFromSTUN(pjsip_transport* transport, switch (stunStatus) { case PJLIB_UTIL_ESTUNNOTRESPOND: - RING_ERR("No response from STUN server %.*s", + JAMI_ERR("No response from STUN server %.*s", (int)stunServerName->slen, stunServerName->ptr); return false; case PJLIB_UTIL_ESTUNSYMMETRIC: - RING_ERR("Different mapped addresses are returned by servers."); + JAMI_ERR("Different mapped addresses are returned by servers."); return false; case PJ_SUCCESS: port = pj_sockaddr_in_get_port(&mapped_addr); addr = IpAddr((const pj_sockaddr&)mapped_addr).toString(); - RING_DBG("STUN server %.*s replied '%s:%u'", + JAMI_DBG("STUN server %.*s replied '%s:%u'", (int)stunServerName->slen, stunServerName->ptr, addr.c_str(), port); return true; default: // use given address, silent any not handled error - RING_WARN("Error from STUN server %.*s, using source address", + JAMI_WARN("Error from STUN server %.*s, using source address", (int)stunServerName->slen, stunServerName->ptr); return false; } } #undef RETURN_IF_NULL #undef RETURN_FALSE_IF_NULL -} // namespace ring +} // namespace jami diff --git a/src/sip/sipvoiplink.h b/src/sip/sipvoiplink.h index 5104ea9ff4..193012c8b7 100644 --- a/src/sip/sipvoiplink.h +++ b/src/sip/sipvoiplink.h @@ -39,7 +39,7 @@ #include <pjnath.h> #include <pjnath/stun_config.h> -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO #include <queue> #endif #include <map> @@ -49,7 +49,7 @@ #include <thread> #include <atomic> -namespace ring { +namespace jami { class SIPCall; class SIPAccountBase; @@ -161,11 +161,11 @@ class SIPVoIPLink { std::atomic_bool running_ {true}; std::thread sipThread_; -#ifdef RING_VIDEO +#ifdef ENABLE_VIDEO void requestKeyframe(const std::string &callID); #endif friend class SIPTest; }; -} // namespace ring +} // namespace jami diff --git a/src/smartools.cpp b/src/smartools.cpp index ebcd1af94f..89e4674629 100644 --- a/src/smartools.cpp +++ b/src/smartools.cpp @@ -25,7 +25,7 @@ #include "client/ring_signal.h" #include "string_utils.h" -namespace ring { +namespace jami { Smartools& Smartools::getInstance() { @@ -63,7 +63,7 @@ Smartools::process() void Smartools::start(std::chrono::milliseconds refreshTimeMs) { - RING_DBG("Start SmartInfo"); + JAMI_DBG("Start SmartInfo"); refreshTimeMs_ = refreshTimeMs; loop_.stop(); loop_.start(); @@ -73,7 +73,7 @@ void Smartools::stop() { std::lock_guard<std::mutex> lk(mutexInfo_); - RING_DBG("Stop SmartInfo"); + JAMI_DBG("Stop SmartInfo"); loop_.stop(); information_.clear(); } @@ -145,4 +145,4 @@ Smartools::setRemoteVideoCodec(const std::string& remoteVideoCodec, const std::s } } - } // end namespace ring + } // end namespace jami diff --git a/src/smartools.h b/src/smartools.h index 55dcf59715..90758ef00f 100644 --- a/src/smartools.h +++ b/src/smartools.h @@ -23,7 +23,7 @@ #include "manager.h" #include <string> -namespace ring { +namespace jami { class Smartools { // Use for the unit tests diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 8a7f12c5f2..ed73294c28 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -32,7 +32,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { #ifdef _WIN32 @@ -109,8 +109,8 @@ split_string_to_unsigned(const std::string &s, char delim) while (std::getline(ss, token, delim)) if (not token.empty()) - result.emplace_back(ring::stoi(token)); + result.emplace_back(jami::stoi(token)); return result; } -} // namespace ring +} // namespace jami diff --git a/src/string_utils.h b/src/string_utils.h index 25b0995753..f30c94de79 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -28,7 +28,7 @@ #include <WTypes.h> #endif -namespace ring { +namespace jami { constexpr static const char* TRUE_STR = "true"; constexpr static const char* FALSE_STR = "false"; @@ -74,6 +74,6 @@ split_string(const std::string& s, char sep); std::vector<unsigned> split_string_to_unsigned(const std::string& s, char sep); -} // namespace ring +} // namespace jami #endif diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 44a4384ccf..ead9435c6b 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -25,7 +25,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { struct ThreadPool::ThreadState { @@ -76,7 +76,7 @@ ThreadPool::run(std::function<void()>&& cb) if (task) task(); } catch (const std::exception& e) { - RING_ERR("Exception running task: %s", e.what()); + JAMI_ERR("Exception running task: %s", e.what()); } } }); diff --git a/src/thread_pool.h b/src/thread_pool.h index c7a53993a1..701231212e 100644 --- a/src/thread_pool.h +++ b/src/thread_pool.h @@ -25,7 +25,7 @@ #include <future> #include <functional> -namespace ring { +namespace jami { class ThreadPool { public: diff --git a/src/threadloop.cpp b/src/threadloop.cpp index a46b831e3b..cbb9b0eba6 100644 --- a/src/threadloop.cpp +++ b/src/threadloop.cpp @@ -23,7 +23,7 @@ #include <ciso646> // fix windows compiler bug -namespace ring { +namespace jami { void ThreadLoop::mainloop(std::thread::id& tid, @@ -38,12 +38,12 @@ ThreadLoop::mainloop(std::thread::id& tid, process(); cleanup(); } else { - RING_ERR("setup failed"); + JAMI_ERR("setup failed"); } } catch (const ThreadLoopException& e) { - RING_ERR("[threadloop:%p] ThreadLoopException: %s", this, e.what()); + JAMI_ERR("[threadloop:%p] ThreadLoopException: %s", this, e.what()); } catch (const std::exception& e) { - RING_ERR("[threadloop:%p] Unwaited exception: %s", this, e.what()); + JAMI_ERR("[threadloop:%p] Unwaited exception: %s", this, e.what()); } stop(); } @@ -70,7 +70,7 @@ ThreadLoop::ThreadLoop(ThreadLoop&& other) ThreadLoop::~ThreadLoop() { if (isRunning()) { - RING_ERR("join() should be explicitly called in owner's destructor"); + JAMI_ERR("join() should be explicitly called in owner's destructor"); join(); } } @@ -81,13 +81,13 @@ ThreadLoop::start() const auto s = state_.load(); if (s == RUNNING) { - RING_ERR("already started"); + JAMI_ERR("already started"); return; } // stop pending but not processed by thread yet? if (s == STOPPING and thread_.joinable()) { - RING_DBG("stop pending"); + JAMI_DBG("stop pending"); thread_.join(); } @@ -153,4 +153,4 @@ InterruptedThreadLoop::stop() ThreadLoop::stop(); cv_.notify_one(); } -} // namespace ring +} // namespace jami diff --git a/src/threadloop.h b/src/threadloop.h index 4eaa8ca9e4..3db436fa3e 100644 --- a/src/threadloop.h +++ b/src/threadloop.h @@ -28,7 +28,7 @@ #include <condition_variable> #include <mutex> -namespace ring { +namespace jami { struct ThreadLoopException : public std::runtime_error { ThreadLoopException() : std::runtime_error("ThreadLoopException") {} @@ -125,4 +125,4 @@ private: std::condition_variable cv_; }; -} // namespace ring +} // namespace jami diff --git a/src/turn_transport.cpp b/src/turn_transport.cpp index 979ff5c835..31e4730413 100644 --- a/src/turn_transport.cpp +++ b/src/turn_transport.cpp @@ -40,7 +40,7 @@ #include <map> #include <condition_variable> -namespace ring { +namespace jami { using MutexGuard = std::lock_guard<std::mutex>; using MutexLock = std::unique_lock<std::mutex>; @@ -190,7 +190,7 @@ TurnTransportPimpl::~TurnTransportPimpl() try { pj_turn_sock_destroy(relay); } catch (...) { - RING_ERR() << "exception during pj_turn_sock_destroy() call (ignored)"; + JAMI_ERR() << "exception during pj_turn_sock_destroy() call (ignored)"; } } ioJobQuit = true; @@ -208,10 +208,10 @@ TurnTransportPimpl::onTurnState(pj_turn_state_t old_state, pj_turn_state_t new_s pj_turn_sock_get_info(relay, &info); peerRelayAddr = IpAddr {info.relay_addr}; mappedAddr = IpAddr {info.mapped_addr}; - RING_DBG("TURN server ready, peer relay address: %s", peerRelayAddr.toString(true, true).c_str()); + JAMI_DBG("TURN server ready, peer relay address: %s", peerRelayAddr.toString(true, true).c_str()); state = RelayState::READY; } else if (old_state <= PJ_TURN_STATE_READY and new_state > PJ_TURN_STATE_READY) { - RING_WARN("TURN server disconnected (%s)", pj_turn_state_name(new_state)); + JAMI_WARN("TURN server disconnected (%s)", pj_turn_state_name(new_state)); state = RelayState::DOWN; MutexGuard lk {apiMutex_}; peerChannels_.clear(); @@ -245,7 +245,7 @@ TurnTransportPimpl::onPeerConnection(pj_uint32_t conn_id, { IpAddr peer_addr (*static_cast<const pj_sockaddr*>(addr), addr_len); if (status == PJ_SUCCESS) { - RING_DBG() << "Received connection attempt from " << peer_addr.toString(true, true) + JAMI_DBG() << "Received connection attempt from " << peer_addr.toString(true, true) << ", id=" << std::hex << conn_id; pj_turn_connect_peer(relay, conn_id, addr, addr_len); @@ -354,7 +354,7 @@ TurnTransport::TurnTransport(const TurnTransportParams& params) pimpl_->relayAddr = pj_strdup3(pimpl_->pool, server.toString().c_str()); // TURN connection/allocation - RING_DBG() << "Connecting to TURN " << server.toString(true, true); + JAMI_DBG() << "Connecting to TURN " << server.toString(true, true); PjsipCall(pj_turn_sock_alloc, pimpl_->relay, &pimpl_->relayAddr, server.getPort(), nullptr, &cred, &turn_alloc_param); @@ -528,4 +528,4 @@ ConnectedTurnTransport::read(ValueType* buf, std::size_t size, std::error_code& return size; } -} // namespace ring +} // namespace jami diff --git a/src/turn_transport.h b/src/turn_transport.h index d6ef03f45a..1b9c363d71 100644 --- a/src/turn_transport.h +++ b/src/turn_transport.h @@ -29,7 +29,7 @@ #include <map> #include <stdexcept> -namespace ring { +namespace jami { class TurnTransportPimpl; @@ -171,4 +171,4 @@ private: RecvCb onRxDataCb_; }; -} // namespace ring +} // namespace jami diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index c72d8b7918..a00711dd63 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -45,7 +45,7 @@ using random_device = dht::crypto::random_device; #include "upnp_context.h" -namespace ring { namespace upnp { +namespace jami { namespace upnp { /** * This should be used to get a UPnPContext. @@ -110,11 +110,11 @@ UPnPContext::UPnPContext() while (pmpRun_) { if (initnatpmp(&natpmp, 0, 0) < 0) { - RING_ERR("NAT-PMP: can't initialize libnatpmp"); + JAMI_ERR("NAT-PMP: can't initialize libnatpmp"); std::unique_lock<std::mutex> lk(pmpMutex_); pmpCv_.wait_for(lk, std::chrono::minutes(1)); } else { - RING_DBG("NAT-PMP: initialized"); + JAMI_DBG("NAT-PMP: initialized"); break; } } @@ -152,7 +152,7 @@ UPnPContext::UPnPContext() } } closenatpmp(&natpmp); - RING_DBG("NAT-PMP: ended"); + JAMI_DBG("NAT-PMP: ended"); }) #endif { @@ -166,7 +166,7 @@ UPnPContext::UPnPContext() */ #ifdef UPNP_ENABLE_IPV6 - RING_DBG("UPnP: IPv6 support enabled, but we will use IPv4"); + JAMI_DBG("UPnP: IPv6 support enabled, but we will use IPv4"); /* IPv6 version seems to fail on some systems with: * UPNP_E_SOCKET_BIND: An error occurred binding a socket. */ /* TODO: figure out why ipv6 version doesn't work */ @@ -174,14 +174,14 @@ UPnPContext::UPnPContext() #endif upnp_err = UpnpInit(0, 0); if ( upnp_err != UPNP_E_SUCCESS ) { - RING_ERR("UPnP: can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err)); + JAMI_ERR("UPnP: can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err)); UpnpFinish(); } else { - RING_DBG("UPnP: using IPv4"); + JAMI_DBG("UPnP: using IPv4"); ip_address = UpnpGetServerIpAddress(); // do not free, it is freed by UpnpFinish() port = UpnpGetServerPort(); - RING_DBG("UPnP: initialiazed on %s:%u", ip_address, port); + JAMI_DBG("UPnP: initialiazed on %s:%u", ip_address, port); // relax the parser to allow malformed XML text ixmlRelaxParser( 1 ); @@ -189,7 +189,7 @@ UPnPContext::UPnPContext() // Register a control point to start looking for devices right away upnp_err = UpnpRegisterClient( cp_callback, this, &ctrlptHandle_ ); if ( upnp_err != UPNP_E_SUCCESS ) { - RING_ERR("UPnP: can't register client: %s", UpnpGetErrorMessage(upnp_err)); + JAMI_ERR("UPnP: can't register client: %s", UpnpGetErrorMessage(upnp_err)); UpnpFinish(); } else { clientRegistered_ = true; @@ -278,14 +278,14 @@ bool UPnPContext::hasValidIGD(std::chrono::seconds timeout) { if (not clientRegistered_ and not pmpRun_) { - RING_WARN("UPnP: Control Point not registered"); + JAMI_WARN("UPnP: Control Point not registered"); return false; } std::unique_lock<std::mutex> lock(validIGDMutex_); if (!validIGDCondVar_.wait_for(lock, timeout, [this]{return hasValidIGD_unlocked();})) { - RING_WARN("UPnP: check for valid IGD timeout"); + JAMI_WARN("UPnP: check for valid IGD timeout"); return false; } @@ -365,12 +365,12 @@ UPnPContext::addMapping(IGD* igd, /* the same mapping, so nothing needs to be done */ *upnp_error = UPNP_E_SUCCESS; ++(mapping_ptr->users); - RING_DBG("UPnp : mapping already exists, incrementing number of users: %d", + JAMI_DBG("UPnp : mapping already exists, incrementing number of users: %d", iter->second.users); return mapping; } else { /* this port is already used by a different mapping */ - RING_WARN("UPnP: cannot add a mapping with an external port which is already used by another:\n\tcurrent: %s\n\ttrying to add: %s", + JAMI_WARN("UPnP: cannot add a mapping with an external port which is already used by another:\n\tcurrent: %s\n\ttrying to add: %s", mapping_ptr->toString().c_str(), mapping.toString().c_str()); *upnp_error = CONFLICT_IN_MAPPING; return {}; @@ -378,7 +378,7 @@ UPnPContext::addMapping(IGD* igd, } /* mapping doesn't exist, so try to add it */ - RING_DBG("adding port mapping : %s", mapping.toString().c_str()); + JAMI_DBG("adding port mapping : %s", mapping.toString().c_str()); #if HAVE_LIBUPNP auto upnp = dynamic_cast<const UPnPIGD*>(igd); @@ -427,7 +427,7 @@ UPnPContext::chooseRandomPort(const IGD& igd, PortType type) port = generateRandomPort(); } - RING_DBG("UPnP: chose random port %u", port); + JAMI_DBG("UPnP: chose random port %u", port); return port; } @@ -456,7 +456,7 @@ UPnPContext::addAnyMapping(uint16_t port_desired, std::lock_guard<std::mutex> lock(validIGDMutex_); IGD* igd = chooseIGD_unlocked(); if (not igd) { - RING_WARN("UPnP: no valid IGD available"); + JAMI_WARN("UPnP: no valid IGD available"); return {}; } @@ -489,7 +489,7 @@ UPnPContext::addAnyMapping(uint16_t port_desired, * 718 : conflictin mapping * 402 : invalid args (due to router implementation) */ - RING_DBG("UPnP: mapping failed (conflicting entry? err = %d), trying with a different port.", + JAMI_DBG("UPnP: mapping failed (conflicting entry? err = %d), trying with a different port.", upnp_error); /* TODO: make sure we don't try sellecting the same random port twice if it fails ? */ port_desired = chooseRandomPort(*igd, type); @@ -500,7 +500,7 @@ UPnPContext::addAnyMapping(uint16_t port_desired, } if (not mapping and numberRetries == MAX_RETRIES) - RING_DBG("UPnP: could not add mapping after %u retries, giving up", MAX_RETRIES); + JAMI_DBG("UPnP: could not add mapping after %u retries, giving up", MAX_RETRIES); return mapping; } @@ -516,7 +516,7 @@ UPnPContext::removeMapping(const Mapping& mapping) std::lock_guard<std::mutex> lock(validIGDMutex_); IGD* igd = chooseIGD_unlocked(); if (not igd) { - RING_WARN("UPnP: no valid IGD available"); + JAMI_WARN("UPnP: no valid IGD available"); return; } @@ -533,13 +533,13 @@ UPnPContext::removeMapping(const Mapping& mapping) if (global_mapping.users > 1) { /* more than one user, simply decrement the number */ --(global_mapping.users); - RING_DBG("UPnP: decrementing users of mapping: %s, %d users remaining", + JAMI_DBG("UPnP: decrementing users of mapping: %s, %d users remaining", mapping.toString().c_str(), global_mapping.users); } else { /* no other users, can delete */ #if HAVE_LIBUPNP if (auto upnp = dynamic_cast<UPnPIGD*>(igd)) { - RING_DBG("UPnP: removing port mapping : %s", + JAMI_DBG("UPnP: removing port mapping : %s", mapping.toString().c_str()); deletePortMapping(*upnp, mapping.getPortExternalStr(), @@ -558,10 +558,10 @@ UPnPContext::removeMapping(const Mapping& mapping) globalMappings->erase(iter); } } else { - RING_WARN("UPnP: cannot remove mapping which doesn't match the existing one in the IGD list"); + JAMI_WARN("UPnP: cannot remove mapping which doesn't match the existing one in the IGD list"); } } else { - RING_WARN("UPnP: cannot remove mapping which is not in the list of existing mappings of the IGD"); + JAMI_WARN("UPnP: cannot remove mapping which is not in the list of existing mappings of the IGD"); } } @@ -576,7 +576,7 @@ UPnPContext::getLocalIP() const if (auto igd = chooseIGD_unlocked()) return igd->localIp; - RING_WARN("UPnP: no valid IGD available"); + JAMI_WARN("UPnP: no valid IGD available"); return {}; } @@ -591,7 +591,7 @@ UPnPContext::getExternalIP() const if (auto igd = chooseIGD_unlocked()) return igd->publicIp; - RING_WARN("UPnP: no valid IGD available"); + JAMI_WARN("UPnP: no valid IGD available"); return {}; } @@ -601,7 +601,7 @@ void UPnPContext::PMPsearchForIGD(const std::shared_ptr<PMPIGD>& pmp_igd, natpmp_t& natpmp) { if (sendpublicaddressrequest(&natpmp) < 0) { - RING_ERR("NAT-PMP: can't send request"); + JAMI_ERR("NAT-PMP: can't send request"); pmp_igd->renewal_ = clock::now() + std::chrono::minutes(1); return; } @@ -618,8 +618,8 @@ UPnPContext::PMPsearchForIGD(const std::shared_ptr<PMPIGD>& pmp_igd, natpmp_t& n pmp_igd->localIp = ip_utils::getLocalAddr(AF_INET); pmp_igd->publicIp = IpAddr(response.pnu.publicaddress.addr); if (not pmpIGD_) { - RING_DBG("NAT-PMP: found new device"); - RING_DBG("NAT-PMP: got external IP: %s", pmp_igd->publicIp.toString().c_str()); + JAMI_DBG("NAT-PMP: found new device"); + JAMI_DBG("NAT-PMP: got external IP: %s", pmp_igd->publicIp.toString().c_str()); { std::lock_guard<std::mutex> lock(validIGDMutex_); pmpIGD_ = pmp_igd; @@ -641,17 +641,17 @@ UPnPContext::PMPaddPortMapping(const PMPIGD& /*pmp_igd*/, natpmp_t& natpmp, Glob mapping.getType() == PortType::UDP ? NATPMP_PROTOCOL_UDP : NATPMP_PROTOCOL_TCP, mapping.getPortInternal(), mapping.getPortExternal(), remove ? 0 : 3600) < 0) { - RING_ERR("NAT-PMP: can't send port mapping request"); + JAMI_ERR("NAT-PMP: can't send port mapping request"); mapping.renewal_ = clock::now() + std::chrono::minutes(1); return; } - RING_DBG("NAT-PMP: sent port mapping %srequest", remove ? "removal " : ""); + JAMI_DBG("NAT-PMP: sent port mapping %srequest", remove ? "removal " : ""); while (pmpRun_) { natpmpresp_t response; std::this_thread::sleep_for(std::chrono::milliseconds(2)); auto r = readnatpmpresponseorretry(&natpmp, &response); if (r < 0 && r != NATPMP_TRYAGAIN) { - RING_ERR("NAT-PMP: can't %sregister port mapping", remove ? "un" : ""); + JAMI_ERR("NAT-PMP: can't %sregister port mapping", remove ? "un" : ""); break; } else if (r != NATPMP_TRYAGAIN) { @@ -666,16 +666,16 @@ void UPnPContext::PMPdeleteAllPortMapping(const PMPIGD& /*pmp_igd*/, natpmp_t& natpmp, int proto) const { if (sendnewportmappingrequest(&natpmp, proto, 0, 0, 0) < 0) { - RING_ERR("NAT-PMP: can't send all port mapping removal request"); + JAMI_ERR("NAT-PMP: can't send all port mapping removal request"); return; } - RING_DBG("NAT-PMP: sent all port mapping removal request"); + JAMI_DBG("NAT-PMP: sent all port mapping removal request"); while (pmpRun_) { natpmpresp_t response; std::this_thread::sleep_for(std::chrono::milliseconds(2)); auto r = readnatpmpresponseorretry(&natpmp, &response); if (r < 0 && r != NATPMP_TRYAGAIN) { - RING_ERR("NAT-PMP: can't remove all port mappings"); + JAMI_ERR("NAT-PMP: can't remove all port mappings"); break; } else if (r != NATPMP_TRYAGAIN) { @@ -693,7 +693,7 @@ void UPnPContext::searchForIGD() { if (not clientRegistered_) { - RING_WARN("UPnP: Control Point not registered"); + JAMI_WARN("UPnP: Control Point not registered"); return; } @@ -717,7 +717,7 @@ UPnPContext::parseDevice(IXML_Document* doc, const UpnpDiscovery* d_event) /* check to see the device type */ std::string deviceType = get_first_doc_item(doc, "deviceType"); if (deviceType.empty()) { - /* RING_DBG("UPnP: could not find deviceType in the description document of the device"); */ + /* JAMI_DBG("UPnP: could not find deviceType in the description document of the device"); */ return; } @@ -739,7 +739,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) */ std::string UDN = get_first_doc_item(doc, "UDN"); if (UDN.empty()) { - RING_DBG("UPnP: could not find UDN in description document of device"); + JAMI_DBG("UPnP: could not find UDN in description document of device"); return; } @@ -759,7 +759,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) std::string friendlyName = get_first_doc_item(doc, "friendlyName"); if (not friendlyName.empty() ) - RING_DBG("UPnP: checking new device of type IGD: '%s'", + JAMI_DBG("UPnP: checking new device of type IGD: '%s'", friendlyName.c_str()); /* determine baseURL */ @@ -817,7 +817,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) if (upnp_err == UPNP_E_SUCCESS) controlURL = absolute_url; else - RING_WARN("UPnP: error resolving absolute controlURL: %s", + JAMI_WARN("UPnP: error resolving absolute controlURL: %s", UpnpGetErrorMessage(upnp_err)); std::free(absolute_url); } @@ -832,7 +832,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) if (upnp_err == UPNP_E_SUCCESS) eventSubURL = absolute_url; else - RING_WARN("UPnP: error resolving absolute eventSubURL: %s", + JAMI_WARN("UPnP: error resolving absolute eventSubURL: %s", UpnpGetErrorMessage(upnp_err)); std::free(absolute_url); } @@ -840,7 +840,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) /* make sure all of the services are defined * and check if the IGD is connected to an external network */ if (not (serviceId.empty() and controlURL.empty() and eventSubURL.empty()) ) { - /* RING_DBG("UPnP: got service info from device:\n\tserviceType: %s\n\tserviceID: %s\n\tcontrolURL: %s\n\teventSubURL: %s", + /* JAMI_DBG("UPnP: got service info from device:\n\tserviceType: %s\n\tserviceID: %s\n\tcontrolURL: %s\n\teventSubURL: %s", serviceType.c_str(), serviceId.c_str(), controlURL.c_str(), eventSubURL.c_str()); */ new_igd.reset(new UPnPIGD( std::move(UDN), @@ -853,7 +853,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) if (isIGDConnected(*new_igd)) { new_igd->publicIp = getExternalIP(*new_igd); if (new_igd->publicIp) { - RING_DBG("UPnP: got external IP: %s", new_igd->publicIp.toString().c_str()); + JAMI_DBG("UPnP: got external IP: %s", new_igd->publicIp.toString().c_str()); new_igd->localIp = ip_utils::getLocalAddr(pj_AF_INET()); if (new_igd->localIp) found_connected_IGD = true; @@ -863,9 +863,9 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) } /* TODO: subscribe to the service to get events, eg: when IP changes */ } else - RING_WARN("UPnP: IGD \"serviceType\" parent node is not called \"service\"!"); + JAMI_WARN("UPnP: IGD \"serviceType\" parent node is not called \"service\"!"); } else - RING_WARN("UPnP: IGD \"serviceType\" has no parent node!"); + JAMI_WARN("UPnP: IGD \"serviceType\" has no parent node!"); } } @@ -874,7 +874,7 @@ UPnPContext::parseIGD(IXML_Document* doc, const UpnpDiscovery* d_event) * updates about state changes, eg: new external IP */ if (found_connected_IGD) { - RING_DBG("UPnP: found a valid IGD: %s", new_igd->getBaseURL().c_str()); + JAMI_DBG("UPnP: found a valid IGD: %s", new_igd->getBaseURL().c_str()); { std::lock_guard<std::mutex> lock(validIGDMutex_); @@ -937,7 +937,7 @@ UPnPContext::cp_callback(Upnp_EventType event_type, const void* event, void* use if (auto upnpContext = static_cast<UPnPContext*>(user_data)) return upnpContext->handleUPnPEvents(event_type, event); - RING_WARN("UPnP callback without UPnPContext"); + JAMI_WARN("UPnP callback without UPnPContext"); return 0; } @@ -947,7 +947,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) switch( event_type ) { case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: - /* RING_DBG("UPnP: CP received a discovery advertisement"); */ + /* JAMI_DBG("UPnP: CP received a discovery advertisement"); */ case UPNP_DISCOVERY_SEARCH_RESULT: { const UpnpDiscovery* d_event = ( const UpnpDiscovery* )event; @@ -955,7 +955,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) int upnp_err; /* if (event_type != UPNP_DISCOVERY_ADVERTISEMENT_ALIVE) - RING_DBG("UPnP: CP received a discovery search result"); */ + JAMI_DBG("UPnP: CP received a discovery search result"); */ /* check if we are already in the process of checking this device */ std::unique_lock<std::mutex> lock(cpDeviceMutex_); @@ -966,10 +966,10 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) lock.unlock(); if (UpnpDiscovery_get_ErrCode(d_event) != UPNP_E_SUCCESS) - RING_WARN("UPnP: Error in discovery event received by the CP: %s", + JAMI_WARN("UPnP: Error in discovery event received by the CP: %s", UpnpGetErrorMessage(UpnpDiscovery_get_ErrCode(d_event))); - /* RING_DBG("UPnP: Control Point received discovery event from device:\n\tid: %s\n\ttype: %s\n\tservice: %s\n\tversion: %s\n\tlocation: %s\n\tOS: %s", + /* JAMI_DBG("UPnP: Control Point received discovery event from device:\n\tid: %s\n\ttype: %s\n\tservice: %s\n\tversion: %s\n\tlocation: %s\n\tOS: %s", d_event->DeviceId, d_event->DeviceType, d_event->ServiceType, d_event->ServiceVer, UpnpDiscovery_get_Location_cstr(d_event), d_event->Os); */ @@ -985,7 +985,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) * because the router has UPnP disabled, but is still sending * UPnP discovery packets * - * RING_WARN("UPnP: Error downloading device description: %s", + * JAMI_WARN("UPnP: Error downloading device description: %s", * UpnpGetErrorMessage(upnp_err)); */ } else { @@ -1001,7 +1001,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) lock.unlock(); } else { lock.unlock(); - /* RING_DBG("UPnP: Control Point is already checking this device"); */ + /* JAMI_DBG("UPnP: Control Point is already checking this device"); */ } } break; @@ -1010,11 +1010,11 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) { const UpnpDiscovery *d_event = (const UpnpDiscovery *)event; - RING_DBG("UPnP: Control Point received ByeBye for device: %s", + JAMI_DBG("UPnP: Control Point received ByeBye for device: %s", UpnpDiscovery_get_DeviceID_cstr(d_event)); if (UpnpDiscovery_get_ErrCode(d_event) != UPNP_E_SUCCESS) - RING_WARN("UPnP: Error in ByeBye received by the CP: %s", + JAMI_WARN("UPnP: Error in ByeBye received by the CP: %s", UpnpGetErrorMessage(UpnpDiscovery_get_ErrCode(d_event))); /* TODO: check if its a device we care about and remove it from the relevant lists */ @@ -1025,7 +1025,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) { /* struct Upnp_Event *e_event UNUSED = (struct Upnp_Event *)event; */ - /* RING_DBG("UPnP: Control Point event received"); */ + /* JAMI_DBG("UPnP: Control Point event received"); */ /* TODO: handle event by updating any changed state variables */ @@ -1034,18 +1034,18 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) case UPNP_EVENT_AUTORENEWAL_FAILED: { - RING_WARN("UPnP: Control Point subscription auto-renewal failed"); + JAMI_WARN("UPnP: Control Point subscription auto-renewal failed"); } break; case UPNP_EVENT_SUBSCRIPTION_EXPIRED: { - RING_DBG("UPnP: Control Point subscription expired"); + JAMI_DBG("UPnP: Control Point subscription expired"); } break; case UPNP_EVENT_SUBSCRIBE_COMPLETE: - /* RING_DBG("UPnP: Control Point async subscription complete"); */ + /* JAMI_DBG("UPnP: Control Point async subscription complete"); */ /* TODO: check if successful */ @@ -1055,7 +1055,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) /* this event will occur whether or not a valid IGD has been found; * it just indicates the search timeout has been reached * - * RING_DBG("UPnP: Control Point search timeout"); + * JAMI_DBG("UPnP: Control Point search timeout"); */ break; @@ -1063,10 +1063,10 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) { const UpnpActionComplete *a_event = (const UpnpActionComplete *)event; - /* RING_DBG("UPnP: Control Point async action complete"); */ + /* JAMI_DBG("UPnP: Control Point async action complete"); */ if (UpnpActionComplete_get_ErrCode(a_event) != UPNP_E_SUCCESS) - RING_WARN("UPnP: Error in action complete event: %s", + JAMI_WARN("UPnP: Error in action complete event: %s", UpnpGetErrorMessage(UpnpActionComplete_get_ErrCode(a_event))); /* TODO: no need for any processing here, just print out results. @@ -1078,10 +1078,10 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) { const UpnpStateVarComplete *sv_event = (const UpnpStateVarComplete *)event; - /* RING_DBG("UPnP: Control Point async get variable complete"); */ + /* JAMI_DBG("UPnP: Control Point async get variable complete"); */ if (UpnpStateVarComplete_get_ErrCode(sv_event) != UPNP_E_SUCCESS) - RING_WARN("UPnP: Error in get variable complete event: %s", + JAMI_WARN("UPnP: Error in get variable complete event: %s", UpnpGetErrorMessage(UpnpStateVarComplete_get_ErrCode(sv_event))); /* TODO: update state variables */ @@ -1089,7 +1089,7 @@ UPnPContext::handleUPnPEvents(Upnp_EventType event_type, const void* event) break; default: - RING_WARN("UPnP: unhandled Control Point event"); + JAMI_WARN("UPnP: unhandled Control Point event"); break; } @@ -1105,7 +1105,7 @@ checkResponseError(IXML_Document* doc) std::string errorCode = get_first_doc_item(doc, "errorCode"); if (not errorCode.empty()) { std::string errorDescription = get_first_doc_item(doc, "errorDescription"); - RING_WARN("UPnP: response contains error: %s : %s", + JAMI_WARN("UPnP: response contains error: %s : %s", errorCode.c_str(), errorDescription.c_str()); } } @@ -1125,7 +1125,7 @@ UPnPContext::isIGDConnected(const UPnPIGD& igd) checkResponseError(response.get()); if( upnp_err != UPNP_E_SUCCESS) { /* TODO: if failed, should we chck if the igd is disconnected? */ - RING_WARN("UPnP: Failed to get GetStatusInfo from: %s, %d: %s", + JAMI_WARN("UPnP: Failed to get GetStatusInfo from: %s, %d: %s", igd.getServiceType().c_str(), upnp_err, UpnpGetErrorMessage(upnp_err)); return false; @@ -1157,7 +1157,7 @@ UPnPContext::getExternalIP(const UPnPIGD& igd) checkResponseError(response.get()); if( upnp_err != UPNP_E_SUCCESS) { /* TODO: if failed, should we chck if the igd is disconnected? */ - RING_WARN("UPnP: Failed to get GetExternalIPAddress from: %s, %d: %s", + JAMI_WARN("UPnP: Failed to get GetExternalIPAddress from: %s, %d: %s", igd.getServiceType().c_str(), upnp_err, UpnpGetErrorMessage(upnp_err)); return {}; } @@ -1170,11 +1170,11 @@ void UPnPContext::removeMappingsByLocalIPAndDescription(const UPnPIGD& igd, const std::string& description) { if (!igd.localIp) { - RING_DBG("UPnP: cannot determine local IP in function removeMappingsByLocalIPAndDescription()"); + JAMI_DBG("UPnP: cannot determine local IP in function removeMappingsByLocalIPAndDescription()"); return; } - RING_DBG("UPnP: removing all port mappings with description: \"%s\" and local ip: %s", + JAMI_DBG("UPnP: removing all port mappings with description: \"%s\" and local ip: %s", description.c_str(), igd.localIp.toString().c_str()); int entry_idx = 0; @@ -1184,7 +1184,7 @@ UPnPContext::removeMappingsByLocalIPAndDescription(const UPnPIGD& igd, const std std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> action(nullptr, ixmlDocument_free); IXML_Document* action_ptr = nullptr; UpnpAddToAction(&action_ptr, "GetGenericPortMappingEntry", igd.getServiceType().c_str(), - "NewPortMappingIndex", ring::to_string(entry_idx).c_str()); + "NewPortMappingIndex", jami::to_string(entry_idx).c_str()); action.reset(action_ptr); std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> response(nullptr, ixmlDocument_free); @@ -1194,7 +1194,7 @@ UPnPContext::removeMappingsByLocalIPAndDescription(const UPnPIGD& igd, const std response.reset(response_ptr); if( not response and upnp_err != UPNP_E_SUCCESS) { /* TODO: if failed, should we chck if the igd is disconnected? */ - RING_WARN("UPnP: Failed to get GetGenericPortMappingEntry from: %s, %d: %s", + JAMI_WARN("UPnP: Failed to get GetGenericPortMappingEntry from: %s, %d: %s", igd.getServiceType().c_str(), upnp_err, UpnpGetErrorMessage(upnp_err)); return; } @@ -1214,7 +1214,7 @@ UPnPContext::removeMappingsByLocalIPAndDescription(const UPnPIGD& igd, const std std::string port_external = get_first_doc_item(response.get(), "NewExternalPort"); std::string protocol = get_first_doc_item(response.get(), "NewProtocol"); - RING_DBG("UPnP: deleting entry with matching desciption and ip:\n\t%s %5s->%s:%-5s '%s'", + JAMI_DBG("UPnP: deleting entry with matching desciption and ip:\n\t%s %5s->%s:%-5s '%s'", protocol.c_str(), port_external.c_str(), client_ip.c_str(), port_internal.c_str(), desc_actual.c_str()); /* delete entry */ @@ -1233,7 +1233,7 @@ UPnPContext::removeMappingsByLocalIPAndDescription(const UPnPIGD& igd, const std done = true; } else { std::string errorDescription = get_first_doc_item(response.get(), "errorDescription"); - RING_WARN("UPnP: GetGenericPortMappingEntry returned with error: %s: %s", + JAMI_WARN("UPnP: GetGenericPortMappingEntry returned with error: %s: %s", errorCode.c_str(), errorDescription.c_str()); done = true; } @@ -1261,7 +1261,7 @@ UPnPContext::deletePortMapping(const UPnPIGD& igd, const std::string& port_exter response.reset(response_ptr); if( upnp_err != UPNP_E_SUCCESS) { /* TODO: if failed, should we check if the igd is disconnected? */ - RING_WARN("UPnP: Failed to get %s from: %s, %d: %s", action_name.c_str(), + JAMI_WARN("UPnP: Failed to get %s from: %s, %d: %s", action_name.c_str(), igd.getServiceType().c_str(), upnp_err, UpnpGetErrorMessage(upnp_err)); return false; } @@ -1269,7 +1269,7 @@ UPnPContext::deletePortMapping(const UPnPIGD& igd, const std::string& port_exter std::string errorCode = get_first_doc_item(response.get(), "errorCode"); if (not errorCode.empty()) { std::string errorDescription = get_first_doc_item(response.get(), "errorDescription"); - RING_WARN("UPnP: %s returned with error: %s: %s", + JAMI_WARN("UPnP: %s returned with error: %s: %s", action_name.c_str(), errorCode.c_str(), errorDescription.c_str()); return false; } @@ -1310,7 +1310,7 @@ UPnPContext::addPortMapping(const UPnPIGD& igd, const Mapping& mapping, int* err response.reset(response_ptr); if( not response and upnp_err != UPNP_E_SUCCESS) { /* TODO: if failed, should we chck if the igd is disconnected? */ - RING_WARN("UPnP: Failed to %s from: %s, %d: %s", action_name.c_str(), + JAMI_WARN("UPnP: Failed to %s from: %s, %d: %s", action_name.c_str(), igd.getServiceType().c_str(), upnp_err, UpnpGetErrorMessage(upnp_err)); *error_code = -1; /* make sure to -1 since we didn't get a response */ return false; @@ -1320,9 +1320,9 @@ UPnPContext::addPortMapping(const UPnPIGD& igd, const Mapping& mapping, int* err std::string errorCode = get_first_doc_item(response.get(), "errorCode"); if (not errorCode.empty()) { std::string errorDescription = get_first_doc_item(response.get(), "errorDescription"); - RING_WARN("UPnP: %s returned with error: %s: %s", + JAMI_WARN("UPnP: %s returned with error: %s: %s", action_name.c_str(), errorCode.c_str(), errorDescription.c_str()); - *error_code = ring::stoi(errorCode); + *error_code = jami::stoi(errorCode); return false; } return true; @@ -1330,4 +1330,4 @@ UPnPContext::addPortMapping(const UPnPIGD& igd, const Mapping& mapping, int* err #endif /* HAVE_LIBUPNP */ -}} // namespace ring::upnp +}} // namespace jami::upnp diff --git a/src/upnp/upnp_context.h b/src/upnp/upnp_context.h index 9a214aaf58..82e33abd0f 100644 --- a/src/upnp/upnp_context.h +++ b/src/upnp/upnp_context.h @@ -50,11 +50,11 @@ #include <atomic> #include <thread> -namespace ring { +namespace jami { class IpAddr; } -namespace ring { namespace upnp { +namespace jami { namespace upnp { class UPnPContext { public: @@ -262,4 +262,4 @@ private: */ std::shared_ptr<UPnPContext> getUPnPContext(); -}} // namespace ring::upnp +}} // namespace jami::upnp diff --git a/src/upnp/upnp_control.cpp b/src/upnp/upnp_control.cpp index 0391b6a9ac..3d8ff7fb24 100644 --- a/src/upnp/upnp_control.cpp +++ b/src/upnp/upnp_control.cpp @@ -31,14 +31,14 @@ #include "upnp_context.h" #include "upnp_igd.h" -namespace ring { namespace upnp { +namespace jami { namespace upnp { Controller::Controller() { try { upnpContext_ = getUPnPContext(); } catch (std::runtime_error& e) { - RING_ERR("UPnP context error: %s", e.what()); + JAMI_ERR("UPnP context error: %s", e.what()); } } @@ -138,4 +138,4 @@ Controller::getExternalIP() const return {}; // empty address } -}} // namespace ring::upnp +}} // namespace jami::upnp diff --git a/src/upnp/upnp_control.h b/src/upnp/upnp_control.h index 4564d4fe78..c232dc423c 100644 --- a/src/upnp/upnp_control.h +++ b/src/upnp/upnp_control.h @@ -31,11 +31,11 @@ #include "noncopyable.h" #include "upnp_igd.h" -namespace ring { +namespace jami { class IpAddr; } -namespace ring { namespace upnp { +namespace jami { namespace upnp { class UPnPContext; @@ -125,6 +125,6 @@ private: void removeMappings(PortType type); }; -}} // namespace ring::upnp +}} // namespace jami::upnp #endif /* UPNP_H_ */ diff --git a/src/upnp/upnp_igd.cpp b/src/upnp/upnp_igd.cpp index 21ce951507..bbe92bc797 100644 --- a/src/upnp/upnp_igd.cpp +++ b/src/upnp/upnp_igd.cpp @@ -20,7 +20,7 @@ #include "upnp_igd.h" -namespace ring { namespace upnp { +namespace jami { namespace upnp { /* move constructor and operator */ Mapping::Mapping(Mapping&& other) noexcept @@ -62,4 +62,4 @@ bool operator!= (const Mapping& cMap1, const Mapping& cMap2) return !(cMap1 == cMap2); } -}} // namespace ring::upnp +}} // namespace jami::upnp diff --git a/src/upnp/upnp_igd.h b/src/upnp/upnp_igd.h index a80202b890..34ddf911a2 100644 --- a/src/upnp/upnp_igd.h +++ b/src/upnp/upnp_igd.h @@ -33,7 +33,7 @@ #include "ip_utils.h" #include "string_utils.h" -namespace ring { namespace upnp { +namespace jami { namespace upnp { enum class PortType {UDP,TCP}; @@ -68,9 +68,9 @@ public: friend bool operator!= (const Mapping& cRedir1, const Mapping& cRedir2); uint16_t getPortExternal() const { return port_external_; } - std::string getPortExternalStr() const { return ring::to_string(port_external_); } + std::string getPortExternalStr() const { return jami::to_string(port_external_); } uint16_t getPortInternal() const { return port_internal_; } - std::string getPortInternalStr() const { return ring::to_string(port_internal_); } + std::string getPortInternalStr() const { return jami::to_string(port_internal_); } PortType getType() const { return type_; } std::string getTypeStr() const { return type_ == PortType::UDP ? "UDP" : "TCP"; } std::string getDescription() const { return description_; } @@ -240,4 +240,4 @@ public: #endif -}} // namespace ring::upnp +}} // namespace jami::upnp diff --git a/src/utf8_utils.cpp b/src/utf8_utils.cpp index 9de9bce6d4..c9657f0ebd 100644 --- a/src/utf8_utils.cpp +++ b/src/utf8_utils.cpp @@ -64,7 +64,7 @@ using ssize_t = SSIZE_T; val <<= 6; \ val |= (*(unsigned char *)p) & 0x3f; -namespace ring { +namespace jami { bool utf8_validate_c_str(const char *str, ssize_t max_len, const char **end); @@ -302,4 +302,4 @@ utf8_make_valid(const std::string & name) return answer; } -} // namespace ring +} // namespace jami diff --git a/src/utf8_utils.h b/src/utf8_utils.h index cf9a23fd41..be54523606 100644 --- a/src/utf8_utils.h +++ b/src/utf8_utils.h @@ -26,7 +26,7 @@ #include <cstdlib> #include <string> -namespace ring { +namespace jami { /** * utf8_validate: @@ -57,6 +57,6 @@ utf8_validate(const std::string & str); std::string utf8_make_valid(const std::string & name); -} // namespace ring +} // namespace jami #endif // H_UTF8_UTILS diff --git a/test/sip/test_SIP.cpp b/test/sip/test_SIP.cpp index eeeb9f9cd8..c66ff0814b 100644 --- a/test/sip/test_SIP.cpp +++ b/test/sip/test_SIP.cpp @@ -31,7 +31,7 @@ #include "test_SIP.h" #include "call_const.h" -using namespace ring; +using namespace jami; static pthread_mutex_t count_mutex; static pthread_cond_t count_nb_thread; diff --git a/test/turn/test_TURN.cpp b/test/turn/test_TURN.cpp index 75eaa1ca91..7c683dfe75 100644 --- a/test/turn/test_TURN.cpp +++ b/test/turn/test_TURN.cpp @@ -28,7 +28,7 @@ #include <thread> #include <vector> -using namespace ring; +using namespace jami; CPPUNIT_TEST_SUITE_REGISTRATION( test_TURN ); diff --git a/test/unitTest/account_factory/testAccount_factory.cpp b/test/unitTest/account_factory/testAccount_factory.cpp index 94402b89dc..75c04a8013 100644 --- a/test/unitTest/account_factory/testAccount_factory.cpp +++ b/test/unitTest/account_factory/testAccount_factory.cpp @@ -27,7 +27,7 @@ #include "account_const.h" -namespace ring { namespace test { +namespace jami { namespace test { class Account_factoryTest : public CppUnit::TestFixture { public: @@ -133,6 +133,6 @@ Account_factoryTest::testClear() CPPUNIT_ASSERT(accountFactory->accountCount()==0); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::Account_factoryTest::name()) +RING_TEST_RUNNER(jami::test::Account_factoryTest::name()) diff --git a/test/unitTest/base64/base64.cpp b/test/unitTest/base64/base64.cpp index 560d258d29..22304ce945 100644 --- a/test/unitTest/base64/base64.cpp +++ b/test/unitTest/base64/base64.cpp @@ -26,7 +26,7 @@ #include "base64.h" -namespace ring { namespace test { +namespace jami { namespace test { class Base64Test : public CppUnit::TestFixture { public: @@ -53,14 +53,14 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Base64Test, Base64Test::name()); void Base64Test::encodingTest() { - const std::string output = ring::base64::encode(test_bytes); + const std::string output = jami::base64::encode(test_bytes); CPPUNIT_ASSERT(test_base64.compare(output) == 0); } void Base64Test::decodingTestSuccess() { - const std::vector<uint8_t> output = ring::base64::decode(test_base64); + const std::vector<uint8_t> output = jami::base64::decode(test_base64); CPPUNIT_ASSERT(std::equal(test_bytes.begin(), test_bytes.end(), output.begin())); } @@ -70,10 +70,10 @@ Base64Test::decodingTestFail() // Currently, the input is not validated, i.e. the function most not throw an // exception if decoding fails to make sure calling code not expecting any // is no broken. (Some validation should be implemented sometimes later, though. - ring::base64::decode(test_invalid_base64); + jami::base64::decode(test_invalid_base64); CPPUNIT_ASSERT(true); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::Base64Test::name()); +RING_TEST_RUNNER(jami::test::Base64Test::name()); diff --git a/test/unitTest/certstore.cpp b/test/unitTest/certstore.cpp index 4d377bbc02..c679d99073 100644 --- a/test/unitTest/certstore.cpp +++ b/test/unitTest/certstore.cpp @@ -26,7 +26,7 @@ #include "security/certstore.h" -namespace ring { namespace test { +namespace jami { namespace test { class CertStoreTest : public CppUnit::TestFixture { public: @@ -45,59 +45,59 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CertStoreTest, CertStoreTest::name()); void CertStoreTest::trustStoreTest() { - ring::tls::TrustStore trustStore; + jami::tls::TrustStore trustStore; auto ca = dht::crypto::generateIdentity("test CA"); auto account = dht::crypto::generateIdentity("test account", ca, 4096, true); auto device = dht::crypto::generateIdentity("test device", account); auto device2 = dht::crypto::generateIdentity("test device 2", account); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::UNDEFINED); - trustStore.setCertificateStatus(ca.second, ring::tls::TrustStore::PermissionStatus::ALLOWED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::ALLOWED); - trustStore.setCertificateStatus(ca.second, ring::tls::TrustStore::PermissionStatus::UNDEFINED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::UNDEFINED); - trustStore.setCertificateStatus(ca.second, ring::tls::TrustStore::PermissionStatus::ALLOWED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::ALLOWED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::UNDEFINED); + trustStore.setCertificateStatus(ca.second, jami::tls::TrustStore::PermissionStatus::ALLOWED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::ALLOWED); + trustStore.setCertificateStatus(ca.second, jami::tls::TrustStore::PermissionStatus::UNDEFINED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::UNDEFINED); + trustStore.setCertificateStatus(ca.second, jami::tls::TrustStore::PermissionStatus::ALLOWED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::ALLOWED); CPPUNIT_ASSERT(trustStore.isAllowed(*ca.second)); CPPUNIT_ASSERT(trustStore.isAllowed(*account.second)); CPPUNIT_ASSERT(trustStore.isAllowed(*device.second)); // Ban device - trustStore.setCertificateStatus(device.second, ring::tls::TrustStore::PermissionStatus::BANNED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(device.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::BANNED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::ALLOWED); + trustStore.setCertificateStatus(device.second, jami::tls::TrustStore::PermissionStatus::BANNED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(device.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::BANNED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::ALLOWED); CPPUNIT_ASSERT(trustStore.isAllowed(*ca.second)); CPPUNIT_ASSERT(trustStore.isAllowed(*account.second)); CPPUNIT_ASSERT(not trustStore.isAllowed(*device.second)); // Ban account - trustStore.setCertificateStatus(account.second, ring::tls::TrustStore::PermissionStatus::BANNED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(account.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::BANNED); + trustStore.setCertificateStatus(account.second, jami::tls::TrustStore::PermissionStatus::BANNED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(account.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::BANNED); CPPUNIT_ASSERT(trustStore.isAllowed(*ca.second)); CPPUNIT_ASSERT(not trustStore.isAllowed(*account.second)); CPPUNIT_ASSERT(not trustStore.isAllowed(*device2.second)); // Unban account - trustStore.setCertificateStatus(account.second, ring::tls::TrustStore::PermissionStatus::ALLOWED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(account.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::ALLOWED); + trustStore.setCertificateStatus(account.second, jami::tls::TrustStore::PermissionStatus::ALLOWED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(account.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::ALLOWED); CPPUNIT_ASSERT(trustStore.isAllowed(*ca.second)); CPPUNIT_ASSERT(trustStore.isAllowed(*account.second)); CPPUNIT_ASSERT(trustStore.isAllowed(*device2.second)); // Ban CA - trustStore.setCertificateStatus(ca.second, ring::tls::TrustStore::PermissionStatus::BANNED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::BANNED); + trustStore.setCertificateStatus(ca.second, jami::tls::TrustStore::PermissionStatus::BANNED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::BANNED); CPPUNIT_ASSERT(not trustStore.isAllowed(*ca.second)); CPPUNIT_ASSERT(not trustStore.isAllowed(*account.second)); CPPUNIT_ASSERT(not trustStore.isAllowed(*device2.second)); - trustStore.setCertificateStatus(ca.second, ring::tls::TrustStore::PermissionStatus::BANNED); - CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == ring::tls::TrustStore::PermissionStatus::BANNED); + trustStore.setCertificateStatus(ca.second, jami::tls::TrustStore::PermissionStatus::BANNED); + CPPUNIT_ASSERT(trustStore.getCertificateStatus(ca.second->getId().toString()) == jami::tls::TrustStore::PermissionStatus::BANNED); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::CertStoreTest::name()); +RING_TEST_RUNNER(jami::test::CertStoreTest::name()); diff --git a/test/unitTest/channel/testChannel.cpp b/test/unitTest/channel/testChannel.cpp index fa61f7f802..47e178dae0 100644 --- a/test/unitTest/channel/testChannel.cpp +++ b/test/unitTest/channel/testChannel.cpp @@ -29,7 +29,7 @@ #include "channel.h" -namespace ring { namespace test { +namespace jami { namespace test { // During a receive operation we should not wait more than this timeout, // otherwise it would indicate a thread starvation. @@ -72,8 +72,8 @@ ChannelTest::emptyStateTest() CPPUNIT_ASSERT(unlimited_channel.empty()); CPPUNIT_ASSERT(unlimited_channel.size() == 0); - CPPUNIT_ASSERT_THROW(limited_channel.receive(timeout), ring::ChannelEmpty); - CPPUNIT_ASSERT_THROW(unlimited_channel.receive(timeout), ring::ChannelEmpty); + CPPUNIT_ASSERT_THROW(limited_channel.receive(timeout), jami::ChannelEmpty); + CPPUNIT_ASSERT_THROW(unlimited_channel.receive(timeout), jami::ChannelEmpty); } void @@ -221,6 +221,6 @@ ChannelTest::dinningPhilosophersTest() [&table, i]{ philosopher_job<N>(table, i); }); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::ChannelTest::name()); +RING_TEST_RUNNER(jami::test::ChannelTest::name()); diff --git a/test/unitTest/fileutils/testFileutils.cpp b/test/unitTest/fileutils/testFileutils.cpp index cd603d65df..53573f436b 100644 --- a/test/unitTest/fileutils/testFileutils.cpp +++ b/test/unitTest/fileutils/testFileutils.cpp @@ -31,7 +31,7 @@ #include <cstdlib> #include <unistd.h> -namespace ring { namespace fileutils { namespace test { +namespace jami { namespace fileutils { namespace test { class FileutilsTest : public CppUnit::TestFixture { public: @@ -178,6 +178,6 @@ FileutilsTest::testFullPath() CPPUNIT_ASSERT(getFullPath(NON_EXISTANT_PATH_BASE, "test").compare(NON_EXISTANT_PATH) == 0); } -}}} // namespace ring::test::fileutils +}}} // namespace jami::test::fileutils -RING_TEST_RUNNER(ring::fileutils::test::FileutilsTest::name()); +RING_TEST_RUNNER(jami::fileutils::test::FileutilsTest::name()); diff --git a/test/unitTest/map_utils/testMap_utils.cpp b/test/unitTest/map_utils/testMap_utils.cpp index b71f837918..9e2dd31966 100644 --- a/test/unitTest/map_utils/testMap_utils.cpp +++ b/test/unitTest/map_utils/testMap_utils.cpp @@ -29,7 +29,7 @@ #include "../../test_runner.h" -namespace ring { namespace map_utils { namespace test { +namespace jami { namespace map_utils { namespace test { class MapUtilsTest : public CppUnit::TestFixture { public: @@ -89,6 +89,6 @@ MapUtilsTest::test_extractValues() } } -}}} // namespace ring::map_utils::test +}}} // namespace jami::map_utils::test -RING_TEST_RUNNER(ring::map_utils::test::MapUtilsTest::name()); +RING_TEST_RUNNER(jami::map_utils::test::MapUtilsTest::name()); diff --git a/test/unitTest/media/audio/test_audio_frame_resizer.cpp b/test/unitTest/media/audio/test_audio_frame_resizer.cpp index 3aea8873e3..f07c628904 100644 --- a/test/unitTest/media/audio/test_audio_frame_resizer.cpp +++ b/test/unitTest/media/audio/test_audio_frame_resizer.cpp @@ -32,7 +32,7 @@ #include <stdexcept> -namespace ring { namespace test { +namespace jami { namespace test { class AudioFrameResizerTest : public CppUnit::TestFixture { public: @@ -129,6 +129,6 @@ AudioFrameResizerTest::testDifferentFormat() CPPUNIT_ASSERT(q_->samples() == 0); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::AudioFrameResizerTest::name()); +RING_TEST_RUNNER(jami::test::AudioFrameResizerTest::name()); diff --git a/test/unitTest/media/audio/test_resampler.cpp b/test/unitTest/media/audio/test_resampler.cpp index 617c1e2141..5f4c3afdae 100644 --- a/test/unitTest/media/audio/test_resampler.cpp +++ b/test/unitTest/media/audio/test_resampler.cpp @@ -29,7 +29,7 @@ #include "../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class ResamplerTest : public CppUnit::TestFixture { public: @@ -132,6 +132,6 @@ ResamplerTest::testRematrix() CPPUNIT_ASSERT(output2->pointer()->data && output2->pointer()->data[0]); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::ResamplerTest::name()); +RING_TEST_RUNNER(jami::test::ResamplerTest::name()); diff --git a/test/unitTest/media/test_media_decoder.cpp b/test/unitTest/media/test_media_decoder.cpp index 5c4e62844a..4b51aa4834 100644 --- a/test/unitTest/media/test_media_decoder.cpp +++ b/test/unitTest/media/test_media_decoder.cpp @@ -32,7 +32,7 @@ #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class MediaDecoderTest : public CppUnit::TestFixture { public: @@ -157,6 +157,6 @@ MediaDecoderTest::writeWav() write(f, length - 8, 4); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::MediaDecoderTest::name()); +RING_TEST_RUNNER(jami::test::MediaDecoderTest::name()); diff --git a/test/unitTest/media/test_media_encoder.cpp b/test/unitTest/media/test_media_encoder.cpp index 414c688fa0..d7e60e790c 100644 --- a/test/unitTest/media/test_media_encoder.cpp +++ b/test/unitTest/media/test_media_encoder.cpp @@ -31,7 +31,7 @@ #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class MediaEncoderTest : public CppUnit::TestFixture { public: @@ -153,11 +153,11 @@ MediaEncoderTest::testMultiStream() options["channels"] = std::to_string(nbChannels); options["width"] = std::to_string(width); options["height"] = std::to_string(height); - auto vp8Codec = std::static_pointer_cast<ring::SystemVideoCodecInfo>( - getSystemCodecContainer()->searchCodecByName("VP8", ring::MEDIA_VIDEO) + auto vp8Codec = std::static_pointer_cast<jami::SystemVideoCodecInfo>( + getSystemCodecContainer()->searchCodecByName("VP8", jami::MEDIA_VIDEO) ); auto opusCodec = std::static_pointer_cast<SystemAudioCodecInfo>( - getSystemCodecContainer()->searchCodecByName("opus", ring::MEDIA_AUDIO) + getSystemCodecContainer()->searchCodecByName("opus", jami::MEDIA_AUDIO) ); try { @@ -196,6 +196,6 @@ MediaEncoderTest::testMultiStream() } } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::MediaEncoderTest::name()); +RING_TEST_RUNNER(jami::test::MediaEncoderTest::name()); diff --git a/test/unitTest/media/test_media_filter.cpp b/test/unitTest/media/test_media_filter.cpp index ce5c100062..f158b198a0 100644 --- a/test/unitTest/media/test_media_filter.cpp +++ b/test/unitTest/media/test_media_filter.cpp @@ -29,7 +29,7 @@ #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class MediaFilterTest : public CppUnit::TestFixture { public: @@ -339,6 +339,6 @@ MediaFilterTest::testReinit() CPPUNIT_ASSERT(filter_->feedInput(frame, "in1") >= 0); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::MediaFilterTest::name()); +RING_TEST_RUNNER(jami::test::MediaFilterTest::name()); diff --git a/test/unitTest/media/test_media_frame.cpp b/test/unitTest/media/test_media_frame.cpp index 06abda6e53..df8ea12070 100644 --- a/test/unitTest/media/test_media_frame.cpp +++ b/test/unitTest/media/test_media_frame.cpp @@ -33,7 +33,7 @@ extern "C" { #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class MediaFrameTest : public CppUnit::TestFixture { public: @@ -120,6 +120,6 @@ MediaFrameTest::testMix() CPPUNIT_ASSERT(d2[6] == std::numeric_limits<AudioSample>::max()); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::MediaFrameTest::name()); +RING_TEST_RUNNER(jami::test::MediaFrameTest::name()); diff --git a/test/unitTest/media/video/testVideo_input.cpp b/test/unitTest/media/video/testVideo_input.cpp index 5f09b7c068..719b050d92 100644 --- a/test/unitTest/media/video/testVideo_input.cpp +++ b/test/unitTest/media/video/testVideo_input.cpp @@ -32,7 +32,7 @@ #include <map> #include <string> -namespace ring { namespace test { +namespace jami { namespace test { class VideoInputTest : public CppUnit::TestFixture { public: @@ -66,6 +66,6 @@ VideoInputTest::testInput() video.switchInput(resource); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::VideoInputTest::name()); +RING_TEST_RUNNER(jami::test::VideoInputTest::name()); diff --git a/test/unitTest/media/video/test_video_scaler.cpp b/test/unitTest/media/video/test_video_scaler.cpp index ebc7da468a..d3ccfa4996 100644 --- a/test/unitTest/media/video/test_video_scaler.cpp +++ b/test/unitTest/media/video/test_video_scaler.cpp @@ -28,7 +28,7 @@ #include "../../../test_runner.h" -namespace ring { namespace video { namespace test { +namespace jami { namespace video { namespace test { class VideoScalerTest : public CppUnit::TestFixture { public: @@ -105,6 +105,6 @@ VideoScalerTest::testScaleWithAspect() CPPUNIT_ASSERT(output.height() == 360); } -}}} // namespace ring::test +}}} // namespace jami::test -RING_TEST_RUNNER(ring::video::test::VideoScalerTest::name()); +RING_TEST_RUNNER(jami::video::test::VideoScalerTest::name()); diff --git a/test/unitTest/smartools/testSmartools.cpp b/test/unitTest/smartools/testSmartools.cpp index 881eeb2ac1..db48b37b28 100644 --- a/test/unitTest/smartools/testSmartools.cpp +++ b/test/unitTest/smartools/testSmartools.cpp @@ -25,7 +25,7 @@ #include "smartools.h" #include "../../test_runner.h" -namespace ring { +namespace jami { class SmartoolsTest : public CppUnit::TestFixture { public: static std::string name() { return "smartools"; } @@ -95,6 +95,6 @@ SmartoolsTest::testSetRemoteInformation() CPPUNIT_ASSERT(Smartools::getInstance().information_.empty()); } -} // namespace ring +} // namespace jami -RING_TEST_RUNNER(ring::SmartoolsTest::name()) +RING_TEST_RUNNER(jami::SmartoolsTest::name()) diff --git a/test/unitTest/string_utils/testString_utils.cpp b/test/unitTest/string_utils/testString_utils.cpp index c4a7d0bea6..26a63c2592 100644 --- a/test/unitTest/string_utils/testString_utils.cpp +++ b/test/unitTest/string_utils/testString_utils.cpp @@ -26,7 +26,7 @@ #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class StringUtilsTest : public CppUnit::TestFixture { public: @@ -81,10 +81,10 @@ void StringUtilsTest::to_number_test() { //test with int - CPPUNIT_ASSERT(ring::stoi(PI_42) == INT); + CPPUNIT_ASSERT(jami::stoi(PI_42) == INT); //test with double - CPPUNIT_ASSERT(ring::stod(PI_DOUBLE) == DOUBLE); + CPPUNIT_ASSERT(jami::stod(PI_DOUBLE) == DOUBLE); } void @@ -101,6 +101,6 @@ StringUtilsTest::split_string_test() && split_string_to_unsigned_result.at(1) == 45454); } -}} // namespace ring_test +}} // namespace jami_test -RING_TEST_RUNNER(ring::test::StringUtilsTest::name()); +RING_TEST_RUNNER(jami::test::StringUtilsTest::name()); diff --git a/test/unitTest/utf8_utils/testUtf8_utils.cpp b/test/unitTest/utf8_utils/testUtf8_utils.cpp index d13d4eb68f..6a964b5628 100644 --- a/test/unitTest/utf8_utils/testUtf8_utils.cpp +++ b/test/unitTest/utf8_utils/testUtf8_utils.cpp @@ -27,7 +27,7 @@ #include "../../test_runner.h" -namespace ring { namespace test { +namespace jami { namespace test { class Utf8UtilsTest : public CppUnit::TestFixture { public: @@ -66,6 +66,6 @@ Utf8UtilsTest::utf8_make_valid_test() CPPUNIT_ASSERT(utf8_validate(str)); } -}} // namespace ring::test +}} // namespace jami::test -RING_TEST_RUNNER(ring::test::Utf8UtilsTest::name()); +RING_TEST_RUNNER(jami::test::Utf8UtilsTest::name()); -- GitLab