WebRtc_Word32 -> int32_t in test/

BUG=314

Review URL: https://webrtc-codereview.appspot.com/1302004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3794 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2013-04-09 11:10:21 +00:00
parent 2550988baa
commit a5f1787f63
34 changed files with 692 additions and 713 deletions

View File

@@ -27,7 +27,7 @@ VoiceChannelTransport::VoiceChannelTransport(VoENetwork* voe_network,
int channel) int channel)
: channel_(channel), : channel_(channel),
voe_network_(voe_network) { voe_network_(voe_network) {
WebRtc_UWord8 socket_threads = 1; uint8_t socket_threads = 1;
socket_transport_ = UdpTransport::Create(channel, socket_threads); socket_transport_ = UdpTransport::Create(channel, socket_threads);
#ifndef WEBRTC_ANDROID #ifndef WEBRTC_ANDROID
EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel, EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel,
@@ -43,23 +43,23 @@ VoiceChannelTransport::~VoiceChannelTransport() {
} }
void VoiceChannelTransport::IncomingRTPPacket( void VoiceChannelTransport::IncomingRTPPacket(
const WebRtc_Word8* incoming_rtp_packet, const int8_t* incoming_rtp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/) { const uint16_t /*from_port*/) {
voe_network_->ReceivedRTPPacket(channel_, incoming_rtp_packet, packet_length); voe_network_->ReceivedRTPPacket(channel_, incoming_rtp_packet, packet_length);
} }
void VoiceChannelTransport::IncomingRTCPPacket( void VoiceChannelTransport::IncomingRTCPPacket(
const WebRtc_Word8* incoming_rtcp_packet, const int8_t* incoming_rtcp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/) { const uint16_t /*from_port*/) {
voe_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet, voe_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet,
packet_length); packet_length);
} }
int VoiceChannelTransport::SetLocalReceiver(WebRtc_UWord16 rtp_port) { int VoiceChannelTransport::SetLocalReceiver(uint16_t rtp_port) {
int return_value = socket_transport_->InitializeReceiveSockets(this, int return_value = socket_transport_->InitializeReceiveSockets(this,
rtp_port); rtp_port);
if (return_value == 0) { if (return_value == 0) {
@@ -69,7 +69,7 @@ int VoiceChannelTransport::SetLocalReceiver(WebRtc_UWord16 rtp_port) {
} }
int VoiceChannelTransport::SetSendDestination(const char* ip_address, int VoiceChannelTransport::SetSendDestination(const char* ip_address,
WebRtc_UWord16 rtp_port) { uint16_t rtp_port) {
return socket_transport_->InitializeSendSockets(ip_address, rtp_port); return socket_transport_->InitializeSendSockets(ip_address, rtp_port);
} }
@@ -78,7 +78,7 @@ VideoChannelTransport::VideoChannelTransport(ViENetwork* vie_network,
int channel) int channel)
: channel_(channel), : channel_(channel),
vie_network_(vie_network) { vie_network_(vie_network) {
WebRtc_UWord8 socket_threads = 1; uint8_t socket_threads = 1;
socket_transport_ = UdpTransport::Create(channel, socket_threads); socket_transport_ = UdpTransport::Create(channel, socket_threads);
#ifndef WEBRTC_ANDROID #ifndef WEBRTC_ANDROID
EXPECT_EQ(0, vie_network_->RegisterSendTransport(channel, EXPECT_EQ(0, vie_network_->RegisterSendTransport(channel,
@@ -94,23 +94,23 @@ VideoChannelTransport::~VideoChannelTransport() {
} }
void VideoChannelTransport::IncomingRTPPacket( void VideoChannelTransport::IncomingRTPPacket(
const WebRtc_Word8* incoming_rtp_packet, const int8_t* incoming_rtp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/) { const uint16_t /*from_port*/) {
vie_network_->ReceivedRTPPacket(channel_, incoming_rtp_packet, packet_length); vie_network_->ReceivedRTPPacket(channel_, incoming_rtp_packet, packet_length);
} }
void VideoChannelTransport::IncomingRTCPPacket( void VideoChannelTransport::IncomingRTCPPacket(
const WebRtc_Word8* incoming_rtcp_packet, const int8_t* incoming_rtcp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/) { const uint16_t /*from_port*/) {
vie_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet, vie_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet,
packet_length); packet_length);
} }
int VideoChannelTransport::SetLocalReceiver(WebRtc_UWord16 rtp_port) { int VideoChannelTransport::SetLocalReceiver(uint16_t rtp_port) {
int return_value = socket_transport_->InitializeReceiveSockets(this, int return_value = socket_transport_->InitializeReceiveSockets(this,
rtp_port); rtp_port);
if (return_value == 0) { if (return_value == 0) {
@@ -120,7 +120,7 @@ int VideoChannelTransport::SetLocalReceiver(WebRtc_UWord16 rtp_port) {
} }
int VideoChannelTransport::SetSendDestination(const char* ip_address, int VideoChannelTransport::SetSendDestination(const char* ip_address,
WebRtc_UWord16 rtp_port) { uint16_t rtp_port) {
return socket_transport_->InitializeSendSockets(ip_address, rtp_port); return socket_transport_->InitializeSendSockets(ip_address, rtp_port);
} }

View File

@@ -28,22 +28,22 @@ class VoiceChannelTransport : public UdpTransportData {
virtual ~VoiceChannelTransport(); virtual ~VoiceChannelTransport();
// Start implementation of UdpTransportData. // Start implementation of UdpTransportData.
void IncomingRTPPacket(const WebRtc_Word8* incoming_rtp_packet, void IncomingRTPPacket(const int8_t* incoming_rtp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/); const uint16_t /*from_port*/);
void IncomingRTCPPacket(const WebRtc_Word8* incoming_rtcp_packet, void IncomingRTCPPacket(const int8_t* incoming_rtcp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/); const uint16_t /*from_port*/);
// End implementation of UdpTransportData. // End implementation of UdpTransportData.
// Specifies the ports to receive RTP packets on. // Specifies the ports to receive RTP packets on.
int SetLocalReceiver(WebRtc_UWord16 rtp_port); int SetLocalReceiver(uint16_t rtp_port);
// Specifies the destination port and IP address for a specified channel. // Specifies the destination port and IP address for a specified channel.
int SetSendDestination(const char* ip_address, WebRtc_UWord16 rtp_port); int SetSendDestination(const char* ip_address, uint16_t rtp_port);
private: private:
int channel_; int channel_;
@@ -59,22 +59,22 @@ class VideoChannelTransport : public UdpTransportData {
virtual ~VideoChannelTransport(); virtual ~VideoChannelTransport();
// Start implementation of UdpTransportData. // Start implementation of UdpTransportData.
void IncomingRTPPacket(const WebRtc_Word8* incoming_rtp_packet, void IncomingRTPPacket(const int8_t* incoming_rtp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/); const uint16_t /*from_port*/);
void IncomingRTCPPacket(const WebRtc_Word8* incoming_rtcp_packet, void IncomingRTCPPacket(const int8_t* incoming_rtcp_packet,
const WebRtc_Word32 packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const WebRtc_UWord16 /*from_port*/); const uint16_t /*from_port*/);
// End implementation of UdpTransportData. // End implementation of UdpTransportData.
// Specifies the ports to receive RTP packets on. // Specifies the ports to receive RTP packets on.
int SetLocalReceiver(WebRtc_UWord16 rtp_port); int SetLocalReceiver(uint16_t rtp_port);
// Specifies the destination port and IP address for a specified channel. // Specifies the destination port and IP address for a specified channel.
int SetSendDestination(const char* ip_address, WebRtc_UWord16 rtp_port); int SetSendDestination(const char* ip_address, uint16_t rtp_port);
private: private:
int channel_; int channel_;

View File

@@ -18,14 +18,14 @@ namespace webrtc {
namespace test { namespace test {
TrafficControlWindows* TrafficControlWindows::instance = NULL; TrafficControlWindows* TrafficControlWindows::instance = NULL;
WebRtc_UWord32 TrafficControlWindows::refCounter = 0; uint32_t TrafficControlWindows::refCounter = 0;
TrafficControlWindows::TrafficControlWindows(const WebRtc_Word32 id) : _id(id) TrafficControlWindows::TrafficControlWindows(const int32_t id) : _id(id)
{ {
} }
TrafficControlWindows* TrafficControlWindows::GetInstance( TrafficControlWindows* TrafficControlWindows::GetInstance(
const WebRtc_Word32 id) const int32_t id)
{ {
if(instance != NULL) if(instance != NULL)
{ {
@@ -165,7 +165,7 @@ void TrafficControlWindows::Release(TrafficControlWindows* gtc)
instance = NULL; instance = NULL;
} }
} }
WebRtc_Word32 TrafficControlWindows::ChangeUniqueId(const WebRtc_Word32 id) int32_t TrafficControlWindows::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
return 0; return 0;

View File

@@ -46,10 +46,10 @@ class TrafficControlWindows
{ {
public: public:
// Factory method. Constructor disabled. // Factory method. Constructor disabled.
static TrafficControlWindows* GetInstance(const WebRtc_Word32 id); static TrafficControlWindows* GetInstance(const int32_t id);
static void Release(TrafficControlWindows* gtc); static void Release(TrafficControlWindows* gtc);
WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); int32_t ChangeUniqueId(const int32_t id);
ULONG TcRegisterClient(ULONG TciVersion, HANDLE ClRegCtx, ULONG TcRegisterClient(ULONG TciVersion, HANDLE ClRegCtx,
PTCI_CLIENT_FUNC_LIST ClientHandlerList, PTCI_CLIENT_FUNC_LIST ClientHandlerList,
@@ -74,8 +74,8 @@ class TrafficControlWindows
ULONG TcDeleteFlow(HANDLE FlowHandle); ULONG TcDeleteFlow(HANDLE FlowHandle);
ULONG TcDeleteFilter(HANDLE FilterHandle); ULONG TcDeleteFilter(HANDLE FilterHandle);
private: private:
TrafficControlWindows(const WebRtc_Word32 id); TrafficControlWindows(const int32_t id);
WebRtc_Word32 _id; int32_t _id;
TCI_CLIENT_FUNC_LIST QoSFunctions; TCI_CLIENT_FUNC_LIST QoSFunctions;
static TrafficControlWindows* instance; static TrafficControlWindows* instance;
@@ -93,7 +93,7 @@ private:
filterAddFn tcAddFilter; filterAddFn tcAddFilter;
filterDeleteFn tcDeleteFilter; filterDeleteFn tcDeleteFilter;
static WebRtc_UWord32 refCounter; static uint32_t refCounter;
}; };
} // namespace test } // namespace test

View File

@@ -19,7 +19,7 @@
namespace webrtc { namespace webrtc {
namespace test { namespace test {
WebRtc_UWord32 UdpSocket2ManagerWindows::_numOfActiveManagers = 0; uint32_t UdpSocket2ManagerWindows::_numOfActiveManagers = 0;
bool UdpSocket2ManagerWindows::_wsaInit = false; bool UdpSocket2ManagerWindows::_wsaInit = false;
UdpSocket2ManagerWindows::UdpSocket2ManagerWindows() UdpSocket2ManagerWindows::UdpSocket2ManagerWindows()
@@ -98,8 +98,8 @@ UdpSocket2ManagerWindows::~UdpSocket2ManagerWindows()
} }
} }
bool UdpSocket2ManagerWindows::Init(WebRtc_Word32 id, bool UdpSocket2ManagerWindows::Init(int32_t id,
WebRtc_UWord8& numOfWorkThreads) { uint8_t& numOfWorkThreads) {
CriticalSectionScoped cs(_pCrit); CriticalSectionScoped cs(_pCrit);
if ((_id != -1) || (_numOfWorkThreads != 0)) { if ((_id != -1) || (_numOfWorkThreads != 0)) {
assert(_id != -1); assert(_id != -1);
@@ -111,7 +111,7 @@ bool UdpSocket2ManagerWindows::Init(WebRtc_Word32 id,
return true; return true;
} }
WebRtc_Word32 UdpSocket2ManagerWindows::ChangeUniqueId(const WebRtc_Word32 id) int32_t UdpSocket2ManagerWindows::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
return 0; return 0;
@@ -133,7 +133,7 @@ bool UdpSocket2ManagerWindows::Start()
_pCrit->Enter(); _pCrit->Enter();
// Start worker threads. // Start worker threads.
_stopped = false; _stopped = false;
WebRtc_Word32 error = 0; int32_t error = 0;
ListItem* pItem = _workerThreadsList.First(); ListItem* pItem = _workerThreadsList.First();
UdpSocket2WorkerWindows* pWorker; UdpSocket2WorkerWindows* pWorker;
while(pItem != NULL && !error) while(pItem != NULL && !error)
@@ -169,7 +169,7 @@ bool UdpSocket2ManagerWindows::StartWorkerThreads()
0, 0); 0, 0);
if(_ioCompletionHandle == NULL) if(_ioCompletionHandle == NULL)
{ {
WebRtc_Word32 error = GetLastError(); int32_t error = GetLastError();
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceError, kTraceError,
kTraceTransport, kTraceTransport,
@@ -182,7 +182,7 @@ bool UdpSocket2ManagerWindows::StartWorkerThreads()
} }
// Create worker threads. // Create worker threads.
WebRtc_UWord32 i = 0; uint32_t i = 0;
bool error = false; bool error = false;
while(i < _numOfWorkThreads && !error) while(i < _numOfWorkThreads && !error)
{ {
@@ -272,7 +272,7 @@ bool UdpSocket2ManagerWindows::Stop()
bool UdpSocket2ManagerWindows::StopWorkerThreads() bool UdpSocket2ManagerWindows::StopWorkerThreads()
{ {
WebRtc_Word32 error = 0; int32_t error = 0;
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceDebug, kTraceDebug,
kTraceTransport, kTraceTransport,
@@ -295,7 +295,7 @@ bool UdpSocket2ManagerWindows::StopWorkerThreads()
// Release all threads waiting for GetQueuedCompletionStatus(..). // Release all threads waiting for GetQueuedCompletionStatus(..).
if(_ioCompletionHandle) if(_ioCompletionHandle)
{ {
WebRtc_UWord32 i = 0; uint32_t i = 0;
for(i = 0; i < _workerThreadsList.GetSize(); i++) for(i = 0; i < _workerThreadsList.GetSize(); i++)
{ {
PostQueuedCompletionStatus(_ioCompletionHandle, 0 ,0 , NULL); PostQueuedCompletionStatus(_ioCompletionHandle, 0 ,0 , NULL);
@@ -365,7 +365,7 @@ bool UdpSocket2ManagerWindows::AddSocketPrv(UdpSocket2Windows* s)
"UdpSocket2ManagerWindows(%d)::AddSocketPrv() socket->GetFd() ==\ "UdpSocket2ManagerWindows(%d)::AddSocketPrv() socket->GetFd() ==\
%d", %d",
_managerNumber, _managerNumber,
(WebRtc_Word32)s->GetFd()); (int32_t)s->GetFd());
_pCrit->Leave(); _pCrit->Leave();
return false; return false;
@@ -375,7 +375,7 @@ bool UdpSocket2ManagerWindows::AddSocketPrv(UdpSocket2Windows* s)
(ULONG_PTR)(s), 0); (ULONG_PTR)(s), 0);
if(_ioCompletionHandle == NULL) if(_ioCompletionHandle == NULL)
{ {
WebRtc_Word32 error = GetLastError(); int32_t error = GetLastError();
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceError, kTraceError,
kTraceTransport, kTraceTransport,
@@ -430,7 +430,7 @@ PerIoContext* UdpSocket2ManagerWindows::PopIoContext()
return pIoC; return pIoC;
} }
WebRtc_Word32 UdpSocket2ManagerWindows::PushIoContext(PerIoContext* pIoContext) int32_t UdpSocket2ManagerWindows::PushIoContext(PerIoContext* pIoContext)
{ {
return _ioContextPool.PushIoContext(pIoContext); return _ioContextPool.PushIoContext(pIoContext);
} }
@@ -450,7 +450,7 @@ IoContextPool::~IoContextPool()
AlignedFree(_pListHead); AlignedFree(_pListHead);
} }
WebRtc_Word32 IoContextPool::Init(WebRtc_UWord32 /*increaseSize*/) int32_t IoContextPool::Init(uint32_t /*increaseSize*/)
{ {
if(_init) if(_init)
{ {
@@ -495,7 +495,7 @@ PerIoContext* IoContextPool::PopIoContext()
return &((IoContextPoolItem*)pListEntry)->payload.ioContext; return &((IoContextPoolItem*)pListEntry)->payload.ioContext;
} }
WebRtc_Word32 IoContextPool::PushIoContext(PerIoContext* pIoContext) int32_t IoContextPool::PushIoContext(PerIoContext* pIoContext)
{ {
// TODO (hellner): Overlapped IO should be completed at this point. Perhaps // TODO (hellner): Overlapped IO should be completed at this point. Perhaps
// add an assert? // add an assert?
@@ -504,9 +504,9 @@ WebRtc_Word32 IoContextPool::PushIoContext(PerIoContext* pIoContext)
IoContextPoolItem* item = ((IoContextPoolItemPayload*)pIoContext)->base; IoContextPoolItem* item = ((IoContextPoolItemPayload*)pIoContext)->base;
const WebRtc_Word32 usedItems = --_inUse; const int32_t usedItems = --_inUse;
const WebRtc_Word32 totalItems = _size.Value(); const int32_t totalItems = _size.Value();
const WebRtc_Word32 freeItems = totalItems - usedItems; const int32_t freeItems = totalItems - usedItems;
if(freeItems < 0) if(freeItems < 0)
{ {
assert(false); assert(false);
@@ -524,14 +524,14 @@ WebRtc_Word32 IoContextPool::PushIoContext(PerIoContext* pIoContext)
return 0; return 0;
} }
WebRtc_Word32 IoContextPool::Free() int32_t IoContextPool::Free()
{ {
if(!_init) if(!_init)
{ {
return 0; return 0;
} }
WebRtc_Word32 itemsFreed = 0; int32_t itemsFreed = 0;
PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead); PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead);
while(pListEntry != NULL) while(pListEntry != NULL)
{ {
@@ -544,7 +544,7 @@ WebRtc_Word32 IoContextPool::Free()
return itemsFreed; return itemsFreed;
} }
WebRtc_Word32 UdpSocket2WorkerWindows::_numOfWorkers = 0; int32_t UdpSocket2WorkerWindows::_numOfWorkers = 0;
UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle) UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle)
: _ioCompletionHandle(ioCompletionHandle), : _ioCompletionHandle(ioCompletionHandle),
@@ -588,7 +588,7 @@ void UdpSocket2WorkerWindows::SetNotAlive()
_pThread->SetNotAlive(); _pThread->SetNotAlive();
} }
WebRtc_Word32 UdpSocket2WorkerWindows::Init() int32_t UdpSocket2WorkerWindows::Init()
{ {
if(!_init) if(!_init)
{ {
@@ -621,7 +621,7 @@ bool UdpSocket2WorkerWindows::Run(ThreadObj obj)
// the UdpSocket2ManagerWindows::StopWorkerThreads() function. // the UdpSocket2ManagerWindows::StopWorkerThreads() function.
bool UdpSocket2WorkerWindows::Process() bool UdpSocket2WorkerWindows::Process()
{ {
WebRtc_Word32 success = 0; int32_t success = 0;
DWORD ioSize = 0; DWORD ioSize = 0;
UdpSocket2Windows* pSocket = NULL; UdpSocket2Windows* pSocket = NULL;
PerIoContext* pIOContext = 0; PerIoContext* pIOContext = 0;
@@ -630,7 +630,7 @@ bool UdpSocket2WorkerWindows::Process()
&ioSize, &ioSize,
(ULONG_PTR*)&pSocket, &pOverlapped, 200); (ULONG_PTR*)&pSocket, &pOverlapped, 200);
WebRtc_UWord32 error = 0; uint32_t error = 0;
if(!success) if(!success)
{ {
error = GetLastError(); error = GetLastError();

View File

@@ -75,13 +75,13 @@ class IoContextPool
public: public:
IoContextPool(); IoContextPool();
virtual ~IoContextPool(); virtual ~IoContextPool();
virtual WebRtc_Word32 Init(WebRtc_UWord32 increaseSize = 128); virtual int32_t Init(uint32_t increaseSize = 128);
// Re-use an old unused IO context or create a new one. // Re-use an old unused IO context or create a new one.
virtual PerIoContext* PopIoContext(); virtual PerIoContext* PopIoContext();
virtual WebRtc_Word32 PushIoContext(PerIoContext* pIoContext); virtual int32_t PushIoContext(PerIoContext* pIoContext);
virtual inline WebRtc_Word32 GetSize(WebRtc_UWord32* inUse = 0) virtual inline int32_t GetSize(uint32_t* inUse = 0)
{return _size.Value();} {return _size.Value();}
virtual WebRtc_Word32 Free(); virtual int32_t Free();
private: private:
// Sample code for use of msfts single linked atomic list can be found here: // Sample code for use of msfts single linked atomic list can be found here:
// http://msdn.microsoft.com/en-us/library/ms686962(VS.85).aspx // http://msdn.microsoft.com/en-us/library/ms686962(VS.85).aspx
@@ -101,8 +101,8 @@ public:
UdpSocket2ManagerWindows(); UdpSocket2ManagerWindows();
virtual ~UdpSocket2ManagerWindows(); virtual ~UdpSocket2ManagerWindows();
virtual bool Init(WebRtc_Word32 id, WebRtc_UWord8& numOfWorkThreads); virtual bool Init(int32_t id, uint8_t& numOfWorkThreads);
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual int32_t ChangeUniqueId(const int32_t id);
virtual bool Start(); virtual bool Start();
virtual bool Stop(); virtual bool Stop();
@@ -115,7 +115,7 @@ public:
return false;} return false;}
PerIoContext* PopIoContext(void); PerIoContext* PopIoContext(void);
WebRtc_Word32 PushIoContext(PerIoContext* pIoContext); int32_t PushIoContext(PerIoContext* pIoContext);
private: private:
bool StopWorkerThreads(); bool StopWorkerThreads();
@@ -123,15 +123,15 @@ private:
bool AddSocketPrv(UdpSocket2Windows* s); bool AddSocketPrv(UdpSocket2Windows* s);
bool RemoveSocketPrv(UdpSocket2Windows* s); bool RemoveSocketPrv(UdpSocket2Windows* s);
static WebRtc_UWord32 _numOfActiveManagers; static uint32_t _numOfActiveManagers;
static bool _wsaInit; static bool _wsaInit;
WebRtc_Word32 _id; int32_t _id;
CriticalSectionWrapper* _pCrit; CriticalSectionWrapper* _pCrit;
WebRtc_Word32 _managerNumber; int32_t _managerNumber;
volatile bool _stopped; volatile bool _stopped;
bool _init; bool _init;
WebRtc_Word32 _numActiveSockets; int32_t _numActiveSockets;
ListWrapper _workerThreadsList; ListWrapper _workerThreadsList;
EventWrapper* _event; EventWrapper* _event;
@@ -147,7 +147,7 @@ public:
virtual bool Start(); virtual bool Start();
virtual bool Stop(); virtual bool Stop();
virtual WebRtc_Word32 Init(); virtual int32_t Init();
virtual void SetNotAlive(); virtual void SetNotAlive();
protected: protected:
static bool Run(ThreadObj obj); static bool Run(ThreadObj obj);
@@ -155,8 +155,8 @@ protected:
private: private:
HANDLE _ioCompletionHandle; HANDLE _ioCompletionHandle;
ThreadWrapper*_pThread; ThreadWrapper*_pThread;
static WebRtc_Word32 _numOfWorkers; static int32_t _numOfWorkers;
WebRtc_Word32 _workerNumber; int32_t _workerNumber;
volatile bool _stop; volatile bool _stop;
bool _init; bool _init;
}; };

View File

@@ -39,7 +39,7 @@ typedef const QOS_DESTADDR* LPCQOS_DESTADDR;
#define QOS_GENERAL_ID_BASE 2000 #define QOS_GENERAL_ID_BASE 2000
#define QOS_OBJECT_DESTADDR (0x00000004 + QOS_GENERAL_ID_BASE) #define QOS_OBJECT_DESTADDR (0x00000004 + QOS_GENERAL_ID_BASE)
UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id, UdpSocket2Windows::UdpSocket2Windows(const int32_t id,
UdpSocketManager* mgr, bool ipV6Enable, UdpSocketManager* mgr, bool ipV6Enable,
bool disableGQOS) bool disableGQOS)
: _id(id), : _id(id),
@@ -85,7 +85,7 @@ UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id,
DWORD dwBufLen = 0; DWORD dwBufLen = 0;
// Set dwBufLen to the size needed to retreive all the requested // Set dwBufLen to the size needed to retreive all the requested
// information from WSAEnumProtocols. // information from WSAEnumProtocols.
WebRtc_Word32 nRet = WSAEnumProtocols(NULL, lpProtocolBuf, &dwBufLen); int32_t nRet = WSAEnumProtocols(NULL, lpProtocolBuf, &dwBufLen);
lpProtocolBuf = (WSAPROTOCOL_INFO*)malloc(dwBufLen); lpProtocolBuf = (WSAPROTOCOL_INFO*)malloc(dwBufLen);
nRet = WSAEnumProtocols(NULL, lpProtocolBuf, &dwBufLen); nRet = WSAEnumProtocols(NULL, lpProtocolBuf, &dwBufLen);
@@ -96,7 +96,7 @@ UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id,
_iProtocol=AF_INET; _iProtocol=AF_INET;
} }
for (WebRtc_Word32 i=0; i<nRet; i++) for (int32_t i=0; i<nRet; i++)
{ {
if (_iProtocol == lpProtocolBuf[i].iAddressFamily && if (_iProtocol == lpProtocolBuf[i].iAddressFamily &&
IPPROTO_UDP == lpProtocolBuf[i].iProtocol) IPPROTO_UDP == lpProtocolBuf[i].iProtocol)
@@ -164,9 +164,9 @@ UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id,
// Disable send buffering on the socket to improve CPU usage. // Disable send buffering on the socket to improve CPU usage.
// This is done by setting SO_SNDBUF to 0. // This is done by setting SO_SNDBUF to 0.
WebRtc_Word32 nZero = 0; int32_t nZero = 0;
WebRtc_Word32 nRet = setsockopt(_socket, SOL_SOCKET, SO_SNDBUF, int32_t nRet = setsockopt(_socket, SOL_SOCKET, SO_SNDBUF,
(char*)&nZero, sizeof(nZero)); (char*)&nZero, sizeof(nZero));
if( nRet == SOCKET_ERROR ) if( nRet == SOCKET_ERROR )
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
@@ -215,7 +215,7 @@ UdpSocket2Windows::~UdpSocket2Windows()
} }
} }
WebRtc_Word32 UdpSocket2Windows::ChangeUniqueId(const WebRtc_Word32 id) int32_t UdpSocket2Windows::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
if (_gtc) if (_gtc)
@@ -238,12 +238,12 @@ bool UdpSocket2Windows::SetCallback(CallbackObj obj, IncomingSocketCallback cb)
_ptrCbRWLock->ReleaseLockExclusive(); _ptrCbRWLock->ReleaseLockExclusive();
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SetCallback ",(WebRtc_Word32)this); "UdpSocket2Windows(%d)::SetCallback ",(int32_t)this);
if(_addedToMgr) if(_addedToMgr)
{ {
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SetCallback alreadey added", "UdpSocket2Windows(%d)::SetCallback alreadey added",
(WebRtc_Word32) this); (int32_t) this);
return false; return false;
} }
@@ -252,20 +252,19 @@ bool UdpSocket2Windows::SetCallback(CallbackObj obj, IncomingSocketCallback cb)
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceDebug, kTraceTransport, _id, kTraceDebug, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SetCallback socket added to manager", "UdpSocket2Windows(%d)::SetCallback socket added to manager",
(WebRtc_Word32)this); (int32_t)this);
_addedToMgr = true; _addedToMgr = true;
return true; return true;
} }
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SetCallback error adding me to mgr", "UdpSocket2Windows(%d)::SetCallback error adding me to mgr",
(WebRtc_Word32) this); (int32_t) this);
return false; return false;
} }
bool UdpSocket2Windows::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, bool UdpSocket2Windows::SetSockopt(int32_t level, int32_t optname,
const WebRtc_Word8* optval, const int8_t* optval, int32_t optlen)
WebRtc_Word32 optlen)
{ {
bool returnValue = true; bool returnValue = true;
if(!AquireSocket()) if(!AquireSocket())
@@ -284,21 +283,21 @@ bool UdpSocket2Windows::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname,
return returnValue; return returnValue;
} }
bool UdpSocket2Windows::StartReceiving(WebRtc_UWord32 receiveBuffers) bool UdpSocket2Windows::StartReceiving(uint32_t receiveBuffers)
{ {
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id,
"UdpSocket2Windows(%d)::StartReceiving(%d)", "UdpSocket2Windows(%d)::StartReceiving(%d)", (int32_t)this,
(WebRtc_Word32)this, receiveBuffers); receiveBuffers);
_wantsIncoming = true; _wantsIncoming = true;
WebRtc_Word32 numberOfReceiveBuffersToCreate = int32_t numberOfReceiveBuffersToCreate =
receiveBuffers - _receiveBuffers.Value(); receiveBuffers - _receiveBuffers.Value();
numberOfReceiveBuffersToCreate = (numberOfReceiveBuffersToCreate < 0) ? numberOfReceiveBuffersToCreate = (numberOfReceiveBuffersToCreate < 0) ?
0 : numberOfReceiveBuffersToCreate; 0 : numberOfReceiveBuffersToCreate;
WebRtc_Word32 error = 0; int32_t error = 0;
for(WebRtc_Word32 i = 0; for(int32_t i = 0;
i < numberOfReceiveBuffersToCreate; i < numberOfReceiveBuffersToCreate;
i++) i++)
{ {
@@ -350,17 +349,16 @@ bool UdpSocket2Windows::Bind(const SocketAddress& name)
return returnValue; return returnValue;
} }
WebRtc_Word32 UdpSocket2Windows::SendTo(const WebRtc_Word8* buf, int32_t UdpSocket2Windows::SendTo(const int8_t* buf, int32_t len,
WebRtc_Word32 len, const SocketAddress& to)
const SocketAddress& to)
{ {
WebRtc_Word32 retVal = 0; int32_t retVal = 0;
WebRtc_Word32 error = 0; int32_t error = 0;
if(len < 0) if(len < 0)
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SendTo(), len= %d < 0", "UdpSocket2Windows(%d)::SendTo(), len= %d < 0",
(WebRtc_Word32)this, len); (int32_t)this, len);
return -1; return -1;
} }
@@ -369,19 +367,19 @@ WebRtc_Word32 UdpSocket2Windows::SendTo(const WebRtc_Word8* buf,
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"UdpSocket2Windows(%d)::SendTo(), pIoContext==0", "UdpSocket2Windows(%d)::SendTo(), pIoContext==0",
(WebRtc_Word32) this); (int32_t) this);
return -1; return -1;
} }
// sizeof(pIoContext->buffer) is smaller than the highest number that // sizeof(pIoContext->buffer) is smaller than the highest number that
// can be represented by a WebRtc_Word32. // can be represented by a int32_t.
if(len >= (WebRtc_Word32) sizeof(pIoContext->buffer)) if(len >= (int32_t) sizeof(pIoContext->buffer))
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceError, kTraceError,
kTraceTransport, kTraceTransport,
_id, _id,
"UdpSocket2Windows(%d)::SendTo(), len= %d > buffer_size = %d", "UdpSocket2Windows(%d)::SendTo(), len= %d > buffer_size = %d",
(WebRtc_Word32) this, (int32_t) this,
len,sizeof(pIoContext->buffer)); len,sizeof(pIoContext->buffer));
len = sizeof(pIoContext->buffer); len = sizeof(pIoContext->buffer);
} }
@@ -435,7 +433,7 @@ WebRtc_Word32 UdpSocket2Windows::SendTo(const WebRtc_Word8* buf,
kTraceTransport, kTraceTransport,
_id, _id,
"UdpSocket2Windows(%d)::SendTo(), error:%d pushing ioContext", "UdpSocket2Windows(%d)::SendTo(), error:%d pushing ioContext",
(WebRtc_Word32)this, error); (int32_t)this, error);
} }
// Roll back. // Roll back.
@@ -444,7 +442,7 @@ WebRtc_Word32 UdpSocket2Windows::SendTo(const WebRtc_Word8* buf,
} }
void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext, void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
WebRtc_UWord32 ioSize, WebRtc_UWord32 error) uint32_t ioSize, uint32_t error)
{ {
if(pIOContext == NULL || error == ERROR_OPERATION_ABORTED) if(pIOContext == NULL || error == ERROR_OPERATION_ABORTED)
{ {
@@ -477,10 +475,10 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
kTraceTransport, kTraceTransport,
_id, _id,
"UdpSocket2Windows::IOCompleted(%d,%d,%d), %d", "UdpSocket2Windows::IOCompleted(%d,%d,%d), %d",
(WebRtc_Word32)pIOContext, (int32_t)pIOContext,
ioSize, ioSize,
error, error,
pIOContext ? (WebRtc_Word32)pIOContext->ioOperation : -1); pIOContext ? (int32_t)pIOContext->ioOperation : -1);
} else { } else {
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceDebug, kTraceDebug,
@@ -490,12 +488,12 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
} }
if(pIOContext) if(pIOContext)
{ {
WebRtc_Word32 remainingReceiveBuffers = --_receiveBuffers; int32_t remainingReceiveBuffers = --_receiveBuffers;
if(remainingReceiveBuffers < 0) if(remainingReceiveBuffers < 0)
{ {
assert(false); assert(false);
} }
WebRtc_Word32 err = 0; int32_t err = 0;
if((err = _mgr->PushIoContext(pIOContext))) if((err = _mgr->PushIoContext(pIOContext)))
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
@@ -524,14 +522,14 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
if(_wantsIncoming && _incomingCb) if(_wantsIncoming && _incomingCb)
{ {
_incomingCb(_obj, _incomingCb(_obj,
reinterpret_cast<const WebRtc_Word8*>( reinterpret_cast<const int8_t*>(
pIOContext->wsabuf.buf), pIOContext->wsabuf.buf),
ioSize, ioSize,
&pIOContext->from); &pIOContext->from);
} }
_ptrCbRWLock->ReleaseLockShared(); _ptrCbRWLock->ReleaseLockShared();
} }
WebRtc_Word32 err = PostRecv(pIOContext); int32_t err = PostRecv(pIOContext);
if(err == 0) if(err == 0)
{ {
// The PerIoContext was posted by a thread controlled by the socket // The PerIoContext was posted by a thread controlled by the socket
@@ -551,14 +549,14 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
// may be deleted at this point. // may be deleted at this point.
} }
WebRtc_Word32 UdpSocket2Windows::PostRecv() int32_t UdpSocket2Windows::PostRecv()
{ {
PerIoContext* pIoContext=_mgr->PopIoContext(); PerIoContext* pIoContext=_mgr->PopIoContext();
if(pIoContext == 0) if(pIoContext == 0)
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"UdpSocket2Windows(%d)::PostRecv(), pIoContext == 0", "UdpSocket2Windows(%d)::PostRecv(), pIoContext == 0",
(WebRtc_Word32)this); (int32_t)this);
return -1; return -1;
} }
// This function may have been called by thread not controlled by the socket // This function may have been called by thread not controlled by the socket
@@ -567,13 +565,13 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv()
return PostRecv(pIoContext); return PostRecv(pIoContext);
} }
WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext) int32_t UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
{ {
if(pIoContext==0) if(pIoContext==0)
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"UdpSocket2Windows(%d)::PostRecv(?), pIoContext==0", "UdpSocket2Windows(%d)::PostRecv(?), pIoContext==0",
(WebRtc_Word32)this); (int32_t)this);
return -1; return -1;
} }
@@ -583,9 +581,9 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
pIoContext->wsabuf.len = sizeof(pIoContext->buffer); pIoContext->wsabuf.len = sizeof(pIoContext->buffer);
pIoContext->fromLen = sizeof(SocketAddress); pIoContext->fromLen = sizeof(SocketAddress);
pIoContext->ioOperation = OP_READ; pIoContext->ioOperation = OP_READ;
WebRtc_Word32 rxError = 0; int32_t rxError = 0;
WebRtc_Word32 nRet = 0; int32_t nRet = 0;
WebRtc_Word32 postingSucessfull = false; int32_t postingSucessfull = false;
if(!AquireSocket()) if(!AquireSocket())
{ {
@@ -601,7 +599,7 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
ReleaseSocket(); ReleaseSocket();
return -1; return -1;
} }
for(WebRtc_Word32 tries = 0; tries < 10; tries++) for(int32_t tries = 0; tries < 10; tries++)
{ {
nRet = WSARecvFrom( nRet = WSARecvFrom(
_socket, _socket,
@@ -625,7 +623,7 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
_id, _id,
"UdpSocket2Windows(%d)::PostRecv(?), WSAerror:%d when\ "UdpSocket2Windows(%d)::PostRecv(?), WSAerror:%d when\
posting new recieve,trie:%d", posting new recieve,trie:%d",
(WebRtc_Word32)this, (int32_t)this,
rxError, rxError,
tries); tries);
// Tell the OS that this is a good place to context switch if // Tell the OS that this is a good place to context switch if
@@ -645,12 +643,12 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
{ {
return 0; return 0;
} }
WebRtc_Word32 remainingReceiveBuffers = --_receiveBuffers; int32_t remainingReceiveBuffers = --_receiveBuffers;
if(remainingReceiveBuffers < 0) if(remainingReceiveBuffers < 0)
{ {
assert(false); assert(false);
} }
WebRtc_Word32 error = 0; int32_t error = 0;
if((error = _mgr->PushIoContext(pIoContext))) if((error = _mgr->PushIoContext(pIoContext)))
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
@@ -658,7 +656,7 @@ WebRtc_Word32 UdpSocket2Windows::PostRecv(PerIoContext* pIoContext)
kTraceTransport, kTraceTransport,
_id, _id,
"UdpSocket2Windows(%d)::PostRecv(?), error:%d when PushIoContext", "UdpSocket2Windows(%d)::PostRecv(?), error:%d when PushIoContext",
(WebRtc_Word32)this, (int32_t)this,
error); error);
} }
// Roll back. // Roll back.
@@ -688,14 +686,14 @@ void UdpSocket2Windows::CloseBlocking()
delete this; delete this;
} }
bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType, bool UdpSocket2Windows::SetQos(int32_t serviceType,
WebRtc_Word32 tokenRate, int32_t tokenRate,
WebRtc_Word32 bucketSize, int32_t bucketSize,
WebRtc_Word32 peekBandwith, int32_t peekBandwith,
WebRtc_Word32 minPolicedSize, int32_t minPolicedSize,
WebRtc_Word32 maxSduSize, int32_t maxSduSize,
const SocketAddress &stRemName, const SocketAddress &stRemName,
WebRtc_Word32 overrideDSCP) int32_t overrideDSCP)
{ {
if(_qos == false) if(_qos == false)
{ {
@@ -706,9 +704,9 @@ bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType,
if(overrideDSCP != 0) if(overrideDSCP != 0)
{ {
FLOWSPEC f; FLOWSPEC f;
WebRtc_Word32 err = CreateFlowSpec(serviceType, tokenRate, bucketSize, int32_t err = CreateFlowSpec(serviceType, tokenRate, bucketSize,
peekBandwith, minPolicedSize, peekBandwith, minPolicedSize,
maxSduSize, &f); maxSduSize, &f);
if(err == -1) if(err == -1)
{ {
return false; return false;
@@ -761,7 +759,7 @@ bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType,
Qos.ProviderSpecific.buf = NULL; Qos.ProviderSpecific.buf = NULL;
ZeroMemory((WebRtc_Word8 *)&QosDestaddr, sizeof(QosDestaddr)); ZeroMemory((int8_t *)&QosDestaddr, sizeof(QosDestaddr));
OSVERSIONINFOEX osvie; OSVERSIONINFOEX osvie;
osvie.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvie.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
@@ -809,7 +807,7 @@ bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType,
} }
// To set QoS with SIO_SET_QOS the socket must be locally bound first // To set QoS with SIO_SET_QOS the socket must be locally bound first
// or the call will fail with error code 10022. // or the call will fail with error code 10022.
WebRtc_Word32 result = WSAIoctl(GetFd(), SIO_SET_QOS, &Qos, sizeof(QOS), int32_t result = WSAIoctl(GetFd(), SIO_SET_QOS, &Qos, sizeof(QOS),
NULL, 0, &BytesRet, NULL,NULL); NULL, 0, &BytesRet, NULL,NULL);
ReleaseSocket(); ReleaseSocket();
if (result == SOCKET_ERROR) if (result == SOCKET_ERROR)
@@ -822,7 +820,7 @@ bool UdpSocket2Windows::SetQos(WebRtc_Word32 serviceType,
return true; return true;
} }
WebRtc_Word32 UdpSocket2Windows::SetTOS(WebRtc_Word32 serviceType) int32_t UdpSocket2Windows::SetTOS(int32_t serviceType)
{ {
SocketAddress socketName; SocketAddress socketName;
@@ -835,7 +833,7 @@ WebRtc_Word32 UdpSocket2Windows::SetTOS(WebRtc_Word32 serviceType)
ReleaseSocket(); ReleaseSocket();
} }
WebRtc_Word32 res = SetTrafficControl(serviceType, -1, name); int32_t res = SetTrafficControl(serviceType, -1, name);
if (res == -1) if (res == -1)
{ {
OSVERSIONINFO OsVersion; OSVERSIONINFO OsVersion;
@@ -845,7 +843,7 @@ WebRtc_Word32 UdpSocket2Windows::SetTOS(WebRtc_Word32 serviceType)
if ((OsVersion.dwMajorVersion == 4)) // NT 4.0 if ((OsVersion.dwMajorVersion == 4)) // NT 4.0
{ {
if(SetSockopt(IPPROTO_IP,IP_TOS , if(SetSockopt(IPPROTO_IP,IP_TOS ,
(WebRtc_Word8*)&serviceType, 4) != 0) (int8_t*)&serviceType, 4) != 0)
{ {
return -1; return -1;
} }
@@ -854,7 +852,7 @@ WebRtc_Word32 UdpSocket2Windows::SetTOS(WebRtc_Word32 serviceType)
return res; return res;
} }
WebRtc_Word32 UdpSocket2Windows::SetPCP(WebRtc_Word32 pcp) int32_t UdpSocket2Windows::SetPCP(int32_t pcp)
{ {
SocketAddress socketName; SocketAddress socketName;
struct sockaddr_in* name = struct sockaddr_in* name =
@@ -868,9 +866,9 @@ WebRtc_Word32 UdpSocket2Windows::SetPCP(WebRtc_Word32 pcp)
return SetTrafficControl(-1, pcp, name); return SetTrafficControl(-1, pcp, name);
} }
WebRtc_Word32 UdpSocket2Windows::SetTrafficControl( int32_t UdpSocket2Windows::SetTrafficControl(
WebRtc_Word32 dscp, int32_t dscp,
WebRtc_Word32 pcp, int32_t pcp,
const struct sockaddr_in* name, const struct sockaddr_in* name,
FLOWSPEC* send, FLOWSPEC* recv) FLOWSPEC* send, FLOWSPEC* recv)
{ {
@@ -988,9 +986,9 @@ WebRtc_Word32 UdpSocket2Windows::SetTrafficControl(
// Find the interface corresponding to the local address. // Find the interface corresponding to the local address.
for(oneinterface = pInterfaceBuffer; for(oneinterface = pInterfaceBuffer;
oneinterface != (PTC_IFC_DESCRIPTOR) oneinterface != (PTC_IFC_DESCRIPTOR)
(((WebRtc_Word8*)pInterfaceBuffer) + BufferSize); (((int8_t*)pInterfaceBuffer) + BufferSize);
oneinterface = (PTC_IFC_DESCRIPTOR) oneinterface = (PTC_IFC_DESCRIPTOR)
((WebRtc_Word8 *)oneinterface + oneinterface->Length)) ((int8_t *)oneinterface + oneinterface->Length))
{ {
char interfaceName[500]; char interfaceName[500];
@@ -1201,8 +1199,8 @@ WebRtc_Word32 UdpSocket2Windows::SetTrafficControl(
IP_PATTERN filterPattern, mask; IP_PATTERN filterPattern, mask;
ZeroMemory((WebRtc_Word8*)&filterPattern, sizeof(IP_PATTERN)); ZeroMemory((int8_t*)&filterPattern, sizeof(IP_PATTERN));
ZeroMemory((WebRtc_Word8*)&mask, sizeof(IP_PATTERN)); ZeroMemory((int8_t*)&mask, sizeof(IP_PATTERN));
filterPattern.ProtocolId = IPPROTO_UDP; filterPattern.ProtocolId = IPPROTO_UDP;
// "name" fields already in network order. // "name" fields already in network order.
@@ -1247,13 +1245,13 @@ WebRtc_Word32 UdpSocket2Windows::SetTrafficControl(
return 0; return 0;
} }
WebRtc_Word32 UdpSocket2Windows::CreateFlowSpec(WebRtc_Word32 serviceType, int32_t UdpSocket2Windows::CreateFlowSpec(int32_t serviceType,
WebRtc_Word32 tokenRate, int32_t tokenRate,
WebRtc_Word32 bucketSize, int32_t bucketSize,
WebRtc_Word32 peekBandwith, int32_t peekBandwith,
WebRtc_Word32 minPolicedSize, int32_t minPolicedSize,
WebRtc_Word32 maxSduSize, int32_t maxSduSize,
FLOWSPEC* f) FLOWSPEC* f)
{ {
if (!f) if (!f)
{ {
@@ -1380,7 +1378,7 @@ bool UdpSocket2Windows::InvalidateSocket()
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"UdpSocket2Windows(%d)::InvalidateSocket() WSAerror: %d", "UdpSocket2Windows(%d)::InvalidateSocket() WSAerror: %d",
(WebRtc_Word32)this, WSAGetLastError()); (int32_t)this, WSAGetLastError());
} }
_socket = INVALID_SOCKET; _socket = INVALID_SOCKET;
_ptrSocketRWLock->ReleaseLockExclusive(); _ptrSocketRWLock->ReleaseLockExclusive();

View File

@@ -39,48 +39,47 @@ struct PerIoContext;
class UdpSocket2Windows : public UdpSocketWrapper class UdpSocket2Windows : public UdpSocketWrapper
{ {
public: public:
UdpSocket2Windows(const WebRtc_Word32 id, UdpSocketManager* mgr, UdpSocket2Windows(const int32_t id, UdpSocketManager* mgr,
bool ipV6Enable = false, bool disableGQOS = false); bool ipV6Enable = false, bool disableGQOS = false);
virtual ~UdpSocket2Windows(); virtual ~UdpSocket2Windows();
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual int32_t ChangeUniqueId(const int32_t id);
virtual bool ValidHandle(); virtual bool ValidHandle();
virtual bool SetCallback(CallbackObj, IncomingSocketCallback); virtual bool SetCallback(CallbackObj, IncomingSocketCallback);
virtual bool Bind(const SocketAddress& name); virtual bool Bind(const SocketAddress& name);
virtual bool SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, virtual bool SetSockopt(int32_t level, int32_t optname,
const WebRtc_Word8* optval, WebRtc_Word32 optlen); const int8_t* optval, int32_t optlen);
virtual bool StartReceiving(const WebRtc_UWord32 receiveBuffers); virtual bool StartReceiving(const uint32_t receiveBuffers);
virtual inline bool StartReceiving() {return StartReceiving(8);} virtual inline bool StartReceiving() {return StartReceiving(8);}
virtual bool StopReceiving(); virtual bool StopReceiving();
virtual WebRtc_Word32 SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, virtual int32_t SendTo(const int8_t* buf, int32_t len,
const SocketAddress& to); const SocketAddress& to);
virtual void CloseBlocking(); virtual void CloseBlocking();
virtual SOCKET GetFd() { return _socket;} virtual SOCKET GetFd() { return _socket;}
virtual bool SetQos(WebRtc_Word32 serviceType, WebRtc_Word32 tokenRate, virtual bool SetQos(int32_t serviceType, int32_t tokenRate,
WebRtc_Word32 bucketSize, WebRtc_Word32 peekBandwith, int32_t bucketSize, int32_t peekBandwith,
WebRtc_Word32 minPolicedSize, WebRtc_Word32 maxSduSize, int32_t minPolicedSize, int32_t maxSduSize,
const SocketAddress &stRemName, const SocketAddress &stRemName,
WebRtc_Word32 overrideDSCP = 0); int32_t overrideDSCP = 0);
virtual WebRtc_Word32 SetTOS(const WebRtc_Word32 serviceType); virtual int32_t SetTOS(const int32_t serviceType);
virtual WebRtc_Word32 SetPCP(const WebRtc_Word32 pcp); virtual int32_t SetPCP(const int32_t pcp);
virtual WebRtc_UWord32 ReceiveBuffers(){return _receiveBuffers.Value();} virtual uint32_t ReceiveBuffers(){return _receiveBuffers.Value();}
protected: protected:
void IOCompleted(PerIoContext* pIOContext, WebRtc_UWord32 ioSize, void IOCompleted(PerIoContext* pIOContext, uint32_t ioSize, uint32_t error);
WebRtc_UWord32 error);
WebRtc_Word32 PostRecv(); int32_t PostRecv();
// Use pIoContext to post a new WSARecvFrom(..). // Use pIoContext to post a new WSARecvFrom(..).
WebRtc_Word32 PostRecv(PerIoContext* pIoContext); int32_t PostRecv(PerIoContext* pIoContext);
private: private:
friend class UdpSocket2WorkerWindows; friend class UdpSocket2WorkerWindows;
@@ -108,18 +107,18 @@ private:
// If dscp is 0 and pcp is 0-7 (1), (2) and (3) will be created. // If dscp is 0 and pcp is 0-7 (1), (2) and (3) will be created.
// Note: input parameter values are assumed to be in valid range, checks // Note: input parameter values are assumed to be in valid range, checks
// must be done by caller. // must be done by caller.
WebRtc_Word32 SetTrafficControl(WebRtc_Word32 dscp, WebRtc_Word32 pcp, int32_t SetTrafficControl(int32_t dscp, int32_t pcp,
const struct sockaddr_in* name, const struct sockaddr_in* name,
FLOWSPEC* send = NULL, FLOWSPEC* send = NULL,
FLOWSPEC* recv = NULL); FLOWSPEC* recv = NULL);
WebRtc_Word32 CreateFlowSpec(WebRtc_Word32 serviceType, int32_t CreateFlowSpec(int32_t serviceType,
WebRtc_Word32 tokenRate, int32_t tokenRate,
WebRtc_Word32 bucketSize, int32_t bucketSize,
WebRtc_Word32 peekBandwith, int32_t peekBandwith,
WebRtc_Word32 minPolicedSize, int32_t minPolicedSize,
WebRtc_Word32 maxSduSize, FLOWSPEC *f); int32_t maxSduSize, FLOWSPEC *f);
WebRtc_Word32 _id; int32_t _id;
RWLockWrapper* _ptrCbRWLock; RWLockWrapper* _ptrCbRWLock;
IncomingSocketCallback _incomingCb; IncomingSocketCallback _incomingCb;
CallbackObj _obj; CallbackObj _obj;
@@ -127,7 +126,7 @@ private:
SocketAddress _remoteAddr; SocketAddress _remoteAddr;
SOCKET _socket; SOCKET _socket;
WebRtc_Word32 _iProtocol; int32_t _iProtocol;
UdpSocket2ManagerWindows* _mgr; UdpSocket2ManagerWindows* _mgr;
CriticalSectionWrapper* _pCrit; CriticalSectionWrapper* _pCrit;

View File

@@ -35,8 +35,7 @@ UdpSocketManagerPosix::UdpSocketManagerPosix()
{ {
} }
bool UdpSocketManagerPosix::Init(WebRtc_Word32 id, bool UdpSocketManagerPosix::Init(int32_t id, uint8_t& numOfWorkThreads) {
WebRtc_UWord8& numOfWorkThreads) {
CriticalSectionScoped cs(_critSect); CriticalSectionScoped cs(_critSect);
if ((_id != -1) || (_numOfWorkThreads != 0)) { if ((_id != -1) || (_numOfWorkThreads != 0)) {
assert(_id != -1); assert(_id != -1);
@@ -74,7 +73,7 @@ UdpSocketManagerPosix::~UdpSocketManagerPosix()
delete _critSect; delete _critSect;
} }
WebRtc_Word32 UdpSocketManagerPosix::ChangeUniqueId(const WebRtc_Word32 id) int32_t UdpSocketManagerPosix::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
return 0; return 0;

View File

@@ -36,10 +36,9 @@ public:
UdpSocketManagerPosix(); UdpSocketManagerPosix();
virtual ~UdpSocketManagerPosix(); virtual ~UdpSocketManagerPosix();
virtual bool Init(WebRtc_Word32 id, virtual bool Init(int32_t id, uint8_t& numOfWorkThreads);
WebRtc_UWord8& numOfWorkThreads);
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual int32_t ChangeUniqueId(const int32_t id);
virtual bool Start(); virtual bool Start();
virtual bool Stop(); virtual bool Stop();
@@ -47,11 +46,11 @@ public:
virtual bool AddSocket(UdpSocketWrapper* s); virtual bool AddSocket(UdpSocketWrapper* s);
virtual bool RemoveSocket(UdpSocketWrapper* s); virtual bool RemoveSocket(UdpSocketWrapper* s);
private: private:
WebRtc_Word32 _id; int32_t _id;
CriticalSectionWrapper* _critSect; CriticalSectionWrapper* _critSect;
WebRtc_UWord8 _numberOfSocketMgr; uint8_t _numberOfSocketMgr;
WebRtc_UWord8 _incSocketMgrNextTime; uint8_t _incSocketMgrNextTime;
WebRtc_UWord8 _nextSocketMgrToAssign; uint8_t _nextSocketMgrToAssign;
UdpSocketManagerPosixImpl* _socketMgr[MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX]; UdpSocketManagerPosixImpl* _socketMgr[MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX];
}; };

View File

@@ -24,8 +24,8 @@ namespace webrtc {
namespace test { namespace test {
TEST(UdpSocketManager, CreateCallsInitAndDoesNotLeakMemory) { TEST(UdpSocketManager, CreateCallsInitAndDoesNotLeakMemory) {
WebRtc_Word32 id = 42; int32_t id = 42;
WebRtc_UWord8 threads = 1; uint8_t threads = 1;
UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); UdpSocketManager* mgr = UdpSocketManager::Create(id, threads);
// Create is supposed to have called init on the object. // Create is supposed to have called init on the object.
EXPECT_FALSE(mgr->Init(id, threads)) EXPECT_FALSE(mgr->Init(id, threads))
@@ -36,8 +36,8 @@ TEST(UdpSocketManager, CreateCallsInitAndDoesNotLeakMemory) {
// Creates a socket and adds it to the socket manager, and then removes it // Creates a socket and adds it to the socket manager, and then removes it
// before destroying the socket manager. // before destroying the socket manager.
TEST(UdpSocketManager, AddAndRemoveSocketDoesNotLeakMemory) { TEST(UdpSocketManager, AddAndRemoveSocketDoesNotLeakMemory) {
WebRtc_Word32 id = 42; int32_t id = 42;
WebRtc_UWord8 threads = 1; uint8_t threads = 1;
UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); UdpSocketManager* mgr = UdpSocketManager::Create(id, threads);
UdpSocketWrapper* socket = UdpSocketWrapper* socket =
UdpSocketWrapper::CreateSocket(id, UdpSocketWrapper::CreateSocket(id,
@@ -61,8 +61,8 @@ TEST(UdpSocketManager, UnremovedSocketsGetCollectedAtManagerDeletion) {
#if defined(_WIN32) #if defined(_WIN32)
// It's hard to test an infinite wait, so we don't. // It's hard to test an infinite wait, so we don't.
#else #else
WebRtc_Word32 id = 42; int32_t id = 42;
WebRtc_UWord8 threads = 1; uint8_t threads = 1;
UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); UdpSocketManager* mgr = UdpSocketManager::Create(id, threads);
UdpSocketWrapper* unused_socket = UdpSocketWrapper::CreateSocket( UdpSocketWrapper* unused_socket = UdpSocketWrapper::CreateSocket(
id, id,

View File

@@ -33,8 +33,8 @@ UdpSocketManager* UdpSocketManager::CreateInstance()
UdpSocketManager* UdpSocketManager::StaticInstance( UdpSocketManager* UdpSocketManager::StaticInstance(
CountOperation count_operation, CountOperation count_operation,
const WebRtc_Word32 id, const int32_t id,
WebRtc_UWord8& numOfWorkThreads) uint8_t& numOfWorkThreads)
{ {
UdpSocketManager* impl = UdpSocketManager* impl =
GetStaticInstance<UdpSocketManager>(count_operation); GetStaticInstance<UdpSocketManager>(count_operation);
@@ -46,15 +46,15 @@ UdpSocketManager* UdpSocketManager::StaticInstance(
return impl; return impl;
} }
UdpSocketManager* UdpSocketManager::Create(const WebRtc_Word32 id, UdpSocketManager* UdpSocketManager::Create(const int32_t id,
WebRtc_UWord8& numOfWorkThreads) uint8_t& numOfWorkThreads)
{ {
return UdpSocketManager::StaticInstance(kAddRef, id, numOfWorkThreads); return UdpSocketManager::StaticInstance(kAddRef, id, numOfWorkThreads);
} }
void UdpSocketManager::Return() void UdpSocketManager::Return()
{ {
WebRtc_UWord8 numOfWorkThreads = 0; uint8_t numOfWorkThreads = 0;
UdpSocketManager::StaticInstance(kRelease, -1, UdpSocketManager::StaticInstance(kRelease, -1,
numOfWorkThreads); numOfWorkThreads);
} }
@@ -63,7 +63,7 @@ UdpSocketManager::UdpSocketManager() : _numOfWorkThreads(0)
{ {
} }
WebRtc_UWord8 UdpSocketManager::WorkThreads() const uint8_t UdpSocketManager::WorkThreads() const
{ {
return _numOfWorkThreads; return _numOfWorkThreads;
} }

View File

@@ -22,16 +22,15 @@ class UdpSocketWrapper;
class UdpSocketManager class UdpSocketManager
{ {
public: public:
static UdpSocketManager* Create(const WebRtc_Word32 id, static UdpSocketManager* Create(const int32_t id,
WebRtc_UWord8& numOfWorkThreads); uint8_t& numOfWorkThreads);
static void Return(); static void Return();
// Initializes the socket manager. Returns true if the manager wasn't // Initializes the socket manager. Returns true if the manager wasn't
// already initialized. // already initialized.
virtual bool Init(WebRtc_Word32 id, virtual bool Init(int32_t id, uint8_t& numOfWorkThreads) = 0;
WebRtc_UWord8& numOfWorkThreads) = 0;
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id) = 0; virtual int32_t ChangeUniqueId(const int32_t id) = 0;
// Start listening to sockets that have been registered via the // Start listening to sockets that have been registered via the
// AddSocket(..) API. // AddSocket(..) API.
@@ -39,7 +38,7 @@ public:
// Stop listening to sockets. // Stop listening to sockets.
virtual bool Stop() = 0; virtual bool Stop() = 0;
virtual WebRtc_UWord8 WorkThreads() const; virtual uint8_t WorkThreads() const;
// Register a socket with the socket manager. // Register a socket with the socket manager.
virtual bool AddSocket(UdpSocketWrapper* s) = 0; virtual bool AddSocket(UdpSocketWrapper* s) = 0;
@@ -50,7 +49,7 @@ protected:
UdpSocketManager(); UdpSocketManager();
virtual ~UdpSocketManager() {} virtual ~UdpSocketManager() {}
WebRtc_UWord8 _numOfWorkThreads; uint8_t _numOfWorkThreads;
// Factory method. // Factory method.
static UdpSocketManager* CreateInstance(); static UdpSocketManager* CreateInstance();
@@ -63,8 +62,8 @@ private:
static UdpSocketManager* StaticInstance( static UdpSocketManager* StaticInstance(
CountOperation count_operation, CountOperation count_operation,
const WebRtc_Word32 id, const int32_t id,
WebRtc_UWord8& numOfWorkThreads); uint8_t& numOfWorkThreads);
}; };
} // namespace test } // namespace test

View File

@@ -26,7 +26,7 @@
namespace webrtc { namespace webrtc {
namespace test { namespace test {
UdpSocketPosix::UdpSocketPosix(const WebRtc_Word32 id, UdpSocketManager* mgr, UdpSocketPosix::UdpSocketPosix(const int32_t id, UdpSocketManager* mgr,
bool ipV6Enable) bool ipV6Enable)
{ {
WEBRTC_TRACE(kTraceMemory, kTraceTransport, id, WEBRTC_TRACE(kTraceMemory, kTraceTransport, id,
@@ -93,7 +93,7 @@ UdpSocketPosix::~UdpSocketPosix()
} }
} }
WebRtc_Word32 UdpSocketPosix::ChangeUniqueId(const WebRtc_Word32 id) int32_t UdpSocketPosix::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
return 0; return 0;
@@ -121,8 +121,8 @@ bool UdpSocketPosix::SetCallback(CallbackObj obj, IncomingSocketCallback cb)
return false; return false;
} }
bool UdpSocketPosix::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, bool UdpSocketPosix::SetSockopt(int32_t level, int32_t optname,
const WebRtc_Word8* optval, WebRtc_Word32 optlen) const int8_t* optval, int32_t optlen)
{ {
if(0 == setsockopt(_socket, level, optname, optval, optlen )) if(0 == setsockopt(_socket, level, optname, optval, optlen ))
{ {
@@ -135,9 +135,9 @@ bool UdpSocketPosix::SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname,
return false; return false;
} }
WebRtc_Word32 UdpSocketPosix::SetTOS(WebRtc_Word32 serviceType) int32_t UdpSocketPosix::SetTOS(int32_t serviceType)
{ {
if (SetSockopt(IPPROTO_IP, IP_TOS ,(WebRtc_Word8*)&serviceType ,4) != 0) if (SetSockopt(IPPROTO_IP, IP_TOS ,(int8_t*)&serviceType ,4) != 0)
{ {
return -1; return -1;
} }
@@ -157,8 +157,8 @@ bool UdpSocketPosix::Bind(const SocketAddress& name)
return false; return false;
} }
WebRtc_Word32 UdpSocketPosix::SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, int32_t UdpSocketPosix::SendTo(const int8_t* buf, int32_t len,
const SocketAddress& to) const SocketAddress& to)
{ {
int size = sizeof(sockaddr); int size = sizeof(sockaddr);
int retVal = sendto(_socket,buf, len, 0, int retVal = sendto(_socket,buf, len, 0,
@@ -182,7 +182,7 @@ void UdpSocketPosix::HasIncoming()
{ {
// replace 2048 with a mcro define and figure out // replace 2048 with a mcro define and figure out
// where 2048 comes from // where 2048 comes from
WebRtc_Word8 buf[2048]; int8_t buf[2048];
int retval; int retval;
SocketAddress from; SocketAddress from;
#if defined(WEBRTC_MAC) #if defined(WEBRTC_MAC)

View File

@@ -28,42 +28,42 @@ namespace test {
class UdpSocketPosix : public UdpSocketWrapper class UdpSocketPosix : public UdpSocketWrapper
{ {
public: public:
UdpSocketPosix(const WebRtc_Word32 id, UdpSocketManager* mgr, UdpSocketPosix(const int32_t id, UdpSocketManager* mgr,
bool ipV6Enable = false); bool ipV6Enable = false);
virtual ~UdpSocketPosix(); virtual ~UdpSocketPosix();
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual int32_t ChangeUniqueId(const int32_t id);
virtual bool SetCallback(CallbackObj obj, IncomingSocketCallback cb); virtual bool SetCallback(CallbackObj obj, IncomingSocketCallback cb);
virtual bool Bind(const SocketAddress& name); virtual bool Bind(const SocketAddress& name);
virtual bool SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, virtual bool SetSockopt(int32_t level, int32_t optname,
const WebRtc_Word8* optval, WebRtc_Word32 optlen); const int8_t* optval, int32_t optlen);
virtual WebRtc_Word32 SetTOS(const WebRtc_Word32 serviceType); virtual int32_t SetTOS(const int32_t serviceType);
virtual WebRtc_Word32 SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, virtual int32_t SendTo(const int8_t* buf, int32_t len,
const SocketAddress& to); const SocketAddress& to);
// Deletes socket in addition to closing it. // Deletes socket in addition to closing it.
// TODO (hellner): make destructor protected. // TODO (hellner): make destructor protected.
virtual void CloseBlocking(); virtual void CloseBlocking();
virtual SOCKET GetFd() {return _socket;} virtual SOCKET GetFd() {return _socket;}
virtual WebRtc_Word32 GetError() {return _error;} virtual int32_t GetError() {return _error;}
virtual bool ValidHandle(); virtual bool ValidHandle();
virtual bool SetQos(WebRtc_Word32 /*serviceType*/, virtual bool SetQos(int32_t /*serviceType*/,
WebRtc_Word32 /*tokenRate*/, int32_t /*tokenRate*/,
WebRtc_Word32 /*bucketSize*/, int32_t /*bucketSize*/,
WebRtc_Word32 /*peekBandwith*/, int32_t /*peekBandwith*/,
WebRtc_Word32 /*minPolicedSize*/, int32_t /*minPolicedSize*/,
WebRtc_Word32 /*maxSduSize*/, int32_t /*maxSduSize*/,
const SocketAddress& /*stRemName*/, const SocketAddress& /*stRemName*/,
WebRtc_Word32 /*overrideDSCP*/) {return false;} int32_t /*overrideDSCP*/) {return false;}
bool CleanUp(); bool CleanUp();
void HasIncoming(); void HasIncoming();
@@ -72,10 +72,10 @@ public:
private: private:
friend class UdpSocketManagerPosix; friend class UdpSocketManagerPosix;
WebRtc_Word32 _id; int32_t _id;
IncomingSocketCallback _incomingCb; IncomingSocketCallback _incomingCb;
CallbackObj _obj; CallbackObj _obj;
WebRtc_Word32 _error; int32_t _error;
SOCKET _socket; SOCKET _socket;
UdpSocketManager* _mgr; UdpSocketManager* _mgr;

View File

@@ -59,7 +59,7 @@ void UdpSocketWrapper::SetEventToNull()
} }
} }
UdpSocketWrapper* UdpSocketWrapper::CreateSocket(const WebRtc_Word32 id, UdpSocketWrapper* UdpSocketWrapper::CreateSocket(const int32_t id,
UdpSocketManager* mgr, UdpSocketManager* mgr,
CallbackObj obj, CallbackObj obj,
IncomingSocketCallback cb, IncomingSocketCallback cb,
@@ -77,7 +77,7 @@ UdpSocketWrapper* UdpSocketWrapper::CreateSocket(const WebRtc_Word32 id,
{ {
WSADATA wsaData; WSADATA wsaData;
WORD wVersionRequested = MAKEWORD( 2, 2 ); WORD wVersionRequested = MAKEWORD( 2, 2 );
WebRtc_Word32 err = WSAStartup( wVersionRequested, &wsaData); int32_t err = WSAStartup( wVersionRequested, &wsaData);
if (err != 0) if (err != 0)
{ {
WEBRTC_TRACE( WEBRTC_TRACE(

View File

@@ -37,14 +37,13 @@ typedef int SOCKET;
#endif #endif
typedef void* CallbackObj; typedef void* CallbackObj;
typedef void(*IncomingSocketCallback)(CallbackObj obj, const WebRtc_Word8* buf, typedef void(*IncomingSocketCallback)(CallbackObj obj, const int8_t* buf,
WebRtc_Word32 len, int32_t len, const SocketAddress* from);
const SocketAddress* from);
class UdpSocketWrapper class UdpSocketWrapper
{ {
public: public:
static UdpSocketWrapper* CreateSocket(const WebRtc_Word32 id, static UdpSocketWrapper* CreateSocket(const int32_t id,
UdpSocketManager* mgr, UdpSocketManager* mgr,
CallbackObj obj, CallbackObj obj,
IncomingSocketCallback cb, IncomingSocketCallback cb,
@@ -52,7 +51,7 @@ public:
bool disableGQOS = false); bool disableGQOS = false);
// Set the unique identifier of this class to id. // Set the unique identifier of this class to id.
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id) = 0; virtual int32_t ChangeUniqueId(const int32_t id) = 0;
// Register cb for receiving callbacks when there are incoming packets. // Register cb for receiving callbacks when there are incoming packets.
// Register obj so that it will be passed in calls to cb. // Register obj so that it will be passed in calls to cb.
@@ -63,7 +62,7 @@ public:
// Start receiving UDP data. // Start receiving UDP data.
virtual bool StartReceiving(); virtual bool StartReceiving();
virtual inline bool StartReceiving(const WebRtc_UWord32 /*receiveBuffers*/) virtual inline bool StartReceiving(const uint32_t /*receiveBuffers*/)
{return StartReceiving();} {return StartReceiving();}
// Stop receiving UDP data. // Stop receiving UDP data.
virtual bool StopReceiving(); virtual bool StopReceiving();
@@ -71,19 +70,18 @@ public:
virtual bool ValidHandle() = 0; virtual bool ValidHandle() = 0;
// Set socket options. // Set socket options.
virtual bool SetSockopt(WebRtc_Word32 level, WebRtc_Word32 optname, virtual bool SetSockopt(int32_t level, int32_t optname,
const WebRtc_Word8* optval, const int8_t* optval, int32_t optlen) = 0;
WebRtc_Word32 optlen) = 0;
// Set TOS for outgoing packets. // Set TOS for outgoing packets.
virtual WebRtc_Word32 SetTOS(const WebRtc_Word32 serviceType) = 0; virtual int32_t SetTOS(const int32_t serviceType) = 0;
// Set 802.1Q PCP field (802.1p) for outgoing VLAN traffic. // Set 802.1Q PCP field (802.1p) for outgoing VLAN traffic.
virtual WebRtc_Word32 SetPCP(const WebRtc_Word32 /*pcp*/) {return -1;} virtual int32_t SetPCP(const int32_t /*pcp*/) {return -1;}
// Send buf of length len to the address specified by to. // Send buf of length len to the address specified by to.
virtual WebRtc_Word32 SendTo(const WebRtc_Word8* buf, WebRtc_Word32 len, virtual int32_t SendTo(const int8_t* buf, int32_t len,
const SocketAddress& to) = 0; const SocketAddress& to) = 0;
virtual void SetEventToNull(); virtual void SetEventToNull();
@@ -91,13 +89,13 @@ public:
virtual void CloseBlocking() {} virtual void CloseBlocking() {}
// tokenRate is in bit/s. peakBandwidt is in byte/s // tokenRate is in bit/s. peakBandwidt is in byte/s
virtual bool SetQos(WebRtc_Word32 serviceType, WebRtc_Word32 tokenRate, virtual bool SetQos(int32_t serviceType, int32_t tokenRate,
WebRtc_Word32 bucketSize, WebRtc_Word32 peekBandwith, int32_t bucketSize, int32_t peekBandwith,
WebRtc_Word32 minPolicedSize, WebRtc_Word32 maxSduSize, int32_t minPolicedSize, int32_t maxSduSize,
const SocketAddress &stRemName, const SocketAddress &stRemName,
WebRtc_Word32 overrideDSCP = 0) = 0; int32_t overrideDSCP = 0) = 0;
virtual WebRtc_UWord32 ReceiveBuffers() {return 0;}; virtual uint32_t ReceiveBuffers() {return 0;};
protected: protected:
// Creating the socket is done via CreateSocket(). // Creating the socket is done via CreateSocket().

View File

@@ -38,8 +38,8 @@ class MockSocketManager : public UdpSocketManager {
void Destroy() { void Destroy() {
delete this; delete this;
} }
MOCK_METHOD2(Init, bool(WebRtc_Word32, WebRtc_UWord8&)); MOCK_METHOD2(Init, bool(int32_t, uint8_t&));
MOCK_METHOD1(ChangeUniqueId, WebRtc_Word32(const WebRtc_Word32)); MOCK_METHOD1(ChangeUniqueId, int32_t(const int32_t));
MOCK_METHOD0(Start, bool()); MOCK_METHOD0(Start, bool());
MOCK_METHOD0(Stop, bool()); MOCK_METHOD0(Stop, bool());
MOCK_METHOD1(AddSocket, bool(UdpSocketWrapper*)); MOCK_METHOD1(AddSocket, bool(UdpSocketWrapper*));
@@ -49,9 +49,9 @@ class MockSocketManager : public UdpSocketManager {
// Creates a socket using the static constructor method and verifies that // Creates a socket using the static constructor method and verifies that
// it's added to the socket manager. // it's added to the socket manager.
TEST(UdpSocketWrapper, CreateSocket) { TEST(UdpSocketWrapper, CreateSocket) {
WebRtc_Word32 id = 42; int32_t id = 42;
// We can't test deletion of sockets without a socket manager. // We can't test deletion of sockets without a socket manager.
WebRtc_UWord8 threads = 1; uint8_t threads = 1;
UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); UdpSocketManager* mgr = UdpSocketManager::Create(id, threads);
UdpSocketWrapper* socket = UdpSocketWrapper* socket =
UdpSocketWrapper::CreateSocket(id, UdpSocketWrapper::CreateSocket(id,

View File

@@ -22,9 +22,9 @@
*/ */
#define SS_MAXSIZE 128 #define SS_MAXSIZE 128
#define SS_ALIGNSIZE (sizeof (WebRtc_UWord64)) #define SS_ALIGNSIZE (sizeof (uint64_t))
#define SS_PAD1SIZE (SS_ALIGNSIZE - sizeof(WebRtc_Word16)) #define SS_PAD1SIZE (SS_ALIGNSIZE - sizeof(int16_t))
#define SS_PAD2SIZE (SS_MAXSIZE - (sizeof(WebRtc_Word16) + SS_PAD1SIZE +\ #define SS_PAD2SIZE (SS_MAXSIZE - (sizeof(int16_t) + SS_PAD1SIZE +\
SS_ALIGNSIZE)) SS_ALIGNSIZE))
// BSD requires use of HAVE_STRUCT_SOCKADDR_SA_LEN // BSD requires use of HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -34,53 +34,53 @@ namespace test {
struct SocketAddressIn { struct SocketAddressIn {
// sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6) // sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6)
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
WebRtc_Word8 sin_length; int8_t sin_length;
WebRtc_Word8 sin_family; int8_t sin_family;
#else #else
WebRtc_Word16 sin_family; int16_t sin_family;
#endif #endif
WebRtc_UWord16 sin_port; uint16_t sin_port;
WebRtc_UWord32 sin_addr; uint32_t sin_addr;
WebRtc_Word8 sin_zero[8]; int8_t sin_zero[8];
}; };
struct Version6InAddress { struct Version6InAddress {
union { union {
WebRtc_UWord8 _s6_u8[16]; uint8_t _s6_u8[16];
WebRtc_UWord32 _s6_u32[4]; uint32_t _s6_u32[4];
WebRtc_UWord64 _s6_u64[2]; uint64_t _s6_u64[2];
} Version6AddressUnion; } Version6AddressUnion;
}; };
struct SocketAddressInVersion6 { struct SocketAddressInVersion6 {
// sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6) // sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6)
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
WebRtc_Word8 sin_length; int8_t sin_length;
WebRtc_Word8 sin_family; int8_t sin_family;
#else #else
WebRtc_Word16 sin_family; int16_t sin_family;
#endif #endif
// Transport layer port number. // Transport layer port number.
WebRtc_UWord16 sin6_port; uint16_t sin6_port;
// IPv6 traffic class and flow info or ip4 address. // IPv6 traffic class and flow info or ip4 address.
WebRtc_UWord32 sin6_flowinfo; uint32_t sin6_flowinfo;
// IPv6 address // IPv6 address
struct Version6InAddress sin6_addr; struct Version6InAddress sin6_addr;
// Set of interfaces for a scope. // Set of interfaces for a scope.
WebRtc_UWord32 sin6_scope_id; uint32_t sin6_scope_id;
}; };
struct SocketAddressStorage { struct SocketAddressStorage {
// sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6) // sin_family should be either AF_INET (IPv4) or AF_INET6 (IPv6)
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
WebRtc_Word8 sin_length; int8_t sin_length;
WebRtc_Word8 sin_family; int8_t sin_family;
#else #else
WebRtc_Word16 sin_family; int16_t sin_family;
#endif #endif
WebRtc_Word8 __ss_pad1[SS_PAD1SIZE]; int8_t __ss_pad1[SS_PAD1SIZE];
WebRtc_UWord64 __ss_align; uint64_t __ss_align;
WebRtc_Word8 __ss_pad2[SS_PAD2SIZE]; int8_t __ss_pad2[SS_PAD2SIZE];
}; };
struct SocketAddress { struct SocketAddress {
@@ -96,15 +96,15 @@ class UdpTransportData {
public: public:
virtual ~UdpTransportData() {}; virtual ~UdpTransportData() {};
virtual void IncomingRTPPacket(const WebRtc_Word8* incomingRtpPacket, virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket,
const WebRtc_Word32 rtpPacketLength, const int32_t rtpPacketLength,
const char* fromIP, const char* fromIP,
const WebRtc_UWord16 fromPort) = 0; const uint16_t fromPort) = 0;
virtual void IncomingRTCPPacket(const WebRtc_Word8* incomingRtcpPacket, virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
const WebRtc_Word32 rtcpPacketLength, const int32_t rtcpPacketLength,
const char* fromIP, const char* fromIP,
const WebRtc_UWord16 fromPort) = 0; const uint16_t fromPort) = 0;
}; };
class UdpTransport : public Transport { class UdpTransport : public Transport {
@@ -137,140 +137,134 @@ class UdpTransport : public Transport {
}; };
// Factory method. Constructor disabled. // Factory method. Constructor disabled.
static UdpTransport* Create(const WebRtc_Word32 id, static UdpTransport* Create(const int32_t id, uint8_t& numSocketThreads);
WebRtc_UWord8& numSocketThreads);
static void Destroy(UdpTransport* module); static void Destroy(UdpTransport* module);
// Prepares the class for sending RTP packets to ipAddr:rtpPort and RTCP // Prepares the class for sending RTP packets to ipAddr:rtpPort and RTCP
// packets to ipAddr:rtpPort+1 if rtcpPort is zero. Otherwise to // packets to ipAddr:rtpPort+1 if rtcpPort is zero. Otherwise to
// ipAddr:rtcpPort. // ipAddr:rtcpPort.
virtual WebRtc_Word32 InitializeSendSockets( virtual int32_t InitializeSendSockets(const char* ipAddr,
const char* ipAddr, const uint16_t rtpPort,
const WebRtc_UWord16 rtpPort, const uint16_t rtcpPort = 0) = 0;
const WebRtc_UWord16 rtcpPort = 0) = 0;
// Register packetCallback for receiving incoming packets. Set the local // Register packetCallback for receiving incoming packets. Set the local
// RTP port to rtpPort. Bind local IP address to ipAddr. If ipAddr is NULL // RTP port to rtpPort. Bind local IP address to ipAddr. If ipAddr is NULL
// bind to local IP ANY. Set the local rtcp port to rtcpPort or rtpPort + 1 // bind to local IP ANY. Set the local rtcp port to rtcpPort or rtpPort + 1
// if rtcpPort is 0. // if rtcpPort is 0.
virtual WebRtc_Word32 InitializeReceiveSockets( virtual int32_t InitializeReceiveSockets(
UdpTransportData* const packetCallback, UdpTransportData* const packetCallback,
const WebRtc_UWord16 rtpPort, const uint16_t rtpPort,
const char* ipAddr = NULL, const char* ipAddr = NULL,
const char* multicastIpAddr = NULL, const char* multicastIpAddr = NULL,
const WebRtc_UWord16 rtcpPort = 0) = 0; const uint16_t rtcpPort = 0) = 0;
// Set local RTP port to rtpPort and RTCP port to rtcpPort or rtpPort + 1 if // Set local RTP port to rtpPort and RTCP port to rtcpPort or rtpPort + 1 if
// rtcpPort is 0. These ports will be used for sending instead of the local // rtcpPort is 0. These ports will be used for sending instead of the local
// ports set by InitializeReceiveSockets(..). // ports set by InitializeReceiveSockets(..).
virtual WebRtc_Word32 InitializeSourcePorts( virtual int32_t InitializeSourcePorts(const uint16_t rtpPort,
const WebRtc_UWord16 rtpPort, const uint16_t rtcpPort = 0) = 0;
const WebRtc_UWord16 rtcpPort = 0) = 0;
// Retrieve local ports used for sending if other than the ports specified // Retrieve local ports used for sending if other than the ports specified
// by InitializeReceiveSockets(..). rtpPort is set to the RTP port. // by InitializeReceiveSockets(..). rtpPort is set to the RTP port.
// rtcpPort is set to the RTCP port. // rtcpPort is set to the RTCP port.
virtual WebRtc_Word32 SourcePorts(WebRtc_UWord16& rtpPort, virtual int32_t SourcePorts(uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const = 0; uint16_t& rtcpPort) const = 0;
// Set ipAddr to the IP address that is currently being listened on. rtpPort // Set ipAddr to the IP address that is currently being listened on. rtpPort
// to the RTP port listened to. rtcpPort to the RTCP port listened on. // to the RTP port listened to. rtcpPort to the RTCP port listened on.
// multicastIpAddr to the multicast IP address group joined (the address // multicastIpAddr to the multicast IP address group joined (the address
// is NULL terminated). // is NULL terminated).
virtual WebRtc_Word32 ReceiveSocketInformation( virtual int32_t ReceiveSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort, uint16_t& rtcpPort,
char multicastIpAddr[kIpAddressVersion6Length]) const = 0; char multicastIpAddr[kIpAddressVersion6Length]) const = 0;
// Set ipAddr to the IP address being sent from. rtpPort to the local RTP // Set ipAddr to the IP address being sent from. rtpPort to the local RTP
// port used for sending and rtcpPort to the local RTCP port used for // port used for sending and rtcpPort to the local RTCP port used for
// sending. // sending.
virtual WebRtc_Word32 SendSocketInformation( virtual int32_t SendSocketInformation(char ipAddr[kIpAddressVersion6Length],
char ipAddr[kIpAddressVersion6Length], uint16_t& rtpPort,
WebRtc_UWord16& rtpPort, uint16_t& rtcpPort) const = 0;
WebRtc_UWord16& rtcpPort) const = 0;
// Put the IP address, RTP port and RTCP port from the last received packet // Put the IP address, RTP port and RTCP port from the last received packet
// into ipAddr, rtpPort and rtcpPort respectively. // into ipAddr, rtpPort and rtcpPort respectively.
virtual WebRtc_Word32 RemoteSocketInformation( virtual int32_t RemoteSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const = 0; uint16_t& rtcpPort) const = 0;
// Enable/disable quality of service if QoS is true or false respectively. // Enable/disable quality of service if QoS is true or false respectively.
// Set the type of service to serviceType, max bitrate in kbit/s to // Set the type of service to serviceType, max bitrate in kbit/s to
// maxBitrate and override DSCP if overrideDSCP is not 0. // maxBitrate and override DSCP if overrideDSCP is not 0.
// Note: Must be called both InitializeSendSockets() and // Note: Must be called both InitializeSendSockets() and
// InitializeReceiveSockets() has been called. // InitializeReceiveSockets() has been called.
virtual WebRtc_Word32 SetQoS(const bool QoS, virtual int32_t SetQoS(const bool QoS,
const WebRtc_Word32 serviceType, const int32_t serviceType,
const WebRtc_UWord32 maxBitrate = 0, const uint32_t maxBitrate = 0,
const WebRtc_Word32 overrideDSCP = 0, const int32_t overrideDSCP = 0,
const bool audio = false) = 0; const bool audio = false) = 0;
// Set QoS to true if quality of service has been turned on. If QoS is true, // Set QoS to true if quality of service has been turned on. If QoS is true,
// also set serviceType to type of service and overrideDSCP to override // also set serviceType to type of service and overrideDSCP to override
// DSCP. // DSCP.
virtual WebRtc_Word32 QoS(bool& QoS, virtual int32_t QoS(bool& QoS,
WebRtc_Word32& serviceType, int32_t& serviceType,
WebRtc_Word32& overrideDSCP) const = 0; int32_t& overrideDSCP) const = 0;
// Set type of service. // Set type of service.
virtual WebRtc_Word32 SetToS(const WebRtc_Word32 DSCP, virtual int32_t SetToS(const int32_t DSCP,
const bool useSetSockOpt = false) = 0; const bool useSetSockOpt = false) = 0;
// Get type of service configuration. // Get type of service configuration.
virtual WebRtc_Word32 ToS(WebRtc_Word32& DSCP, virtual int32_t ToS(int32_t& DSCP,
bool& useSetSockOpt) const = 0; bool& useSetSockOpt) const = 0;
// Set Priority Code Point (IEEE 802.1Q) // Set Priority Code Point (IEEE 802.1Q)
// Note: for Linux this function will set the priority for the socket, // Note: for Linux this function will set the priority for the socket,
// which then can be mapped to a PCP value with vconfig. // which then can be mapped to a PCP value with vconfig.
virtual WebRtc_Word32 SetPCP(const WebRtc_Word32 PCP) = 0; virtual int32_t SetPCP(const int32_t PCP) = 0;
// Get Priority Code Point // Get Priority Code Point
virtual WebRtc_Word32 PCP(WebRtc_Word32& PCP) const = 0; virtual int32_t PCP(int32_t& PCP) const = 0;
// Enable IPv6. // Enable IPv6.
// Note: this API must be called before any call to // Note: this API must be called before any call to
// InitializeReceiveSockets() or InitializeSendSockets(). It is not // InitializeReceiveSockets() or InitializeSendSockets(). It is not
// possible to go back to IPv4 (default) after this call. // possible to go back to IPv4 (default) after this call.
virtual WebRtc_Word32 EnableIpV6() = 0; virtual int32_t EnableIpV6() = 0;
// Return true if IPv6 has been enabled. // Return true if IPv6 has been enabled.
virtual bool IpV6Enabled() const = 0; virtual bool IpV6Enabled() const = 0;
// Only allow packets received from filterIPAddress to be processed. // Only allow packets received from filterIPAddress to be processed.
// Note: must be called after EnableIPv6(), if IPv6 is used. // Note: must be called after EnableIPv6(), if IPv6 is used.
virtual WebRtc_Word32 SetFilterIP( virtual int32_t SetFilterIP(
const char filterIPAddress[kIpAddressVersion6Length]) = 0; const char filterIPAddress[kIpAddressVersion6Length]) = 0;
// Write the filter IP address (if any) to filterIPAddress. // Write the filter IP address (if any) to filterIPAddress.
virtual WebRtc_Word32 FilterIP( virtual int32_t FilterIP(
char filterIPAddress[kIpAddressVersion6Length]) const = 0; char filterIPAddress[kIpAddressVersion6Length]) const = 0;
// Only allow RTP packets from rtpFilterPort and RTCP packets from // Only allow RTP packets from rtpFilterPort and RTCP packets from
// rtcpFilterPort be processed. // rtcpFilterPort be processed.
// Note: must be called after EnableIPv6(), if IPv6 is used. // Note: must be called after EnableIPv6(), if IPv6 is used.
virtual WebRtc_Word32 SetFilterPorts( virtual int32_t SetFilterPorts(const uint16_t rtpFilterPort,
const WebRtc_UWord16 rtpFilterPort, const uint16_t rtcpFilterPort) = 0;
const WebRtc_UWord16 rtcpFilterPort) = 0;
// Set rtpFilterPort to the filter RTP port and rtcpFilterPort to the // Set rtpFilterPort to the filter RTP port and rtcpFilterPort to the
// filter RTCP port (if filtering based on port is enabled). // filter RTCP port (if filtering based on port is enabled).
virtual WebRtc_Word32 FilterPorts(WebRtc_UWord16& rtpFilterPort, virtual int32_t FilterPorts(uint16_t& rtpFilterPort,
WebRtc_UWord16& rtcpFilterPort) const = 0; uint16_t& rtcpFilterPort) const = 0;
// Set the number of buffers that the socket implementation may use for // Set the number of buffers that the socket implementation may use for
// receiving packets to numberOfSocketBuffers. I.e. the number of packets // receiving packets to numberOfSocketBuffers. I.e. the number of packets
// that can be received in parallell. // that can be received in parallell.
// Note: this API only has effect on Windows. // Note: this API only has effect on Windows.
virtual WebRtc_Word32 StartReceiving( virtual int32_t StartReceiving(const uint32_t numberOfSocketBuffers) = 0;
const WebRtc_UWord32 numberOfSocketBuffers) = 0;
// Stop receive incoming packets. // Stop receive incoming packets.
virtual WebRtc_Word32 StopReceiving() = 0; virtual int32_t StopReceiving() = 0;
// Return true incoming packets are received. // Return true incoming packets are received.
virtual bool Receiving() const = 0; virtual bool Receiving() const = 0;
@@ -288,79 +282,79 @@ class UdpTransport : public Transport {
// with InitializeSendSockets(..) is used if portnr is 0. The same IP // with InitializeSendSockets(..) is used if portnr is 0. The same IP
// address as set with InitializeSendSockets(..) is used if ip is NULL. // address as set with InitializeSendSockets(..) is used if ip is NULL.
// If isRTCP is true the port used will be the RTCP port. // If isRTCP is true the port used will be the RTCP port.
virtual WebRtc_Word32 SendRaw(const WebRtc_Word8* data, virtual int32_t SendRaw(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_Word32 isRTCP, int32_t isRTCP,
WebRtc_UWord16 portnr = 0, uint16_t portnr = 0,
const char* ip = NULL) = 0; const char* ip = NULL) = 0;
// Send RTP data with size length to the address specified by to. // Send RTP data with size length to the address specified by to.
virtual WebRtc_Word32 SendRTPPacketTo(const WebRtc_Word8* data, virtual int32_t SendRTPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to) = 0; const SocketAddress& to) = 0;
// Send RTCP data with size length to the address specified by to. // Send RTCP data with size length to the address specified by to.
virtual WebRtc_Word32 SendRTCPPacketTo(const WebRtc_Word8* data, virtual int32_t SendRTCPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to) = 0; const SocketAddress& to) = 0;
// Send RTP data with size length to ip:rtpPort where ip is the ip set by // Send RTP data with size length to ip:rtpPort where ip is the ip set by
// the InitializeSendSockets(..) call. // the InitializeSendSockets(..) call.
virtual WebRtc_Word32 SendRTPPacketTo(const WebRtc_Word8* data, virtual int32_t SendRTPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_UWord16 rtpPort) = 0; uint16_t rtpPort) = 0;
// Send RTCP data with size length to ip:rtcpPort where ip is the ip set by // Send RTCP data with size length to ip:rtcpPort where ip is the ip set by
// the InitializeSendSockets(..) call. // the InitializeSendSockets(..) call.
virtual WebRtc_Word32 SendRTCPPacketTo(const WebRtc_Word8* data, virtual int32_t SendRTCPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_UWord16 rtcpPort) = 0; uint16_t rtcpPort) = 0;
// Set the IP address to which packets are sent to ipaddr. // Set the IP address to which packets are sent to ipaddr.
virtual WebRtc_Word32 SetSendIP( virtual int32_t SetSendIP(
const char ipaddr[kIpAddressVersion6Length]) = 0; const char ipaddr[kIpAddressVersion6Length]) = 0;
// Set the send RTP and RTCP port to rtpPort and rtcpPort respectively. // Set the send RTP and RTCP port to rtpPort and rtcpPort respectively.
virtual WebRtc_Word32 SetSendPorts(const WebRtc_UWord16 rtpPort, virtual int32_t SetSendPorts(const uint16_t rtpPort,
const WebRtc_UWord16 rtcpPort = 0) = 0; const uint16_t rtcpPort = 0) = 0;
// Retreive the last registered error code. // Retreive the last registered error code.
virtual ErrorCode LastError() const = 0; virtual ErrorCode LastError() const = 0;
// Put the local IPv4 address in localIP. // Put the local IPv4 address in localIP.
// Note: this API is for IPv4 only. // Note: this API is for IPv4 only.
static WebRtc_Word32 LocalHostAddress(WebRtc_UWord32& localIP); static int32_t LocalHostAddress(uint32_t& localIP);
// Put the local IP6 address in localIP. // Put the local IP6 address in localIP.
// Note: this API is for IPv6 only. // Note: this API is for IPv6 only.
static WebRtc_Word32 LocalHostAddressIPV6(char localIP[16]); static int32_t LocalHostAddressIPV6(char localIP[16]);
// Return a copy of hostOrder (host order) in network order. // Return a copy of hostOrder (host order) in network order.
static WebRtc_UWord16 Htons(WebRtc_UWord16 hostOrder); static uint16_t Htons(uint16_t hostOrder);
// Return a copy of hostOrder (host order) in network order. // Return a copy of hostOrder (host order) in network order.
static WebRtc_UWord32 Htonl(WebRtc_UWord32 hostOrder); static uint32_t Htonl(uint32_t hostOrder);
// Return IPv4 address in ip as 32 bit integer. // Return IPv4 address in ip as 32 bit integer.
static WebRtc_UWord32 InetAddrIPV4(const char* ip); static uint32_t InetAddrIPV4(const char* ip);
// Convert the character string src into a network address structure in // Convert the character string src into a network address structure in
// the af address family and put it in dst. // the af address family and put it in dst.
// Note: same functionality as inet_pton(..) // Note: same functionality as inet_pton(..)
static WebRtc_Word32 InetPresentationToNumeric(WebRtc_Word32 af, static int32_t InetPresentationToNumeric(int32_t af,
const char* src, const char* src,
void* dst); void* dst);
// Set ip and sourcePort according to address. As input parameter ipSize // Set ip and sourcePort according to address. As input parameter ipSize
// is the length of ip. As output parameter it's the number of characters // is the length of ip. As output parameter it's the number of characters
// written to ip (not counting the '\0' character). // written to ip (not counting the '\0' character).
// Note: this API is only implemented on Windows and Linux. // Note: this API is only implemented on Windows and Linux.
static WebRtc_Word32 IPAddress(const SocketAddress& address, static int32_t IPAddress(const SocketAddress& address,
char* ip, char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort); uint16_t& sourcePort);
// Set ip and sourcePort according to address. As input parameter ipSize // Set ip and sourcePort according to address. As input parameter ipSize
// is the length of ip. As output parameter it's the number of characters // is the length of ip. As output parameter it's the number of characters
@@ -369,10 +363,10 @@ class UdpTransport : public Transport {
// Additional note: this API caches the address of the last call to it. If // Additional note: this API caches the address of the last call to it. If
// address is likley to be the same for multiple calls it may be beneficial // address is likley to be the same for multiple calls it may be beneficial
// to call this API instead of IPAddress(). // to call this API instead of IPAddress().
virtual WebRtc_Word32 IPAddressCached(const SocketAddress& address, virtual int32_t IPAddressCached(const SocketAddress& address,
char* ip, char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort) = 0; uint16_t& sourcePort) = 0;
// Return true if ipaddr is a valid IP address. // Return true if ipaddr is a valid IP address.
// If ipV6 is false ipaddr is interpreted as an IPv4 address otherwise it // If ipV6 is false ipaddr is interpreted as an IPv4 address otherwise it

View File

@@ -68,7 +68,7 @@ namespace test {
class SocketFactory : public UdpTransportImpl::SocketFactoryInterface { class SocketFactory : public UdpTransportImpl::SocketFactoryInterface {
public: public:
UdpSocketWrapper* CreateSocket(const WebRtc_Word32 id, UdpSocketWrapper* CreateSocket(const int32_t id,
UdpSocketManager* mgr, UdpSocketManager* mgr,
CallbackObj obj, CallbackObj obj,
IncomingSocketCallback cb, IncomingSocketCallback cb,
@@ -82,8 +82,8 @@ class SocketFactory : public UdpTransportImpl::SocketFactoryInterface {
// Creates an UdpTransport using the definition of SocketFactory above, // Creates an UdpTransport using the definition of SocketFactory above,
// and passes (creating if needed) a pointer to the static singleton // and passes (creating if needed) a pointer to the static singleton
// UdpSocketManager. // UdpSocketManager.
UdpTransport* UdpTransport::Create(const WebRtc_Word32 id, UdpTransport* UdpTransport::Create(const int32_t id,
WebRtc_UWord8& numSocketThreads) uint8_t& numSocketThreads)
{ {
return new UdpTransportImpl(id, return new UdpTransportImpl(id,
new SocketFactory(), new SocketFactory(),
@@ -102,7 +102,7 @@ void UdpTransport::Destroy(UdpTransport* module)
} }
} }
UdpTransportImpl::UdpTransportImpl(const WebRtc_Word32 id, UdpTransportImpl::UdpTransportImpl(const int32_t id,
SocketFactoryInterface* maker, SocketFactoryInterface* maker,
UdpSocketManager* socket_manager) UdpSocketManager* socket_manager)
: _id(id), : _id(id),
@@ -191,22 +191,22 @@ bool SameAddress(const SocketAddress& address1, const SocketAddress& address2)
} }
void UdpTransportImpl::GetCachedAddress(char* ip, void UdpTransportImpl::GetCachedAddress(char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort) uint16_t& sourcePort)
{ {
const WebRtc_UWord32 originalIPSize = ipSize; const uint32_t originalIPSize = ipSize;
// If the incoming string is too small, fill it as much as there is room // If the incoming string is too small, fill it as much as there is room
// for. Make sure that there is room for the '\0' character. // for. Make sure that there is room for the '\0' character.
ipSize = (ipSize - 1 < _previousIPSize) ? ipSize - 1 : _previousIPSize; ipSize = (ipSize - 1 < _previousIPSize) ? ipSize - 1 : _previousIPSize;
memcpy(ip,_previousIP,sizeof(WebRtc_Word8)*(ipSize + 1)); memcpy(ip,_previousIP,sizeof(int8_t)*(ipSize + 1));
ip[originalIPSize - 1] = '\0'; ip[originalIPSize - 1] = '\0';
sourcePort = _previousSourcePort; sourcePort = _previousSourcePort;
} }
WebRtc_Word32 UdpTransportImpl::IPAddressCached(const SocketAddress& address, int32_t UdpTransportImpl::IPAddressCached(const SocketAddress& address,
char* ip, char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort) uint16_t& sourcePort)
{ {
{ {
ReadLockScoped rl(*_cachLock); ReadLockScoped rl(*_cachLock);
@@ -231,12 +231,12 @@ WebRtc_Word32 UdpTransportImpl::IPAddressCached(const SocketAddress& address,
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::InitializeReceiveSockets( int32_t UdpTransportImpl::InitializeReceiveSockets(
UdpTransportData* const packetCallback, UdpTransportData* const packetCallback,
const WebRtc_UWord16 portnr, const uint16_t portnr,
const char* ip, const char* ip,
const char* multicastIpAddr, const char* multicastIpAddr,
const WebRtc_UWord16 rtcpPort) const uint16_t rtcpPort)
{ {
{ {
CriticalSectionScoped cs(_critPacketCallback); CriticalSectionScoped cs(_critPacketCallback);
@@ -359,10 +359,10 @@ WebRtc_Word32 UdpTransportImpl::InitializeReceiveSockets(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::ReceiveSocketInformation( int32_t UdpTransportImpl::ReceiveSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort, uint16_t& rtcpPort,
char multicastIpAddr[kIpAddressVersion6Length]) const char multicastIpAddr[kIpAddressVersion6Length]) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -383,10 +383,10 @@ WebRtc_Word32 UdpTransportImpl::ReceiveSocketInformation(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SendSocketInformation( int32_t UdpTransportImpl::SendSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const uint16_t& rtcpPort) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
rtpPort = _destPort; rtpPort = _destPort;
@@ -397,10 +397,10 @@ WebRtc_Word32 UdpTransportImpl::SendSocketInformation(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::RemoteSocketInformation( int32_t UdpTransportImpl::RemoteSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const uint16_t& rtcpPort) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
rtpPort = _fromPort; rtpPort = _fromPort;
@@ -414,9 +414,9 @@ WebRtc_Word32 UdpTransportImpl::RemoteSocketInformation(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::FilterPorts( int32_t UdpTransportImpl::FilterPorts(
WebRtc_UWord16& rtpFilterPort, uint16_t& rtpFilterPort,
WebRtc_UWord16& rtcpFilterPort) const uint16_t& rtcpFilterPort) const
{ {
CriticalSectionScoped cs(_critFilter); CriticalSectionScoped cs(_critFilter);
rtpFilterPort = _rtpFilterPort; rtpFilterPort = _rtpFilterPort;
@@ -424,9 +424,9 @@ WebRtc_Word32 UdpTransportImpl::FilterPorts(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SetQoS(bool QoS, WebRtc_Word32 serviceType, int32_t UdpTransportImpl::SetQoS(bool QoS, int32_t serviceType,
WebRtc_UWord32 maxBitrate, uint32_t maxBitrate,
WebRtc_Word32 overrideDSCP, bool audio) int32_t overrideDSCP, bool audio)
{ {
if(QoS) if(QoS)
{ {
@@ -437,9 +437,9 @@ WebRtc_Word32 UdpTransportImpl::SetQoS(bool QoS, WebRtc_Word32 serviceType,
} }
} }
WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType, int32_t UdpTransportImpl::EnableQoS(int32_t serviceType,
bool audio, WebRtc_UWord32 maxBitrate, bool audio, uint32_t maxBitrate,
WebRtc_Word32 overrideDSCP) int32_t overrideDSCP)
{ {
if (_ipV6Enabled) if (_ipV6Enabled)
{ {
@@ -524,10 +524,10 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
// Minimum packet size in bytes for which the requested quality of service // Minimum packet size in bytes for which the requested quality of service
// will be provided. The smallest RTP header is 12 byte. // will be provided. The smallest RTP header is 12 byte.
const WebRtc_Word32 min_policed_size = 12; const int32_t min_policed_size = 12;
// Max SDU, maximum packet size permitted or used in the traffic flow, in // Max SDU, maximum packet size permitted or used in the traffic flow, in
// bytes. // bytes.
const WebRtc_Word32 max_sdu_size = 1500; const int32_t max_sdu_size = 1500;
// Enable QoS for RTP sockets. // Enable QoS for RTP sockets.
if(maxBitrate) if(maxBitrate)
@@ -544,13 +544,13 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
"Enable QOS for audio with max bitrate:%d", "Enable QOS for audio with max bitrate:%d",
maxBitrate); maxBitrate);
const WebRtc_Word32 token_rate = maxBitrate*125; const int32_t token_rate = maxBitrate*125;
// The largest audio packets are 60ms frames. This is a fraction // The largest audio packets are 60ms frames. This is a fraction
// more than 16 packets/second. These 16 frames are sent, at max, // more than 16 packets/second. These 16 frames are sent, at max,
// at a bitrate of maxBitrate*125 -> 1 frame is maxBitrate*125/16 ~ // at a bitrate of maxBitrate*125 -> 1 frame is maxBitrate*125/16 ~
// maxBitrate * 8. // maxBitrate * 8.
const WebRtc_Word32 bucket_size = maxBitrate * 8; const int32_t bucket_size = maxBitrate * 8;
const WebRtc_Word32 peek_bandwith = maxBitrate * 125; const int32_t peek_bandwith = maxBitrate * 125;
if (!rtpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, peek_bandwith, min_policed_size,
max_sdu_size, _remoteRTPAddr, overrideDSCP)) max_sdu_size, _remoteRTPAddr, overrideDSCP))
@@ -568,14 +568,14 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
// Allow for a token rate that is twice that of the maximum bitrate // Allow for a token rate that is twice that of the maximum bitrate
// (in bytes). // (in bytes).
const WebRtc_Word32 token_rate = maxBitrate*250; const int32_t token_rate = maxBitrate*250;
// largest average frame size (key frame size). Assuming that a // largest average frame size (key frame size). Assuming that a
// keyframe is 25% of the bitrate during the second its sent // keyframe is 25% of the bitrate during the second its sent
// Assume that a key frame is 25% of the bitrate the second that it // Assume that a key frame is 25% of the bitrate the second that it
// is sent. The largest frame size is then maxBitrate* 125 * 0.25 ~ // is sent. The largest frame size is then maxBitrate* 125 * 0.25 ~
// 31. // 31.
const WebRtc_Word32 bucket_size = maxBitrate*31; const int32_t bucket_size = maxBitrate*31;
const WebRtc_Word32 peek_bandwith = maxBitrate*125; const int32_t peek_bandwith = maxBitrate*125;
if (!rtpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, max_sdu_size, peek_bandwith, min_policed_size, max_sdu_size,
_remoteRTPAddr, overrideDSCP)) _remoteRTPAddr, overrideDSCP))
@@ -593,9 +593,9 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
"Enable QOS for audio with default max bitrate"); "Enable QOS for audio with default max bitrate");
// Let max bitrate be 240kbit/s. // Let max bitrate be 240kbit/s.
const WebRtc_Word32 token_rate = 30000; const int32_t token_rate = 30000;
const WebRtc_Word32 bucket_size = 2000; const int32_t bucket_size = 2000;
const WebRtc_Word32 peek_bandwith = 30000; const int32_t peek_bandwith = 30000;
if (!rtpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, max_sdu_size, peek_bandwith, min_policed_size, max_sdu_size,
_remoteRTPAddr, overrideDSCP)) _remoteRTPAddr, overrideDSCP))
@@ -612,9 +612,9 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
"Enable QOS for video with default max bitrate"); "Enable QOS for video with default max bitrate");
// Let max bitrate be 10mbit/s. // Let max bitrate be 10mbit/s.
const WebRtc_Word32 token_rate = 128000*10; const int32_t token_rate = 128000*10;
const WebRtc_Word32 bucket_size = 32000; const int32_t bucket_size = 32000;
const WebRtc_Word32 peek_bandwith = 256000; const int32_t peek_bandwith = 256000;
if (!rtpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, max_sdu_size, peek_bandwith, min_policed_size, max_sdu_size,
_remoteRTPAddr, overrideDSCP)) _remoteRTPAddr, overrideDSCP))
@@ -630,9 +630,9 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
// TODO (hellner): shouldn't RTCP be based on 5% of the maximum bandwidth? // TODO (hellner): shouldn't RTCP be based on 5% of the maximum bandwidth?
if(audio) if(audio)
{ {
const WebRtc_Word32 token_rate = 200; const int32_t token_rate = 200;
const WebRtc_Word32 bucket_size = 200; const int32_t bucket_size = 200;
const WebRtc_Word32 peek_bandwith = 400; const int32_t peek_bandwith = 400;
if (!rtcpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtcpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, max_sdu_size, peek_bandwith, min_policed_size, max_sdu_size,
_remoteRTCPAddr, overrideDSCP)) _remoteRTCPAddr, overrideDSCP))
@@ -643,9 +643,9 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
} }
}else }else
{ {
const WebRtc_Word32 token_rate = 5000; const int32_t token_rate = 5000;
const WebRtc_Word32 bucket_size = 100; const int32_t bucket_size = 100;
const WebRtc_Word32 peek_bandwith = 10000; const int32_t peek_bandwith = 10000;
if (!rtcpSock->SetQos(serviceType, token_rate, bucket_size, if (!rtcpSock->SetQos(serviceType, token_rate, bucket_size,
peek_bandwith, min_policed_size, max_sdu_size, peek_bandwith, min_policed_size, max_sdu_size,
_remoteRTCPAddr, _overrideDSCP)) _remoteRTCPAddr, _overrideDSCP))
@@ -662,7 +662,7 @@ WebRtc_Word32 UdpTransportImpl::EnableQoS(WebRtc_Word32 serviceType,
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::DisableQoS() int32_t UdpTransportImpl::DisableQoS()
{ {
if(_qos == false) if(_qos == false)
{ {
@@ -695,8 +695,8 @@ WebRtc_Word32 UdpTransportImpl::DisableQoS()
return -1; return -1;
} }
const WebRtc_Word32 service_type = 0; // = SERVICETYPE_NOTRAFFIC const int32_t service_type = 0; // = SERVICETYPE_NOTRAFFIC
const WebRtc_Word32 not_specified = -1; const int32_t not_specified = -1;
if (!rtpSock->SetQos(service_type, not_specified, not_specified, if (!rtpSock->SetQos(service_type, not_specified, not_specified,
not_specified, not_specified, not_specified, not_specified, not_specified, not_specified,
_remoteRTPAddr, _overrideDSCP)) _remoteRTPAddr, _overrideDSCP))
@@ -714,8 +714,8 @@ WebRtc_Word32 UdpTransportImpl::DisableQoS()
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::QoS(bool& QoS, WebRtc_Word32& serviceType, int32_t UdpTransportImpl::QoS(bool& QoS, int32_t& serviceType,
WebRtc_Word32& overrideDSCP) const int32_t& overrideDSCP) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
QoS = _qos; QoS = _qos;
@@ -724,7 +724,7 @@ WebRtc_Word32 UdpTransportImpl::QoS(bool& QoS, WebRtc_Word32& serviceType,
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SetToS(WebRtc_Word32 DSCP, bool useSetSockOpt) int32_t UdpTransportImpl::SetToS(int32_t DSCP, bool useSetSockOpt)
{ {
if (_qos) if (_qos)
{ {
@@ -835,7 +835,7 @@ WebRtc_Word32 UdpTransportImpl::SetToS(WebRtc_Word32 DSCP, bool useSetSockOpt)
else else
{ {
bool receiving=_receiving; bool receiving=_receiving;
WebRtc_UWord32 noOfReceiveBuffers = 0; uint32_t noOfReceiveBuffers = 0;
if(receiving) if(receiving)
{ {
noOfReceiveBuffers=_ptrRtpSocket->ReceiveBuffers(); noOfReceiveBuffers=_ptrRtpSocket->ReceiveBuffers();
@@ -879,9 +879,9 @@ WebRtc_Word32 UdpTransportImpl::SetToS(WebRtc_Word32 DSCP, bool useSetSockOpt)
#endif // #ifdef _WIN32 #endif // #ifdef _WIN32
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id,
"Setting TOS using SetSockopt"); "Setting TOS using SetSockopt");
WebRtc_Word32 TOSShifted = DSCP << 2; int32_t TOSShifted = DSCP << 2;
if (!rtpSock->SetSockopt(IPPROTO_IP, IP_TOS, if (!rtpSock->SetSockopt(IPPROTO_IP, IP_TOS,
(WebRtc_Word8*) &TOSShifted, 4)) (int8_t*) &TOSShifted, 4))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"Could not SetSockopt tos value on RTP socket"); "Could not SetSockopt tos value on RTP socket");
@@ -889,7 +889,7 @@ WebRtc_Word32 UdpTransportImpl::SetToS(WebRtc_Word32 DSCP, bool useSetSockOpt)
return -1; return -1;
} }
if (!rtcpSock->SetSockopt(IPPROTO_IP, IP_TOS, if (!rtcpSock->SetSockopt(IPPROTO_IP, IP_TOS,
(WebRtc_Word8*) &TOSShifted, 4)) (int8_t*) &TOSShifted, 4))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"Could not sSetSockopt tos value on RTCP socket"); "Could not sSetSockopt tos value on RTCP socket");
@@ -920,8 +920,8 @@ WebRtc_Word32 UdpTransportImpl::SetToS(WebRtc_Word32 DSCP, bool useSetSockOpt)
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::ToS(WebRtc_Word32& DSCP, int32_t UdpTransportImpl::ToS(int32_t& DSCP,
bool& useSetSockOpt) const bool& useSetSockOpt) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
DSCP = _tos; DSCP = _tos;
@@ -929,7 +929,7 @@ WebRtc_Word32 UdpTransportImpl::ToS(WebRtc_Word32& DSCP,
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SetPCP(WebRtc_Word32 PCP) int32_t UdpTransportImpl::SetPCP(int32_t PCP)
{ {
if (_qos) if (_qos)
@@ -1000,7 +1000,7 @@ WebRtc_Word32 UdpTransportImpl::SetPCP(WebRtc_Word32 PCP)
} }
#elif defined(WEBRTC_LINUX) #elif defined(WEBRTC_LINUX)
if (!rtpSock->SetSockopt(SOL_SOCKET, SO_PRIORITY, (WebRtc_Word8*) &PCP, if (!rtpSock->SetSockopt(SOL_SOCKET, SO_PRIORITY, (int8_t*) &PCP,
sizeof(PCP))) sizeof(PCP)))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
@@ -1008,7 +1008,7 @@ WebRtc_Word32 UdpTransportImpl::SetPCP(WebRtc_Word32 PCP)
_lastError = kPcpError; _lastError = kPcpError;
return -1; return -1;
} }
if (!rtcpSock->SetSockopt(SOL_SOCKET, SO_PRIORITY, (WebRtc_Word8*) &PCP, if (!rtcpSock->SetSockopt(SOL_SOCKET, SO_PRIORITY, (int8_t*) &PCP,
sizeof(PCP))) sizeof(PCP)))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
@@ -1025,7 +1025,7 @@ WebRtc_Word32 UdpTransportImpl::SetPCP(WebRtc_Word32 PCP)
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::PCP(WebRtc_Word32& PCP) const int32_t UdpTransportImpl::PCP(int32_t& PCP) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
PCP = _pcp; PCP = _pcp;
@@ -1037,7 +1037,7 @@ bool UdpTransportImpl::SetSockOptUsed()
return _useSetSockOpt; return _useSetSockOpt;
} }
WebRtc_Word32 UdpTransportImpl::EnableIpV6() { int32_t UdpTransportImpl::EnableIpV6() {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
const bool initialized = (_ptrSendRtpSocket || _ptrRtpSocket); const bool initialized = (_ptrSendRtpSocket || _ptrRtpSocket);
@@ -1053,7 +1053,7 @@ WebRtc_Word32 UdpTransportImpl::EnableIpV6() {
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::FilterIP( int32_t UdpTransportImpl::FilterIP(
char filterIPAddress[kIpAddressVersion6Length]) const char filterIPAddress[kIpAddressVersion6Length]) const
{ {
@@ -1069,12 +1069,12 @@ WebRtc_Word32 UdpTransportImpl::FilterIP(
return -1; return -1;
} }
CriticalSectionScoped cs(_critFilter); CriticalSectionScoped cs(_critFilter);
WebRtc_UWord32 ipSize = kIpAddressVersion6Length; uint32_t ipSize = kIpAddressVersion6Length;
WebRtc_UWord16 sourcePort; uint16_t sourcePort;
return IPAddress(_filterIPAddress, filterIPAddress, ipSize, sourcePort); return IPAddress(_filterIPAddress, filterIPAddress, ipSize, sourcePort);
} }
WebRtc_Word32 UdpTransportImpl::SetFilterIP( int32_t UdpTransportImpl::SetFilterIP(
const char filterIPAddress[kIpAddressVersion6Length]) const char filterIPAddress[kIpAddressVersion6Length])
{ {
if(filterIPAddress == NULL) if(filterIPAddress == NULL)
@@ -1118,8 +1118,8 @@ WebRtc_Word32 UdpTransportImpl::SetFilterIP(
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SetFilterPorts(WebRtc_UWord16 rtpFilterPort, int32_t UdpTransportImpl::SetFilterPorts(uint16_t rtpFilterPort,
WebRtc_UWord16 rtcpFilterPort) uint16_t rtcpFilterPort)
{ {
CriticalSectionScoped cs(_critFilter); CriticalSectionScoped cs(_critFilter);
_rtpFilterPort = rtpFilterPort; _rtpFilterPort = rtpFilterPort;
@@ -1388,7 +1388,7 @@ UdpTransportImpl::ErrorCode UdpTransportImpl::BindLocalRTPSocket()
mreq.imr_interface.s_addr = INADDR_ANY; mreq.imr_interface.s_addr = INADDR_ANY;
if (!_ptrRtpSocket->SetSockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP, if (!_ptrRtpSocket->SetSockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP,
(WebRtc_Word8*)&mreq,sizeof (mreq))) (int8_t*)&mreq,sizeof (mreq)))
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceError, kTraceError,
@@ -1460,7 +1460,7 @@ UdpTransportImpl::ErrorCode UdpTransportImpl::BindLocalRTCPSocket()
mreq.imr_interface.s_addr = INADDR_ANY; mreq.imr_interface.s_addr = INADDR_ANY;
if (!_ptrRtcpSocket->SetSockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP, if (!_ptrRtcpSocket->SetSockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP,
(WebRtc_Word8*)&mreq,sizeof (mreq))) (int8_t*)&mreq,sizeof (mreq)))
{ {
WEBRTC_TRACE( WEBRTC_TRACE(
kTraceError, kTraceError,
@@ -1476,8 +1476,8 @@ UdpTransportImpl::ErrorCode UdpTransportImpl::BindLocalRTCPSocket()
return kNoSocketError; return kNoSocketError;
} }
WebRtc_Word32 UdpTransportImpl::InitializeSourcePorts(WebRtc_UWord16 rtpPort, int32_t UdpTransportImpl::InitializeSourcePorts(uint16_t rtpPort,
WebRtc_UWord16 rtcpPort) uint16_t rtcpPort)
{ {
if(rtpPort == 0) if(rtpPort == 0)
@@ -1529,8 +1529,8 @@ WebRtc_Word32 UdpTransportImpl::InitializeSourcePorts(WebRtc_UWord16 rtpPort,
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SourcePorts(WebRtc_UWord16& rtpPort, int32_t UdpTransportImpl::SourcePorts(uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const uint16_t& rtcpPort) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1541,11 +1541,9 @@ WebRtc_Word32 UdpTransportImpl::SourcePorts(WebRtc_UWord16& rtpPort,
#ifdef _WIN32 #ifdef _WIN32
WebRtc_Word32 UdpTransportImpl::StartReceiving( int32_t UdpTransportImpl::StartReceiving(uint32_t numberOfSocketBuffers)
WebRtc_UWord32 numberOfSocketBuffers)
#else #else
WebRtc_Word32 UdpTransportImpl::StartReceiving( int32_t UdpTransportImpl::StartReceiving(uint32_t /*numberOfSocketBuffers*/)
WebRtc_UWord32 /*numberOfSocketBuffers*/)
#endif #endif
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1594,7 +1592,7 @@ bool UdpTransportImpl::Receiving() const
return _receiving; return _receiving;
} }
WebRtc_Word32 UdpTransportImpl::StopReceiving() int32_t UdpTransportImpl::StopReceiving()
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1624,10 +1622,10 @@ WebRtc_Word32 UdpTransportImpl::StopReceiving()
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::InitializeSendSockets( int32_t UdpTransportImpl::InitializeSendSockets(
const char* ipaddr, const char* ipaddr,
const WebRtc_UWord16 rtpPort, const uint16_t rtpPort,
const WebRtc_UWord16 rtcpPort) const uint16_t rtcpPort)
{ {
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1684,7 +1682,7 @@ WebRtc_Word32 UdpTransportImpl::InitializeSendSockets(
// TODO (grunell): Multicast support is experimantal. // TODO (grunell): Multicast support is experimantal.
// Put the first digit of the remote address in val. // Put the first digit of the remote address in val.
WebRtc_Word32 val = ntohl(_remoteRTPAddr._sockaddr_in.sin_addr)>> 24; int32_t val = ntohl(_remoteRTPAddr._sockaddr_in.sin_addr)>> 24;
if((val > 223) && (val < 240)) if((val > 223) && (val < 240))
{ {
@@ -1707,10 +1705,10 @@ WebRtc_Word32 UdpTransportImpl::InitializeSendSockets(
} }
// Set Time To Live to same region // Set Time To Live to same region
WebRtc_Word32 iOptVal = 64; int32_t iOptVal = 64;
if (!rtpSock->SetSockopt(IPPROTO_IP, IP_MULTICAST_TTL, if (!rtpSock->SetSockopt(IPPROTO_IP, IP_MULTICAST_TTL,
(WebRtc_Word8*)&iOptVal, (int8_t*)&iOptVal,
sizeof (WebRtc_Word32))) sizeof (int32_t)))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"setsockopt for multicast error on RTP socket"); "setsockopt for multicast error on RTP socket");
@@ -1720,8 +1718,8 @@ WebRtc_Word32 UdpTransportImpl::InitializeSendSockets(
return -1; return -1;
} }
if (!rtcpSock->SetSockopt(IPPROTO_IP, IP_MULTICAST_TTL, if (!rtcpSock->SetSockopt(IPPROTO_IP, IP_MULTICAST_TTL,
(WebRtc_Word8*)&iOptVal, (int8_t*)&iOptVal,
sizeof (WebRtc_Word32))) sizeof (int32_t)))
{ {
WEBRTC_TRACE(kTraceError, kTraceTransport, _id, WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
"setsockopt for multicast error on RTCP socket"); "setsockopt for multicast error on RTCP socket");
@@ -1735,7 +1733,7 @@ WebRtc_Word32 UdpTransportImpl::InitializeSendSockets(
return 0; return 0;
} }
void UdpTransportImpl::BuildSockaddrIn(WebRtc_UWord16 portnr, void UdpTransportImpl::BuildSockaddrIn(uint16_t portnr,
const char* ip, const char* ip,
SocketAddress& remoteAddr) const SocketAddress& remoteAddr) const
{ {
@@ -1766,11 +1764,11 @@ void UdpTransportImpl::BuildSockaddrIn(WebRtc_UWord16 portnr,
} }
} }
WebRtc_Word32 UdpTransportImpl::SendRaw(const WebRtc_Word8 *data, int32_t UdpTransportImpl::SendRaw(const int8_t *data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_Word32 isRTCP, int32_t isRTCP,
WebRtc_UWord16 portnr, uint16_t portnr,
const char* ip) const char* ip)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
if(isRTCP) if(isRTCP)
@@ -1842,9 +1840,9 @@ WebRtc_Word32 UdpTransportImpl::SendRaw(const WebRtc_Word8 *data,
} }
} }
WebRtc_Word32 UdpTransportImpl::SendRTPPacketTo(const WebRtc_Word8* data, int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to) const SocketAddress& to)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
if(_ptrSendRtpSocket) if(_ptrSendRtpSocket)
@@ -1858,9 +1856,9 @@ WebRtc_Word32 UdpTransportImpl::SendRTPPacketTo(const WebRtc_Word8* data,
return -1; return -1;
} }
WebRtc_Word32 UdpTransportImpl::SendRTCPPacketTo(const WebRtc_Word8* data, int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to) const SocketAddress& to)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1876,9 +1874,9 @@ WebRtc_Word32 UdpTransportImpl::SendRTCPPacketTo(const WebRtc_Word8* data,
return -1; return -1;
} }
WebRtc_Word32 UdpTransportImpl::SendRTPPacketTo(const WebRtc_Word8* data, int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const WebRtc_UWord16 rtpPort) const uint16_t rtpPort)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
// Use the current SocketAdress but update it with rtpPort. // Use the current SocketAdress but update it with rtpPort.
@@ -1904,9 +1902,9 @@ WebRtc_Word32 UdpTransportImpl::SendRTPPacketTo(const WebRtc_Word8* data,
return -1; return -1;
} }
WebRtc_Word32 UdpTransportImpl::SendRTCPPacketTo(const WebRtc_Word8* data, int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data,
WebRtc_UWord32 length, uint32_t length,
const WebRtc_UWord16 rtcpPort) const uint16_t rtcpPort)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
@@ -1989,12 +1987,12 @@ int UdpTransportImpl::SendPacket(int /*channel*/, const void* data, int length)
if(_ptrSendRtpSocket) if(_ptrSendRtpSocket)
{ {
return _ptrSendRtpSocket->SendTo((const WebRtc_Word8*)data, length, return _ptrSendRtpSocket->SendTo((const int8_t*)data, length,
_remoteRTPAddr); _remoteRTPAddr);
} else if(_ptrRtpSocket) } else if(_ptrRtpSocket)
{ {
return _ptrRtpSocket->SendTo((const WebRtc_Word8*)data, length, return _ptrRtpSocket->SendTo((const int8_t*)data, length,
_remoteRTPAddr); _remoteRTPAddr);
} }
return -1; return -1;
@@ -2055,17 +2053,17 @@ int UdpTransportImpl::SendRTCPPacket(int /*channel*/, const void* data,
if(_ptrSendRtcpSocket) if(_ptrSendRtcpSocket)
{ {
return _ptrSendRtcpSocket->SendTo((const WebRtc_Word8*)data, length, return _ptrSendRtcpSocket->SendTo((const int8_t*)data, length,
_remoteRTCPAddr); _remoteRTCPAddr);
} else if(_ptrRtcpSocket) } else if(_ptrRtcpSocket)
{ {
return _ptrRtcpSocket->SendTo((const WebRtc_Word8*)data, length, return _ptrRtcpSocket->SendTo((const int8_t*)data, length,
_remoteRTCPAddr); _remoteRTCPAddr);
} }
return -1; return -1;
} }
WebRtc_Word32 UdpTransportImpl::SetSendIP(const char* ipaddr) int32_t UdpTransportImpl::SetSendIP(const char* ipaddr)
{ {
if(!IsIpAddressValid(ipaddr,IpV6Enabled())) if(!IsIpAddressValid(ipaddr,IpV6Enabled()))
{ {
@@ -2078,8 +2076,7 @@ WebRtc_Word32 UdpTransportImpl::SetSendIP(const char* ipaddr)
return 0; return 0;
} }
WebRtc_Word32 UdpTransportImpl::SetSendPorts(WebRtc_UWord16 rtpPort, int32_t UdpTransportImpl::SetSendPorts(uint16_t rtpPort, uint16_t rtcpPort)
WebRtc_UWord16 rtcpPort)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
_destPort = rtpPort; _destPort = rtpPort;
@@ -2096,8 +2093,8 @@ WebRtc_Word32 UdpTransportImpl::SetSendPorts(WebRtc_UWord16 rtpPort,
} }
void UdpTransportImpl::IncomingRTPCallback(CallbackObj obj, void UdpTransportImpl::IncomingRTPCallback(CallbackObj obj,
const WebRtc_Word8* rtpPacket, const int8_t* rtpPacket,
WebRtc_Word32 rtpPacketLength, int32_t rtpPacketLength,
const SocketAddress* from) const SocketAddress* from)
{ {
if (rtpPacket && rtpPacketLength > 0) if (rtpPacket && rtpPacketLength > 0)
@@ -2108,8 +2105,8 @@ void UdpTransportImpl::IncomingRTPCallback(CallbackObj obj,
} }
void UdpTransportImpl::IncomingRTCPCallback(CallbackObj obj, void UdpTransportImpl::IncomingRTCPCallback(CallbackObj obj,
const WebRtc_Word8* rtcpPacket, const int8_t* rtcpPacket,
WebRtc_Word32 rtcpPacketLength, int32_t rtcpPacketLength,
const SocketAddress* from) const SocketAddress* from)
{ {
if (rtcpPacket && rtcpPacketLength > 0) if (rtcpPacket && rtcpPacketLength > 0)
@@ -2120,13 +2117,13 @@ void UdpTransportImpl::IncomingRTCPCallback(CallbackObj obj,
} }
} }
void UdpTransportImpl::IncomingRTPFunction(const WebRtc_Word8* rtpPacket, void UdpTransportImpl::IncomingRTPFunction(const int8_t* rtpPacket,
WebRtc_Word32 rtpPacketLength, int32_t rtpPacketLength,
const SocketAddress* fromSocket) const SocketAddress* fromSocket)
{ {
char ipAddress[kIpAddressVersion6Length]; char ipAddress[kIpAddressVersion6Length];
WebRtc_UWord32 ipAddressLength = kIpAddressVersion6Length; uint32_t ipAddressLength = kIpAddressVersion6Length;
WebRtc_UWord16 portNr = 0; uint16_t portNr = 0;
{ {
CriticalSectionScoped cs(_critFilter); CriticalSectionScoped cs(_critFilter);
@@ -2183,13 +2180,13 @@ void UdpTransportImpl::IncomingRTPFunction(const WebRtc_Word8* rtpPacket,
} }
} }
void UdpTransportImpl::IncomingRTCPFunction(const WebRtc_Word8* rtcpPacket, void UdpTransportImpl::IncomingRTCPFunction(const int8_t* rtcpPacket,
WebRtc_Word32 rtcpPacketLength, int32_t rtcpPacketLength,
const SocketAddress* fromSocket) const SocketAddress* fromSocket)
{ {
char ipAddress[kIpAddressVersion6Length]; char ipAddress[kIpAddressVersion6Length];
WebRtc_UWord32 ipAddressLength = kIpAddressVersion6Length; uint32_t ipAddressLength = kIpAddressVersion6Length;
WebRtc_UWord16 portNr = 0; uint16_t portNr = 0;
{ {
CriticalSectionScoped cs(_critFilter); CriticalSectionScoped cs(_critFilter);
@@ -2263,7 +2260,7 @@ bool UdpTransportImpl::FilterIPAddress(const SocketAddress* fromAddress)
if (_filterIPAddress._sockaddr_storage.sin_family == AF_INET6) if (_filterIPAddress._sockaddr_storage.sin_family == AF_INET6)
{ {
// IP is stored in sin_6addr. // IP is stored in sin_6addr.
for (WebRtc_Word32 i = 0; i < 4; i++) for (int32_t i = 0; i < 4; i++)
{ {
if (_filterIPAddress._sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i] != 0 && if (_filterIPAddress._sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i] != 0 &&
_filterIPAddress._sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i] != fromAddress->_sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i]) _filterIPAddress._sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i] != fromAddress->_sockaddr_in6.sin6_addr.Version6AddressUnion._s6_u32[i])
@@ -2314,27 +2311,27 @@ void UdpTransportImpl::CloseSendSockets()
} }
} }
WebRtc_UWord16 UdpTransport::Htons(const WebRtc_UWord16 port) uint16_t UdpTransport::Htons(const uint16_t port)
{ {
return htons(port); return htons(port);
} }
WebRtc_UWord32 UdpTransport::Htonl(const WebRtc_UWord32 a) uint32_t UdpTransport::Htonl(const uint32_t a)
{ {
return htonl(a); return htonl(a);
} }
WebRtc_UWord32 UdpTransport::InetAddrIPV4(const char* ip) uint32_t UdpTransport::InetAddrIPV4(const char* ip)
{ {
return ::inet_addr(ip); return ::inet_addr(ip);
} }
WebRtc_Word32 UdpTransport::InetPresentationToNumeric(WebRtc_Word32 af, int32_t UdpTransport::InetPresentationToNumeric(int32_t af,
const char* src, const char* src,
void* dst) void* dst)
{ {
#if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) #if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
const WebRtc_Word32 result = inet_pton(af, src, dst); const int32_t result = inet_pton(af, src, dst);
return result > 0 ? 0 : -1; return result > 0 ? 0 : -1;
#elif defined(_WIN32) #elif defined(_WIN32)
@@ -2343,7 +2340,7 @@ WebRtc_Word32 UdpTransport::InetPresentationToNumeric(WebRtc_Word32 af,
if(af == AF_INET) if(af == AF_INET)
{ {
WebRtc_Word32 result = WSAStringToAddressA( int32_t result = WSAStringToAddressA(
(const LPSTR)src, (const LPSTR)src,
af, af,
0, 0,
@@ -2359,7 +2356,7 @@ WebRtc_Word32 UdpTransport::InetPresentationToNumeric(WebRtc_Word32 af,
} }
else if(af == AF_INET6) else if(af == AF_INET6)
{ {
WebRtc_Word32 result = WSAStringToAddressA( int32_t result = WSAStringToAddressA(
(const LPSTR)src, (const LPSTR)src,
af, af,
0, 0,
@@ -2382,7 +2379,7 @@ WebRtc_Word32 UdpTransport::InetPresentationToNumeric(WebRtc_Word32 af,
#endif #endif
} }
WebRtc_Word32 UdpTransport::LocalHostAddressIPV6(char n_localIP[16]) int32_t UdpTransport::LocalHostAddressIPV6(char n_localIP[16])
{ {
#if defined(_WIN32) #if defined(_WIN32)
@@ -2620,7 +2617,7 @@ WebRtc_Word32 UdpTransport::LocalHostAddressIPV6(char n_localIP[16])
#endif #endif
} }
WebRtc_Word32 UdpTransport::LocalHostAddress(WebRtc_UWord32& localIP) int32_t UdpTransport::LocalHostAddress(uint32_t& localIP)
{ {
#if defined(_WIN32) #if defined(_WIN32)
hostent* localHost; hostent* localHost;
@@ -2642,7 +2639,7 @@ WebRtc_Word32 UdpTransport::LocalHostAddress(WebRtc_UWord32& localIP)
} }
else else
{ {
WebRtc_Word32 error = WSAGetLastError(); int32_t error = WSAGetLastError();
WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1, WEBRTC_TRACE(kTraceWarning, kTraceTransport, -1,
"gethostbyname failed, error:%d", error); "gethostbyname failed, error:%d", error);
return -1; return -1;
@@ -2730,14 +2727,14 @@ WebRtc_Word32 UdpTransport::LocalHostAddress(WebRtc_UWord32& localIP)
#endif #endif
} }
WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address, int32_t UdpTransport::IPAddress(const SocketAddress& address,
char* ip, char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort) uint16_t& sourcePort)
{ {
#if defined(_WIN32) #if defined(_WIN32)
DWORD dwIPSize = ipSize; DWORD dwIPSize = ipSize;
WebRtc_Word32 returnvalue = WSAAddressToStringA((LPSOCKADDR)(&address), int32_t returnvalue = WSAAddressToStringA((LPSOCKADDR)(&address),
sizeof(SocketAddress), sizeof(SocketAddress),
NULL, NULL,
ip, ip,
@@ -2747,7 +2744,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
return -1; return -1;
} }
WebRtc_UWord16 source_port = 0; uint16_t source_port = 0;
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".
@@ -2756,7 +2753,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
{ {
*ipEnd = '\0'; *ipEnd = '\0';
} }
ipSize = (WebRtc_Word32)strlen(ip); ipSize = (int32_t)strlen(ip);
if(ipSize == 0) if(ipSize == 0)
{ {
return -1; return -1;
@@ -2770,11 +2767,11 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
if(ipEnd != NULL) if(ipEnd != NULL)
{ {
// Calculate length // Calculate length
WebRtc_Word32 adrSize = WebRtc_Word32(ipEnd - ip) - 1; int32_t adrSize = int32_t(ipEnd - ip) - 1;
memmove(ip, &ip[1], adrSize); // Remove '[' memmove(ip, &ip[1], adrSize); // Remove '['
*(ipEnd - 1) = '\0'; *(ipEnd - 1) = '\0';
} }
ipSize = (WebRtc_Word32)strlen(ip); ipSize = (int32_t)strlen(ip);
if(ipSize == 0) if(ipSize == 0)
{ {
return -1; return -1;
@@ -2787,7 +2784,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
return 0; return 0;
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
WebRtc_Word32 ipFamily = address._sockaddr_storage.sin_family; int32_t ipFamily = address._sockaddr_storage.sin_family;
const void* ptrNumericIP = NULL; const void* ptrNumericIP = NULL;
if(ipFamily == AF_INET) if(ipFamily == AF_INET)
@@ -2806,7 +2803,7 @@ WebRtc_Word32 UdpTransport::IPAddress(const SocketAddress& address,
{ {
return -1; return -1;
} }
WebRtc_UWord16 source_port; uint16_t source_port;
if(ipFamily == AF_INET) if(ipFamily == AF_INET)
{ {
source_port = address._sockaddr_in.sin_port; source_port = address._sockaddr_in.sin_port;
@@ -2826,19 +2823,19 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
{ {
if(ipV6) if(ipV6)
{ {
WebRtc_Word32 len = (WebRtc_Word32)strlen(ipadr); int32_t len = (int32_t)strlen(ipadr);
if( len>39 || len == 0) if( len>39 || len == 0)
{ {
return false; return false;
} }
WebRtc_Word32 i; int32_t i;
WebRtc_Word32 colonPos[7] = {0,0,0,0,0,0,0}; int32_t colonPos[7] = {0,0,0,0,0,0,0};
WebRtc_Word32 lastColonPos = -2; int32_t lastColonPos = -2;
WebRtc_Word32 nColons = 0; int32_t nColons = 0;
WebRtc_Word32 nDubbleColons = 0; int32_t nDubbleColons = 0;
WebRtc_Word32 nDots = 0; int32_t nDots = 0;
WebRtc_Word32 error = 0; int32_t error = 0;
char c; char c;
for(i = 0; i < len ; i++) for(i = 0; i < len ; i++)
{ {
@@ -2885,7 +2882,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
return false; return false;
} }
lastColonPos = -1; lastColonPos = -1;
WebRtc_Word32 charsBeforeColon = 0; int32_t charsBeforeColon = 0;
for(i = 0; i < nColons; i++) for(i = 0; i < nColons; i++)
{ {
charsBeforeColon=colonPos[i]-lastColonPos-1; charsBeforeColon=colonPos[i]-lastColonPos-1;
@@ -2895,7 +2892,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
} }
lastColonPos=colonPos[i]; lastColonPos=colonPos[i];
} }
WebRtc_Word32 lengthAfterLastColon = len - lastColonPos - 1; int32_t lengthAfterLastColon = len - lastColonPos - 1;
if(nDots == 0) if(nDots == 0)
{ {
if(lengthAfterLastColon > 4) if(lengthAfterLastColon > 4)
@@ -2909,16 +2906,16 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
} }
else else
{ {
WebRtc_Word32 len = (WebRtc_Word32)strlen(ipadr); int32_t len = (int32_t)strlen(ipadr);
if((len>15)||(len==0)) if((len>15)||(len==0))
{ {
return false; return false;
} }
// IPv4 should be [0-255].[0-255].[0-255].[0-255] // IPv4 should be [0-255].[0-255].[0-255].[0-255]
WebRtc_Word32 i; int32_t i;
WebRtc_Word32 nDots = 0; int32_t nDots = 0;
WebRtc_Word32 iDotPos[4] = {0,0,0,0}; int32_t iDotPos[4] = {0,0,0,0};
for (i = 0; (i < len) && (nDots < 4); i++) for (i = 0; (i < len) && (nDots < 4); i++)
{ {
@@ -2946,7 +2943,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
char nr[4]; char nr[4];
memset(nr,0,4); memset(nr,0,4);
strncpy(nr,&ipadr[0],iDotPos[0]); strncpy(nr,&ipadr[0],iDotPos[0]);
WebRtc_Word32 num = atoi(nr); int32_t num = atoi(nr);
if (num > 255) if (num > 255)
{ {
break; break;
@@ -2960,7 +2957,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
char nr[4]; char nr[4];
memset(nr,0,4); memset(nr,0,4);
strncpy(nr,&ipadr[iDotPos[0]+1], iDotPos[1] - iDotPos[0] - 1); strncpy(nr,&ipadr[iDotPos[0]+1], iDotPos[1] - iDotPos[0] - 1);
WebRtc_Word32 num = atoi(nr); int32_t num = atoi(nr);
if (num > 255) if (num > 255)
break; break;
} else { } else {
@@ -2972,7 +2969,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
char nr[4]; char nr[4];
memset(nr,0,4); memset(nr,0,4);
strncpy(nr,&ipadr[iDotPos[1]+1], iDotPos[1] - iDotPos[0] - 1); strncpy(nr,&ipadr[iDotPos[1]+1], iDotPos[1] - iDotPos[0] - 1);
WebRtc_Word32 num = atoi(nr); int32_t num = atoi(nr);
if (num > 255) if (num > 255)
break; break;

View File

@@ -30,7 +30,7 @@ public:
class SocketFactoryInterface { class SocketFactoryInterface {
public: public:
virtual ~SocketFactoryInterface() {} virtual ~SocketFactoryInterface() {}
virtual UdpSocketWrapper* CreateSocket(const WebRtc_Word32 id, virtual UdpSocketWrapper* CreateSocket(const int32_t id,
UdpSocketManager* mgr, UdpSocketManager* mgr,
CallbackObj obj, CallbackObj obj,
IncomingSocketCallback cb, IncomingSocketCallback cb,
@@ -41,113 +41,111 @@ public:
// Constructor, only called by UdpTransport::Create and tests. // Constructor, only called by UdpTransport::Create and tests.
// The constructor takes ownership of the "maker". // The constructor takes ownership of the "maker".
// The constructor does not take ownership of socket_manager. // The constructor does not take ownership of socket_manager.
UdpTransportImpl(const WebRtc_Word32 id, UdpTransportImpl(const int32_t id,
SocketFactoryInterface* maker, SocketFactoryInterface* maker,
UdpSocketManager* socket_manager); UdpSocketManager* socket_manager);
virtual ~UdpTransportImpl(); virtual ~UdpTransportImpl();
// UdpTransport functions // UdpTransport functions
virtual WebRtc_Word32 InitializeSendSockets( virtual int32_t InitializeSendSockets(
const char* ipAddr, const char* ipAddr,
const WebRtc_UWord16 rtpPort, const uint16_t rtpPort,
const WebRtc_UWord16 rtcpPort = 0); const uint16_t rtcpPort = 0);
virtual WebRtc_Word32 InitializeReceiveSockets( virtual int32_t InitializeReceiveSockets(
UdpTransportData* const packetCallback, UdpTransportData* const packetCallback,
const WebRtc_UWord16 rtpPort, const uint16_t rtpPort,
const char* ipAddr = NULL, const char* ipAddr = NULL,
const char* multicastIpAddr = NULL, const char* multicastIpAddr = NULL,
const WebRtc_UWord16 rtcpPort = 0); const uint16_t rtcpPort = 0);
virtual WebRtc_Word32 InitializeSourcePorts( virtual int32_t InitializeSourcePorts(
const WebRtc_UWord16 rtpPort, const uint16_t rtpPort,
const WebRtc_UWord16 rtcpPort = 0); const uint16_t rtcpPort = 0);
virtual WebRtc_Word32 SourcePorts(WebRtc_UWord16& rtpPort, virtual int32_t SourcePorts(uint16_t& rtpPort, uint16_t& rtcpPort) const;
WebRtc_UWord16& rtcpPort) const; virtual int32_t ReceiveSocketInformation(
virtual WebRtc_Word32 ReceiveSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort, uint16_t& rtcpPort,
char multicastIpAddr[kIpAddressVersion6Length]) const; char multicastIpAddr[kIpAddressVersion6Length]) const;
virtual WebRtc_Word32 SendSocketInformation( virtual int32_t SendSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const; uint16_t& rtcpPort) const;
virtual WebRtc_Word32 RemoteSocketInformation( virtual int32_t RemoteSocketInformation(
char ipAddr[kIpAddressVersion6Length], char ipAddr[kIpAddressVersion6Length],
WebRtc_UWord16& rtpPort, uint16_t& rtpPort,
WebRtc_UWord16& rtcpPort) const; uint16_t& rtcpPort) const;
virtual WebRtc_Word32 SetQoS(const bool QoS, virtual int32_t SetQoS(const bool QoS,
const WebRtc_Word32 serviceType, const int32_t serviceType,
const WebRtc_UWord32 maxBitrate = 0, const uint32_t maxBitrate = 0,
const WebRtc_Word32 overrideDSCP = 0, const int32_t overrideDSCP = 0,
const bool audio = false); const bool audio = false);
virtual WebRtc_Word32 QoS(bool& QoS, WebRtc_Word32& serviceType, virtual int32_t QoS(bool& QoS, int32_t& serviceType,
WebRtc_Word32& overrideDSCP) const; int32_t& overrideDSCP) const;
virtual WebRtc_Word32 SetToS(const WebRtc_Word32 DSCP, virtual int32_t SetToS(const int32_t DSCP,
const bool useSetSockOpt = false); const bool useSetSockOpt = false);
virtual WebRtc_Word32 ToS(WebRtc_Word32& DSCP, virtual int32_t ToS(int32_t& DSCP, bool& useSetSockOpt) const;
bool& useSetSockOpt) const; virtual int32_t SetPCP(const int32_t PCP);
virtual WebRtc_Word32 SetPCP(const WebRtc_Word32 PCP); virtual int32_t PCP(int32_t& PCP) const;
virtual WebRtc_Word32 PCP(WebRtc_Word32& PCP) const; virtual int32_t EnableIpV6();
virtual WebRtc_Word32 EnableIpV6();
virtual bool IpV6Enabled() const; virtual bool IpV6Enabled() const;
virtual WebRtc_Word32 SetFilterIP( virtual int32_t SetFilterIP(
const char filterIPAddress[kIpAddressVersion6Length]); const char filterIPAddress[kIpAddressVersion6Length]);
virtual WebRtc_Word32 FilterIP( virtual int32_t FilterIP(
char filterIPAddress[kIpAddressVersion6Length]) const; char filterIPAddress[kIpAddressVersion6Length]) const;
virtual WebRtc_Word32 SetFilterPorts(const WebRtc_UWord16 rtpFilterPort, virtual int32_t SetFilterPorts(const uint16_t rtpFilterPort,
const WebRtc_UWord16 rtcpFilterPort); const uint16_t rtcpFilterPort);
virtual WebRtc_Word32 FilterPorts(WebRtc_UWord16& rtpFilterPort, virtual int32_t FilterPorts(uint16_t& rtpFilterPort,
WebRtc_UWord16& rtcpFilterPort) const; uint16_t& rtcpFilterPort) const;
virtual WebRtc_Word32 StartReceiving( virtual int32_t StartReceiving(
const WebRtc_UWord32 numberOfSocketBuffers); const uint32_t numberOfSocketBuffers);
virtual WebRtc_Word32 StopReceiving(); virtual int32_t StopReceiving();
virtual bool Receiving() const; virtual bool Receiving() const;
virtual bool SendSocketsInitialized() const; virtual bool SendSocketsInitialized() const;
virtual bool SourcePortsInitialized() const; virtual bool SourcePortsInitialized() const;
virtual bool ReceiveSocketsInitialized() const; virtual bool ReceiveSocketsInitialized() const;
virtual WebRtc_Word32 SendRaw(const WebRtc_Word8* data, virtual int32_t SendRaw(const int8_t* data,
WebRtc_UWord32 length, WebRtc_Word32 isRTCP, uint32_t length, int32_t isRTCP,
WebRtc_UWord16 portnr = 0, uint16_t portnr = 0,
const char* ip = NULL); const char* ip = NULL);
virtual WebRtc_Word32 SendRTPPacketTo(const WebRtc_Word8 *data, virtual int32_t SendRTPPacketTo(const int8_t *data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to); const SocketAddress& to);
virtual WebRtc_Word32 SendRTCPPacketTo(const WebRtc_Word8 *data, virtual int32_t SendRTCPPacketTo(const int8_t *data,
WebRtc_UWord32 length, uint32_t length,
const SocketAddress& to); const SocketAddress& to);
virtual WebRtc_Word32 SendRTPPacketTo(const WebRtc_Word8 *data, virtual int32_t SendRTPPacketTo(const int8_t *data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_UWord16 rtpPort); uint16_t rtpPort);
virtual WebRtc_Word32 SendRTCPPacketTo(const WebRtc_Word8 *data, virtual int32_t SendRTCPPacketTo(const int8_t *data,
WebRtc_UWord32 length, uint32_t length,
WebRtc_UWord16 rtcpPort); uint16_t rtcpPort);
// Transport functions // Transport functions
virtual int SendPacket(int channel, const void* data, int length); virtual int SendPacket(int channel, const void* data, int length);
virtual int SendRTCPPacket(int channel, const void* data, int length); virtual int SendRTCPPacket(int channel, const void* data, int length);
// UdpTransport functions continue. // UdpTransport functions continue.
virtual WebRtc_Word32 SetSendIP(const char* ipaddr); virtual int32_t SetSendIP(const char* ipaddr);
virtual WebRtc_Word32 SetSendPorts(const WebRtc_UWord16 rtpPort, virtual int32_t SetSendPorts(const uint16_t rtpPort,
const WebRtc_UWord16 rtcpPort = 0); const uint16_t rtcpPort = 0);
virtual ErrorCode LastError() const; virtual ErrorCode LastError() const;
virtual WebRtc_Word32 IPAddressCached(const SocketAddress& address, virtual int32_t IPAddressCached(const SocketAddress& address,
char* ip, char* ip,
WebRtc_UWord32& ipSize, uint32_t& ipSize,
WebRtc_UWord16& sourcePort); uint16_t& sourcePort);
WebRtc_Word32 Id() const {return _id;} int32_t Id() const {return _id;}
protected: protected:
// IncomingSocketCallback signature functions for receiving callbacks from // IncomingSocketCallback signature functions for receiving callbacks from
// UdpSocketWrapper. // UdpSocketWrapper.
static void IncomingRTPCallback(CallbackObj obj, static void IncomingRTPCallback(CallbackObj obj,
const WebRtc_Word8* rtpPacket, const int8_t* rtpPacket,
WebRtc_Word32 rtpPacketLength, int32_t rtpPacketLength,
const SocketAddress* from); const SocketAddress* from);
static void IncomingRTCPCallback(CallbackObj obj, static void IncomingRTCPCallback(CallbackObj obj,
const WebRtc_Word8* rtcpPacket, const int8_t* rtcpPacket,
WebRtc_Word32 rtcpPacketLength, int32_t rtcpPacketLength,
const SocketAddress* from); const SocketAddress* from);
void CloseSendSockets(); void CloseSendSockets();
@@ -158,7 +156,7 @@ protected:
// Update _remoteRTCPAddr according to _destPortRTCP and _destIP // Update _remoteRTCPAddr according to _destPortRTCP and _destIP
void BuildRemoteRTCPAddr(); void BuildRemoteRTCPAddr();
void BuildSockaddrIn(WebRtc_UWord16 portnr, const char* ip, void BuildSockaddrIn(uint16_t portnr, const char* ip,
SocketAddress& remoteAddr) const; SocketAddress& remoteAddr) const;
ErrorCode BindLocalRTPSocket(); ErrorCode BindLocalRTPSocket();
@@ -167,28 +165,27 @@ protected:
ErrorCode BindRTPSendSocket(); ErrorCode BindRTPSendSocket();
ErrorCode BindRTCPSendSocket(); ErrorCode BindRTCPSendSocket();
void IncomingRTPFunction(const WebRtc_Word8* rtpPacket, void IncomingRTPFunction(const int8_t* rtpPacket,
WebRtc_Word32 rtpPacketLength, int32_t rtpPacketLength,
const SocketAddress* from); const SocketAddress* from);
void IncomingRTCPFunction(const WebRtc_Word8* rtcpPacket, void IncomingRTCPFunction(const int8_t* rtcpPacket,
WebRtc_Word32 rtcpPacketLength, int32_t rtcpPacketLength,
const SocketAddress* from); const SocketAddress* from);
bool FilterIPAddress(const SocketAddress* fromAddress); bool FilterIPAddress(const SocketAddress* fromAddress);
bool SetSockOptUsed(); bool SetSockOptUsed();
WebRtc_Word32 EnableQoS(WebRtc_Word32 serviceType, bool audio, int32_t EnableQoS(int32_t serviceType, bool audio,
WebRtc_UWord32 maxBitrate, uint32_t maxBitrate, int32_t overrideDSCP);
WebRtc_Word32 overrideDSCP);
WebRtc_Word32 DisableQoS(); int32_t DisableQoS();
private: private:
void GetCachedAddress(char* ip, WebRtc_UWord32& ipSize, void GetCachedAddress(char* ip, uint32_t& ipSize,
WebRtc_UWord16& sourcePort); uint16_t& sourcePort);
WebRtc_Word32 _id; int32_t _id;
SocketFactoryInterface* _socket_creator; SocketFactoryInterface* _socket_creator;
// Protects the sockets from being re-configured while receiving packets. // Protects the sockets from being re-configured while receiving packets.
CriticalSectionWrapper* _crit; CriticalSectionWrapper* _crit;
@@ -199,21 +196,21 @@ private:
ErrorCode _lastError; ErrorCode _lastError;
// Remote RTP and RTCP ports. // Remote RTP and RTCP ports.
WebRtc_UWord16 _destPort; uint16_t _destPort;
WebRtc_UWord16 _destPortRTCP; uint16_t _destPortRTCP;
// Local RTP and RTCP ports. // Local RTP and RTCP ports.
WebRtc_UWord16 _localPort; uint16_t _localPort;
WebRtc_UWord16 _localPortRTCP; uint16_t _localPortRTCP;
// Local port number when the local port for receiving and local port number // Local port number when the local port for receiving and local port number
// for sending are not the same. // for sending are not the same.
WebRtc_UWord16 _srcPort; uint16_t _srcPort;
WebRtc_UWord16 _srcPortRTCP; uint16_t _srcPortRTCP;
// Remote port from which last received packet was sent. // Remote port from which last received packet was sent.
WebRtc_UWord16 _fromPort; uint16_t _fromPort;
WebRtc_UWord16 _fromPortRTCP; uint16_t _fromPortRTCP;
char _fromIP[kIpAddressVersion6Length]; char _fromIP[kIpAddressVersion6Length];
char _destIP[kIpAddressVersion6Length]; char _destIP[kIpAddressVersion6Length];
@@ -234,26 +231,26 @@ private:
SocketAddress _localRTPAddr; SocketAddress _localRTPAddr;
SocketAddress _localRTCPAddr; SocketAddress _localRTCPAddr;
WebRtc_Word32 _tos; int32_t _tos;
bool _receiving; bool _receiving;
bool _useSetSockOpt; bool _useSetSockOpt;
bool _qos; bool _qos;
WebRtc_Word32 _pcp; int32_t _pcp;
bool _ipV6Enabled; bool _ipV6Enabled;
WebRtc_Word32 _serviceType; int32_t _serviceType;
WebRtc_Word32 _overrideDSCP; int32_t _overrideDSCP;
WebRtc_UWord32 _maxBitrate; uint32_t _maxBitrate;
// Cache used by GetCachedAddress(..). // Cache used by GetCachedAddress(..).
RWLockWrapper* _cachLock; RWLockWrapper* _cachLock;
SocketAddress _previousAddress; SocketAddress _previousAddress;
char _previousIP[kIpAddressVersion6Length]; char _previousIP[kIpAddressVersion6Length];
WebRtc_UWord32 _previousIPSize; uint32_t _previousIPSize;
WebRtc_UWord16 _previousSourcePort; uint16_t _previousSourcePort;
SocketAddress _filterIPAddress; SocketAddress _filterIPAddress;
WebRtc_UWord16 _rtpFilterPort; uint16_t _rtpFilterPort;
WebRtc_UWord16 _rtcpFilterPort; uint16_t _rtcpFilterPort;
UdpTransportData* _packetCallback; UdpTransportData* _packetCallback;
}; };

View File

@@ -28,21 +28,20 @@ namespace test {
class MockUdpSocketWrapper : public UdpSocketWrapper { class MockUdpSocketWrapper : public UdpSocketWrapper {
public: public:
// The following methods have to be mocked because they are pure. // The following methods have to be mocked because they are pure.
MOCK_METHOD1(ChangeUniqueId, WebRtc_Word32(WebRtc_Word32)); MOCK_METHOD1(ChangeUniqueId, int32_t(int32_t));
MOCK_METHOD2(SetCallback, bool(CallbackObj, IncomingSocketCallback)); MOCK_METHOD2(SetCallback, bool(CallbackObj, IncomingSocketCallback));
MOCK_METHOD1(Bind, bool(const SocketAddress&)); MOCK_METHOD1(Bind, bool(const SocketAddress&));
MOCK_METHOD0(ValidHandle, bool()); MOCK_METHOD0(ValidHandle, bool());
MOCK_METHOD4(SetSockopt, bool(WebRtc_Word32, WebRtc_Word32, MOCK_METHOD4(SetSockopt, bool(int32_t, int32_t,
const WebRtc_Word8*, const int8_t*,
WebRtc_Word32)); int32_t));
MOCK_METHOD1(SetTOS, WebRtc_Word32(WebRtc_Word32)); MOCK_METHOD1(SetTOS, int32_t(int32_t));
MOCK_METHOD3(SendTo, WebRtc_Word32(const WebRtc_Word8*, WebRtc_Word32, MOCK_METHOD3(SendTo, int32_t(const int8_t*, int32_t, const SocketAddress&));
const SocketAddress&)); MOCK_METHOD8(SetQos, bool(int32_t, int32_t,
MOCK_METHOD8(SetQos, bool(WebRtc_Word32, WebRtc_Word32, int32_t, int32_t,
WebRtc_Word32, WebRtc_Word32, int32_t, int32_t,
WebRtc_Word32, WebRtc_Word32,
const SocketAddress &, const SocketAddress &,
WebRtc_Word32)); int32_t));
}; };
class MockUdpSocketManager : public UdpSocketManager { class MockUdpSocketManager : public UdpSocketManager {
@@ -51,8 +50,8 @@ class MockUdpSocketManager : public UdpSocketManager {
void Destroy() { void Destroy() {
delete this; delete this;
} }
MOCK_METHOD2(Init, bool(WebRtc_Word32, WebRtc_UWord8&)); MOCK_METHOD2(Init, bool(int32_t, uint8_t&));
MOCK_METHOD1(ChangeUniqueId, WebRtc_Word32(const WebRtc_Word32)); MOCK_METHOD1(ChangeUniqueId, int32_t(const int32_t));
MOCK_METHOD0(Start, bool()); MOCK_METHOD0(Start, bool());
MOCK_METHOD0(Stop, bool()); MOCK_METHOD0(Stop, bool());
MOCK_METHOD1(AddSocket, bool(UdpSocketWrapper*)); MOCK_METHOD1(AddSocket, bool(UdpSocketWrapper*));
@@ -65,7 +64,7 @@ class MockSocketFactory :
MockSocketFactory(std::vector<MockUdpSocketWrapper*>* socket_counter) MockSocketFactory(std::vector<MockUdpSocketWrapper*>* socket_counter)
: socket_counter_(socket_counter) { : socket_counter_(socket_counter) {
} }
UdpSocketWrapper* CreateSocket(const WebRtc_Word32 id, UdpSocketWrapper* CreateSocket(const int32_t id,
UdpSocketManager* mgr, UdpSocketManager* mgr,
CallbackObj obj, CallbackObj obj,
IncomingSocketCallback cb, IncomingSocketCallback cb,
@@ -110,15 +109,15 @@ private:
}; };
TEST_F(UDPTransportTest, CreateTransport) { TEST_F(UDPTransportTest, CreateTransport) {
WebRtc_Word32 id = 0; int32_t id = 0;
WebRtc_UWord8 threads = 1; uint8_t threads = 1;
UdpTransport* transport = UdpTransport::Create(id, threads); UdpTransport* transport = UdpTransport::Create(id, threads);
UdpTransport::Destroy(transport); UdpTransport::Destroy(transport);
} }
// This test verifies that the mock_socket is not called from the constructor. // This test verifies that the mock_socket is not called from the constructor.
TEST_F(UDPTransportTest, ConstructorDoesNotCreateSocket) { TEST_F(UDPTransportTest, ConstructorDoesNotCreateSocket) {
WebRtc_Word32 id = 0; int32_t id = 0;
UdpTransportImpl::SocketFactoryInterface* null_maker = NULL; UdpTransportImpl::SocketFactoryInterface* null_maker = NULL;
UdpSocketManager* null_manager = NULL; UdpSocketManager* null_manager = NULL;
UdpTransport* transport = new UdpTransportImpl(id, UdpTransport* transport = new UdpTransportImpl(id,
@@ -128,7 +127,7 @@ TEST_F(UDPTransportTest, ConstructorDoesNotCreateSocket) {
} }
TEST_F(UDPTransportTest, InitializeSourcePorts) { TEST_F(UDPTransportTest, InitializeSourcePorts) {
WebRtc_Word32 id = 0; int32_t id = 0;
UdpTransportImpl::SocketFactoryInterface* mock_maker UdpTransportImpl::SocketFactoryInterface* mock_maker
= new MockSocketFactory(sockets_created()); = new MockSocketFactory(sockets_created());
MockUdpSocketManager* mock_manager = new MockUdpSocketManager(); MockUdpSocketManager* mock_manager = new MockUdpSocketManager();

View File

@@ -58,7 +58,7 @@ void FrameReaderImpl::Close() {
} }
} }
bool FrameReaderImpl::ReadFrame(WebRtc_UWord8* source_buffer) { bool FrameReaderImpl::ReadFrame(uint8_t* source_buffer) {
assert(source_buffer); assert(source_buffer);
if (input_file_ == NULL) { if (input_file_ == NULL) {
fprintf(stderr, "FrameReader is not initialized (input file is NULL)\n"); fprintf(stderr, "FrameReader is not initialized (input file is NULL)\n");

View File

@@ -33,7 +33,7 @@ class FrameReader {
// for the frame size. // for the frame size.
// Returns true if there are more frames to read, false if we've already // Returns true if there are more frames to read, false if we've already
// read the last frame (in the previous call). // read the last frame (in the previous call).
virtual bool ReadFrame(WebRtc_UWord8* source_buffer) = 0; virtual bool ReadFrame(uint8_t* source_buffer) = 0;
// Closes the input file if open. Essentially makes this class impossible // Closes the input file if open. Essentially makes this class impossible
// to use anymore. Will also be invoked by the destructor. // to use anymore. Will also be invoked by the destructor.
@@ -55,7 +55,7 @@ class FrameReaderImpl : public FrameReader {
FrameReaderImpl(std::string input_filename, size_t frame_length_in_bytes); FrameReaderImpl(std::string input_filename, size_t frame_length_in_bytes);
virtual ~FrameReaderImpl(); virtual ~FrameReaderImpl();
bool Init(); bool Init();
bool ReadFrame(WebRtc_UWord8* source_buffer); bool ReadFrame(uint8_t* source_buffer);
void Close(); void Close();
size_t FrameLength() { return frame_length_in_bytes_; } size_t FrameLength() { return frame_length_in_bytes_; }
int NumberOfFrames() { return number_of_frames_; } int NumberOfFrames() { return number_of_frames_; }

View File

@@ -54,7 +54,7 @@ TEST_F(FrameReaderTest, InitSuccess) {
} }
TEST_F(FrameReaderTest, ReadFrame) { TEST_F(FrameReaderTest, ReadFrame) {
WebRtc_UWord8 buffer[3]; uint8_t buffer[3];
bool result = frame_reader_->ReadFrame(buffer); bool result = frame_reader_->ReadFrame(buffer);
ASSERT_FALSE(result); // No more files to read. ASSERT_FALSE(result); // No more files to read.
ASSERT_EQ(kInputFileContents[0], buffer[0]); ASSERT_EQ(kInputFileContents[0], buffer[0]);
@@ -63,7 +63,7 @@ TEST_F(FrameReaderTest, ReadFrame) {
} }
TEST_F(FrameReaderTest, ReadFrameUninitialized) { TEST_F(FrameReaderTest, ReadFrameUninitialized) {
WebRtc_UWord8 buffer[3]; uint8_t buffer[3];
FrameReaderImpl file_reader(kInputFilename, kFrameLength); FrameReaderImpl file_reader(kInputFilename, kFrameLength);
ASSERT_FALSE(file_reader.ReadFrame(buffer)); ASSERT_FALSE(file_reader.ReadFrame(buffer));
} }

View File

@@ -48,7 +48,7 @@ void FrameWriterImpl::Close() {
} }
} }
bool FrameWriterImpl::WriteFrame(WebRtc_UWord8* frame_buffer) { bool FrameWriterImpl::WriteFrame(uint8_t* frame_buffer) {
assert(frame_buffer); assert(frame_buffer);
if (output_file_ == NULL) { if (output_file_ == NULL) {
fprintf(stderr, "FrameWriter is not initialized (output file is NULL)\n"); fprintf(stderr, "FrameWriter is not initialized (output file is NULL)\n");

View File

@@ -31,7 +31,7 @@ class FrameWriter {
// Writes a frame of the configured frame length to the output file. // Writes a frame of the configured frame length to the output file.
// Returns true if the write was successful, false otherwise. // Returns true if the write was successful, false otherwise.
virtual bool WriteFrame(WebRtc_UWord8* frame_buffer) = 0; virtual bool WriteFrame(uint8_t* frame_buffer) = 0;
// Closes the output file if open. Essentially makes this class impossible // Closes the output file if open. Essentially makes this class impossible
// to use anymore. Will also be invoked by the destructor. // to use anymore. Will also be invoked by the destructor.
@@ -53,7 +53,7 @@ class FrameWriterImpl : public FrameWriter {
FrameWriterImpl(std::string output_filename, size_t frame_length_in_bytes); FrameWriterImpl(std::string output_filename, size_t frame_length_in_bytes);
virtual ~FrameWriterImpl(); virtual ~FrameWriterImpl();
bool Init(); bool Init();
bool WriteFrame(WebRtc_UWord8* frame_buffer); bool WriteFrame(uint8_t* frame_buffer);
void Close(); void Close();
size_t FrameLength() { return frame_length_in_bytes_; } size_t FrameLength() { return frame_length_in_bytes_; }

View File

@@ -44,7 +44,7 @@ TEST_F(FrameWriterTest, InitSuccess) {
} }
TEST_F(FrameWriterTest, WriteFrame) { TEST_F(FrameWriterTest, WriteFrame) {
WebRtc_UWord8 buffer[kFrameLength]; uint8_t buffer[kFrameLength];
memset(buffer, 9, kFrameLength); // Write lots of 9s to the buffer memset(buffer, 9, kFrameLength); // Write lots of 9s to the buffer
bool result = frame_writer_->WriteFrame(buffer); bool result = frame_writer_->WriteFrame(buffer);
ASSERT_TRUE(result); // success ASSERT_TRUE(result); // success
@@ -54,7 +54,7 @@ TEST_F(FrameWriterTest, WriteFrame) {
} }
TEST_F(FrameWriterTest, WriteFrameUninitialized) { TEST_F(FrameWriterTest, WriteFrameUninitialized) {
WebRtc_UWord8 buffer[3]; uint8_t buffer[3];
FrameWriterImpl frame_writer(kOutputFilename, kFrameLength); FrameWriterImpl frame_writer(kOutputFilename, kFrameLength);
ASSERT_FALSE(frame_writer.WriteFrame(buffer)); ASSERT_FALSE(frame_writer.WriteFrame(buffer));
} }

View File

@@ -21,7 +21,7 @@ namespace test {
class MockFrameReader : public FrameReader { class MockFrameReader : public FrameReader {
public: public:
MOCK_METHOD0(Init, bool()); MOCK_METHOD0(Init, bool());
MOCK_METHOD1(ReadFrame, bool(WebRtc_UWord8* source_buffer)); MOCK_METHOD1(ReadFrame, bool(uint8_t* source_buffer));
MOCK_METHOD0(Close, void()); MOCK_METHOD0(Close, void());
MOCK_METHOD0(FrameLength, size_t()); MOCK_METHOD0(FrameLength, size_t());
MOCK_METHOD0(NumberOfFrames, int()); MOCK_METHOD0(NumberOfFrames, int());

View File

@@ -21,7 +21,7 @@ namespace test {
class MockFrameWriter : public FrameWriter { class MockFrameWriter : public FrameWriter {
public: public:
MOCK_METHOD0(Init, bool()); MOCK_METHOD0(Init, bool());
MOCK_METHOD1(WriteFrame, bool(WebRtc_UWord8* frame_buffer)); MOCK_METHOD1(WriteFrame, bool(uint8_t* frame_buffer));
MOCK_METHOD0(Close, void()); MOCK_METHOD0(Close, void());
MOCK_METHOD0(FrameLength, size_t()); MOCK_METHOD0(FrameLength, size_t());
}; };

View File

@@ -21,7 +21,7 @@ PacketReader::PacketReader()
PacketReader::~PacketReader() {} PacketReader::~PacketReader() {}
void PacketReader::InitializeReading(WebRtc_UWord8* data, void PacketReader::InitializeReading(uint8_t* data,
int data_length_in_bytes, int data_length_in_bytes,
int packet_size_in_bytes) { int packet_size_in_bytes) {
assert(data); assert(data);
@@ -34,7 +34,7 @@ void PacketReader::InitializeReading(WebRtc_UWord8* data,
initialized_ = true; initialized_ = true;
} }
int PacketReader::NextPacket(WebRtc_UWord8** packet_pointer) { int PacketReader::NextPacket(uint8_t** packet_pointer) {
if (!initialized_) { if (!initialized_) {
fprintf(stderr, "Attempting to use uninitialized PacketReader!\n"); fprintf(stderr, "Attempting to use uninitialized PacketReader!\n");
return -1; return -1;

View File

@@ -11,7 +11,7 @@
#ifndef WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_ #ifndef WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_
#define WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_ #define WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_
#include "typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
namespace test { namespace test {
@@ -28,7 +28,7 @@ class PacketReader {
// 0 length will result in no packets are read. // 0 length will result in no packets are read.
// * packet_size_in_bytes is the number of bytes to read in each NextPacket // * packet_size_in_bytes is the number of bytes to read in each NextPacket
// method call. Must be > 0 // method call. Must be > 0
virtual void InitializeReading(WebRtc_UWord8* data, int data_length_in_bytes, virtual void InitializeReading(uint8_t* data, int data_length_in_bytes,
int packet_size_in_bytes); int packet_size_in_bytes);
// Moves the supplied pointer to the beginning of the next packet. // Moves the supplied pointer to the beginning of the next packet.
@@ -37,10 +37,10 @@ class PacketReader {
// the last packet) // the last packet)
// * 0 if there are no more packets to read // * 0 if there are no more packets to read
// * -1 if InitializeReading has not been called (also prints to stderr). // * -1 if InitializeReading has not been called (also prints to stderr).
virtual int NextPacket(WebRtc_UWord8** packet_pointer); virtual int NextPacket(uint8_t** packet_pointer);
private: private:
WebRtc_UWord8* data_; uint8_t* data_;
int data_length_; int data_length_;
int packet_size_; int packet_size_;
int currentIndex_; int currentIndex_;

View File

@@ -28,8 +28,8 @@ class PacketReaderTest: public PacketRelatedTest {
} }
void VerifyPacketData(int expected_length, void VerifyPacketData(int expected_length,
int actual_length, int actual_length,
WebRtc_UWord8* original_data_pointer, uint8_t* original_data_pointer,
WebRtc_UWord8* new_data_pointer) { uint8_t* new_data_pointer) {
EXPECT_EQ(expected_length, actual_length); EXPECT_EQ(expected_length, actual_length);
EXPECT_EQ(*original_data_pointer, *new_data_pointer); EXPECT_EQ(*original_data_pointer, *new_data_pointer);
EXPECT_EQ(0, memcmp(original_data_pointer, new_data_pointer, EXPECT_EQ(0, memcmp(original_data_pointer, new_data_pointer,
@@ -40,7 +40,7 @@ class PacketReaderTest: public PacketRelatedTest {
// Test lack of initialization // Test lack of initialization
TEST_F(PacketReaderTest, Uninitialized) { TEST_F(PacketReaderTest, Uninitialized) {
WebRtc_UWord8* data_pointer = NULL; uint8_t* data_pointer = NULL;
EXPECT_EQ(-1, reader_->NextPacket(&data_pointer)); EXPECT_EQ(-1, reader_->NextPacket(&data_pointer));
EXPECT_EQ(NULL, data_pointer); EXPECT_EQ(NULL, data_pointer);
} }
@@ -53,8 +53,8 @@ TEST_F(PacketReaderTest, InitializeZeroLengthArgument) {
// Test with something smaller than one packet // Test with something smaller than one packet
TEST_F(PacketReaderTest, NormalSmallData) { TEST_F(PacketReaderTest, NormalSmallData) {
const int kDataLengthInBytes = 1499; const int kDataLengthInBytes = 1499;
WebRtc_UWord8 data[kDataLengthInBytes]; uint8_t data[kDataLengthInBytes];
WebRtc_UWord8* data_pointer = data; uint8_t* data_pointer = data;
memset(data, 1, kDataLengthInBytes); memset(data, 1, kDataLengthInBytes);
reader_->InitializeReading(data, kDataLengthInBytes, kPacketSizeInBytes); reader_->InitializeReading(data, kDataLengthInBytes, kPacketSizeInBytes);
@@ -70,8 +70,8 @@ TEST_F(PacketReaderTest, NormalSmallData) {
// Test with data length that exactly matches one packet // Test with data length that exactly matches one packet
TEST_F(PacketReaderTest, NormalOnePacketData) { TEST_F(PacketReaderTest, NormalOnePacketData) {
WebRtc_UWord8 data[kPacketSizeInBytes]; uint8_t data[kPacketSizeInBytes];
WebRtc_UWord8* data_pointer = data; uint8_t* data_pointer = data;
memset(data, 1, kPacketSizeInBytes); memset(data, 1, kPacketSizeInBytes);
reader_->InitializeReading(data, kPacketSizeInBytes, kPacketSizeInBytes); reader_->InitializeReading(data, kPacketSizeInBytes, kPacketSizeInBytes);
@@ -112,8 +112,8 @@ TEST_F(PacketReaderTest, NormalLargeData) {
TEST_F(PacketReaderTest, EmptyData) { TEST_F(PacketReaderTest, EmptyData) {
const int kDataLengthInBytes = 0; const int kDataLengthInBytes = 0;
// But don't really try to allocate a zero-length array... // But don't really try to allocate a zero-length array...
WebRtc_UWord8 data[kPacketSizeInBytes]; uint8_t data[kPacketSizeInBytes];
WebRtc_UWord8* data_pointer = data; uint8_t* data_pointer = data;
reader_->InitializeReading(data, kDataLengthInBytes, kPacketSizeInBytes); reader_->InitializeReading(data, kDataLengthInBytes, kPacketSizeInBytes);
EXPECT_EQ(kDataLengthInBytes, reader_->NextPacket(&data_pointer)); EXPECT_EQ(kDataLengthInBytes, reader_->NextPacket(&data_pointer));
// Do it again to make sure nothing changes // Do it again to make sure nothing changes

View File

@@ -26,12 +26,12 @@ const int kPacketDataNumberOfPackets = 3;
class PacketRelatedTest: public testing::Test { class PacketRelatedTest: public testing::Test {
protected: protected:
// Tree packet byte arrays with data used for verification: // Tree packet byte arrays with data used for verification:
WebRtc_UWord8 packet1_[kPacketSizeInBytes]; uint8_t packet1_[kPacketSizeInBytes];
WebRtc_UWord8 packet2_[kPacketSizeInBytes]; uint8_t packet2_[kPacketSizeInBytes];
WebRtc_UWord8 packet3_[1]; uint8_t packet3_[1];
// Construct a data structure containing these packets // Construct a data structure containing these packets
WebRtc_UWord8 packet_data_[kPacketDataLength]; uint8_t packet_data_[kPacketDataLength];
WebRtc_UWord8* packet_data_pointer_; uint8_t* packet_data_pointer_;
PacketRelatedTest() { PacketRelatedTest() {
packet_data_pointer_ = packet_data_; packet_data_pointer_ = packet_data_;