From b10ad06ecc380ca4de258cc5c180212ed1d8961d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 27 Aug 2019 12:17:39 -0400
Subject: [PATCH] sipcall: fix rotation

Change-Id: I96bea87e43cf08ddf0b2805f13d35c3efa6c2db7
---
 src/media/video/video_rtp_session.cpp |  2 ++
 src/sip/sipcall.cpp                   | 15 +++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/media/video/video_rtp_session.cpp b/src/media/video/video_rtp_session.cpp
index 2a28e1b52f..3ea7dd0a89 100644
--- a/src/media/video/video_rtp_session.cpp
+++ b/src/media/video/video_rtp_session.cpp
@@ -530,6 +530,8 @@ void
 VideoRtpSession::setChangeOrientationCallback(std::function<void(int)> cb)
 {
     changeOrientationCallback_ = std::move(cb);
+    if (sender_)
+        sender_->setChangeOrientationCallback(changeOrientationCallback_);
 }
 
 float
diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index 71e5dccc19..995d71c216 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -912,6 +912,15 @@ SIPCall::startAllMedia()
     bool peer_holding {true};
     int slotN = -1;
 
+#ifdef ENABLE_VIDEO
+    videortp_->setChangeOrientationCallback([wthis = weak()] (int angle) {
+        runOnMainThread([wthis, angle] {
+            if (auto this_ = wthis.lock())
+                this_->setVideoOrientation(angle);
+        });
+    });
+#endif
+
     for (const auto& slot : slots) {
         ++slotN;
         const auto& local = slot.first;
@@ -998,12 +1007,6 @@ SIPCall::startAllMedia()
                 this_->requestKeyframe();
         });
     });
-    videortp_->setChangeOrientationCallback([wthis = weak()] (int angle) {
-        runOnMainThread([wthis, angle] {
-            if (auto this_ = wthis.lock())
-                this_->setVideoOrientation(angle);
-        });
-    });
 #endif
 
     if (not isSubcall() and peerHolding_ != peer_holding) {
-- 
GitLab