From 5376181841d0f42925b0036ffd00b50ac234ff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joni=20R=C3=A4s=C3=A4nen?= Date: Mon, 13 May 2019 12:57:16 +0300 Subject: [PATCH] refactor(Global): Converted more error prints to new format. --- src/common.h | 4 ++-- src/kvazzupcore.cpp | 10 +++++++--- src/mediamanager.cpp | 16 ++++++++++------ src/scalefilter.cpp | 6 +++--- src/sip/sipdialogstate.cpp | 16 ++++++++++------ src/sip/siptransactions.cpp | 20 +++++++++++++------- src/tcpconnection.cpp | 2 -- src/video/camerainfo.cpp | 6 ++++-- src/video/displayfilter.cpp | 3 ++- src/video/yuvtorgb32.cpp | 5 ++++- 10 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/common.h b/src/common.h index 0bb6fe1b..357e6c26 100644 --- a/src/common.h +++ b/src/common.h @@ -21,8 +21,8 @@ void printDebug(DebugType type, QObject* object, // print debug information // DEBUG_NORMAL is for one time informational debug printing. -// DEBUG_ERROR is for events that should not be able to happen in Kvazzup and result in problems -// DEBUG_WARNING is for events that should not be able to happen in Kvazzup which do not result in problems +// DEBUG_WARNING is for events that should not be able to happen in Kvazzup which do not cause problems. +// DEBUG_ERROR is for events that should not be able to happen in Kvazzup and results in problems. // DEBUG_PEER_ERROR is for events that are errors in behavior of entities that are not us. void printDebug(DebugType type, QString className, QString context = "", QString description = "", diff --git a/src/kvazzupcore.cpp b/src/kvazzupcore.cpp index fd70e456..3d8b7c43 100644 --- a/src/kvazzupcore.cpp +++ b/src/kvazzupcore.cpp @@ -4,6 +4,8 @@ #include "globalsdpstate.h" +#include "common.h" + #include @@ -129,17 +131,19 @@ void KvazzupCore::peerAccepted(uint32_t sessionID) { if(states_[sessionID] == CALLRINGINWITHTHEM || states_[sessionID] == CALLINGTHEM) { - qDebug() << "Accepting," << metaObject()->className() << ": They accepted our call!"; + printDebug(DEBUG_NORMAL, this, "Accepting", "They accepted our call!"); states_[sessionID] = CALLNEGOTIATING; } else { - qDebug() << "PEER ERROR, accepting" << metaObject()->className() << ": Got an accepted call even though we have not yet called them!"; + printDebug(DEBUG_PEER_ERROR, this, "Accepting", + "Got an accepted call even though we have not yet called them!"); } } else { - qDebug() << "ERROR, accepting" << metaObject()->className() << ": : Peer accepted a session which is not in Call manager"; + printDebug(DEBUG_ERROR, this, "Accepting", + "Peer accepted a session which is not in Core."); } } diff --git a/src/mediamanager.cpp b/src/mediamanager.cpp index 8a997ff0..0c9c357b 100644 --- a/src/mediamanager.cpp +++ b/src/mediamanager.cpp @@ -169,17 +169,19 @@ void MediaManager::createOutgoingMedia(uint32_t sessionID, const MediaInfo& remo } else { - qDebug() << "ERROR: Unsupported media type in :" << remoteMedia.type; + printDebug(DEBUG_ERROR, this, "Add Participant", "Unsupported media type!", + {"type"}, QStringList() << remoteMedia.type); } } else { - qDebug() << "ERROR: SDP transport protocol not supported."; + printDebug(DEBUG_ERROR, this, "Add Participant", "SDP transport protocol not supported."); } } else { - qDebug() << "Not creating media because they don't seem to want any according to attribute"; + printDebug(DEBUG_NORMAL, this, "Add Participant", + "Not creating media because they don't seem to want any according to attribute."); } } @@ -212,17 +214,19 @@ void MediaManager::createIncomingMedia(uint32_t sessionID, const MediaInfo &loca } else { - qDebug() << "ERROR: Unsupported media type in :" << localMedia.type; + printDebug(DEBUG_ERROR, this, "Add Participant", "Unsupported incoming media type!", + {"type"}, QStringList() << localMedia.type); } } else { - qDebug() << "ERROR: SDP transport protocol not supported."; + printDebug(DEBUG_ERROR, this, "Add Participant", "Incoming SDP transport protocol not supported."); } } else { - qDebug() << "Not creating media because they don't seem to want any according to attribute"; + printDebug(DEBUG_NORMAL, this, "Add Participant", + "Not creating media because they don't seem to want any according to attribute."); } } diff --git a/src/scalefilter.cpp b/src/scalefilter.cpp index a9f41389..16c00704 100644 --- a/src/scalefilter.cpp +++ b/src/scalefilter.cpp @@ -21,7 +21,7 @@ void ScaleFilter::process() { if(newSize_ == QSize(0,0)) { - qDebug() << "ERROR: Size not set for scaler"; + printDebug(DEBUG_ERROR, this, "Initiate Video", "Size not set for scaler."); return; } @@ -30,8 +30,8 @@ void ScaleFilter::process() { if(input->height == 0 || input->width == 0 || input->data_size == 0) { - qDebug() << "ERROR: The resolution of input image for scaler is not set:" - << input->width << "x" << input->height; + printDebug(DEBUG_ERROR, this, "Initiate Video", "The resolution of input image for scaler is not set.", + {"Width", "Height"}, {QString::number(input->width), QString::number(input->height)}); return; } diff --git a/src/sip/sipdialogstate.cpp b/src/sip/sipdialogstate.cpp index 23e73ba8..317fa99b 100644 --- a/src/sip/sipdialogstate.cpp +++ b/src/sip/sipdialogstate.cpp @@ -85,19 +85,22 @@ void SIPDialogState::createDialogFromINVITE(std::shared_ptr &inM { if(correctRequestDialog(inMessage->dialog, SIP_INVITE, inMessage->cSeq)) { - qDebug() << "ERROR: Re-INVITE should be processed differently."; + printDebug(DEBUG_ERROR, "SIPDialogState", "SIP Create Dialog", + "Re-INVITE should be processed differently."); return; } else { - qDebug() << "PEER_ERROR: Got a request not belonging to this dialog"; + printDebug(DEBUG_PEER_ERROR, "SIPDialogState", "SIP Create Dialog", + "Got a request not belonging to this dialog."); } } remoteTag_ = inMessage->dialog->fromTag; if(remoteTag_ == "") { - qDebug() << "PEER_ERROR: They did not provide their tag in INVITE!"; + printDebug(DEBUG_PEER_ERROR, "SIPDialogState", "SIP Create Dialog", + "They did not provide their tag in INVITE!"); // TODO: send an error response. } @@ -129,9 +132,10 @@ void SIPDialogState::getRequestDialogInfo(SIPRequest &outRequest, QString localA if(localUri_.username == "" || localUri_.host == "" || remoteUri_.username == "" || remoteUri_.host == "") { - qDebug() << "ERROR: The dialog state info has not been set, but we are using it." << - "username:" << localUri_.username << "host" << localUri_.host << - "remote username:" << remoteUri_.username << "host:" << remoteUri_.host; + printDebug(DEBUG_ERROR, "SIPDialogState", "SIP Send Request", + "The dialog state info has not been set, but we are using it.", + {"username", "host", "remote username", "remote host"}, + {localUri_.username, localUri_.host, remoteUri_.username, remoteUri_.host}); } outRequest.requestURI = requestUri_; diff --git a/src/sip/siptransactions.cpp b/src/sip/siptransactions.cpp index 219f46e3..3c333c20 100644 --- a/src/sip/siptransactions.cpp +++ b/src/sip/siptransactions.cpp @@ -40,8 +40,9 @@ void SIPTransactions::init(SIPTransactionUser *callControl) << ": Listening to SIP TCP connections on port:" << sipPort_; if (!tcpServer_.listen(QHostAddress::Any, sipPort_)) { - qDebug() << "ERROR," << metaObject()->className() - << "failed to listen to socket. Is it reserved?"; + printDebug(DEBUG_ERROR, this, "Initiate SIP", + "Failed to listen to socket. Is it reserved?"); + // TODO announce it to user! } @@ -160,7 +161,8 @@ void SIPTransactions::startCall(Contact &address) if(isServer) { - qDebug() << "ERROR: Proxy calling has not been yet implemented"; + printDebug(DEBUG_ERROR, this, "SIP Start Call", + "Proxy calling has not been yet implemented"); } else { @@ -196,7 +198,8 @@ void SIPTransactions::startPeerToPeerCall(quint32 transportID, Contact &remote) // this start call will commence once the connection has been established if(!dialogData->client->startCall(remote.realName)) { - qDebug() << "WARNING: Could not start a call according to session."; + printDebug(DEBUG_WARNING, this, "SIP Start Call", + "Could not start a call according to session."); } } @@ -655,7 +658,8 @@ void SIPTransactions::sendDialogRequest(uint32_t sessionID, RequestType type) { if(dialogs_[sessionID]->localSdp_ == nullptr) { - qDebug() << "ERROR: Missing local final SDP when its supposed to be sent."; + printDebug(DEBUG_ERROR, this, "SIP Send Request", + "Missing local final SDP when its supposed to be sent."); // TODO: send client error. return; } @@ -679,8 +683,10 @@ void SIPTransactions::sendNonDialogRequest(SIP_URI& uri, RequestType type) { if (registrations_.find(uri.host) == registrations_.end()) { - qDebug() << "ERROR: Registration information should have been created " - "already before sending REGISTER message!"; + printDebug(DEBUG_ERROR, this, "SIP Send Request", + "Registration information should have been created " + "already before sending REGISTER message!"); + return; } diff --git a/src/tcpconnection.cpp b/src/tcpconnection.cpp index 38a498a6..1e33e33a 100644 --- a/src/tcpconnection.cpp +++ b/src/tcpconnection.cpp @@ -261,8 +261,6 @@ void TCPConnection::disconnected() void TCPConnection::printError(int socketError, const QString &message) { - qWarning() << "ERROR. Socket error" << socketError - << "Error:" << message; printDebug(DEBUG_ERROR, this, "TCP", "Socket Error", {"Code", "Message"}, {QString::number(socketError), message}); } diff --git a/src/video/camerainfo.cpp b/src/video/camerainfo.cpp index 0bea8fbc..15ff5160 100644 --- a/src/video/camerainfo.cpp +++ b/src/video/camerainfo.cpp @@ -1,9 +1,10 @@ #include "camerainfo.h" +#include "common.h" + #include #include - const std::map pixelFormatStrings = {{QVideoFrame::Format_Invalid, "INVALID"}, {QVideoFrame::Format_ARGB32, "ARGB32"}, {QVideoFrame::Format_ARGB32_Premultiplied, "ARGB32_Premultiplied"}, @@ -149,7 +150,8 @@ std::unique_ptr CameraInfo::loadCamera(int deviceID) QList cameras = QCameraInfo::availableCameras(); if(deviceID == -1 || deviceID >= cameras.size()) { - qDebug() << "ERROR: Invalid deviceID for getVideoCapabilities"; + printDebug(DEBUG_ERROR, "CameraInfo", "SIP Send Request", + "Invalid deviceID for getVideoCapabilities"); return std::unique_ptr (nullptr); } diff --git a/src/video/displayfilter.cpp b/src/video/displayfilter.cpp index 6c601551..8ef078c3 100644 --- a/src/video/displayfilter.cpp +++ b/src/video/displayfilter.cpp @@ -42,7 +42,8 @@ void DisplayFilter::updateSettings() } else { - qDebug() << "ERROR: Missing settings value flip threads"; + printDebug(DEBUG_ERROR, "CameraInfo", "SIP Send Request", + "Missing settings value flip threads."); } Filter::updateSettings(); diff --git a/src/video/yuvtorgb32.cpp b/src/video/yuvtorgb32.cpp index 7d6e8a87..88666369 100644 --- a/src/video/yuvtorgb32.cpp +++ b/src/video/yuvtorgb32.cpp @@ -2,6 +2,8 @@ #include "optimized/yuv2rgb.h" +#include "common.h" + #include #include @@ -36,7 +38,8 @@ void YUVtoRGB32::updateSettings() } else { - qDebug() << "ERROR: Missing settings value YUV threads"; + printDebug(DEBUG_ERROR, "CameraInfo", "SIP Send Request", + "Missing settings value YUV threads."); } Filter::updateSettings();