Skip to content

Commit

Permalink
refactor(Global): Converted more error prints to new format.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrsnen committed May 13, 2019
1 parent 9b47915 commit 5376181
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
10 changes: 7 additions & 3 deletions src/kvazzupcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "globalsdpstate.h"

#include "common.h"

#include <QHostAddress>


Expand Down Expand Up @@ -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.");
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/mediamanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -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.");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/scalefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
16 changes: 10 additions & 6 deletions src/sip/sipdialogstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,22 @@ void SIPDialogState::createDialogFromINVITE(std::shared_ptr<SIPMessageInfo> &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.
}

Expand Down Expand Up @@ -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_;
Expand Down
20 changes: 13 additions & 7 deletions src/sip/siptransactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions src/tcpconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down
6 changes: 4 additions & 2 deletions src/video/camerainfo.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "camerainfo.h"

#include "common.h"

#include <QCameraInfo>
#include <QDebug>


const std::map<QVideoFrame::PixelFormat, QString> pixelFormatStrings = {{QVideoFrame::Format_Invalid, "INVALID"},
{QVideoFrame::Format_ARGB32, "ARGB32"},
{QVideoFrame::Format_ARGB32_Premultiplied, "ARGB32_Premultiplied"},
Expand Down Expand Up @@ -149,7 +150,8 @@ std::unique_ptr<QCamera> CameraInfo::loadCamera(int deviceID)
QList<QCameraInfo> 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<QCamera> (nullptr);
}

Expand Down
3 changes: 2 additions & 1 deletion src/video/displayfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/video/yuvtorgb32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "optimized/yuv2rgb.h"

#include "common.h"

#include <QSettings>
#include <QDebug>

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5376181

Please sign in to comment.