deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 11 | #ifndef WEBRTC_API_ORTC_UDPTRANSPORTINTERFACE_H_ |
| 12 | #define WEBRTC_API_ORTC_UDPTRANSPORTINTERFACE_H_ |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 13 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 14 | #include "webrtc/api/ortc/packettransportinterface.h" |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 15 | #include "webrtc/api/proxy.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 16 | #include "webrtc/rtc_base/socketaddress.h" |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | // Interface for a raw UDP transport (not using ICE), meaning a combination of |
| 21 | // a local/remote IP address/port. |
| 22 | // |
| 23 | // An instance can be instantiated using OrtcFactory. |
| 24 | // |
| 25 | // Each instance reserves a UDP port, which will be freed when the |
| 26 | // UdpTransportInterface destructor is called. |
| 27 | // |
| 28 | // Calling SetRemoteAddress sets the destination of outgoing packets; without a |
| 29 | // destination, packets can't be sent, but they can be received. |
deadbeef | 225bfc0 | 2017-04-06 21:47:33 -0700 | [diff] [blame] | 30 | class UdpTransportInterface : public virtual PacketTransportInterface { |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 31 | public: |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 32 | // Get the address of the socket allocated for this transport. |
| 33 | virtual rtc::SocketAddress GetLocalAddress() const = 0; |
| 34 | |
| 35 | // Sets the address to which packets will be delivered. |
| 36 | // |
| 37 | // Calling with a "nil" (default-constructed) address is legal, and unsets |
| 38 | // any previously set destination. |
| 39 | // |
| 40 | // However, calling with an incomplete address (port or IP not set) will |
| 41 | // fail. |
| 42 | virtual bool SetRemoteAddress(const rtc::SocketAddress& dest) = 0; |
| 43 | // Simple getter. If never set, returns nil address. |
| 44 | virtual rtc::SocketAddress GetRemoteAddress() const = 0; |
| 45 | }; |
| 46 | |
deadbeef | d1c0998 | 2017-01-18 15:16:37 -0800 | [diff] [blame] | 47 | } // namespace webrtc |
| 48 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 49 | #endif // WEBRTC_API_ORTC_UDPTRANSPORTINTERFACE_H_ |