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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 delete packet; | 98 delete packet; |
99 } | 99 } |
100 return res; | 100 return res; |
101 } | 101 } |
102 | 102 |
103 bool TestClient::CheckTimestamp(int64_t packet_timestamp) { | 103 bool TestClient::CheckTimestamp(int64_t packet_timestamp) { |
104 bool res = true; | 104 bool res = true; |
105 if (packet_timestamp == -1) { | 105 if (packet_timestamp == -1) { |
106 res = false; | 106 res = false; |
107 } | 107 } |
108 int64_t time_us = rtc::TimeMicros(); | |
109 if (prev_packet_timestamp_ != -1) { | 108 if (prev_packet_timestamp_ != -1) { |
110 if (packet_timestamp < prev_packet_timestamp_) { | 109 if (packet_timestamp < prev_packet_timestamp_) { |
111 res = false; | 110 res = false; |
112 } | 111 } |
113 const int64_t kErrorMarginUs = 20000; | |
114 if (packet_timestamp - prev_packet_timestamp_ < | |
115 time_us - prev_time_us_ - kErrorMarginUs || | |
116 packet_timestamp - prev_packet_timestamp_ > | |
117 time_us - prev_time_us_ + kErrorMarginUs) { | |
118 res = false; | |
119 } | |
120 } | 112 } |
121 prev_packet_timestamp_ = packet_timestamp; | 113 prev_packet_timestamp_ = packet_timestamp; |
122 prev_time_us_ = time_us; | |
123 return res; | 114 return res; |
124 } | 115 } |
125 | 116 |
126 bool TestClient::CheckNoPacket() { | 117 bool TestClient::CheckNoPacket() { |
127 bool res; | 118 bool res; |
128 Packet* packet = NextPacket(kNoPacketTimeoutMs); | 119 Packet* packet = NextPacket(kNoPacketTimeoutMs); |
129 res = (packet == NULL); | 120 res = (packet == NULL); |
130 delete packet; | 121 delete packet; |
131 return res; | 122 return res; |
132 } | 123 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 : addr(p.addr), buf(0), size(p.size), packet_time(p.packet_time) { | 158 : addr(p.addr), buf(0), size(p.size), packet_time(p.packet_time) { |
168 buf = new char[size]; | 159 buf = new char[size]; |
169 memcpy(buf, p.buf, size); | 160 memcpy(buf, p.buf, size); |
170 } | 161 } |
171 | 162 |
172 TestClient::Packet::~Packet() { | 163 TestClient::Packet::~Packet() { |
173 delete[] buf; | 164 delete[] buf; |
174 } | 165 } |
175 | 166 |
176 } // namespace rtc | 167 } // namespace rtc |
OLD | NEW |