OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 int rtp_sendtime_extension_id; // extension header id present in packet. | 28 int rtp_sendtime_extension_id; // extension header id present in packet. |
29 std::vector<char> srtp_auth_key; // Authentication key. | 29 std::vector<char> srtp_auth_key; // Authentication key. |
30 int srtp_auth_tag_len; // Authentication tag length. | 30 int srtp_auth_tag_len; // Authentication tag length. |
31 int64 srtp_packet_index; // Required for Rtp Packet authentication. | 31 int64 srtp_packet_index; // Required for Rtp Packet authentication. |
32 }; | 32 }; |
33 | 33 |
34 // This structure holds meta information for the packet which is about to send | 34 // This structure holds meta information for the packet which is about to send |
35 // over network. | 35 // over network. |
36 struct PacketOptions { | 36 struct PacketOptions { |
37 PacketOptions() : dscp(DSCP_NO_CHANGE) {} | 37 PacketOptions() : dscp(DSCP_NO_CHANGE), packet_id(-1) {} |
38 explicit PacketOptions(DiffServCodePoint dscp) : dscp(dscp) {} | 38 PacketOptions(DiffServCodePoint dscp) : dscp(dscp), packet_id(-1) {} |
39 | 39 |
40 DiffServCodePoint dscp; | 40 DiffServCodePoint dscp; |
41 int packet_id; // 16 bits, -1 represents "not set". | |
41 PacketTimeUpdateParams packet_time_params; | 42 PacketTimeUpdateParams packet_time_params; |
42 }; | 43 }; |
43 | 44 |
44 // This structure will have the information about when packet is actually | 45 // This structure will have the information about when packet is actually |
45 // received by socket. | 46 // received by socket. |
46 struct PacketTime { | 47 struct PacketTime { |
47 PacketTime() : timestamp(-1), not_before(-1) {} | 48 PacketTime() : timestamp(-1), not_before(-1) {} |
48 PacketTime(int64 timestamp, int64 not_before) | 49 PacketTime(int64 timestamp, int64 not_before) |
49 : timestamp(timestamp), not_before(not_before) { | 50 : timestamp(timestamp), not_before(not_before) { |
50 } | 51 } |
51 | 52 |
52 int64 timestamp; // Receive time after socket delivers the data. | 53 int64 timestamp; // Receive time after socket delivers the data. |
53 int64 not_before; // Earliest possible time the data could have arrived, | 54 int64 not_before; // Earliest possible time the data could have arrived, |
54 // indicating the potential error in the |timestamp| value, | 55 // indicating the potential error in the |timestamp| value, |
55 // in case the system, is busy. For example, the time of | 56 // in case the system, is busy. For example, the time of |
56 // the last select() call. | 57 // the last select() call. |
57 // If unknown, this value will be set to zero. | 58 // If unknown, this value will be set to zero. |
58 }; | 59 }; |
59 | 60 |
60 inline PacketTime CreatePacketTime(int64 not_before) { | 61 inline PacketTime CreatePacketTime(int64 not_before) { |
61 return PacketTime(TimeMicros(), not_before); | 62 return PacketTime(TimeMicros(), not_before); |
62 } | 63 } |
63 | 64 |
65 struct SentPacket { | |
66 SentPacket() : packet_id(-1), send_time_ms(-1) {} | |
67 SentPacket(int32 packet_id, int64 send_time_ms) | |
68 : packet_id(packet_id), send_time_ms(send_time_ms) {} | |
69 | |
70 int packet_id; | |
71 int64 send_time_ms; | |
72 }; | |
73 | |
64 // Provides the ability to receive packets asynchronously. Sends are not | 74 // Provides the ability to receive packets asynchronously. Sends are not |
65 // buffered since it is acceptable to drop packets under high load. | 75 // buffered since it is acceptable to drop packets under high load. |
66 class AsyncPacketSocket : public sigslot::has_slots<> { | 76 class AsyncPacketSocket : public sigslot::has_slots<> { |
67 public: | 77 public: |
68 enum State { | 78 enum State { |
69 STATE_CLOSED, | 79 STATE_CLOSED, |
70 STATE_BINDING, | 80 STATE_BINDING, |
71 STATE_BOUND, | 81 STATE_BOUND, |
72 STATE_CONNECTING, | 82 STATE_CONNECTING, |
73 STATE_CONNECTED | 83 STATE_CONNECTED |
(...skipping 28 matching lines...) Expand all Loading... | |
102 // TODO: Remove SetError(). | 112 // TODO: Remove SetError(). |
103 virtual int GetError() const = 0; | 113 virtual int GetError() const = 0; |
104 virtual void SetError(int error) = 0; | 114 virtual void SetError(int error) = 0; |
105 | 115 |
106 // Emitted each time a packet is read. Used only for UDP and | 116 // Emitted each time a packet is read. Used only for UDP and |
107 // connected TCP sockets. | 117 // connected TCP sockets. |
108 sigslot::signal5<AsyncPacketSocket*, const char*, size_t, | 118 sigslot::signal5<AsyncPacketSocket*, const char*, size_t, |
109 const SocketAddress&, | 119 const SocketAddress&, |
110 const PacketTime&> SignalReadPacket; | 120 const PacketTime&> SignalReadPacket; |
111 | 121 |
122 // Emitted each time a packet is sent. | |
123 sigslot::signal3<AsyncPacketSocket*, const SocketAddress&, const SentPacket&> | |
124 SignalPacketSent; | |
stefan-webrtc
2015/10/05 13:43:19
I'm not sure if I actually need SocketAddress here
pthatcher1
2015/10/05 18:30:14
You shouldn't care what socket it is, as long as t
stefan-webrtc
2015/10/07 16:55:25
Acknowledged.
| |
125 | |
112 // Emitted when the socket is currently able to send. | 126 // Emitted when the socket is currently able to send. |
113 sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend; | 127 sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend; |
114 | 128 |
115 // Emitted after address for the socket is allocated, i.e. binding | 129 // Emitted after address for the socket is allocated, i.e. binding |
116 // is finished. State of the socket is changed from BINDING to BOUND | 130 // is finished. State of the socket is changed from BINDING to BOUND |
117 // (for UDP and server TCP sockets) or CONNECTING (for client TCP | 131 // (for UDP and server TCP sockets) or CONNECTING (for client TCP |
118 // sockets). | 132 // sockets). |
119 sigslot::signal2<AsyncPacketSocket*, const SocketAddress&> SignalAddressReady; | 133 sigslot::signal2<AsyncPacketSocket*, const SocketAddress&> SignalAddressReady; |
120 | 134 |
121 // Emitted for client TCP sockets when state is changed from | 135 // Emitted for client TCP sockets when state is changed from |
122 // CONNECTING to CONNECTED. | 136 // CONNECTING to CONNECTED. |
123 sigslot::signal1<AsyncPacketSocket*> SignalConnect; | 137 sigslot::signal1<AsyncPacketSocket*> SignalConnect; |
124 | 138 |
125 // Emitted for client TCP sockets when state is changed from | 139 // Emitted for client TCP sockets when state is changed from |
126 // CONNECTED to CLOSED. | 140 // CONNECTED to CLOSED. |
127 sigslot::signal2<AsyncPacketSocket*, int> SignalClose; | 141 sigslot::signal2<AsyncPacketSocket*, int> SignalClose; |
128 | 142 |
129 // Used only for listening TCP sockets. | 143 // Used only for listening TCP sockets. |
130 sigslot::signal2<AsyncPacketSocket*, AsyncPacketSocket*> SignalNewConnection; | 144 sigslot::signal2<AsyncPacketSocket*, AsyncPacketSocket*> SignalNewConnection; |
131 | 145 |
132 private: | 146 private: |
133 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket); | 147 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket); |
134 }; | 148 }; |
135 | 149 |
136 } // namespace rtc | 150 } // namespace rtc |
137 | 151 |
138 #endif // WEBRTC_BASE_ASYNCPACKETSOCKET_H_ | 152 #endif // WEBRTC_BASE_ASYNCPACKETSOCKET_H_ |
OLD | NEW |