From 21f81fc6e24481e368b43d24f05953a4a0323119 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Thu, 15 Aug 2019 16:23:32 -0400
Subject: [PATCH] sipvoiplink: cleanup

Change-Id: I7d266d9d82d76715f8f88807e4944821a04aee20
---
 src/media/video/video_receive_thread.cpp |  2 +-
 src/sip/sipvoiplink.cpp                  | 17 +++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/media/video/video_receive_thread.cpp b/src/media/video/video_receive_thread.cpp
index d3135d6817..b520a6e182 100644
--- a/src/media/video/video_receive_thread.cpp
+++ b/src/media/video/video_receive_thread.cpp
@@ -87,7 +87,7 @@ bool VideoReceiveThread::setup()
     dstWidth_ = args_.width;
     dstHeight_ = args_.height;
 
-    const std::string SDP_FILENAME = "dummyFilename";
+    static const std::string SDP_FILENAME = "dummyFilename";
     if (args_.input.empty()) {
         args_.format = "sdp";
         args_.input = SDP_FILENAME;
diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp
index c7f27d5861..a9a1166a7d 100644
--- a/src/sip/sipvoiplink.cpp
+++ b/src/sip/sipvoiplink.cpp
@@ -952,26 +952,23 @@ handleMediaControl(SIPCall& call, pjsip_msg_body* body)
 
         /* Apply and answer the INFO request */
         pj_strset(&control_st, (char *) body->data, body->len);
-        constexpr pj_str_t PICT_FAST_UPDATE = CONST_PJ_STR("picture_fast_update");
-        constexpr pj_str_t DEVICE_ORIENTATION = CONST_PJ_STR("device_orientation");
+        static constexpr pj_str_t PICT_FAST_UPDATE = CONST_PJ_STR("picture_fast_update");
+        static constexpr pj_str_t DEVICE_ORIENTATION = CONST_PJ_STR("device_orientation");
 
         if (pj_strstr(&control_st, &PICT_FAST_UPDATE)) {
             call.sendKeyframe();
             return true;
         } else if (pj_strstr(&control_st, &DEVICE_ORIENTATION)) {
-            int rotation = 0;
-            std::string body_msg = control_st.ptr;
+            static const std::regex ORIENTATION_REGEX("device_orientation=([-+]?[0-9]+)");
+
+            std::string body_msg(control_st.ptr, control_st.slen);
             std::smatch matched_pattern;
-            std::regex str_pattern("device_orientation=([-+]?[0-9]+)");
+            std::regex_search(body_msg, matched_pattern, ORIENTATION_REGEX);
 
-            std::regex_search(body_msg, matched_pattern, str_pattern);
             if (matched_pattern.ready() && !matched_pattern.empty() && matched_pattern[1].matched) {
-                rotation = std::stoi(matched_pattern[1]);
-
+                int rotation = std::stoi(matched_pattern[1]);
                 JAMI_WARN("Rotate video %d deg.", rotation);
-
                 call.getVideoRtp().setRotation(rotation);
-
                 return true;
             }
         }
-- 
GitLab