Chromium Code Reviews| 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), transport_sequence_number(-1) {} |
| 38 explicit PacketOptions(DiffServCodePoint dscp) : dscp(dscp) {} | 38 PacketOptions(DiffServCodePoint dscp) |
| 39 : dscp(dscp), transport_sequence_number(-1) {} | |
| 39 | 40 |
| 40 DiffServCodePoint dscp; | 41 DiffServCodePoint dscp; |
| 42 int32 transport_sequence_number; // 16 bits, -1 represents "not set". | |
|
pthatcher1
2015/09/25 23:24:58
I'm not to excited about something so RTP-specific
stefan-webrtc
2015/09/28 12:10:50
I could call it packet_id. I'm not sure that's a l
pthatcher1
2015/09/28 23:58:40
It's more generic because the layer that's doing t
stefan-webrtc
2015/10/02 13:29:12
I'm convinced. Fixed.
| |
| 41 PacketTimeUpdateParams packet_time_params; | 43 PacketTimeUpdateParams packet_time_params; |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 // This structure will have the information about when packet is actually | 46 // This structure will have the information about when packet is actually |
| 45 // received by socket. | 47 // received by socket. |
| 46 struct PacketTime { | 48 struct PacketTime { |
| 47 PacketTime() : timestamp(-1), not_before(-1) {} | 49 PacketTime() : timestamp(-1), not_before(-1) {} |
| 48 PacketTime(int64 timestamp, int64 not_before) | 50 PacketTime(int64 timestamp, int64 not_before) |
| 49 : timestamp(timestamp), not_before(not_before) { | 51 : timestamp(timestamp), not_before(not_before) { |
| 50 } | 52 } |
| 51 | 53 |
| 52 int64 timestamp; // Receive time after socket delivers the data. | 54 int64 timestamp; // Receive time after socket delivers the data. |
| 53 int64 not_before; // Earliest possible time the data could have arrived, | 55 int64 not_before; // Earliest possible time the data could have arrived, |
| 54 // indicating the potential error in the |timestamp| value, | 56 // indicating the potential error in the |timestamp| value, |
| 55 // in case the system, is busy. For example, the time of | 57 // in case the system, is busy. For example, the time of |
| 56 // the last select() call. | 58 // the last select() call. |
| 57 // If unknown, this value will be set to zero. | 59 // If unknown, this value will be set to zero. |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 inline PacketTime CreatePacketTime(int64 not_before) { | 62 inline PacketTime CreatePacketTime(int64 not_before) { |
| 61 return PacketTime(TimeMicros(), not_before); | 63 return PacketTime(TimeMicros(), not_before); |
| 62 } | 64 } |
| 63 | 65 |
| 66 struct SentPacket { | |
| 67 SentPacket() : transport_sequence_number(-1), send_time_ms(-1) {} | |
| 68 SentPacket(int32 transport_sequence_number, int64 send_time_ms) | |
| 69 : transport_sequence_number(transport_sequence_number), | |
| 70 send_time_ms(send_time_ms) {} | |
| 71 | |
| 72 int32 transport_sequence_number; | |
| 73 int64 send_time_ms; | |
| 74 }; | |
| 75 | |
| 64 // Provides the ability to receive packets asynchronously. Sends are not | 76 // Provides the ability to receive packets asynchronously. Sends are not |
| 65 // buffered since it is acceptable to drop packets under high load. | 77 // buffered since it is acceptable to drop packets under high load. |
| 66 class AsyncPacketSocket : public sigslot::has_slots<> { | 78 class AsyncPacketSocket : public sigslot::has_slots<> { |
| 67 public: | 79 public: |
| 68 enum State { | 80 enum State { |
| 69 STATE_CLOSED, | 81 STATE_CLOSED, |
| 70 STATE_BINDING, | 82 STATE_BINDING, |
| 71 STATE_BOUND, | 83 STATE_BOUND, |
| 72 STATE_CONNECTING, | 84 STATE_CONNECTING, |
| 73 STATE_CONNECTED | 85 STATE_CONNECTED |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 102 // TODO: Remove SetError(). | 114 // TODO: Remove SetError(). |
| 103 virtual int GetError() const = 0; | 115 virtual int GetError() const = 0; |
| 104 virtual void SetError(int error) = 0; | 116 virtual void SetError(int error) = 0; |
| 105 | 117 |
| 106 // Emitted each time a packet is read. Used only for UDP and | 118 // Emitted each time a packet is read. Used only for UDP and |
| 107 // connected TCP sockets. | 119 // connected TCP sockets. |
| 108 sigslot::signal5<AsyncPacketSocket*, const char*, size_t, | 120 sigslot::signal5<AsyncPacketSocket*, const char*, size_t, |
| 109 const SocketAddress&, | 121 const SocketAddress&, |
| 110 const PacketTime&> SignalReadPacket; | 122 const PacketTime&> SignalReadPacket; |
| 111 | 123 |
| 124 // Emitted each time a packet is sent. | |
| 125 sigslot::signal2<AsyncPacketSocket*, const SentPacket&> SignalPacketSent; | |
|
pthatcher1
2015/09/25 23:24:57
I don't actually see this implemented anywhere. D
stefan-webrtc
2015/09/28 12:10:50
It's implemented in Chromium here: https://coderev
| |
| 126 | |
| 112 // Emitted when the socket is currently able to send. | 127 // Emitted when the socket is currently able to send. |
| 113 sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend; | 128 sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend; |
| 114 | 129 |
| 115 // Emitted after address for the socket is allocated, i.e. binding | 130 // Emitted after address for the socket is allocated, i.e. binding |
| 116 // is finished. State of the socket is changed from BINDING to BOUND | 131 // is finished. State of the socket is changed from BINDING to BOUND |
| 117 // (for UDP and server TCP sockets) or CONNECTING (for client TCP | 132 // (for UDP and server TCP sockets) or CONNECTING (for client TCP |
| 118 // sockets). | 133 // sockets). |
| 119 sigslot::signal2<AsyncPacketSocket*, const SocketAddress&> SignalAddressReady; | 134 sigslot::signal2<AsyncPacketSocket*, const SocketAddress&> SignalAddressReady; |
| 120 | 135 |
| 121 // Emitted for client TCP sockets when state is changed from | 136 // Emitted for client TCP sockets when state is changed from |
| 122 // CONNECTING to CONNECTED. | 137 // CONNECTING to CONNECTED. |
| 123 sigslot::signal1<AsyncPacketSocket*> SignalConnect; | 138 sigslot::signal1<AsyncPacketSocket*> SignalConnect; |
| 124 | 139 |
| 125 // Emitted for client TCP sockets when state is changed from | 140 // Emitted for client TCP sockets when state is changed from |
| 126 // CONNECTED to CLOSED. | 141 // CONNECTED to CLOSED. |
| 127 sigslot::signal2<AsyncPacketSocket*, int> SignalClose; | 142 sigslot::signal2<AsyncPacketSocket*, int> SignalClose; |
| 128 | 143 |
| 129 // Used only for listening TCP sockets. | 144 // Used only for listening TCP sockets. |
| 130 sigslot::signal2<AsyncPacketSocket*, AsyncPacketSocket*> SignalNewConnection; | 145 sigslot::signal2<AsyncPacketSocket*, AsyncPacketSocket*> SignalNewConnection; |
| 131 | 146 |
| 132 private: | 147 private: |
| 133 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket); | 148 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket); |
| 134 }; | 149 }; |
| 135 | 150 |
| 136 } // namespace rtc | 151 } // namespace rtc |
| 137 | 152 |
| 138 #endif // WEBRTC_BASE_ASYNCPACKETSOCKET_H_ | 153 #endif // WEBRTC_BASE_ASYNCPACKETSOCKET_H_ |
| OLD | NEW |