Commit eb39e6f2 authored by Guillaume Roguez's avatar Guillaume Roguez

debug: cleanup or add a bunch of debug strings

This cleanup permits a better lisibility (and so usability) of
debug string over the code.
This is not exhaustive, just for the related issue needs.

Issue: #79075
Change-Id: I8885f6d46b6edb454a2d15305ba48d7e9bdf6d42
parent 10f56705
......@@ -29,6 +29,7 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <iostream>
#include <thread>
#include <cstring>
......@@ -47,7 +48,11 @@ print_title()
std::cout
<< "Ring Daemon " << DRing::version()
<< ", by Savoir-Faire Linux 2004-2015" << std::endl
<< "http://www.ring.cx/" << std::endl;
<< "http://www.ring.cx/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl
#endif
<< std::endl;
}
static void
......@@ -202,9 +207,5 @@ main(int argc, char *argv [])
signal(SIGHUP, signal_handler);
signal(SIGTERM, signal_handler);
#ifdef RING_VIDEO
std::cerr << "Warning: built with video support" << std::endl;
#endif
return run();
}
......@@ -50,9 +50,14 @@ static int ringFlags = 0;
static void
print_title()
{
std::cout << "Ring Daemon " << DRing::version()
<< ", by Savoir-Faire Linux 2004-2015" << std::endl
<< "http://www.ring.cx/" << std::endl;
std::cout
<< "Ring Daemon " << DRing::version()
<< ", by Savoir-Faire Linux 2004-2015" << std::endl
<< "http://www.ring.cx/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl
#endif
<< std::endl;
}
static void
......@@ -219,9 +224,5 @@ main(int argc, char *argv [])
signal(SIGHUP, signal_handler);
signal(SIGTERM, signal_handler);
#ifdef RING_VIDEO
std::cerr << "Warning: built with video support" << std::endl;
#endif
return run();
}
......@@ -58,7 +58,11 @@ print_title()
std::cout
<< "Ring Daemon " << DRing::version()
<< ", by Savoir-Faire Linux 2004-2015" << std::endl
<< "http://www.ring.cx/" << std::endl;
<< "http://www.ring.cx/" << std::endl
#ifdef RING_VIDEO
<< "[Video support enabled]" << std::endl
#endif
<< std::endl;
}
static void
......@@ -223,9 +227,5 @@ main(int argc, char *argv [])
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
#ifdef RING_VIDEO
std::cerr << "Warning: built with video support" << std::endl;
#endif
return run();
}
......@@ -85,6 +85,8 @@ void Conference::add(const std::string &participant_id)
#ifdef RING_VIDEO
if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id))
call->getVideoRtp().enterConference(this);
else
RING_ERR("no call associate to participant %s", participant_id.c_str());
#endif // RING_VIDEO
}
}
......
......@@ -116,7 +116,7 @@ AudioSender::setup(SocketPair& socketPair)
try {
/* Encoder setup */
RING_WARN("audioEncoder_->openOutput %s", dest_.c_str());
RING_DBG("audioEncoder_->openOutput %s", dest_.c_str());
audioEncoder_->openOutput(dest_.c_str(), args_);
audioEncoder_->setInitSeqVal(seqVal_);
audioEncoder_->setIOContext(muxContext_);
......@@ -128,7 +128,7 @@ AudioSender::setup(SocketPair& socketPair)
std::string sdp;
audioEncoder_->print_sdp(sdp);
RING_WARN("\n%s", sdp.c_str());
RING_DBG("\n%s", sdp.c_str());
return true;
}
......
......@@ -92,7 +92,7 @@ AudioRecord::AudioRecord() : fileHandle_(nullptr)
, filename_(createFilename())
, savePath_()
{
RING_WARN("Generate filename for this call %s ", filename_.c_str());
RING_DBG("Generate filename for this call %s ", filename_.c_str());
}
AudioRecord::~AudioRecord()
......
......@@ -184,8 +184,8 @@ int MediaDecoder::setupFromAudioData(const AudioFormat format)
decoderCtx_->channels = format.nb_channels;
decoderCtx_->sample_rate = format.sample_rate;
RING_WARN("Audio decoding using %s with %s",
inputDecoder_->name, format.toString().c_str());
RING_DBG("Audio decoding using %s with %s",
inputDecoder_->name, format.toString().c_str());
if (emulateRate_) {
RING_DBG("Using framerate emulation");
......
......@@ -594,7 +594,7 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
v = av_dict_get(options_, "frame_size", NULL, 0);
if (v) {
encoderCtx_->frame_size = atoi(v->value);
RING_WARN("[%s] Frame size %d", encoderName, encoderCtx_->frame_size);
RING_DBG("[%s] Frame size %d", encoderName, encoderCtx_->frame_size);
} else {
RING_WARN("[%s] Frame size not set", encoderName);
}
......
......@@ -73,6 +73,7 @@ bool VideoInput::setup()
}
if (not attach(sink_.get()))
RING_WARN("Failed to attach sink");
RING_DBG("VideoInput ready to capture");
return true;
}
......
......@@ -254,11 +254,15 @@ void VideoRtpSession::setupConferenceVideoPipeline(Conference* conference)
if (videoLocal_)
videoLocal_->detach(sender_.get());
videoMixer_->attach(sender_.get());
} else {
RING_WARN("[call:%s] no sender", callID_.c_str(), conference->getConfID().c_str());
}
if (receiveThread_) {
receiveThread_->enterConference();
receiveThread_->attach(videoMixer_.get());
} else {
RING_WARN("[call:%s] no receiver", callID_.c_str(), conference->getConfID().c_str());
}
}
......@@ -268,6 +272,8 @@ void VideoRtpSession::enterConference(Conference* conference)
exitConference();
RING_DBG("[call:%s] enterConference (conf: %s)", callID_.c_str(),
conference->getConfID().c_str());
conference_ = conference;
if (send_.enabled or receiveThread_)
......@@ -278,6 +284,8 @@ void VideoRtpSession::exitConference()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
RING_DBG("[call:%s] exitConference (conf: %s)", callID_.c_str(),
conference_->getConfID().c_str());
if (videoMixer_) {
if (sender_)
......
......@@ -566,17 +566,20 @@ RingAccount::handleEvents()
.cert_check = [remote_h](unsigned status,
const gnutls_datum_t* cert_list,
unsigned cert_num) -> pj_status_t {
RING_WARN("TLS certificate check for %s",
remote_h.toString().c_str());
if (status & GNUTLS_CERT_EXPIRED ||
status & GNUTLS_CERT_NOT_ACTIVATED)
status & GNUTLS_CERT_NOT_ACTIVATED) {
RING_ERR("Expired certificate for %s", remote_h.toString().c_str());
return PJ_SSL_CERT_EVALIDITY_PERIOD;
else if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
} else if (status & GNUTLS_CERT_INSECURE_ALGORITHM) {
RING_ERR("Untrusted certificate for %s", remote_h.toString().c_str());
return PJ_SSL_CERT_EUNTRUSTED;
}
if (cert_num == 0)
if (cert_num == 0) {
RING_ERR("Unknown TLS certificate error for %s",
remote_h.toString().c_str());
return PJ_SSL_CERT_EUNKNOWN;
}
try {
std::vector<uint8_t> crt_blob(cert_list[0].data,
......@@ -590,13 +593,15 @@ RingAccount::handleEvents()
if (tls_id != remote_h) {
RING_ERR("Certificate public key (ID %s) doesn't match expectation (%s)",
tls_id.toString().c_str(),
remote_h.toString().c_str());
tls_id.toString().c_str(), remote_h.toString().c_str());
return PJ_SSL_CERT_EUNTRUSTED;
}
} catch (const std::exception& e) {
RING_ERR("TLS certificate exception for %s: %s",
remote_h.toString().c_str(), e.what());
return PJ_SSL_CERT_EUNKNOWN;
}
RING_DBG("Certificate verified for %s", remote_h.toString().c_str());
return PJ_SUCCESS;
}
};
......
......@@ -146,7 +146,7 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt,
};
base.destroy = [](pjsip_transport *transport) -> pj_status_t {
auto& this_ = reinterpret_cast<TransportData*>(transport)->self;
RING_WARN("SipsIceTransport@%p: destroy", this_);
RING_DBG("SipsIceTransport@%p: destroy", this_);
delete this_;
return PJ_SUCCESS;
};
......@@ -284,7 +284,7 @@ SipsIceTransport::startTlsSession()
GNUTLS_X509_FMT_DER);
if (ret < 0)
throw std::runtime_error("Can't load CA.");
RING_WARN("Loaded %s", param_.ca_list.c_str());
RING_DBG("Loaded %s", param_.ca_list.c_str());
}
if (param_.id.first) {
/* Load certificate, key and pass */
......@@ -592,15 +592,15 @@ SipsIceTransport::onHandshakeComplete(pj_status_t status)
{
/* Update certificates info on successful handshake */
if (status == PJ_SUCCESS) {
RING_WARN("Handshake success on remote %s",
RING_DBG("Handshake success on remote %s",
remote_.toString(true).c_str());
certUpdate();
} else {
/* Handshake failed destroy ourself silently. */
char errmsg[PJ_ERR_MSG_SIZE];
RING_WARN("Handshake failed on remote %s: %s",
remote_.toString(true).c_str(),
pj_strerror(status, errmsg, sizeof(errmsg)).ptr);
RING_ERR("Handshake failed on remote %s: %s",
remote_.toString(true).c_str(),
pj_strerror(status, errmsg, sizeof(errmsg)).ptr);
}
ChangeStateEventData eventData;
......@@ -719,7 +719,7 @@ SipsIceTransport::handleEvents()
for (const auto& pair: ackBuf) {
const auto& f = pair.first;
f.tdata_op_key->tdata = nullptr;
RING_ERR("status: %d", pair.second);
RING_DBG("status: %d", pair.second);
if (f.tdata_op_key->callback)
f.tdata_op_key->callback(getTransportBase(), f.tdata_op_key->token,
pair.second);
......@@ -730,7 +730,7 @@ SipsIceTransport::handleEvents()
bool
SipsIceTransport::setup()
{
RING_WARN("Starting GnuTLS thread");
RING_DBG("Starting GnuTLS thread");
// permit incoming packets
ice_->setOnRecv(comp_id_, [this](uint8_t* buf, size_t len) {
......@@ -738,8 +738,7 @@ SipsIceTransport::setup()
std::lock_guard<std::mutex> l(inputBuffMtx_);
tlsInputBuff_.emplace_back(buf, buf+len);
canRead_ = true;
RING_DBG("Ice: got data at %lu",
clock::now().time_since_epoch().count());
RING_DBG("TLS(ice): rx %uB", len);
}
cv_.notify_all();
return len;
......@@ -871,7 +870,7 @@ SipsIceTransport::loop()
void
SipsIceTransport::clean()
{
RING_WARN("Ending GnuTLS thread");
RING_DBG("Ending GnuTLS thread");
// Forbid GnuTLS <-> ICE IOs
ice_->setOnRecv(comp_id_, nullptr);
......@@ -1107,7 +1106,7 @@ SipsIceTransport::trySend(pjsip_tx_data_op_key *pck)
void
SipsIceTransport::shutdown()
{
RING_WARN("%s", __PRETTY_FUNCTION__);
RING_DBG("%s", __PRETTY_FUNCTION__);
state_ = TlsConnectionState::DISCONNECTED;
tlsThread_.stop();
cv_.notify_all();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment