| OLD | NEW | 
|   1 /* |   1 /* | 
|   2  *  Copyright 2016 The WebRTC Project Authors. All rights reserved. |   2  *  Copyright 2016 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  | 
|  11 #ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |  11 #ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ | 
|  12 #define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |  12 #define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ | 
|  13  |  13  | 
 |  14 #include <string> | 
 |  15 #include <vector> | 
 |  16  | 
 |  17 #include "webrtc/base/sigslot.h" | 
 |  18 #include "webrtc/base/socket.h" | 
 |  19  | 
|  14 namespace cricket { |  20 namespace cricket { | 
|  15 class TransportChannel; |  21 class TransportChannel; | 
|  16 } |  22 } | 
|  17  |  23  | 
|  18 namespace rtc { |  24 namespace rtc { | 
|  19 typedef cricket::TransportChannel PacketTransportInterface; |  25 struct PacketOptions; | 
|  20 } |  26 struct PacketTime; | 
 |  27 struct SentPacket; | 
 |  28  | 
 |  29 class PacketTransportInterface : public sigslot::has_slots<> { | 
 |  30  public: | 
 |  31   virtual ~PacketTransportInterface() {} | 
 |  32  | 
 |  33   // Identify the object for logging and debug purpose. | 
 |  34   virtual const std::string debug_name() const = 0; | 
 |  35  | 
 |  36   // The transport has been established. | 
 |  37   virtual bool writable() const = 0; | 
 |  38  | 
 |  39   // Attempts to send the given packet. | 
 |  40   // The return value is < 0 on failure. The return value in failure case is not | 
 |  41   // descriptive. Depending on failure cause and implementation details | 
 |  42   // GetError() returns an descriptive errno.h error value. | 
 |  43   // This mimics posix socket send() or sendto() behavior. | 
 |  44   // TODO(johan): Reliable, meaningful, consistent error codes for all | 
 |  45   // implementations would be nice. | 
 |  46   // TODO(johan): Remove the default argument once channel code is updated. | 
 |  47   virtual int SendPacket(const char* data, | 
 |  48                          size_t len, | 
 |  49                          const rtc::PacketOptions& options, | 
 |  50                          int flags = 0) = 0; | 
 |  51  | 
 |  52   // Sets a socket option. Note that not all options are | 
 |  53   // supported by all transport types. | 
 |  54   virtual int SetOption(rtc::Socket::Option opt, int value) = 0; | 
 |  55  | 
 |  56   // TODO(pthatcher): Once Chrome's MockPacketTransportInterface implements | 
 |  57   // this, remove the default implementation. | 
 |  58   virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } | 
 |  59  | 
 |  60   // Returns the most recent error that occurred on this channel. | 
 |  61   virtual int GetError() = 0; | 
 |  62  | 
 |  63   // Emitted when the writable state, represented by |writable()|, changes. | 
 |  64   sigslot::signal1<PacketTransportInterface*> SignalWritableState; | 
 |  65  | 
 |  66   //  Emitted when the PacketTransportInterface is ready to send packets. "Ready | 
 |  67   //  to send" is more sensitive than the writable state; a transport may be | 
 |  68   //  writable, but temporarily not able to send packets. For example, the | 
 |  69   //  underlying transport's socket buffer may be full, as indicated by | 
 |  70   //  SendPacket's return code and/or GetError. | 
 |  71   sigslot::signal1<PacketTransportInterface*> SignalReadyToSend; | 
 |  72  | 
 |  73   // Signalled each time a packet is received on this channel. | 
 |  74   sigslot::signal5<PacketTransportInterface*, | 
 |  75                    const char*, | 
 |  76                    size_t, | 
 |  77                    const rtc::PacketTime&, | 
 |  78                    int> | 
 |  79       SignalReadPacket; | 
 |  80  | 
 |  81   // Signalled each time a packet is sent on this channel. | 
 |  82   sigslot::signal2<PacketTransportInterface*, const rtc::SentPacket&> | 
 |  83       SignalSentPacket; | 
 |  84 }; | 
 |  85  | 
 |  86 }  // namespace rtc | 
|  21  |  87  | 
|  22 #endif  // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ |  88 #endif  // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ | 
| OLD | NEW |