Improve WebRTC debug

This commit is contained in:
David Rowe 2021-11-20 11:06:05 +13:00
parent 861b8398f4
commit fb79d57fef
2 changed files with 65 additions and 7 deletions

View file

@ -71,7 +71,7 @@ WDCPeerConnectionObserver::WDCPeerConnectionObserver(WDCConnection* parent) :
void WDCPeerConnectionObserver::OnSignalingChange(PeerConnectionInterface::SignalingState newState) {
#ifdef WEBRTC_DEBUG
QStringList states{
QStringList states {
"Stable",
"HaveLocalOffer",
"HaveLocalPrAnswer",
@ -79,7 +79,7 @@ void WDCPeerConnectionObserver::OnSignalingChange(PeerConnectionInterface::Signa
"HaveRemotePrAnswer",
"Closed"
};
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnSignalingChange()" << newState << states[newState];
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnSignalingChange() :" << newState << states[newState];
#endif
}
@ -91,7 +91,12 @@ void WDCPeerConnectionObserver::OnRenegotiationNeeded() {
void WDCPeerConnectionObserver::OnIceGatheringChange(PeerConnectionInterface::IceGatheringState newState) {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnIceGatheringChange()" << newState;
QStringList states {
"New",
"Gathering",
"Complete"
};
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnIceGatheringChange() :" << newState << states[newState];
#endif
}
@ -102,6 +107,39 @@ void WDCPeerConnectionObserver::OnIceCandidate(const IceCandidateInterface* cand
_parent->sendIceCandidate(candidate);
}
void WDCPeerConnectionObserver::OnIceConnectionChange(PeerConnectionInterface::IceConnectionState newState) {
#ifdef WEBRTC_DEBUG
QStringList states {
"New",
"Checking",
"Connected",
"Completed",
"Failed",
"Disconnected",
"Closed",
"Max"
};
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnIceConnectionChange() :" << newState << states[newState];
#endif
}
void WDCPeerConnectionObserver::OnStandardizedIceConnectionChange(PeerConnectionInterface::IceConnectionState newState) {
#ifdef WEBRTC_DEBUG
QStringList states {
"New",
"Checking",
"Connected",
"Completed",
"Failed",
"Disconnected",
"Closed",
"Max"
};
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnStandardizedIceConnectionChange() :" << newState
<< states[newState];
#endif
}
void WDCPeerConnectionObserver::OnDataChannel(rtc::scoped_refptr<DataChannelInterface> dataChannel) {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnDataChannel()";
@ -111,7 +149,16 @@ void WDCPeerConnectionObserver::OnDataChannel(rtc::scoped_refptr<DataChannelInte
void WDCPeerConnectionObserver::OnConnectionChange(PeerConnectionInterface::PeerConnectionState newState) {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnConnectionChange()" << (uint)newState;
QStringList states {
"New",
"Connecting",
"Connected",
"Disconnected",
"Failed",
"Closed"
};
qCDebug(networking_webrtc) << "WDCPeerConnectionObserver::OnConnectionChange() :" << (uint)newState
<< states[(uint)newState];
#endif
_parent->onPeerConnectionStateChanged(newState);
}
@ -267,7 +314,7 @@ void WDCConnection::sendIceCandidate(const IceCandidateInterface* candidate) {
void WDCConnection::onPeerConnectionStateChanged(PeerConnectionInterface::PeerConnectionState state) {
#ifdef WEBRTC_DEBUG
const char* STATES[] = {
QStringList states {
"New",
"Connecting",
"Connected",
@ -275,7 +322,7 @@ void WDCConnection::onPeerConnectionStateChanged(PeerConnectionInterface::PeerCo
"Failed",
"Closed"
};
qCDebug(networking_webrtc) << "WDCConnection::onPeerConnectionStateChanged() :" << (int)state << STATES[(int)state];
qCDebug(networking_webrtc) << "WDCConnection::onPeerConnectionStateChanged() :" << (int)state << states[(int)state];
#endif
}
@ -372,7 +419,7 @@ bool WDCConnection::sendDataMessage(const DataBuffer& buffer) {
void WDCConnection::closePeerConnection() {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WDCConnection::closePeerConnection()";
qCDebug(networking_webrtc) << "WDCConnection::closePeerConnection() :" << (int)_peerConnection->peer_connection_state();
#endif
_peerConnection->Close();
_peerConnection = nullptr;
@ -430,6 +477,9 @@ WebRTCDataChannels::~WebRTCDataChannels() {
}
void WebRTCDataChannels::reset() {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WebRTCDataChannels::reset() :" << _connectionsByID.count();
#endif
QHashIterator<QString, WDCConnection*> i(_connectionsByID);
while (i.hasNext()) {
i.next();

View file

@ -88,6 +88,14 @@ public:
/// @param candidate The new ICE candidate.
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
/// @brief Called when the legacy ICE connection state changes.
/// @param new_state The new ICE connection state.
virtual void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState newState) override;
/// @brief Called when the standards-compliant ICE connection state changes.
/// @param new_state The new ICE connection state.
virtual void OnStandardizedIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState newState) override;
/// @brief Called when a remote peer opens a data channel.
/// @param dataChannel The data channel.
void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel) override;