- making rtphone buildable on Windows

This commit is contained in:
Dmytro Bogovych 2025-04-21 13:12:56 +03:00
parent 8d0c8ba4de
commit 83373cb586
11 changed files with 52 additions and 9 deletions

View File

@ -28,15 +28,18 @@ include_directories(${OPENSSL_INCLUDE})
if (CMAKE_SYSTEM MATCHES "Windows*") if (CMAKE_SYSTEM MATCHES "Windows*")
add_definitions (-DTARGET_WIN -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -D_UNICODE -D_CRT_SECURE_NO_WARNINGS) add_definitions (-DTARGET_WIN -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -D_UNICODE -D_CRT_SECURE_NO_WARNINGS)
set (TARGET_WIN ON)
endif() endif()
if (CMAKE_SYSTEM MATCHES "Linux*") if (CMAKE_SYSTEM MATCHES "Linux*")
add_definitions (-DTARGET_LINUX -DHAVE_NETINET_IN_H) add_definitions (-DTARGET_LINUX -DHAVE_NETINET_IN_H)
set (TARGET_LINUX ON)
endif() endif()
if (CMAKE_SYSTEM MATCHES "Darwin*") if (CMAKE_SYSTEM MATCHES "Darwin*")
add_definitions (-DTARGET_OSX) add_definitions (-DTARGET_OSX)
set (TARGET_OSX ON)
endif() endif()
if (CMAKE_SYSTEM MATCHES "Android") if (CMAKE_SYSTEM MATCHES "Android")
@ -45,10 +48,12 @@ if (CMAKE_SYSTEM MATCHES "Android")
add_subdirectory (${OBOE_DIR} ./oboe) add_subdirectory (${OBOE_DIR} ./oboe)
include_directories (${OBOE_DIR}/include) include_directories (${OBOE_DIR}/include)
add_definitions(-DTARGET_ANDROID -DHAVE_NETINET_IN_H) add_definitions(-DTARGET_ANDROID -DHAVE_NETINET_IN_H)
set (TARGET_ANDROID ON)
endif() endif()
if (USE_MUSL) if (USE_MUSL)
add_definitions(-DTARGET_MUSL) add_definitions(-DTARGET_MUSL)
set (TARGET_MUSL ON)
endif() endif()
set (RTPHONE_SOURCES set (RTPHONE_SOURCES

View File

@ -6,6 +6,7 @@
#include "Agent_AudioManager.h" #include "Agent_AudioManager.h"
#include "../engine/audio/Audio_WavFile.h" #include "../engine/audio/Audio_WavFile.h"
#include "../engine/audio/Audio_Null.h" #include "../engine/audio/Audio_Null.h"
#include "HL_String.h"
#if defined(TARGET_ANDROID) #if defined(TARGET_ANDROID)
# include "../engine/audio/Audio_Android.h" # include "../engine/audio/Audio_Android.h"
@ -171,7 +172,7 @@ void AudioManager::startPlayFile(int usageId, const std::string& path, AudioTarg
// Check if file exists // Check if file exists
Audio::PWavFileReader r = std::make_shared<Audio::WavFileReader>(); Audio::PWavFileReader r = std::make_shared<Audio::WavFileReader>();
#ifdef TARGET_WIN #ifdef TARGET_WIN
r->open(StringHelper::makeTstring(path)); r->open(strx::makeTstring(path));
#else #else
r->open(path); r->open(path);
#endif #endif

View File

@ -1,4 +1,4 @@
/* Copyright(C) 2007-2017 VoIP objects (voipobjects.com) /* Copyright(C) 2007-2025 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/. */
@ -6,7 +6,7 @@
#ifndef __AUDIO_DSOUND_H #ifndef __AUDIO_DSOUND_H
#define __AUDIO_DSOUND_H #define __AUDIO_DSOUND_H
#include "../config.h" #include "../engine_config.h"
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>

View File

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

View File

@ -8,7 +8,7 @@
#ifdef TARGET_WIN #ifdef TARGET_WIN
#include "../config.h" #include "../engine_config.h"
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>

View File

@ -423,3 +423,26 @@ std::string strx::removeQuotes(const std::string& s)
return r; return r;
} }
#if defined(TARGET_WIN)
// MSVC++ lacks memmem support
const void *memmem(const void *haystack, size_t haystack_len,
const void * const needle, const size_t needle_len)
{
if (haystack == NULL) return NULL; // or assert(haystack != NULL);
if (haystack_len == 0) return NULL;
if (needle == NULL) return NULL; // or assert(needle != NULL);
if (needle_len == 0) return NULL;
for (const char *h = (const char*)haystack;
haystack_len >= needle_len;
++h, --haystack_len) {
if (!memcmp(h, needle, needle_len)) {
return h;
}
}
return nullptr;
}
#endif

View File

@ -84,4 +84,11 @@ public:
}; };
#if defined(TARGET_WIN)
// MSVC++ lacks memmem support
extern const void *memmem(const void *haystack, size_t haystack_len,
const void * const needle, const size_t needle_len);
#endif
#endif #endif

View File

@ -14,6 +14,11 @@
#include <functional> #include <functional>
#include <assert.h> #include <assert.h>
#if defined(TARGET_WIN)
# include <WinSock2.h>
# include <Windows.h>
#endif
typedef std::recursive_mutex Mutex; typedef std::recursive_mutex Mutex;
typedef std::unique_lock<std::recursive_mutex> Lock; typedef std::unique_lock<std::recursive_mutex> Lock;

View File

@ -6,6 +6,8 @@
#include "../helper/HL_Log.h" #include "../helper/HL_Log.h"
#include "../helper/HL_IuUP.h" #include "../helper/HL_IuUP.h"
#include <iostream>
#define LOG_SUBSYSTEM "AmrCodec" #define LOG_SUBSYSTEM "AmrCodec"
using namespace MT; using namespace MT;

View File

@ -3,7 +3,9 @@
* 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/. */
#define NOMINMAX #if defined(TARGET_WIN) && !defined(NOMINMAX)
# define NOMINMAX
#endif
#include "../engine_config.h" #include "../engine_config.h"
#include "MT_AudioReceiver.h" #include "MT_AudioReceiver.h"
@ -14,6 +16,7 @@
#include "../audio/Audio_Interface.h" #include "../audio/Audio_Interface.h"
#include "../audio/Audio_Resampler.h" #include "../audio/Audio_Resampler.h"
#include <cmath> #include <cmath>
#include <iostream>
#if !defined(TARGET_ANDROID) && !defined(TARGET_OPENWRT) && !defined(TARGET_WIN) && !defined(TARGET_RPI) && defined(USE_AMR_CODEC) #if !defined(TARGET_ANDROID) && !defined(TARGET_OPENWRT) && !defined(TARGET_WIN) && !defined(TARGET_RPI) && defined(USE_AMR_CODEC)
# include "MT_AmrCodec.h" # include "MT_AmrCodec.h"

View File

@ -3,10 +3,6 @@
#define HAVE_STDLIB_H #define HAVE_STDLIB_H
#ifdef WIN32
# define inline __inline
#endif
#ifdef WIN32 #ifdef WIN32
#define HAVE_WINSOCK2_H 1 #define HAVE_WINSOCK2_H 1
#define CPU_CISC 1 #define CPU_CISC 1