@@ -25,8 +25,10 @@ static webrtc::CriticalSectionWrapper* _fake_peer_connection_cs = webrtc::Critic
25
25
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> _fake_peer_connection (webrtc::CreatePeerConnectionFactory());
26
26
#endif
27
27
28
- static const char kFirefoxPattern [] = " Firefox" ;
28
+ #if 0
29
+ static const char kFirefoxPattern[] = "Firefox";
29
30
static const char kInternetExplorerPattern[] = "MSIE";
31
+ #endif
30
32
static const char kAutoDetectPattern [] = " " ;
31
33
#if 1
32
34
# define kAgentHoldingProxyInfo kAutoDetectPattern
@@ -38,58 +40,60 @@ static const char kAutoDetectPattern[] = "";
38
40
# endif
39
41
#endif
40
42
43
+ // TODO(mdi): On OSX We have to include "portallocatorfactory.cc" because it seems like "portallocatorfactory.o" is missing in libjingle_peerconnection
44
+ // This could cause duplicated symbols if the bug get fixed by Google
41
45
//
42
46
// _RTCPortAllocatorFactory
43
47
//
44
48
class _RTCPortAllocatorFactory : public webrtc ::PortAllocatorFactory
45
49
{
46
- public:
50
+ public:
47
51
_RTCPortAllocatorFactory (rtc::Thread* worker_thread)
48
52
: webrtc::PortAllocatorFactory(worker_thread)
49
53
{
50
54
51
- }
52
- virtual ~_RTCPortAllocatorFactory ()
53
- {
54
- }
55
-
56
- virtual cricket::PortAllocator* CreatePortAllocator (
57
- const std::vector<StunConfiguration>& stun,
58
- const std::vector<TurnConfiguration>& turn)
59
- {
60
- cricket::PortAllocator* allocator_ = webrtc::PortAllocatorFactory::CreatePortAllocator (stun, turn);
61
- if (allocator_) {
62
- cricket::ProtocolType protocol;
63
- rtc::ProxyInfo proxyInfo;
55
+ }
56
+ virtual ~_RTCPortAllocatorFactory ()
57
+ {
58
+ }
59
+
60
+ virtual cricket::PortAllocator* CreatePortAllocator (
61
+ const std::vector<StunConfiguration>& stun,
62
+ const std::vector<TurnConfiguration>& turn)
63
+ {
64
+ cricket::PortAllocator* allocator_ = webrtc::PortAllocatorFactory::CreatePortAllocator (stun, turn);
65
+ if (allocator_) {
66
+ cricket::ProtocolType protocol;
67
+ rtc::ProxyInfo proxyInfo;
64
68
static const struct {
65
69
std::string scheme;
66
70
rtc::ProxyType proxy_type;
67
71
} PROXIES[] = {
68
72
{ " http" , rtc::ProxyType::PROXY_HTTPS },
69
73
{ " https" , rtc::ProxyType::PROXY_HTTPS },
70
74
{ " socks5" , rtc::ProxyType::PROXY_SOCKS5 }
71
- };
72
- for (size_t i = 0 ; i < turn.size (); ++i) {
73
- if (cricket::StringToProto (turn[i].transport_type .c_str (), &protocol)) {
74
- if (protocol == cricket::ProtocolType::PROTO_TCP || protocol == cricket::ProtocolType::PROTO_SSLTCP) {
75
- for (size_t j = 0 ; j < sizeof (PROXIES) / sizeof (PROXIES[0 ]); ++j) {
76
- std::string url = PROXIES[j].scheme + " ://" + turn[i].server .hostname ();
77
- if (rtc::GetProxySettingsForUrl (kAgentHoldingProxyInfo , url.c_str (), &proxyInfo, false )) {
78
- if (proxyInfo.type != rtc::ProxyType::PROXY_NONE && !proxyInfo.address .IsAnyIP () && !proxyInfo.address .IsLoopbackIP () && proxyInfo.address .hostname () != " localhost" ) {
79
- if (proxyInfo.type == rtc::ProxyType::PROXY_UNKNOWN) {
80
- proxyInfo.type = PROXIES[j].proxy_type ;
81
- }
82
- allocator_->set_proxy (kAgentHoldingProxyInfo , proxyInfo);
83
- goto proxy_done;
84
- }
85
- }
86
- }
87
- }
88
- }
89
- }
90
- }
91
- proxy_done:
92
- return allocator_;
75
+ };
76
+ for (size_t i = 0 ; i < turn.size (); ++i) {
77
+ if (cricket::StringToProto (turn[i].transport_type .c_str (), &protocol)) {
78
+ if (protocol == cricket::ProtocolType::PROTO_TCP || protocol == cricket::ProtocolType::PROTO_SSLTCP) {
79
+ for (size_t j = 0 ; j < sizeof (PROXIES) / sizeof (PROXIES[0 ]); ++j) {
80
+ std::string url = PROXIES[j].scheme + " ://" + turn[i].server .hostname ();
81
+ if (rtc::GetProxySettingsForUrl (kAgentHoldingProxyInfo , url.c_str (), &proxyInfo, false )) {
82
+ if (proxyInfo.type != rtc::ProxyType::PROXY_NONE && !proxyInfo.address .IsAnyIP () && !proxyInfo.address .IsLoopbackIP () && proxyInfo.address .hostname () != " localhost" ) {
83
+ if (proxyInfo.type == rtc::ProxyType::PROXY_UNKNOWN) {
84
+ proxyInfo.type = PROXIES[j].proxy_type ;
85
+ }
86
+ allocator_->set_proxy (kAgentHoldingProxyInfo , proxyInfo);
87
+ goto proxy_done;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ proxy_done:
96
+ return allocator_;
93
97
}
94
98
private:
95
99
@@ -158,7 +162,7 @@ WEBRTC_EVERYWHERE_API rtc::Thread* GetWorkerThread()
158
162
WEBRTC_EVERYWHERE_API rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> GetPortAllocatorFactory ()
159
163
{
160
164
if (!_port_allocator_factory) {
161
- _port_allocator_factory = new rtc::RefCountedObject<_RTCPortAllocatorFactory>(GetWorkerThread ());
165
+ _port_allocator_factory = new rtc::RefCountedObject<_RTCPortAllocatorFactory>(GetWorkerThread ());
162
166
}
163
167
return _port_allocator_factory;
164
168
}
@@ -323,26 +327,26 @@ _File::_File(const char* path, bool write /*= false*/)
323
327
: m_write(write)
324
328
325
329
{
326
- m_file = open (path, write ? O_CREAT | O_RDWR : O_CREAT | O_RDONLY );
330
+ m_file = fopen (path, write ? " w " : " r " );
327
331
}
328
332
329
333
_File::~_File ()
330
334
{
331
335
if (IsValid ()) {
332
- close (m_file);
336
+ fclose (m_file);
333
337
m_file = 0 ;
334
338
}
335
339
}
336
340
337
341
bool _File::IsValid ()const
338
342
{
339
- return m_file != - 1 ;
343
+ return !!m_file ;
340
344
}
341
345
342
346
bool _File::LockInterProcess (bool exclusive /* = false*/ )
343
347
{
344
348
if (IsValid ()) {
345
- if (flock (m_file, exclusive ? LOCK_EX : LOCK_SH) == 0 ) {
349
+ if (flock (fileno ( m_file) , exclusive ? LOCK_EX : LOCK_SH) == 0 ) {
346
350
return true ;
347
351
}
348
352
}
@@ -352,7 +356,7 @@ bool _File::LockInterProcess(bool exclusive /*= false*/)
352
356
bool _File::UnlockInterProcess ()
353
357
{
354
358
if (IsValid ()) {
355
- if (flock (m_file, LOCK_UN) == 0 ) {
359
+ if (flock (fileno ( m_file) , LOCK_UN) == 0 ) {
356
360
return true ;
357
361
}
358
362
}
@@ -364,10 +368,10 @@ cpp11::shared_ptr<_Buffer> _File::Read()
364
368
{
365
369
if (IsValid ()) {
366
370
struct stat _stat;
367
- if (fstat (m_file, &_stat) == 0 && _stat.st_size ) {
371
+ if (fstat (fileno ( m_file) , &_stat) == 0 && _stat.st_size ) {
368
372
cpp11::shared_ptr<_Buffer> buffer (new _Buffer (NULL , (size_t )_stat.st_size ));
369
373
if (buffer && buffer->getPtr ()) {
370
- if (read (m_file, (void *)buffer->getPtr (), buffer->getSize ()) == buffer->getSize ()) {
374
+ if (read (fileno ( m_file) , (void *)buffer->getPtr (), buffer->getSize ()) == buffer->getSize ()) {
371
375
return buffer;
372
376
}
373
377
}
@@ -380,15 +384,15 @@ bool _File::Write(cpp11::shared_ptr<_Buffer>& buffer, bool append /*= false*/)
380
384
{
381
385
if (IsValid () && buffer && buffer->getPtr () && buffer->getSize ()) {
382
386
if (!append) {
383
- FILE* fp = fdopen (m_file, " w" ); // will be closed when close() is called
387
+ FILE* fp = fdopen (fileno ( m_file) , " w" ); // will be closed when close() is called
384
388
if (!fp) {
385
389
return false ;
386
390
}
387
391
rewind (fp);
388
392
}
389
- if (write (m_file, buffer->getPtr (), buffer->getSize ()) == buffer->getSize ()) {
393
+ if (write (fileno ( m_file) , buffer->getPtr (), buffer->getSize ()) == buffer->getSize ()) {
390
394
if (!append) {
391
- if (ftruncate (m_file, buffer->getSize ()) != 0 ) {
395
+ if (ftruncate (fileno ( m_file) , buffer->getSize ()) != 0 ) {
392
396
return false ;
393
397
}
394
398
}
@@ -404,7 +408,7 @@ bool _File::GetModificationTime(_FTIME *time)
404
408
#define LONG long
405
409
if (IsValid ()) {
406
410
struct stat _stat;
407
- if (fstat (m_file, &_stat) == 0 ) {
411
+ if (fstat (fileno ( m_file) , &_stat) == 0 ) {
408
412
time_t tt = (time_t )_stat.st_mtimespec .tv_sec ;
409
413
LONGLONG ll = Int32x32To64 (tt, 10000000 ) + 116444736000000000 ;
410
414
time ->dwLowDateTime = (unsigned long ) ll;
0 commit comments