From 57bc2d33d14e159a8c7ba830646cad43251b9536 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Thu, 8 Oct 2015 14:13:16 -0400 Subject: [PATCH] media_encoder: disable sdp related logging - refactored media_encoder::print_sdp(): log result only if DEBUG_SDP build variable is defined - video_sender: remove sdp_ variable seems not to be used anywhere Issue: #81581 Change-Id: I191e520d2ff81907adf9db90dfdf96616d3c50d4 --- src/media/audio/audio_rtp_session.cpp | 6 +++--- src/media/media_encoder.cpp | 19 ++++++++++++------- src/media/media_encoder.h | 2 +- src/media/video/video_sender.cpp | 3 +-- src/media/video/video_sender.h | 2 -- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/media/audio/audio_rtp_session.cpp b/src/media/audio/audio_rtp_session.cpp index ae2b4d17ce..7d44261dde 100644 --- a/src/media/audio/audio_rtp_session.cpp +++ b/src/media/audio/audio_rtp_session.cpp @@ -116,9 +116,9 @@ AudioSender::setup(SocketPair& socketPair) return false; } - std::string sdp; - audioEncoder_->print_sdp(sdp); - RING_DBG("\n%s", sdp.c_str()); +#ifdef DEBUG_SDP + audioEncoder_->print_sdp(); +#endif return true; } diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp index 6ad69c3d65..6705bdeac1 100644 --- a/src/media/media_encoder.cpp +++ b/src/media/media_encoder.cpp @@ -33,9 +33,10 @@ #include <algorithm> #include <thread> // hardware_concurrency -namespace ring { +// Define following line if you need to debug libav SDP +//#define DEBUG_SDP 1 -using std::string; +namespace ring { MediaEncoder::MediaEncoder() : outputCtx_(avformat_alloc_context()) @@ -496,21 +497,25 @@ int MediaEncoder::flush() return ret; } -void MediaEncoder::print_sdp(std::string &sdp_) +std::string +MediaEncoder::print_sdp() { /* theora sdp can be huge */ const auto sdp_size = outputCtx_->streams[0]->codec->extradata_size + 2048; + std::string result; std::string sdp(sdp_size, '\0'); av_sdp_create(&outputCtx_, 1, &(*sdp.begin()), sdp_size); std::istringstream iss(sdp); - string line; - sdp_ = ""; + std::string line; while (std::getline(iss, line)) { /* strip windows line ending */ line = line.substr(0, line.length() - 1); - sdp_ += line + "\n"; + result += line + "\n"; } - RING_DBG("Sending SDP: \n%s", sdp_.c_str()); +#ifdef DEBUG_SDP + RING_DBG("Sending SDP:\n%s", result.c_str()); +#endif + return result; } void MediaEncoder::prepareEncoderContext(bool is_video) diff --git a/src/media/media_encoder.h b/src/media/media_encoder.h index 01f3489066..d6458fefee 100644 --- a/src/media/media_encoder.h +++ b/src/media/media_encoder.h @@ -72,7 +72,7 @@ public: int encode_audio(const AudioBuffer &input); int flush(); - void print_sdp(std::string &sdp_); + std::string print_sdp(); /* getWidth and getHeight return size of the encoded frame. * Values have meaning only after openOutput call. diff --git a/src/media/video/video_sender.cpp b/src/media/video/video_sender.cpp index 979953826f..0d30f46482 100644 --- a/src/media/video/video_sender.cpp +++ b/src/media/video/video_sender.cpp @@ -47,13 +47,12 @@ VideoSender::VideoSender(const std::string& dest, const DeviceParams& dev, videoEncoder_->setIOContext(muxContext_); videoEncoder_->startIO(); - videoEncoder_->print_sdp(sdp_); + videoEncoder_->print_sdp(); } VideoSender::~VideoSender() { videoEncoder_->flush(); - } diff --git a/src/media/video/video_sender.h b/src/media/video/video_sender.h index e5a4511fbf..6ea7214aa3 100644 --- a/src/media/video/video_sender.h +++ b/src/media/video/video_sender.h @@ -50,7 +50,6 @@ public: ~VideoSender(); - std::string getSDP() const { return sdp_; } void forceKeyFrame(); // as VideoFramePassiveReader @@ -77,7 +76,6 @@ private: std::atomic<int> forceKeyFrame_ {KEYFRAMES_AT_START}; int keyFrameFreq_ {0}; // Set keyframe rate, 0 to disable auto-keyframe. Computed in constructor int64_t frameNumber_ = 0; - std::string sdp_ = ""; }; }} // namespace ring::video -- GitLab