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

Unified Diff: webrtc/p2p/base/packettransportinterface.h

Issue 2416023002: Introduce rtc::PacketTransportInterface and let cricket::TransportChannel inherit. (Closed)
Patch Set: Rebase. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/transportchannel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/packettransportinterface.h
diff --git a/webrtc/p2p/base/packettransportinterface.h b/webrtc/p2p/base/packettransportinterface.h
index a18081cf72b896a5a1160e08f32e838b9b0b641d..c796c6c2fa11194a1391e7b0b48ba7b277dafdea 100644
--- a/webrtc/p2p/base/packettransportinterface.h
+++ b/webrtc/p2p/base/packettransportinterface.h
@@ -11,12 +11,78 @@
#ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_
#define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_
+#include <string>
+#include <vector>
+
+#include "webrtc/base/sigslot.h"
+#include "webrtc/base/socket.h"
+
namespace cricket {
class TransportChannel;
}
namespace rtc {
-typedef cricket::TransportChannel PacketTransportInterface;
-}
+struct PacketOptions;
+struct PacketTime;
+struct SentPacket;
+
+class PacketTransportInterface : public sigslot::has_slots<> {
+ public:
+ virtual ~PacketTransportInterface() {}
+
+ // Identify the object for logging and debug purpose.
+ virtual const std::string debug_name() const = 0;
+
+ // The transport has been established.
+ virtual bool writable() const = 0;
+
+ // Attempts to send the given packet.
+ // The return value is < 0 on failure. The return value in failure case is not
+ // descriptive. Depending on failure cause and implementation details
+ // GetError() returns an descriptive errno.h error value.
+ // This mimics posix socket send() or sendto() behavior.
+ // TODO(johan): Reliable, meaningful, consistent error codes for all
+ // implementations would be nice.
+ // TODO(johan): Remove the default argument once channel code is updated.
+ virtual int SendPacket(const char* data,
+ size_t len,
+ const rtc::PacketOptions& options,
+ int flags = 0) = 0;
+
+ // Sets a socket option. Note that not all options are
+ // supported by all transport types.
+ virtual int SetOption(rtc::Socket::Option opt, int value) = 0;
+
+ // TODO(pthatcher): Once Chrome's MockPacketTransportInterface implements
+ // this, remove the default implementation.
+ virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; }
+
+ // Returns the most recent error that occurred on this channel.
+ virtual int GetError() = 0;
+
+ // Emitted when the writable state, represented by |writable()|, changes.
+ sigslot::signal1<PacketTransportInterface*> SignalWritableState;
+
+ // Emitted when the PacketTransportInterface is ready to send packets. "Ready
+ // to send" is more sensitive than the writable state; a transport may be
+ // writable, but temporarily not able to send packets. For example, the
+ // underlying transport's socket buffer may be full, as indicated by
+ // SendPacket's return code and/or GetError.
+ sigslot::signal1<PacketTransportInterface*> SignalReadyToSend;
+
+ // Signalled each time a packet is received on this channel.
+ sigslot::signal5<PacketTransportInterface*,
+ const char*,
+ size_t,
+ const rtc::PacketTime&,
+ int>
+ SignalReadPacket;
+
+ // Signalled each time a packet is sent on this channel.
+ sigslot::signal2<PacketTransportInterface*, const rtc::SentPacket&>
+ SignalSentPacket;
+};
+
+} // namespace rtc
#endif // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/transportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698