OLD | NEW |
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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |