- more changes to unify development across different projects (callers / server / hasq / softphone)

This commit is contained in:
Dmytro Bogovych 2018-06-05 13:52:17 +03:00
parent 14fb3bbdbf
commit 5afaa1299e
16 changed files with 62 additions and 53 deletions

View File

@ -55,3 +55,4 @@ target_link_libraries(rtphone ice_stack jrtplib g729_codec gsm_codec
opencore-amrnb opencore-amrwb opencore-amrnb opencore-amrwb
helper_lib audio_lib webrtc speexdsp helper_lib audio_lib webrtc speexdsp
ssl crypto opus uuid dl) ssl crypto opus uuid dl)

View File

@ -1,8 +1,9 @@
/* Copyright(C) 2007-2014 VoIP objects (voipobjects.com) /* Copyright(C) 2007-2018 VoIP objects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <assert.h>
#include "Audio_DataWindow.h" #include "Audio_DataWindow.h"
using namespace Audio; using namespace Audio;

View File

@ -6,6 +6,7 @@
#define NOMINMAX #define NOMINMAX
#include "Audio_DevicePair.h" #include "Audio_DevicePair.h"
#include <algorithm> #include <algorithm>
#include <assert.h>
#define LOG_SUBSYSTEM "Audio" #define LOG_SUBSYSTEM "Audio"

View File

@ -7,6 +7,7 @@
# include <WinSock2.h> # include <WinSock2.h>
#endif #endif
#include <assert.h>
#include "Audio_Helper.h" #include "Audio_Helper.h"
#include "../helper/HL_Exception.h" #include "../helper/HL_Exception.h"

View File

@ -1,14 +1,17 @@
/* Copyright(C) 2007-2014 VoIP objects (voipobjects.com) /* Copyright(C) 2007-2018 VoIP objects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "../config.h" #include "../config.h"
#include "../helper/HL_Exception.h" #include "../helper/HL_Exception.h"
#include "Audio_Mixer.h"
#include <algorithm>
#include "../helper/HL_Log.h" #include "../helper/HL_Log.h"
#include <algorithm>
#include <assert.h>
#include "Audio_Mixer.h"
#define LOG_SUBSYSTEM "Mixer" #define LOG_SUBSYSTEM "Mixer"
using namespace Audio; using namespace Audio;

View File

@ -1,5 +1,6 @@
#include "Audio_Null.h" #include "Audio_Null.h"
#include "helper/HL_Log.h" #include "helper/HL_Log.h"
#include <assert.h>
#define LOG_SUBSYSTEM "NULL audio" #define LOG_SUBSYSTEM "NULL audio"
using namespace Audio; using namespace Audio;

View File

@ -10,9 +10,9 @@
# include "signal_processing_library/signal_processing_library.h" # include "signal_processing_library/signal_processing_library.h"
#endif #endif
#include "../helper/HL_Pointer.h"
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <map>
namespace Audio namespace Audio
{ {

View File

@ -31,6 +31,8 @@ typedef struct {
#define LOG_SUBSYSTEM "WavFileReader" #define LOG_SUBSYSTEM "WavFileReader"
#define LOCK std::unique_lock<std::mutex> lock(mFileMtx);
using namespace Audio; using namespace Audio;
// ---------------------- WavFileReader ------------------------- // ---------------------- WavFileReader -------------------------
@ -71,7 +73,7 @@ std::string WavFileReader::readChunk()
bool WavFileReader::open(const std::tstring& filename) bool WavFileReader::open(const std::tstring& filename)
{ {
Lock lock(mFileMtx); LOCK;
try try
{ {
#ifdef WIN32 #ifdef WIN32
@ -160,7 +162,7 @@ bool WavFileReader::open(const std::tstring& filename)
void WavFileReader::close() void WavFileReader::close()
{ {
Lock lock(mFileMtx); LOCK;
if (NULL != mHandle) if (NULL != mHandle)
fclose(mHandle); fclose(mHandle);
@ -179,7 +181,7 @@ unsigned WavFileReader::read(void* buffer, unsigned bytes)
unsigned WavFileReader::read(short* buffer, unsigned samples) unsigned WavFileReader::read(short* buffer, unsigned samples)
{ {
Lock lock(mFileMtx); LOCK;
if (!mHandle) if (!mHandle)
return 0; return 0;
@ -208,14 +210,14 @@ unsigned WavFileReader::read(short* buffer, unsigned samples)
bool WavFileReader::isOpened() bool WavFileReader::isOpened()
{ {
Lock lock(mFileMtx); LOCK;
return (mHandle != 0); return (mHandle != 0);
} }
void WavFileReader::rewind() void WavFileReader::rewind()
{ {
Lock l(mFileMtx); LOCK;
if (mHandle) if (mHandle)
fseek(mHandle, mDataOffset, SEEK_SET); fseek(mHandle, mDataOffset, SEEK_SET);
@ -223,14 +225,14 @@ void WavFileReader::rewind()
std::tstring WavFileReader::filename() const std::tstring WavFileReader::filename() const
{ {
Lock lock(mFileMtx); LOCK;
return mFileName; return mFileName;
} }
unsigned WavFileReader::size() const unsigned WavFileReader::size() const
{ {
Lock l(mFileMtx); LOCK;
return mDataLength; return mDataLength;
} }
@ -258,7 +260,7 @@ void WavFileWriter::checkWriteResult(int result)
bool WavFileWriter::open(const std::tstring& filename, int rate, int channels) bool WavFileWriter::open(const std::tstring& filename, int rate, int channels)
{ {
Lock lock(mFileMtx); LOCK;
close(); close();
@ -324,7 +326,7 @@ bool WavFileWriter::open(const std::tstring& filename, int rate, int channels)
void WavFileWriter::close() void WavFileWriter::close()
{ {
Lock lock(mFileMtx); LOCK;
if (mHandle) if (mHandle)
{ {
@ -335,7 +337,7 @@ void WavFileWriter::close()
unsigned WavFileWriter::write(const void* buffer, unsigned bytes) unsigned WavFileWriter::write(const void* buffer, unsigned bytes)
{ {
Lock l(mFileMtx); LOCK;
if (!mHandle) if (!mHandle)
return 0; return 0;
@ -361,14 +363,15 @@ unsigned WavFileWriter::write(const void* buffer, unsigned bytes)
bool WavFileWriter::isOpened() bool WavFileWriter::isOpened()
{ {
Lock lock(mFileMtx); LOCK;
return (mHandle != 0); return (mHandle != 0);
} }
std::tstring WavFileWriter::filename() std::tstring WavFileWriter::filename()
{ {
Lock lock(mFileMtx); LOCK;
return mFileName; return mFileName;
} }

View File

@ -1,4 +1,4 @@
/* Copyright(C) 2007-2017 VoIPobjects (voipobjects.com) /* Copyright(C) 2007-2018 VoIPobjects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -7,13 +7,15 @@
#ifndef __AUDIO_WAVFILE_H #ifndef __AUDIO_WAVFILE_H
#define __AUDIO_WAVFILE_H #define __AUDIO_WAVFILE_H
#include "helper/HL_Sync.h" //#include "helper/HL_Types.h"
#include "helper/HL_Types.h"
#include "Audio_Resampler.h" #include "Audio_Resampler.h"
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <memory> #include <memory>
#include <mutex>
#include "helper/HL_Types.h"
namespace Audio namespace Audio
{ {
@ -26,7 +28,7 @@ namespace Audio
short mBits; short mBits;
int mRate; int mRate;
std::tstring mFileName; std::tstring mFileName;
mutable Mutex mFileMtx; mutable std::mutex mFileMtx;
unsigned mDataOffset; unsigned mDataOffset;
unsigned mDataLength; unsigned mDataLength;
Resampler mResampler; Resampler mResampler;
@ -57,7 +59,7 @@ namespace Audio
protected: protected:
FILE* mHandle; /// Handle of audio file. FILE* mHandle; /// Handle of audio file.
std::tstring mFileName; /// Path to requested audio file. std::tstring mFileName; /// Path to requested audio file.
Mutex mFileMtx; /// Mutex to protect this instance. std::mutex mFileMtx; /// Mutex to protect this instance.
int mWritten; /// Amount of written data (in bytes) int mWritten; /// Amount of written data (in bytes)
int mLengthOffset; /// Position of length field. int mLengthOffset; /// Position of length field.
int mRate, mChannels; int mRate, mChannels;

View File

@ -20,3 +20,4 @@ set (AUDIOLIB_SOURCES
) )
add_library(audio_lib ${AUDIOLIB_SOURCES}) add_library(audio_lib ${AUDIOLIB_SOURCES})
target_include_directories(audio_lib PRIVATE ../../libs/speex/include ../../libs ../)

View File

@ -4,26 +4,7 @@ project (helper_lib)
set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (HELPER_LIB_SOURCES file(GLOB HELPER_LIB_SOURCES "*.cpp" "*.h")
HL_AsyncCommand.cpp
HL_Calculator.cpp
HL_CsvReader.cpp
HL_Epoll.cpp
HL_HepSupport.cpp
HL_IuUP.cpp
HL_Log.cpp
HL_NetworkFrame.cpp
HL_NetworkSocket.cpp
HL_OsVersion.cpp
HL_Pointer.cpp
HL_Rtp.cpp
HL_Singletone.cpp
HL_SocketHeap.cpp
HL_String.cpp
HL_Sync.cpp
HL_Usb.cpp
HL_Uuid.cpp
HL_VariantMap.cpp
)
add_library(helper_lib ${HELPER_LIB_SOURCES}) add_library(helper_lib ${HELPER_LIB_SOURCES})
target_include_directories(helper_lib PRIVATE ../../libs/ ../../engine ../)

View File

@ -6,15 +6,13 @@
#ifndef __SMART_POINTER_H #ifndef __SMART_POINTER_H
#define __SMART_POINTER_H #define __SMART_POINTER_H
#ifdef USE_NATIVE_SMARTPTR #include <memory>
# include <memory> #define SharedPtr std::shared_ptr
# define SharedPtr std::shared_ptr
#else
#include "../../libs/resiprocate/rutil/SharedPtr.hxx"
using resip::SharedPtr;
#endif
#include "HL_Sync.h" #include "HL_Sync.h"
#include <map> #include <map>
class UsageCounter class UsageCounter
{ {
public: public:

View File

@ -7,9 +7,9 @@
#include "HL_Exception.h" #include "HL_Exception.h"
#include "HL_String.h" #include "HL_String.h"
#include "rtprawpacket.h" #include "jrtplib/src/rtprawpacket.h"
#include "rtpipv4address.h" #include "jrtplib/src/rtpipv4address.h"
#include <alloc.h> #include <alloca.h>
#include <sstream> #include <sstream>
#include <tuple> #include <tuple>

View File

@ -10,6 +10,8 @@
#endif #endif
#include <set> #include <set>
#include <assert.h> #include <assert.h>
#include <unistd.h> // Responsible for close() call on Linux
#include "HL_SocketHeap.h" #include "HL_SocketHeap.h"
#include "HL_Log.h" #include "HL_Log.h"
#include "HL_Sync.h" #include "HL_Sync.h"
@ -279,6 +281,7 @@ void SocketHeap::thread()
SyncHelper::delay(1000); // Delay for 1 millisecond SyncHelper::delay(1000); // Delay for 1 millisecond
} }
mId = 0; mId = 0;
mShutdown = false;
//#endif //#endif
} }

View File

@ -103,7 +103,10 @@ protected:
Mutex mDeleteGuard; Mutex mDeleteGuard;
char mTempPacket[MAX_UDPPACKET_SIZE]; char mTempPacket[MAX_UDPPACKET_SIZE];
volatile bool mShutdown = false;
int mId = 0;
bool isShutdown() const { return mShutdown; }
virtual void thread(); virtual void thread();
// Processes mDeleteVector -> updates mSocketMap, removes socket items and closes sockets specified in mDeleteVector // Processes mDeleteVector -> updates mSocketMap, removes socket items and closes sockets specified in mDeleteVector

View File

@ -0,0 +1,10 @@
project (media_lib)
# Rely on C++ 11
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB MEDIA_LIB_SOURCES "*.cpp" "*.h")
add_library(media_lib ${MEDIA_LIB_SOURCES})
target_include_directories(media_lib PRIVATE ../../libs/ ../ ../../libs/srtp/include ../../libs/srtp/crypto/include)