Commit 217cd761 authored by Aymeric Moizard's avatar Aymeric Moizard
Browse files

fix dscp on vista and above

parent 92c452dc
...@@ -61,11 +61,12 @@ ...@@ -61,11 +61,12 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libeay32.lib Ws2_32.lib libsrtp.lib Winmm.lib libcmtd.lib" AdditionalDependencies="Qwave.lib delayimp.lib libeay32.lib Ws2_32.lib libsrtp.lib Winmm.lib libcmtd.lib"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\win32-bin\lib&quot;" AdditionalLibraryDirectories="&quot;..\..\..\win32-bin\lib&quot;"
IgnoreAllDefaultLibraries="true" IgnoreAllDefaultLibraries="true"
ModuleDefinitionFile="oRTP.def" ModuleDefinitionFile="oRTP.def"
DelayLoadDLLs="Qwave.dll"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/oRTP.pdb" ProgramDatabaseFile="$(OutDir)/oRTP.pdb"
SubSystem="2" SubSystem="2"
...@@ -141,11 +142,13 @@ ...@@ -141,11 +142,13 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libeay32.lib Ws2_32.lib libsrtp.lib Winmm.lib libcmt.lib" AdditionalDependencies="Qwave.lib delayimp.lib libeay32.lib Ws2_32.lib libsrtp.lib Winmm.lib libcmt.lib"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\win32-bin\lib&quot;" AdditionalLibraryDirectories="&quot;..\..\..\win32-bin\lib&quot;"
IgnoreAllDefaultLibraries="true" IgnoreAllDefaultLibraries="true"
ModuleDefinitionFile="oRTP.def" ModuleDefinitionFile="oRTP.def"
DelayLoadDLLs="Qwave.dll"
AssemblyLinkResource=""
GenerateDebugInformation="false" GenerateDebugInformation="false"
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
......
...@@ -114,6 +114,8 @@ typedef struct _RtpStream ...@@ -114,6 +114,8 @@ typedef struct _RtpStream
struct sockaddr_in rem_addr; struct sockaddr_in rem_addr;
#endif #endif
int rem_addrlen; int rem_addrlen;
void *QoSHandle;
unsigned long QoSFlowID;
JitterControl jittctl; JitterControl jittctl;
uint32_t snd_time_offset;/*the scheduler time when the application send its first timestamp*/ uint32_t snd_time_offset;/*the scheduler time when the application send its first timestamp*/
uint32_t snd_ts_offset; /* the first application timestamp sent by the application */ uint32_t snd_ts_offset; /* the first application timestamp sent by the application */
......
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
#include "utils.h" #include "utils.h"
#include "rtpsession_priv.h" #include "rtpsession_priv.h"
#if (_WIN32_WINNT >= 0x0600)
#include <delayimp.h>
#undef ExternC /* avoid redefinition... */
#include <QOS2.h>
#endif
extern mblk_t *rtcp_create_simple_bye_packet(uint32_t ssrc, const char *reason); 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); extern int rtcp_sr_init(RtpSession *session, char *buf, int size);
extern int rtcp_rr_init(RtpSession *session, char *buf, int size); extern int rtcp_rr_init(RtpSession *session, char *buf, int size);
...@@ -1333,6 +1339,45 @@ void rtp_session_uninit (RtpSession * session) ...@@ -1333,6 +1339,45 @@ void rtp_session_uninit (RtpSession * session)
session->signal_tables = o_list_free(session->signal_tables); session->signal_tables = o_list_free(session->signal_tables);
msgb_allocator_uninit(&session->allocator); msgb_allocator_uninit(&session->allocator);
#if (_WIN32_WINNT >= 0x0600)
if (session->rtp.QoSFlowID != 0)
{
OSVERSIONINFOEX ovi;
memset(&ovi, 0, sizeof(ovi));
ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx((LPOSVERSIONINFO) & ovi);
ortp_message("check OS support for qwave.lib: %i %i %i\n",
ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
if (ovi.dwMajorVersion > 5) {
if (FAILED(__HrLoadAllImportsForDll("qwave.dll"))) {
ortp_warning("Failed to load qwave.dll: no QoS available\n" );
}
else
{
BOOL QoSResult;
QoSResult = QOSRemoveSocketFromFlow(session->rtp.QoSHandle,
0,
session->rtp.QoSFlowID,
0);
if (QoSResult != TRUE){
ortp_error("QOSRemoveSocketFromFlow failed to end a flow with error %d\n",
GetLastError());
}
session->rtp.QoSFlowID=0;
}
}
}
if (session->rtp.QoSHandle != NULL)
{
QOSCloseHandle(session->rtp.QoSHandle);
session->rtp.QoSHandle=NULL;
}
#endif
} }
/** /**
......
...@@ -22,13 +22,18 @@ ...@@ -22,13 +22,18 @@
#include "ortp/rtpsession.h" #include "ortp/rtpsession.h"
#include "rtpsession_priv.h" #include "rtpsession_priv.h"
#if defined(WIN32) || defined(_WIN32_WCE) #if defined(WIN32) || defined(_WIN32_WCE)
#include "ortp-config-win32.h" #include "ortp-config-win32.h"
#elif HAVE_CONFIG_H #elif HAVE_CONFIG_H
#include "ortp-config.h" /*needed for HAVE_SYS_UIO_H */ #include "ortp-config.h" /*needed for HAVE_SYS_UIO_H */
#endif #endif
#if (_WIN32_WINNT >= 0x0600)
#include <delayimp.h>
#undef ExternC
#include <QOS2.h>
#endif
#ifdef HAVE_SYS_UIO_H #ifdef HAVE_SYS_UIO_H
#include <sys/uio.h> #include <sys/uio.h>
#define USE_SENDMSG 1 #define USE_SENDMSG 1
...@@ -444,6 +449,9 @@ int rtp_session_get_multicast_loopback(RtpSession *session) ...@@ -444,6 +449,9 @@ int rtp_session_get_multicast_loopback(RtpSession *session)
int rtp_session_set_dscp(RtpSession *session, int dscp){ int rtp_session_set_dscp(RtpSession *session, int dscp){
int retval=0; int retval=0;
int tos; int tos;
#if (_WIN32_WINNT >= 0x0600)
OSVERSIONINFOEX ovi;
#endif
// Store new DSCP value if one is specified // Store new DSCP value if one is specified
if (dscp>=0) session->dscp = dscp; if (dscp>=0) session->dscp = dscp;
...@@ -451,27 +459,90 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){ ...@@ -451,27 +459,90 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
// Don't do anything if socket hasn't been created yet // Don't do anything if socket hasn't been created yet
if (session->rtp.socket < 0) return 0; if (session->rtp.socket < 0) return 0;
// DSCP value is in the upper six bits of the TOS field #if (_WIN32_WINNT >= 0x0600)
tos = (session->dscp << 2) & 0xFC; memset(&ovi, 0, sizeof(ovi));
switch (session->rtp.sockfamily) { ovi.dwOSVersionInfoSize = sizeof(ovi);
case AF_INET: GetVersionEx((LPOSVERSIONINFO) & ovi);
retval = setsockopt(session->rtp.socket, IPPROTO_IP, IP_TOS, (SOCKET_OPTION_VALUE)&tos, sizeof(tos));
break; ortp_message("check OS support for qwave.lib: %i %i %i\n",
ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
if (ovi.dwMajorVersion > 5) {
if (FAILED(__HrLoadAllImportsForDll("qwave.dll"))) {
ortp_warning("Failed to load qwave.dll: no QoS available\n" );
}
else
{
if (session->dscp==0)
tos=QOSTrafficTypeBestEffort;
else if (session->dscp==0x8)
tos=QOSTrafficTypeBackground;
else if (session->dscp==0x28)
tos=QOSTrafficTypeAudioVideo;
else if (session->dscp==0x38)
tos=QOSTrafficTypeVoice;
else
tos=QOSTrafficTypeExcellentEffort; /* 0x28 */
if (session->rtp.QoSHandle==NULL) {
QOS_VERSION version;
BOOL QoSResult;
version.MajorVersion = 1;
version.MinorVersion = 0;
QoSResult = QOSCreateHandle(&version, &session->rtp.QoSHandle);
if (QoSResult != TRUE){
ortp_error("QOSCreateHandle failed to create handle with error %d\n",
GetLastError());
retval=-1;
}
}
if (session->rtp.QoSHandle!=NULL) {
BOOL QoSResult;
QoSResult = QOSAddSocketToFlow(
session->rtp.QoSHandle,
session->rtp.socket,
(struct sockaddr*)&session->rtp.rem_addr,
tos,
QOS_NON_ADAPTIVE_FLOW,
&session->rtp.QoSFlowID);
if (QoSResult != TRUE){
ortp_error("QOSAddSocketToFlow failed to add a flow with error %d\n",
GetLastError());
retval=-1;
}
}
}
} else {
#endif
// DSCP value is in the upper six bits of the TOS field
tos = (session->dscp << 2) & 0xFC;
switch (session->rtp.sockfamily) {
case AF_INET:
retval = setsockopt(session->rtp.socket, IPPROTO_IP, IP_TOS, (SOCKET_OPTION_VALUE)&tos, sizeof(tos));
break;
#ifdef ORTP_INET6 #ifdef ORTP_INET6
case AF_INET6: case AF_INET6:
# ifdef IPV6_TCLASS /*seems not defined by my libc*/ # ifdef IPV6_TCLASS /*seems not defined by my libc*/
retval = setsockopt(session->rtp.socket, IPPROTO_IPV6, IPV6_TCLASS, retval = setsockopt(session->rtp.socket, IPPROTO_IPV6, IPV6_TCLASS,
(SOCKET_OPTION_VALUE)&tos, sizeof(tos)); (SOCKET_OPTION_VALUE)&tos, sizeof(tos));
# else # else
/*in case that works:*/ /*in case that works:*/
retval = setsockopt(session->rtp.socket, IPPROTO_IPV6, IP_TOS, retval = setsockopt(session->rtp.socket, IPPROTO_IPV6, IP_TOS,
(SOCKET_OPTION_VALUE)&tos, sizeof(tos)); (SOCKET_OPTION_VALUE)&tos, sizeof(tos));
# endif
break;
#endif #endif
break; default:
#endif retval=-1;
default: }
retval=-1; #if (_WIN32_WINNT >= 0x0600)
} }
#endif
if (retval<0) if (retval<0)
ortp_warning("Failed to set DSCP value on socket."); ortp_warning("Failed to set DSCP value on socket.");
......
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