Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: webrtc/test/channel_transport/udp_transport_impl.cc

Issue 1369263002: Unify Transport and newapi::Transport interfaces. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 { 1849 {
1850 return _ptrSendRtpSocket->SendTo(data,length,to); 1850 return _ptrSendRtpSocket->SendTo(data,length,to);
1851 1851
1852 } else if(_ptrRtpSocket) 1852 } else if(_ptrRtpSocket)
1853 { 1853 {
1854 return _ptrRtpSocket->SendTo(data,length,to); 1854 return _ptrRtpSocket->SendTo(data,length,to);
1855 } 1855 }
1856 return -1; 1856 return -1;
1857 } 1857 }
1858 1858
1859 int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, 1859 int32_t UdpTransportImpl::SendRtcpTo(const int8_t* data,
1860 size_t length, 1860 size_t length,
1861 const SocketAddress& to) 1861 const SocketAddress& to)
1862 { 1862 {
1863 1863
1864 CriticalSectionScoped cs(_crit); 1864 CriticalSectionScoped cs(_crit);
1865 1865
1866 if(_ptrSendRtcpSocket) 1866 if(_ptrSendRtcpSocket)
1867 { 1867 {
1868 return _ptrSendRtcpSocket->SendTo(data,length,to); 1868 return _ptrSendRtcpSocket->SendTo(data,length,to);
1869 1869
(...skipping 25 matching lines...) Expand all
1895 { 1895 {
1896 return _ptrSendRtpSocket->SendTo(data,length,to); 1896 return _ptrSendRtpSocket->SendTo(data,length,to);
1897 1897
1898 } else if(_ptrRtpSocket) 1898 } else if(_ptrRtpSocket)
1899 { 1899 {
1900 return _ptrRtpSocket->SendTo(data,length,to); 1900 return _ptrRtpSocket->SendTo(data,length,to);
1901 } 1901 }
1902 return -1; 1902 return -1;
1903 } 1903 }
1904 1904
1905 int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, 1905 int32_t UdpTransportImpl::SendRtcpTo(const int8_t* data,
1906 size_t length, 1906 size_t length,
1907 const uint16_t rtcpPort) 1907 const uint16_t rtcpPort)
1908 { 1908 {
1909 CriticalSectionScoped cs(_crit); 1909 CriticalSectionScoped cs(_crit);
1910 1910
1911 // Use the current SocketAdress but update it with rtcpPort. 1911 // Use the current SocketAdress but update it with rtcpPort.
1912 SocketAddress to; 1912 SocketAddress to;
1913 memcpy(&to, &_remoteRTCPAddr, sizeof(SocketAddress)); 1913 memcpy(&to, &_remoteRTCPAddr, sizeof(SocketAddress));
1914 1914
1915 if(_ipV6Enabled) 1915 if(_ipV6Enabled)
1916 { 1916 {
1917 to._sockaddr_in6.sin6_port = Htons(rtcpPort); 1917 to._sockaddr_in6.sin6_port = Htons(rtcpPort);
1918 } else 1918 } else
1919 { 1919 {
1920 to._sockaddr_in.sin_port = Htons(rtcpPort); 1920 to._sockaddr_in.sin_port = Htons(rtcpPort);
1921 } 1921 }
1922 1922
1923 if(_ptrSendRtcpSocket) 1923 if(_ptrSendRtcpSocket)
1924 { 1924 {
1925 return _ptrSendRtcpSocket->SendTo(data,length,to); 1925 return _ptrSendRtcpSocket->SendTo(data,length,to);
1926 1926
1927 } else if(_ptrRtcpSocket) 1927 } else if(_ptrRtcpSocket)
1928 { 1928 {
1929 return _ptrRtcpSocket->SendTo(data,length,to); 1929 return _ptrRtcpSocket->SendTo(data,length,to);
1930 } 1930 }
1931 return -1; 1931 return -1;
1932 } 1932 }
1933 1933
1934 int UdpTransportImpl::SendPacket(const void* data, size_t length) { 1934 bool UdpTransportImpl::SendRtp(const uint8_t* data, size_t length) {
1935 WEBRTC_TRACE(kTraceStream, kTraceTransport, _id, "%s", __FUNCTION__); 1935 WEBRTC_TRACE(kTraceStream, kTraceTransport, _id, "%s", __FUNCTION__);
1936 1936
1937 CriticalSectionScoped cs(_crit); 1937 CriticalSectionScoped cs(_crit);
1938 1938
1939 if(_destIP[0] == 0) 1939 if(_destIP[0] == 0)
1940 { 1940 {
1941 return -1; 1941 return false;
1942 } 1942 }
1943 if(_destPort == 0) 1943 if(_destPort == 0)
1944 { 1944 {
1945 return -1; 1945 return false;
1946 } 1946 }
1947 1947
1948 // Create socket if it hasn't been set up already. 1948 // Create socket if it hasn't been set up already.
1949 // TODO (hellner): why not fail here instead. Sockets not being initialized 1949 // TODO (hellner): why not fail here instead. Sockets not being initialized
1950 // indicates that there is a problem somewhere. 1950 // indicates that there is a problem somewhere.
1951 if( _ptrSendRtpSocket == NULL && 1951 if( _ptrSendRtpSocket == NULL &&
1952 _ptrRtpSocket == NULL) 1952 _ptrRtpSocket == NULL)
1953 { 1953 {
1954 WEBRTC_TRACE( 1954 WEBRTC_TRACE(
1955 kTraceStateInfo, 1955 kTraceStateInfo,
(...skipping 17 matching lines...) Expand all
1973 } 1973 }
1974 _localPort = _destPort; 1974 _localPort = _destPort;
1975 1975
1976 ErrorCode retVal = BindLocalRTPSocket(); 1976 ErrorCode retVal = BindLocalRTPSocket();
1977 if(retVal != kNoSocketError) 1977 if(retVal != kNoSocketError)
1978 { 1978 {
1979 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, 1979 WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
1980 "SendPacket() failed to bind RTP socket"); 1980 "SendPacket() failed to bind RTP socket");
1981 _lastError = retVal; 1981 _lastError = retVal;
1982 CloseReceiveSockets(); 1982 CloseReceiveSockets();
1983 return -1; 1983 return false;
1984 } 1984 }
1985 } 1985 }
1986 1986
1987 if(_ptrSendRtpSocket) 1987 if(_ptrSendRtpSocket)
1988 { 1988 {
1989 return _ptrSendRtpSocket->SendTo((const int8_t*)data, length, 1989 return _ptrSendRtpSocket->SendTo((const int8_t*)data, length,
1990 _remoteRTPAddr); 1990 _remoteRTPAddr) >= 0;
1991 1991
1992 } else if(_ptrRtpSocket) 1992 } else if(_ptrRtpSocket)
1993 { 1993 {
1994 return _ptrRtpSocket->SendTo((const int8_t*)data, length, 1994 return _ptrRtpSocket->SendTo((const int8_t*)data, length,
1995 _remoteRTPAddr); 1995 _remoteRTPAddr) >= 0;
1996 } 1996 }
1997 return -1; 1997 return false;
1998 } 1998 }
1999 1999
2000 int UdpTransportImpl::SendRTCPPacket(const void* data, size_t length) { 2000 bool UdpTransportImpl::SendRtcp(const uint8_t* data, size_t length) {
2001 CriticalSectionScoped cs(_crit); 2001 CriticalSectionScoped cs(_crit);
2002 if(_destIP[0] == 0) 2002 if(_destIP[0] == 0)
2003 { 2003 {
2004 return -1; 2004 return false;
2005 } 2005 }
2006 if(_destPortRTCP == 0) 2006 if(_destPortRTCP == 0)
2007 { 2007 {
2008 return -1; 2008 return false;
2009 } 2009 }
2010 2010
2011 // Create socket if it hasn't been set up already. 2011 // Create socket if it hasn't been set up already.
2012 // TODO (hellner): why not fail here instead. Sockets not being initialized 2012 // TODO (hellner): why not fail here instead. Sockets not being initialized
2013 // indicates that there is a problem somewhere. 2013 // indicates that there is a problem somewhere.
2014 if( _ptrSendRtcpSocket == NULL && 2014 if( _ptrSendRtcpSocket == NULL &&
2015 _ptrRtcpSocket == NULL) 2015 _ptrRtcpSocket == NULL)
2016 { 2016 {
2017 WEBRTC_TRACE( 2017 WEBRTC_TRACE(
2018 kTraceStateInfo, 2018 kTraceStateInfo,
(...skipping 15 matching lines...) Expand all
2034 strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000", 2034 strncpy(_localIP, "0000:0000:0000:0000:0000:0000:0000:0000",
2035 kIpAddressVersion6Length); 2035 kIpAddressVersion6Length);
2036 } 2036 }
2037 _localPortRTCP = _destPortRTCP; 2037 _localPortRTCP = _destPortRTCP;
2038 2038
2039 ErrorCode retVal = BindLocalRTCPSocket(); 2039 ErrorCode retVal = BindLocalRTCPSocket();
2040 if(retVal != kNoSocketError) 2040 if(retVal != kNoSocketError)
2041 { 2041 {
2042 _lastError = retVal; 2042 _lastError = retVal;
2043 WEBRTC_TRACE(kTraceError, kTraceTransport, _id, 2043 WEBRTC_TRACE(kTraceError, kTraceTransport, _id,
2044 "SendRTCPPacket() failed to bind RTCP socket"); 2044 "SendRtcp() failed to bind RTCP socket");
2045 CloseReceiveSockets(); 2045 CloseReceiveSockets();
2046 return -1; 2046 return false;
2047 } 2047 }
2048 } 2048 }
2049 2049
2050 if(_ptrSendRtcpSocket) 2050 if(_ptrSendRtcpSocket)
2051 { 2051 {
2052 return _ptrSendRtcpSocket->SendTo((const int8_t*)data, length, 2052 return _ptrSendRtcpSocket->SendTo((const int8_t*)data, length,
2053 _remoteRTCPAddr); 2053 _remoteRTCPAddr) >= 0;
2054 } else if(_ptrRtcpSocket) 2054 } else if(_ptrRtcpSocket)
2055 { 2055 {
2056 return _ptrRtcpSocket->SendTo((const int8_t*)data, length, 2056 return _ptrRtcpSocket->SendTo((const int8_t*)data, length,
2057 _remoteRTCPAddr); 2057 _remoteRTCPAddr) >= 0;
2058 } 2058 }
2059 return -1; 2059 return false;
2060 } 2060 }
2061 2061
2062 int32_t UdpTransportImpl::SetSendIP(const char* ipaddr) 2062 int32_t UdpTransportImpl::SetSendIP(const char* ipaddr)
2063 { 2063 {
2064 if(!IsIpAddressValid(ipaddr,IpV6Enabled())) 2064 if(!IsIpAddressValid(ipaddr,IpV6Enabled()))
2065 { 2065 {
2066 return kIpAddressInvalid; 2066 return kIpAddressInvalid;
2067 } 2067 }
2068 CriticalSectionScoped cs(_crit); 2068 CriticalSectionScoped cs(_crit);
2069 strncpy(_destIP, ipaddr,kIpAddressVersion6Length); 2069 strncpy(_destIP, ipaddr,kIpAddressVersion6Length);
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 if (nDots != 3 || !allUnder256) 2983 if (nDots != 3 || !allUnder256)
2984 { 2984 {
2985 return false; 2985 return false;
2986 } 2986 }
2987 } 2987 }
2988 return true; 2988 return true;
2989 } 2989 }
2990 2990
2991 } // namespace test 2991 } // namespace test
2992 } // namespace webrtc 2992 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698