Prepare future change of WebRtc_Word8 in udp module
Review URL: https://webrtc-codereview.appspot.com/439007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1870 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2050f84b98
commit
f5516240ad
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* Use of this source code is governed by a BSD-style license
|
||||||
* that can be found in the LICENSE file in the root of the source
|
* that can be found in the LICENSE file in the root of the source
|
||||||
@ -591,7 +591,7 @@ WebRtc_Word32 UdpSocket2WorkerWindows::Init()
|
|||||||
{
|
{
|
||||||
if(!_init)
|
if(!_init)
|
||||||
{
|
{
|
||||||
const WebRtc_Word8* threadName = "UdpSocket2ManagerWindows_thread";
|
const char* threadName = "UdpSocket2ManagerWindows_thread";
|
||||||
_pThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority,
|
_pThread = ThreadWrapper::CreateThread(Run, this, kRealtimePriority,
|
||||||
threadName);
|
threadName);
|
||||||
if(_pThread == NULL)
|
if(_pThread == NULL)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* Use of this source code is governed by a BSD-style license
|
||||||
* that can be found in the LICENSE file in the root of the source
|
* that can be found in the LICENSE file in the root of the source
|
||||||
@ -163,7 +163,7 @@ UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id,
|
|||||||
// This is done by setting SO_SNDBUF to 0.
|
// This is done by setting SO_SNDBUF to 0.
|
||||||
WebRtc_Word32 nZero = 0;
|
WebRtc_Word32 nZero = 0;
|
||||||
WebRtc_Word32 nRet = setsockopt(_socket, SOL_SOCKET, SO_SNDBUF,
|
WebRtc_Word32 nRet = setsockopt(_socket, SOL_SOCKET, SO_SNDBUF,
|
||||||
(WebRtc_Word8*)&nZero, sizeof(nZero));
|
(char*)&nZero, sizeof(nZero));
|
||||||
if( nRet == SOCKET_ERROR )
|
if( nRet == SOCKET_ERROR )
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(
|
WEBRTC_TRACE(
|
||||||
@ -269,7 +269,8 @@ bool UdpSocket2Windows::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(0 != setsockopt(_socket, level, optname, optval, optlen ))
|
if(0 != setsockopt(_socket, level, optname,
|
||||||
|
reinterpret_cast<const char*>(optval), optlen ))
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
|
||||||
"UdpSocket2Windows::SetSockopt(), WSAerror:%d",
|
"UdpSocket2Windows::SetSockopt(), WSAerror:%d",
|
||||||
@ -548,7 +549,10 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
|
|||||||
_ptrCbRWLock->AcquireLockShared();
|
_ptrCbRWLock->AcquireLockShared();
|
||||||
if(_wantsIncoming && _incomingCb)
|
if(_wantsIncoming && _incomingCb)
|
||||||
{
|
{
|
||||||
_incomingCb(_obj,pIOContext->wsabuf.buf, ioSize,
|
_incomingCb(_obj,
|
||||||
|
reinterpret_cast<const WebRtc_Word8*>(
|
||||||
|
pIOContext->wsabuf.buf),
|
||||||
|
ioSize,
|
||||||
&pIOContext->from);
|
&pIOContext->from);
|
||||||
}
|
}
|
||||||
_ptrCbRWLock->ReleaseLockShared();
|
_ptrCbRWLock->ReleaseLockShared();
|
||||||
@ -697,7 +701,8 @@ void UdpSocket2Windows::CloseBlocking()
|
|||||||
if(AquireSocket())
|
if(AquireSocket())
|
||||||
{
|
{
|
||||||
setsockopt(_socket, SOL_SOCKET, SO_LINGER,
|
setsockopt(_socket, SOL_SOCKET, SO_LINGER,
|
||||||
(WebRtc_Word8 *)&lingerStruct, sizeof(lingerStruct));
|
reinterpret_cast<const char*>(&lingerStruct),
|
||||||
|
sizeof(lingerStruct));
|
||||||
ReleaseSocket();
|
ReleaseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,7 +828,7 @@ bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Qos.ProviderSpecific.len = QosDestaddr.ObjectHdr.ObjectLength;
|
Qos.ProviderSpecific.len = QosDestaddr.ObjectHdr.ObjectLength;
|
||||||
Qos.ProviderSpecific.buf = (WebRtc_Word8*)&QosDestaddr;
|
Qos.ProviderSpecific.buf = (char*)&QosDestaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AquireSocket())
|
if(AquireSocket())
|
||||||
@ -1015,7 +1020,7 @@ WebRtc_Word32 UdpSocket2Windows::SetTrafficControl(
|
|||||||
((WebRtc_Word8 *)oneinterface + oneinterface->Length))
|
((WebRtc_Word8 *)oneinterface + oneinterface->Length))
|
||||||
{
|
{
|
||||||
|
|
||||||
WebRtc_Word8 interfaceName[500];
|
char interfaceName[500];
|
||||||
WideCharToMultiByte(CP_ACP, 0, oneinterface->pInterfaceName, -1,
|
WideCharToMultiByte(CP_ACP, 0, oneinterface->pInterfaceName, -1,
|
||||||
interfaceName, sizeof(interfaceName), 0, 0 );
|
interfaceName, sizeof(interfaceName), 0, 0 );
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* Use of this source code is governed by a BSD-style license
|
||||||
* that can be found in the LICENSE file in the root of the source
|
* that can be found in the LICENSE file in the root of the source
|
||||||
@ -18,7 +18,7 @@ UdpSocketManagerWindows::UdpSocketManagerWindows()
|
|||||||
: UdpSocketManager(),
|
: UdpSocketManager(),
|
||||||
_id(-1)
|
_id(-1)
|
||||||
{
|
{
|
||||||
const WebRtc_Word8* threadName = "UdpSocketManagerWindows_Thread";
|
const char* threadName = "UdpSocketManagerWindows_Thread";
|
||||||
_critSectList = CriticalSectionWrapper::CreateCriticalSection();
|
_critSectList = CriticalSectionWrapper::CreateCriticalSection();
|
||||||
_thread = ThreadWrapper::CreateThread(UdpSocketManagerWindows::Run,
|
_thread = ThreadWrapper::CreateThread(UdpSocketManagerWindows::Run,
|
||||||
this, kRealtimePriority, threadName);
|
this, kRealtimePriority, threadName);
|
||||||
|
@ -178,7 +178,9 @@ bool UdpSocketPosix::ValidHandle()
|
|||||||
|
|
||||||
void UdpSocketPosix::HasIncoming()
|
void UdpSocketPosix::HasIncoming()
|
||||||
{
|
{
|
||||||
char buf[2048];
|
// replace 2048 with a mcro define and figure out
|
||||||
|
// where 2048 comes from
|
||||||
|
WebRtc_Word8 buf[2048];
|
||||||
int retval;
|
int retval;
|
||||||
SocketAddress from;
|
SocketAddress from;
|
||||||
#if defined(WEBRTC_MAC_INTEL) || defined(WEBRTC_MAC)
|
#if defined(WEBRTC_MAC_INTEL) || defined(WEBRTC_MAC)
|
||||||
@ -211,7 +213,7 @@ void UdpSocketPosix::HasIncoming()
|
|||||||
default:
|
default:
|
||||||
if(_wantsIncoming && _incomingCb)
|
if(_wantsIncoming && _incomingCb)
|
||||||
{
|
{
|
||||||
_incomingCb(_obj,buf, retval, &from);
|
_incomingCb(_obj, buf, retval, &from);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license
|
* Use of this source code is governed by a BSD-style license
|
||||||
* that can be found in the LICENSE file in the root of the source
|
* that can be found in the LICENSE file in the root of the source
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SocketAddress _remoteAddr;
|
SocketAddress _remoteAddr;
|
||||||
WebRtc_Word8 _buffer[MAX_PACKET_SIZE];
|
char _buffer[MAX_PACKET_SIZE];
|
||||||
WebRtc_Word32 _length;
|
WebRtc_Word32 _length;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -214,7 +214,8 @@ bool UdpSocketWindows::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname,
|
|||||||
const WebRtc_Word8* optval,
|
const WebRtc_Word8* optval,
|
||||||
WebRtc_Word32 optlen)
|
WebRtc_Word32 optlen)
|
||||||
{
|
{
|
||||||
if(0 == setsockopt(_socket, level, optname, optval, optlen))
|
if(0 == setsockopt(_socket, level, optname,
|
||||||
|
reinterpret_cast<const char*>(optval), optlen))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -256,7 +257,7 @@ WebRtc_Word32 UdpSocketWindows::SendTo(const WebRtc_Word8* buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 retVal;
|
WebRtc_Word32 retVal;
|
||||||
retVal = sendto(_socket, buf, len, 0,
|
retVal = sendto(_socket, reinterpret_cast<const char*>(buf), len, 0,
|
||||||
reinterpret_cast<const struct sockaddr*>(&to),
|
reinterpret_cast<const struct sockaddr*>(&to),
|
||||||
sizeof(SocketAddress));
|
sizeof(SocketAddress));
|
||||||
|
|
||||||
@ -276,10 +277,11 @@ WebRtc_Word32 UdpSocketWindows::SendTo(const WebRtc_Word8* buf,
|
|||||||
|
|
||||||
void UdpSocketWindows::HasIncoming()
|
void UdpSocketWindows::HasIncoming()
|
||||||
{
|
{
|
||||||
WebRtc_Word8 buf[MAX_PACKET_SIZE];
|
char buf[MAX_PACKET_SIZE];
|
||||||
SocketAddress from;
|
SocketAddress from;
|
||||||
int fromlen = sizeof(from);
|
int fromlen = sizeof(from);
|
||||||
WebRtc_Word32 retval = recvfrom(_socket,buf, sizeof(buf), 0,
|
WebRtc_Word32 retval = recvfrom(_socket, buf,
|
||||||
|
sizeof(buf), 0,
|
||||||
reinterpret_cast<struct sockaddr*>(&from),
|
reinterpret_cast<struct sockaddr*>(&from),
|
||||||
&fromlen);
|
&fromlen);
|
||||||
|
|
||||||
@ -293,7 +295,8 @@ void UdpSocketWindows::HasIncoming()
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(_wantsIncoming && _incomingCb)
|
if(_wantsIncoming && _incomingCb)
|
||||||
_incomingCb(_obj,buf, retval, &from);
|
_incomingCb(_obj, reinterpret_cast<WebRtc_Word8*>(buf),
|
||||||
|
retval, &from);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,7 +365,7 @@ void UdpSocketWindows::SetWritable()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(sendto(
|
if(sendto(
|
||||||
_socket,packet->_buffer,
|
_socket, packet->_buffer,
|
||||||
packet->_length,
|
packet->_length,
|
||||||
0,
|
0,
|
||||||
reinterpret_cast<const struct sockaddr*>(
|
reinterpret_cast<const struct sockaddr*>(
|
||||||
@ -445,7 +448,7 @@ bool UdpSocketWindows::SetQos(WebRtc_Word32 serviceType,
|
|||||||
QosDestaddr->SocketAddress = (SOCKADDR*)&stRemName;
|
QosDestaddr->SocketAddress = (SOCKADDR*)&stRemName;
|
||||||
QosDestaddr->SocketAddressLength = sizeof(SocketAddress);
|
QosDestaddr->SocketAddressLength = sizeof(SocketAddress);
|
||||||
Qos.ProviderSpecific.len = QosDestaddr->ObjectHdr.ObjectLength;
|
Qos.ProviderSpecific.len = QosDestaddr->ObjectHdr.ObjectLength;
|
||||||
Qos.ProviderSpecific.buf = (WebRtc_Word8*)p;
|
Qos.ProviderSpecific.buf = (char*)p;
|
||||||
|
|
||||||
// Socket must be bound for this call to be successfull. If socket is not
|
// Socket must be bound for this call to be successfull. If socket is not
|
||||||
// bound WSAGetLastError() will return 10022.
|
// bound WSAGetLastError() will return 10022.
|
||||||
@ -604,7 +607,7 @@ WebRtc_Word32 UdpSocketWindows::SetTOSByte(WebRtc_Word32 serviceType,
|
|||||||
((WebRtc_Word8*)oneinterface + oneinterface->Length))
|
((WebRtc_Word8*)oneinterface + oneinterface->Length))
|
||||||
{
|
{
|
||||||
|
|
||||||
WebRtc_Word8 interfaceName[500];
|
char interfaceName[500];
|
||||||
WideCharToMultiByte(CP_ACP, 0, oneinterface->pInterfaceName, -1,
|
WideCharToMultiByte(CP_ACP, 0, oneinterface->pInterfaceName, -1,
|
||||||
interfaceName, sizeof(interfaceName), 0, 0);
|
interfaceName, sizeof(interfaceName), 0, 0);
|
||||||
|
|
||||||
|
@ -2763,7 +2763,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
|
|||||||
if(address._sockaddr_storage.sin_family == AF_INET)
|
if(address._sockaddr_storage.sin_family == AF_INET)
|
||||||
{
|
{
|
||||||
// Parse IP assuming format "a.b.c.d:port".
|
// Parse IP assuming format "a.b.c.d:port".
|
||||||
WebRtc_Word8* ipEnd = strchr(ip,':');
|
char* ipEnd = strchr(ip,':');
|
||||||
if(ipEnd != NULL)
|
if(ipEnd != NULL)
|
||||||
{
|
{
|
||||||
*ipEnd = '\0';
|
*ipEnd = '\0';
|
||||||
@ -2778,7 +2778,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Parse IP assuming format "[address]:port".
|
// Parse IP assuming format "[address]:port".
|
||||||
WebRtc_Word8* ipEnd = strchr(ip,']');
|
char* ipEnd = strchr(ip,']');
|
||||||
if(ipEnd != NULL)
|
if(ipEnd != NULL)
|
||||||
{
|
{
|
||||||
// Calculate length
|
// Calculate length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user