OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 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 |
| 11 #ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |
| 12 #define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |
| 13 |
| 14 #include <string> |
| 15 #include <vector> |
| 16 |
| 17 #include "webrtc/base/sigslot.h" |
| 18 |
| 19 namespace rtc { |
| 20 struct PacketOptions; |
| 21 struct PacketTime; |
| 22 |
| 23 struct PacketTransportInterface : public sigslot::has_slots<> { |
| 24 virtual ~PacketTransportInterface() {} |
| 25 virtual const std::string debug_name() const = 0; |
| 26 virtual bool writable() const = 0; |
| 27 |
| 28 // Attempts to send the given packet. The return value is < 0 on failure. |
| 29 // TODO(johan): Remove the default argument once channel code is updated. |
| 30 virtual int SendPacket(const char* data, |
| 31 size_t len, |
| 32 const rtc::PacketOptions& options, |
| 33 int flags = 0) = 0; |
| 34 |
| 35 // Sets a socket option. Note that not all options are |
| 36 // supported by all transport types. |
| 37 virtual int SetOption(rtc::Socket::Option opt, int value) = 0; |
| 38 |
| 39 // TODO(pthatcher): Once Chrome's MockPacketTransportInterface implments |
| 40 // this, remove the default implementation. |
| 41 virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } |
| 42 |
| 43 // Returns the most recent error that occurred on this channel. |
| 44 virtual int GetError() = 0; |
| 45 |
| 46 sigslot::signal1<PacketTransportInterface*> SignalWritableState; |
| 47 |
| 48 // Emitted when the PacketTransportInterface's ability to send has changed. |
| 49 sigslot::signal1<PacketTransportInterface*> SignalReadyToSend; |
| 50 |
| 51 // Signalled each time a packet is received on this channel. |
| 52 sigslot::signal5<PacketTransportInterface*, |
| 53 const char*, |
| 54 size_t, |
| 55 const rtc::PacketTime&, |
| 56 int> |
| 57 SignalReadPacket; |
| 58 |
| 59 // Signalled each time a packet is sent on this channel. |
| 60 sigslot::signal2<PacketTransportInterface*, const rtc::SentPacket&> |
| 61 SignalSentPacket; |
| 62 }; |
| 63 |
| 64 } // namespace rtc |
| 65 |
| 66 #endif // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |
OLD | NEW |