/* * Copyright 2017 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.
*/
// If this constructor is called, a new fake ICE transport will be created, // and this FakeDtlsTransport will take the ownership.
FakeDtlsTransport(const std::string& name, int component)
: FakeDtlsTransport(std::make_unique<FakeIceTransport>(name, component)) {
}
FakeDtlsTransport(const std::string& name, int component,
rtc::Thread* network_thread)
: FakeDtlsTransport(std::make_unique<FakeIceTransport>(name,
component,
network_thread)) {}
// If async, will send packets by "Post"-ing to message queue instead of // synchronously "Send"-ing. void SetAsync(bool async) { ice_transport_->SetAsync(async); } void SetAsyncDelay(int delay_ms) { ice_transport_->SetAsyncDelay(delay_ms); }
// SetWritable, SetReceiving and SetDestination are the main methods that can // be used for testing, to simulate connectivity or lack thereof. void SetWritable(bool writable) {
ice_transport_->SetWritable(writable);
set_writable(writable);
} void SetReceiving(bool receiving) {
ice_transport_->SetReceiving(receiving);
set_receiving(receiving);
} void SetDtlsState(webrtc::DtlsTransportState state) {
dtls_state_ = state;
SendDtlsState(this, dtls_state_);
}
// Simulates the two DTLS transports connecting to each other. // If `asymmetric` is true this method only affects this FakeDtlsTransport. // If false, it affects `dest` as well. void SetDestination(FakeDtlsTransport* dest, bool asymmetric = false) { if (dest == dest_) { return;
}
RTC_DCHECK(!dest || !dest_)
<< "Changing fake destination from one to another is not supported."; if (dest && !dest_) { // This simulates the DTLS handshake.
dest_ = dest; if (local_cert_ && dest_->local_cert_) {
do_dtls_ = true;
RTC_LOG(LS_INFO) << "FakeDtlsTransport is doing DTLS";
} else {
do_dtls_ = false;
RTC_LOG(LS_INFO) << "FakeDtlsTransport is not doing DTLS";
}
SetWritable(true); if (!asymmetric) {
dest->SetDestination(this, true);
} // If the `dtls_role_` is unset, set it to SSL_CLIENT by default. if (!dtls_role_) {
dtls_role_ = std::move(rtc::SSL_CLIENT);
}
SetDtlsState(webrtc::DtlsTransportState::kConnected);
ice_transport_->SetDestination( static_cast<FakeIceTransport*>(dest->ice_transport()), asymmetric);
} else { // Simulates loss of connectivity, by asymmetrically forgetting dest_.
dest_ = nullptr;
SetWritable(false);
ice_transport_->SetDestination(nullptr, asymmetric);
}
}
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.