This commit is contained in:
Dmytro Bogovych 2019-10-11 20:31:45 +03:00
parent 94d7471aec
commit 3102efaf4f
5 changed files with 774 additions and 773 deletions

View File

@ -60,21 +60,21 @@ set (rtphone_engine engine)
set (USE_AMR_CODEC OFF CACHE BOOL "Use AMR codec. Requires libraries.") set (USE_AMR_CODEC OFF CACHE BOOL "Use AMR codec. Requires libraries.")
set (USE_EVS_CODEC OFF CACHE BOOL "Use EVS codec.") set (USE_EVS_CODEC OFF CACHE BOOL "Use EVS codec.")
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set (CMAKE_POSITION_INDEPENDENT_CODE ON)
set (OPENSSL_INCLUDE ${LIB_PLATFORM}/openssl/1.0/include) set (OPENSSL_INCLUDE ${LIB_PLATFORM}/openssl/1.0/include)
message ("Using OpenSSL include files from ${OPENSSL_INCLUDE}") message ("Using OpenSSL include files from ${OPENSSL_INCLUDE}")
if (CMAKE_SYSTEM MATCHES "Windows*") if (CMAKE_SYSTEM MATCHES "Windows*")
add_definitions(-DTARGET_WIN) add_definitions (-DTARGET_WIN -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -D_UNICODE -D_CRT_SECURE_NO_WARNINGS)
endif() endif()
if (CMAKE_SYSTEM MATCHES "Linux*") if (CMAKE_SYSTEM MATCHES "Linux*")
add_definitions(-DTARGET_LINUX) add_definitions (-DTARGET_LINUX)
endif() endif()
if (CMAKE_SYSTEM MATCHES "Darwin*") if (CMAKE_SYSTEM MATCHES "Darwin*")
add_definitions(-DTARGET_OSX) add_definitions (-DTARGET_OSX)
endif() endif()
set (RTPHONE_SOURCES set (RTPHONE_SOURCES
@ -133,7 +133,7 @@ set (RTPHONE_HEADERS
${rtphone_engine}/endpoint/EP_Session.h ${rtphone_engine}/endpoint/EP_Session.h
) )
add_library(rtphone STATIC ${RTPHONE_SOURCES} ${RTPHONE_HEADERS}) add_library (rtphone STATIC ${RTPHONE_SOURCES} ${RTPHONE_HEADERS})
add_subdirectory(${rtphone_libs}/resiprocate) add_subdirectory(${rtphone_libs}/resiprocate)
add_subdirectory(${rtphone_libs}/ice) add_subdirectory(${rtphone_libs}/ice)
@ -150,7 +150,7 @@ add_subdirectory(${rtphone_engine}/helper)
add_subdirectory(${rtphone_engine}/audio) add_subdirectory(${rtphone_engine}/audio)
add_subdirectory(${rtphone_engine}/media) add_subdirectory(${rtphone_engine}/media)
set(LIBS ice_stack jrtplib g729_codec gsm_codec set (LIBS ice_stack jrtplib g729_codec gsm_codec
gsmhr_codec g722_codec srtp resiprocate helper_lib audio_lib webrtc speexdsp gsmhr_codec g722_codec srtp resiprocate helper_lib audio_lib webrtc speexdsp
uuid) uuid)
@ -161,7 +161,7 @@ else ()
endif () endif ()
if (USE_AMR_CODEC) if (USE_AMR_CODEC)
set(LIBS ${LIBS} opencore-amrnb opencore-amrwb) set (LIBS ${LIBS} opencore-amrnb opencore-amrwb)
endif (USE_AMR_CODEC) endif (USE_AMR_CODEC)
target_link_libraries(rtphone target_link_libraries(rtphone

View File

@ -78,7 +78,7 @@ void DSoundInit::load()
hr = ::CoInitialize(NULL); hr = ::CoInitialize(NULL);
//load the DirectSound DLL //load the DirectSound DLL
mRoutines.mInstance = ::LoadLibrary(L"dsound.dll"); mRoutines.mInstance = ::LoadLibraryW(L"dsound.dll");
if (!mRoutines.mInstance) if (!mRoutines.mInstance)
throw std::logic_error("Cannot load dsound.dll"); throw std::logic_error("Cannot load dsound.dll");
@ -107,7 +107,7 @@ void DSoundInit::unload()
// --------------- VistaEnumerator --------------------- // --------------- VistaEnumerator ---------------------
VistaEnumerator::VistaEnumerator() VistaEnumerator::VistaEnumerator()
:mCollection(NULL), mDefaultDevice(NULL), mEnumerator(NULL), mDirection(eCapture) :mCollection(NULL), mDefaultDevice(NULL), mEnumerator(NULL), mDirection(eCapture)
{ {
} }
@ -271,7 +271,7 @@ int VistaEnumerator::indexOfDefaultDevice()
// -------------- XpEnumerator --------------- // -------------- XpEnumerator ---------------
XpEnumerator::XpEnumerator() XpEnumerator::XpEnumerator()
:mDirection(-1) :mDirection(-1)
{ {
} }
@ -287,8 +287,8 @@ void XpEnumerator::open(int direction)
int count = waveInGetNumDevs(); int count = waveInGetNumDevs();
for (int i=0; i<count; i++) for (int i=0; i<count; i++)
{ {
WAVEINCAPS caps; WAVEINCAPSW caps;
if (waveInGetDevCaps(i, &caps, sizeof caps) == MMSYSERR_NOERROR) if (waveInGetDevCapsW(i, &caps, sizeof caps) == MMSYSERR_NOERROR)
mNameList.push_back(caps.szPname); mNameList.push_back(caps.szPname);
else else
mNameList.push_back(L"Bad device"); mNameList.push_back(L"Bad device");
@ -299,8 +299,8 @@ void XpEnumerator::open(int direction)
int count = waveOutGetNumDevs(); int count = waveOutGetNumDevs();
for (int i=0; i<count; i++) for (int i=0; i<count; i++)
{ {
WAVEOUTCAPS caps; WAVEOUTCAPSW caps;
if (waveOutGetDevCaps(i, &caps, sizeof caps) == MMSYSERR_NOERROR) if (waveOutGetDevCapsW(i, &caps, sizeof caps) == MMSYSERR_NOERROR)
mNameList.push_back(caps.szPname); mNameList.push_back(caps.szPname);
else else
mNameList.push_back(L"Bad device"); mNameList.push_back(L"Bad device");
@ -346,11 +346,11 @@ int XpEnumerator::indexOfDefaultDevice()
// -------- DSoundInputDevice --------------- // -------- DSoundInputDevice ---------------
DSoundInputDevice::DSoundInputDevice(GUID deviceId) DSoundInputDevice::DSoundInputDevice(GUID deviceId)
:mSimulate(false), mBufferIndex(0), mGUID(deviceId), mThreadHandle(0), mDenoiser(AUDIO_SAMPLERATE), mEnableDenoiser(true), :mSimulate(false), mBufferIndex(0), mGUID(deviceId), mThreadHandle(0), mDenoiser(AUDIO_SAMPLERATE), mEnableDenoiser(true),
mNullAudio(AUDIO_MIC_BUFFER_LENGTH, AUDIO_MIC_BUFFER_COUNT) mNullAudio(AUDIO_MIC_BUFFER_LENGTH, AUDIO_MIC_BUFFER_COUNT)
#ifdef AUDIO_DUMPINPUT #ifdef AUDIO_DUMPINPUT
,mDump(AUDIO_SAMPLERATE) ,mDump(AUDIO_SAMPLERATE)
#endif #endif
{ {
gDSoundInit.load(); gDSoundInit.load();
@ -642,10 +642,10 @@ void DSoundInputDevice::threadProc(void* arg)
DSoundOutputDevice::DSoundOutputDevice(GUID deviceId) DSoundOutputDevice::DSoundOutputDevice(GUID deviceId)
:mDevice(NULL), mPrimaryBuffer(NULL), mBuffer(NULL), :mDevice(NULL), mPrimaryBuffer(NULL), mBuffer(NULL),
mWriteOffset(0), mPlayedSamples(0), mTotalPlayed(0), mTail(0), mWriteOffset(0), mPlayedSamples(0), mTotalPlayed(0), mTail(0),
mThreadHandle(0), mSimulate(false), mGUID(deviceId), mThreadHandle(0), mSimulate(false), mGUID(deviceId),
mNullAudio(AUDIO_SPK_BUFFER_LENGTH, AUDIO_SPK_BUFFER_COUNT) mNullAudio(AUDIO_SPK_BUFFER_LENGTH, AUDIO_SPK_BUFFER_COUNT)
{ {
gDSoundInit.load(); gDSoundInit.load();
mShutdownSignal = ::CreateEvent(NULL, FALSE, FALSE, NULL); mShutdownSignal = ::CreateEvent(NULL, FALSE, FALSE, NULL);

View File

@ -31,9 +31,9 @@
namespace Audio namespace Audio
{ {
class VistaEnumerator: public Enumerator class VistaEnumerator: public Enumerator
{ {
public: public:
VistaEnumerator(); VistaEnumerator();
~VistaEnumerator(); ~VistaEnumerator();
@ -45,7 +45,7 @@ namespace Audio
int idAt(int index); int idAt(int index);
int indexOfDefaultDevice(); int indexOfDefaultDevice();
protected: protected:
IMMDeviceCollection* mCollection; IMMDeviceCollection* mCollection;
IMMDevice* mDefaultDevice; IMMDevice* mDefaultDevice;
IMMDeviceEnumerator* mEnumerator; IMMDeviceEnumerator* mEnumerator;
@ -54,11 +54,11 @@ namespace Audio
void enumerate(); void enumerate();
IMMDevice* mapIndexToInterface(int index); IMMDevice* mapIndexToInterface(int index);
}; };
class XpEnumerator: public Enumerator class XpEnumerator: public Enumerator
{ {
public: public:
XpEnumerator(); XpEnumerator();
~XpEnumerator(); ~XpEnumerator();
@ -70,25 +70,25 @@ namespace Audio
int idAt(int index); int idAt(int index);
int indexOfDefaultDevice(); int indexOfDefaultDevice();
protected: protected:
std::vector<std::wstring> mNameList; std::vector<std::wstring> mNameList;
int mDirection; int mDirection;
}; };
class DSoundHelper class DSoundHelper
{ {
public: public:
static void checkComResult(HRESULT code); static void checkComResult(HRESULT code);
static GUID deviceId2Guid(int deviceId, bool captureDevice); static GUID deviceId2Guid(int deviceId, bool captureDevice);
}; };
#if !defined(_MSC_VER) #if !defined(_MSC_VER)
typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8;
#endif #endif
class DSoundInputDevice: public InputDevice class DSoundInputDevice: public InputDevice
{ {
public: public:
DSoundInputDevice(GUID deviceId); DSoundInputDevice(GUID deviceId);
~DSoundInputDevice(); ~DSoundInputDevice();
@ -102,7 +102,7 @@ namespace Audio
int readBuffer(void* buffer); int readBuffer(void* buffer);
Format getFormat(); Format getFormat();
protected: protected:
Mutex mGuard; /// Mutex to protect this instance. Mutex mGuard; /// Mutex to protect this instance.
LPDIRECTSOUNDCAPTURE8 mDevice; LPDIRECTSOUNDCAPTURE8 mDevice;
LPDIRECTSOUNDCAPTUREBUFFER8 mBuffer; LPDIRECTSOUNDCAPTUREBUFFER8 mBuffer;
@ -134,11 +134,11 @@ namespace Audio
void closeDevice(); void closeDevice();
static void threadProc(void* arg); static void threadProc(void* arg);
}; };
class DSoundOutputDevice: public OutputDevice class DSoundOutputDevice: public OutputDevice
{ {
public: public:
DSoundOutputDevice(GUID deviceId); DSoundOutputDevice(GUID deviceId);
~DSoundOutputDevice(); ~DSoundOutputDevice();
@ -151,7 +151,7 @@ namespace Audio
bool closing(); bool closing();
Format getFormat(); Format getFormat();
protected: protected:
Mutex mGuard; /// Mutex to protect this instance Mutex mGuard; /// Mutex to protect this instance
int mDeviceID; int mDeviceID;
LPDIRECTSOUND8 mDevice; LPDIRECTSOUND8 mDevice;
@ -181,7 +181,7 @@ namespace Audio
bool getMediaFrame(); bool getMediaFrame();
static void threadProc(void* arg); static void threadProc(void* arg);
}; };
} }
#endif #endif

View File

@ -5,10 +5,10 @@ set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (USE_NULL_UUID OFF CACHE BOOL "When enabled linking to libuuid is avoided") set (USE_NULL_UUID OFF CACHE BOOL "When enabled linking to libuuid is avoided")
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set (CMAKE_POSITION_INDEPENDENT_CODE ON)
file(GLOB HELPER_LIB_SOURCES "*.cpp" "*.h") file (GLOB HELPER_LIB_SOURCES "*.cpp" "*.h")
add_library(helper_lib ${HELPER_LIB_SOURCES}) add_library(helper_lib ${HELPER_LIB_SOURCES})
target_include_directories(helper_lib PRIVATE ../../libs/ ../../engine ../) target_include_directories(helper_lib PRIVATE ../../libs/ ../../engine ../)
target_compile_definitions(helper_lib PRIVATE -D_CRT_SECURE_NO_WARNINGS) target_compile_definitions(helper_lib PRIVATE -D_CRT_SECURE_NO_WARNINGS -D_UNICODE)

View File

@ -1,5 +1,6 @@
#include "HL_Usb.h" #include "HL_Usb.h"
#include "HL_Exception.h" #include "HL_Exception.h"
#ifdef TARGET_WIN #ifdef TARGET_WIN
#include <devguid.h> #include <devguid.h>
@ -9,7 +10,7 @@
UsbChangeListener::UsbChangeListener() UsbChangeListener::UsbChangeListener()
:mNotifyHandle(NULL), mHiddenWindow(NULL), mDelegate(NULL) :mNotifyHandle(NULL), mHiddenWindow(NULL), mDelegate(NULL)
{ {
wsprintf(mWindowClassName, ADR_WINDOW_CLASS_NAME, (unsigned int)rand()); wsprintfW(mWindowClassName, ADR_WINDOW_CLASS_NAME, (unsigned int)rand());
} }
UsbChangeListener::~UsbChangeListener() UsbChangeListener::~UsbChangeListener()
@ -30,16 +31,16 @@ UsbChangeListener::Delegate* UsbChangeListener::getDelegate() const
void UsbChangeListener::start() void UsbChangeListener::start()
{ {
// Exposing Window to Mixer // Exposing Window to Mixer
WNDCLASSEX wcx; WNDCLASSEXW wcx;
memset( &wcx, 0, sizeof(WNDCLASSEX) ); memset( &wcx, 0, sizeof(WNDCLASSEXW) );
wcx.cbSize = sizeof(WNDCLASSEX); wcx.cbSize = sizeof(WNDCLASSEXW);
wcx.lpszClassName = mWindowClassName; wcx.lpszClassName = mWindowClassName;
wcx.lpfnWndProc = (WNDPROC)ADRWindowProc; wcx.lpfnWndProc = (WNDPROC)ADRWindowProc;
::RegisterClassEx(&wcx); ::RegisterClassExW(&wcx);
wchar_t windowname[128]; wchar_t windowname[128];
wsprintf(windowname, ADR_WINDOW_NAME, rand()); wsprintfW(windowname, ADR_WINDOW_NAME, rand());
mHiddenWindow = CreateWindow( mWindowClassName, mHiddenWindow = CreateWindowW( mWindowClassName,
windowname, windowname,
WS_POPUP | WS_DISABLED, WS_POPUP | WS_DISABLED,
0, 0, 0, 0, 0, 0, 0, 0,
@ -102,7 +103,7 @@ void UsbChangeListener::stop()
::DestroyWindow(mHiddenWindow); ::DestroyWindow(mHiddenWindow);
mHiddenWindow = NULL; mHiddenWindow = NULL;
::UnregisterClass(mWindowClassName, NULL); ::UnregisterClassW(mWindowClassName, NULL);
} }
} }