Commit e186c806 authored by Ghislain MARY's avatar Ghislain MARY

Port to Windows Phone 8.

parent 41abaf15
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
BOOL APIENTRY DllMain(HMODULE /* hModule */, DWORD ul_reason_for_call, LPVOID /* lpReserved */)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
......@@ -70,8 +70,7 @@
<PreprocessorDefinitions>_WIN32;_WINDLL;_USRDLL;_CRT_SECURE_NO_WARNINGS;ORTP_INET6;WIN32;ORTP_EXPORTS;WINDOWS_NATIVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
......@@ -88,8 +87,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
......@@ -103,12 +101,11 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WIN32;_WINDLL;_USRDLL;_CRT_SECURE_NO_WARNINGS;ORTP_INET6;WIN32;ORTP_EXPORTS;WINDOWS_NATIVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
......@@ -117,7 +114,7 @@
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;delayimp.lib;Winmm.lib;qwave.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(TargetDir)$(TargetName)_dll.lib</ImportLibrary>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
......@@ -125,8 +122,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
......@@ -162,98 +158,40 @@
<ClInclude Include="..\..\..\..\src\rtptimer.h" />
<ClInclude Include="..\..\..\..\src\scheduler.h" />
<ClInclude Include="..\..\..\..\src\utils.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="..\..\..\..\src\winrttimer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\src\avprofile.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\b64.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\dll_entry.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\event.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\jitterctl.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\logging.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\netsim.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\ortp.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\ortp_srtp.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\payloadtype.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\port.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\posixtimer.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtcp.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtcpparse.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtpparse.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtpprofile.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtpsession.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtpsession_inet.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtpsignaltable.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rtptimer.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\scheduler.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\sessionset.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\str_utils.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\stun.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\stun_udp.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\telephonyevents.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\utils.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\zrtp.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\..\src\avprofile.c" />
<ClCompile Include="..\..\..\..\src\b64.c" />
<ClCompile Include="..\..\..\..\src\dll_entry.c" />
<ClCompile Include="..\..\..\..\src\event.c" />
<ClCompile Include="..\..\..\..\src\jitterctl.c" />
<ClCompile Include="..\..\..\..\src\logging.c" />
<ClCompile Include="..\..\..\..\src\netsim.c" />
<ClCompile Include="..\..\..\..\src\ortp.c" />
<ClCompile Include="..\..\..\..\src\ortp_srtp.c" />
<ClCompile Include="..\..\..\..\src\payloadtype.c" />
<ClCompile Include="..\..\..\..\src\port.c" />
<ClCompile Include="..\..\..\..\src\posixtimer.c" />
<ClCompile Include="..\..\..\..\src\rtcp.c" />
<ClCompile Include="..\..\..\..\src\rtcpparse.c" />
<ClCompile Include="..\..\..\..\src\rtpparse.c" />
<ClCompile Include="..\..\..\..\src\rtpprofile.c" />
<ClCompile Include="..\..\..\..\src\rtpsession.c" />
<ClCompile Include="..\..\..\..\src\rtpsession_inet.c" />
<ClCompile Include="..\..\..\..\src\rtpsignaltable.c" />
<ClCompile Include="..\..\..\..\src\rtptimer.c" />
<ClCompile Include="..\..\..\..\src\scheduler.c" />
<ClCompile Include="..\..\..\..\src\sessionset.c" />
<ClCompile Include="..\..\..\..\src\str_utils.c" />
<ClCompile Include="..\..\..\..\src\stun.c" />
<ClCompile Include="..\..\..\..\src\stun_udp.c" />
<ClCompile Include="..\..\..\..\src\telephonyevents.c" />
<ClCompile Include="..\..\..\..\src\utils.c" />
<ClCompile Include="..\..\..\..\src\winrttimer.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\..\..\src\zrtp.c" />
</ItemGroup>
<ItemGroup>
<Reference Include="Windows">
......@@ -268,4 +206,4 @@
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
//
// pch.cpp
// Include the standard header and generate the precompiled header.
//
#include "pch.h"
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include "targetver.h"
// Windows Header Files:
#include <windows.h>
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
......@@ -148,8 +148,13 @@ typedef __int16 int16_t;
typedef SOCKET ortp_socket_t;
#if WINAPI_FAMILY_APP
typedef CONDITION_VARIABLE ortp_cond_t;
typedef SRWLOCK ortp_mutex_t;
#else
typedef HANDLE ortp_cond_t;
typedef HANDLE ortp_mutex_t;
#endif
typedef HANDLE ortp_thread_t;
#define ortp_thread_create WIN_thread_create
......@@ -320,7 +325,7 @@ ORTP_PUBLIC void ortp_shm_close(void *memory);
#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
#ifdef ORTP_EXPORTS
#define VAR_DECLSPEC __declspec(dllexport)
#define VAR_DECLSPEC extern __declspec(dllexport)
#else
#define VAR_DECLSPEC __declspec(dllimport)
#endif
......
......@@ -9,7 +9,11 @@
typedef struct __STRUCT_SHARED_DATA__
{
DWORD m_nReference;
#if WINAPI_FAMILY_APP
ULONGLONG m_ullStartTime;
#else
DWORD m_dwStartTime;
#endif
BOOL m_bInitialize;
} SHARED_DATA, * LPSHARED_DATA;
......@@ -25,6 +29,9 @@ extern DWORD dwoRTPLogLevel;
#define SHMEMSIZE sizeof(SHARED_DATA)
#if WINAPI_FAMILY_APP
static SHARED_DATA sharedData;
#endif
static LPSHARED_DATA lpSharedData;
static HANDLE hMapObject = NULL; // handle to file mapping
......@@ -52,6 +59,10 @@ BOOL WINAPI DllMain(
return FALSE;
}
#if WINAPI_FAMILY_APP
fInit = TRUE;
lpSharedData = &sharedData;
#else
// Create a named file mapping object.
hMapObject = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file
NULL, // default security attributes
......@@ -75,6 +86,7 @@ BOOL WINAPI DllMain(
0); // default: map entire file
if (lpSharedData == NULL)
return FALSE;
#endif
// Initialize memory if this is the first process.
......@@ -82,7 +94,11 @@ BOOL WINAPI DllMain(
{
OutputDebugString("--> dll_entry.c - oRTP.dll - Initializing module\n");
#if WINAPI_FAMILY_APP
lpSharedData->m_ullStartTime = GetTickCount64();
#else
lpSharedData->m_dwStartTime = GetTickCount();
#endif
lpSharedData->m_nReference = 1;
lpSharedData->m_bInitialize = FALSE;
......@@ -130,7 +146,7 @@ BOOL WINAPI DllMain(
ortp_exit();
UnregisterLog(&dwoRTPLogLevel, "LOG_ORTP");
#if !WINAPI_FAMILY_APP
// Unmap shared memory from the process's address space.
UnmapViewOfFile(lpSharedData);
lpSharedData = NULL;
......@@ -138,6 +154,7 @@ BOOL WINAPI DllMain(
// Close the process's handle to the file-mapping object.
CloseHandle(hMapObject);
hMapObject = INVALID_HANDLE_VALUE;
#endif
}
}
break;
......
......@@ -202,25 +202,39 @@ int __ortp_thread_create(pthread_t *thread, pthread_attr_t *attr, void * (*routi
int WIN_mutex_init(ortp_mutex_t *mutex, void *attr)
{
#if WINAPI_FAMILY_APP
InitializeSRWLock(mutex);
#else
*mutex=CreateMutex(NULL, FALSE, NULL);
#endif
return 0;
}
int WIN_mutex_lock(ortp_mutex_t * hMutex)
{
#if WINAPI_FAMILY_APP
AcquireSRWLockExclusive(hMutex);
#else
WaitForSingleObject(*hMutex, INFINITE); /* == WAIT_TIMEOUT; */
#endif
return 0;
}
int WIN_mutex_unlock(ortp_mutex_t * hMutex)
{
#if WINAPI_FAMILY_APP
ReleaseSRWLockExclusive(hMutex);
#else
ReleaseMutex(*hMutex);
#endif
return 0;
}
int WIN_mutex_destroy(ortp_mutex_t * hMutex)
{
#if !WINAPI_FAMILY_APP
CloseHandle(*hMutex);
#endif
return 0;
}
......@@ -262,22 +276,34 @@ int WIN_thread_join(ortp_thread_t thread_h, void **unused)
int WIN_cond_init(ortp_cond_t *cond, void *attr)
{
#if WINAPI_FAMILY_APP
InitializeConditionVariable(cond);
#else
*cond=CreateEvent(NULL, FALSE, FALSE, NULL);
#endif
return 0;
}
int WIN_cond_wait(ortp_cond_t* hCond, ortp_mutex_t * hMutex)
{
#if WINAPI_FAMILY_APP
SleepConditionVariableSRW(hCond, hMutex, INFINITE, 0);
#else
//gulp: this is not very atomic ! bug here ?
WIN_mutex_unlock(hMutex);
WaitForSingleObject(*hCond, INFINITE);
WIN_mutex_lock(hMutex);
#endif
return 0;
}
int WIN_cond_signal(ortp_cond_t * hCond)
{
#if WINAPI_FAMILY_APP
WakeConditionVariable(hCond);
#else
SetEvent(*hCond);
#endif
return 0;
}
......@@ -289,7 +315,9 @@ int WIN_cond_broadcast(ortp_cond_t * hCond)
int WIN_cond_destroy(ortp_cond_t * hCond)
{
#if !WINAPI_FAMILY_APP
CloseHandle(*hCond);
#endif
return 0;
}
......@@ -483,6 +511,10 @@ static HANDLE event=NULL;
/* portable named pipes */
ortp_pipe_t ortp_server_pipe_create(const char *name){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return INVALID_HANDLE_VALUE;
#else
ortp_pipe_t h;
char *pipename=make_pipe_name(name);
h=CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_MESSAGE|PIPE_WAIT,1,
......@@ -493,6 +525,7 @@ ortp_pipe_t ortp_server_pipe_create(const char *name){
}
if (event==NULL) event=CreateEvent(NULL,TRUE,FALSE,NULL);
return h;
#endif
}
......@@ -501,6 +534,10 @@ even if nobody connects to the pipe.
ortp_server_pipe_close() makes this function to exit.
*/
ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return INVALID_HANDLE_VALUE;
#else
OVERLAPPED ol;
DWORD undef;
HANDLE handles[2];
......@@ -516,19 +553,34 @@ ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server){
}
CloseHandle(ol.hEvent);
return INVALID_HANDLE_VALUE;
#endif
}
int ortp_server_pipe_close_client(ortp_pipe_t server){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return -1;
#else
return DisconnectNamedPipe(server)==TRUE ? 0 : -1;
#endif
}
int ortp_server_pipe_close(ortp_pipe_t spipe){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return -1;
#else
SetEvent(event);
//CancelIoEx(spipe,NULL); /*vista only*/
return CloseHandle(spipe);
#endif
}
ortp_pipe_t ortp_client_pipe_connect(const char *name){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return INVALID_HANDLE_VALUE;
#else
char *pipename=make_pipe_name(name);
ortp_pipe_t hpipe = CreateFile(
pipename, // pipe name
......@@ -541,6 +593,7 @@ ortp_pipe_t ortp_client_pipe_connect(const char *name){
NULL); // no template file
ortp_free(pipename);
return hpipe;
#endif
}
int ortp_pipe_read(ortp_pipe_t p, uint8_t *buf, int len){
......@@ -573,6 +626,10 @@ typedef struct MapInfo{
static OList *maplist=NULL;
void *ortp_shm_open(unsigned int keyid, int size, int create){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
return NULL;
#else
HANDLE h;
char name[64];
void *buf;
......@@ -611,9 +668,13 @@ void *ortp_shm_open(unsigned int keyid, int size, int create){
ortp_error("MapViewOfFile failed");
}
return buf;
#endif
}
void ortp_shm_close(void *mem){
#if WINAPI_FAMILY_APP
ortp_error("%s not supported!", __FUNCTION__);
#else
OList *elem;
for(elem=maplist;elem!=NULL;elem=elem->next){
MapInfo *i=(MapInfo*)elem->data;
......@@ -626,6 +687,7 @@ void ortp_shm_close(void *mem){
}
}
ortp_error("No shared memory at %p was found.",mem);
#endif
}
......@@ -639,6 +701,11 @@ void ortp_shm_close(void *mem){
void ortp_get_cur_time(ortpTimeSpec *ret){
#if defined(_WIN32_WCE) || defined(WIN32)
#if WINAPI_FAMILY_APP
ULONGLONG timemillis = GetTickCount64();
ret->tv_sec = timemillis / 1000;
ret->tv_nsec = (timemillis % 1000) * 1000000LL;
#else
DWORD timemillis;
# if defined(_WIN32_WCE)
timemillis=GetTickCount();
......@@ -647,6 +714,7 @@ void ortp_get_cur_time(ortpTimeSpec *ret){
# endif
ret->tv_sec=timemillis/1000;
ret->tv_nsec=(timemillis%1000)*1000000LL;
#endif
#elif defined(__MACH__) && defined(__GNUC__) && (__GNUC__ >= 3)
struct timeval tv;
gettimeofday(&tv, NULL);
......
......@@ -90,6 +90,17 @@ RtpTimer posix_timer={ 0,
#else //WIN32
#if WINAPI_FAMILY_APP
#include "winrttimer.h"
RtpTimer posix_timer={ 0,
winrt_timer_init,
winrt_timer_do,
winrt_timer_close,
{0, TIME_INTERVAL * 1000}};
#else
#include <windows.h>
#include <mmsystem.h>
......@@ -172,6 +183,7 @@ RtpTimer posix_timer={ 0,
win_timer_do,
win_timer_close,
{0,TIME_INTERVAL * 1000}};
#endif
#endif // _WIN32
......@@ -35,8 +35,10 @@
#if (_WIN32_WINNT >= 0x0600)
#include <delayimp.h>
#undef ExternC /* avoid redefinition... */
#if !WINAPI_FAMILY_APP
#include <QOS2.h>
#endif
#endif
extern mblk_t *rtcp_create_simple_bye_packet(uint32_t ssrc, const char *reason);
extern int rtcp_sr_init(RtpSession *session, char *buf, int size);
......@@ -1416,7 +1418,7 @@ void rtp_session_uninit (RtpSession * session)
if (session->net_sim_ctx)
ortp_network_simulator_destroy(session->net_sim_ctx);
#if (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT >= 0x0600) && !WINAPI_FAMILY_APP
if (session->rtp.QoSFlowID != 0)
{
OSVERSIONINFOEX ovi;
......
......@@ -33,10 +33,12 @@
#if (_WIN32_WINNT >= 0x0600)
#include <delayimp.h>
#undef ExternC
#if !WINAPI_FAMILY_APP
#include <QOS2.h>
#endif
#endif
#if defined(WIN32) || defined(_WIN32_WCE)
#if (defined(WIN32) || defined(_WIN32_WCE)) && !WINAPI_FAMILY_APP
#include <Mswsock.h>
#endif
......@@ -563,6 +565,8 @@ int rtp_session_get_multicast_loopback(RtpSession *session)
int rtp_session_set_dscp(RtpSession *session, int dscp){
int retval=0;
int tos;
int proto;
int value_type;
#if (_WIN32_WINNT >= 0x0600)
OSVERSIONINFOEX ovi;
#endif
......@@ -573,7 +577,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
// Don't do anything if socket hasn't been created yet
if (session->rtp.socket == (ortp_socket_t)-1) return 0;
#if (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT >= 0x0600) && !WINAPI_FAMILY_APP
memset(&ovi, 0, sizeof(ovi));
ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx((LPOSVERSIONINFO) & ovi);
......@@ -632,8 +636,6 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
}
} else {
#endif
int proto;
int value_type;
// DSCP value is in the upper six bits of the TOS field
tos = (session->dscp << 2) & 0xFC;
switch (session->rtp.sockfamily) {
......@@ -663,7 +665,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
ortp_error("Fail to set DSCP value on rtcp socket: %s",getSocketError());
}
}
#if (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT >= 0x0600) && !WINAPI_FAMILY_APP
}
#endif
return retval;
......
......@@ -1170,6 +1170,8 @@ stunRand(void)
#if defined(_WIN32_WCE)
tick = GetTickCount ();
#elif WINAPI_FAMILY_APP
tick = GetTickCount64();
#elif defined(_MSC_VER)
{
volatile unsigned int lowtick=0,hightick=0;
......
#include <windows.h>
#using <Windows.winmd>
#include "winrttimer.h"
#include "ortp/logging.h"
using namespace Windows::Foundation;
using namespace Windows::System::Threading;
class WinRTTimer
{
public:
WinRTTimer();
~WinRTTimer();
void run();
private:
ThreadPoolTimer^ PeriodicTimer;
HANDLE SleepEvent;
ULONGLONG LateTicks;
ULONGLONG PosixTimerTime;
ULONGLONG OffsetTime;
};
WinRTTimer::WinRTTimer()
: LateTicks(0), PosixTimerTime(0), OffsetTime(GetTickCount64())
{
TimeSpan period;
period.Duration = TIME_INTERVAL * 10000;
SleepEvent = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
PeriodicTimer = ThreadPoolTimer::CreatePeriodicTimer(
ref new TimerElapsedHandler([this](ThreadPoolTimer^ source)
{
if (source == PeriodicTimer) {
PosixTimerTime += TIME_INTERVAL;
}
}), period);
}
WinRTTimer::~WinRTTimer()
{
PeriodicTimer->Cancel();
}
void WinRTTimer::run()
{
// If timer have expired while we where out of this method
// Try to run after lost time.
if (LateTicks > 0) {
LateTicks--;
PosixTimerTime += TIME_INTERVAL;
return;
}
ULONGLONG diff = GetTickCount64() - PosixTimerTime - OffsetTime;
if (diff > TIME_INTERVAL) {
LateTicks = diff / TIME_INTERVAL;
ortp_warning("We must catchup %i ticks.", LateTicks);
return;
}
WaitForSingleObjectEx(SleepEvent, TIME_TIMEOUT, FALSE);
}
static WinRTTimer *timer;
void winrt_timer_init(void)
{
timer = new WinRTTimer();
}
void winrt_timer_do(void)
{
timer->run();
}
void winrt_timer_close(void)
{
delete timer;
}
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void winrt_timer_init(void);
void winrt_timer_do(void);
void winrt_timer_close(void);
#ifdef __cplusplus
};
#endif
#define TIME_INTERVAL 50
#define TIME_TIMEOUT 100
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment