OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 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_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_ | |
12 #define WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_ | |
13 | |
14 #include <arpa/inet.h> | |
15 #include <netinet/in.h> | |
16 #include <sys/socket.h> | |
17 #include <sys/types.h> | |
18 | |
19 #include "webrtc/base/event.h" | |
20 #include "webrtc/base/criticalsection.h" | |
21 #include "webrtc/test/channel_transport/udp_socket_wrapper.h" | |
22 | |
23 namespace webrtc { | |
24 namespace test { | |
25 | |
26 #define SOCKET_ERROR -1 | |
27 | |
28 class UdpSocketPosix : public UdpSocketWrapper | |
29 { | |
30 public: | |
31 UdpSocketPosix(const int32_t id, UdpSocketManager* mgr, | |
32 bool ipV6Enable = false); | |
33 | |
34 virtual ~UdpSocketPosix(); | |
35 | |
36 bool SetCallback(CallbackObj obj, IncomingSocketCallback cb) override; | |
37 | |
38 bool Bind(const SocketAddress& name) override; | |
39 | |
40 bool SetSockopt(int32_t level, | |
41 int32_t optname, | |
42 const int8_t* optval, | |
43 int32_t optlen) override; | |
44 | |
45 int32_t SetTOS(const int32_t serviceType) override; | |
46 | |
47 int32_t SendTo(const int8_t* buf, | |
48 size_t len, | |
49 const SocketAddress& to) override; | |
50 | |
51 // Deletes socket in addition to closing it. | |
52 // TODO (hellner): make destructor protected. | |
53 void CloseBlocking() override; | |
54 | |
55 SOCKET GetFd(); | |
56 | |
57 bool ValidHandle() override; | |
58 | |
59 bool SetQos(int32_t /*serviceType*/, | |
60 int32_t /*tokenRate*/, | |
61 int32_t /*bucketSize*/, | |
62 int32_t /*peekBandwith*/, | |
63 int32_t /*minPolicedSize*/, | |
64 int32_t /*maxSduSize*/, | |
65 const SocketAddress& /*stRemName*/, | |
66 int32_t /*overrideDSCP*/) override; | |
67 | |
68 bool CleanUp(); | |
69 void HasIncoming(); | |
70 bool WantsIncoming(); | |
71 void ReadyForDeletion(); | |
72 private: | |
73 friend class UdpSocketManagerPosix; | |
74 | |
75 const int32_t _id; | |
76 IncomingSocketCallback _incomingCb; | |
77 CallbackObj _obj; | |
78 | |
79 SOCKET _socket; | |
80 UdpSocketManager* _mgr; | |
81 rtc::Event _closeBlockingCompletedCond; | |
82 rtc::Event _readyForDeletionCond; | |
83 | |
84 bool _closeBlockingActive; | |
85 bool _closeBlockingCompleted; | |
86 bool _readyForDeletion; | |
87 | |
88 rtc::CriticalSection _cs; | |
89 }; | |
90 | |
91 } // namespace test | |
92 } // namespace webrtc | |
93 | |
94 #endif // WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_ | |
OLD | NEW |