/* * Copyright 2004 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
bool TestClient::CheckConnState(AsyncPacketSocket::State state) { // Wait for our timeout value until the socket reaches the desired state.
int64_t end = TimeAfter(kTimeoutMs); while (socket_->GetState() != state && TimeUntil(end) > 0) {
AdvanceTime(1);
} return (socket_->GetState() == state);
}
std::unique_ptr<TestClient::Packet> TestClient::NextPacket(int timeout_ms) { // If no packets are currently available, we go into a get/dispatch loop for // at most timeout_ms. If, during the loop, a packet arrives, then we can // stop early and return it.
// Note that the case where no packet arrives is important. We often want to // test that a packet does not arrive.
// Note also that we only try to pump our current thread's message queue. // Pumping another thread's queue could lead to messages being dispatched from // the wrong thread to non-thread-safe objects.
int64_t end = TimeAfter(timeout_ms); while (TimeUntil(end) > 0) {
{
webrtc::MutexLock lock(&mutex_); if (packets_.size() != 0) { break;
}
}
AdvanceTime(1);
}
// Return the first packet placed in the queue.
std::unique_ptr<Packet> packet;
webrtc::MutexLock lock(&mutex_); if (packets_.size() > 0) {
packet = std::move(packets_.front());
packets_.erase(packets_.begin());
}
bool TestClient::CheckTimestamp(
std::optional<webrtc::Timestamp> packet_timestamp) { bool res = true; if (!packet_timestamp) {
res = false;
} if (prev_packet_timestamp_) { if (packet_timestamp < prev_packet_timestamp_) {
res = false;
}
}
prev_packet_timestamp_ = packet_timestamp; return res;
}
void TestClient::AdvanceTime(int ms) { // If the test is using a fake clock, we must advance the fake clock to // advance time. Otherwise, ProcessMessages will work. if (fake_clock_) {
SIMULATED_WAIT(false, ms, *fake_clock_);
} else {
Thread::Current()->ProcessMessages(1);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.