diff --git a/src/media/media_recorder.cpp b/src/media/media_recorder.cpp index 4da743ade..ed0effb5d 100644 --- a/src/media/media_recorder.cpp +++ b/src/media/media_recorder.cpp @@ -78,7 +78,7 @@ struct MediaRecorder::StreamObserver : public Observer(m.get()); AVFrameSideData* sideData = av_frame_get_side_data(framePtr->pointer(), AV_FRAME_DATA_DISPLAYMATRIX); - int angle = sideData ? av_display_rotation_get(reinterpret_cast(sideData->data)) : 0; + int angle = sideData ? -av_display_rotation_get(reinterpret_cast(sideData->data)) : 0; if (angle != rotation_) { videoRotationFilter_ = jami::video::getTransposeFilter(angle, ROTATION_FILTER_INPUT_NAME, framePtr->width(), framePtr->height(), framePtr->format(), true); rotation_ = angle; diff --git a/src/media/video/sinkclient.cpp b/src/media/video/sinkclient.cpp index f8f91b2b2..b9b3fe065 100644 --- a/src/media/video/sinkclient.cpp +++ b/src/media/video/sinkclient.cpp @@ -367,7 +367,7 @@ SinkClient::update(Observable>* /*obs*/, int angle = 0; if (side_data) { auto matrix_rotation = reinterpret_cast(side_data->data); - angle = av_display_rotation_get(matrix_rotation); + angle = -av_display_rotation_get(matrix_rotation); } if (angle != rotation_) { filter_ = getTransposeFilter(angle, FILTER_INPUT_NAME, frame->width(), frame->height(), AV_PIX_FMT_RGB32, false); diff --git a/src/media/video/video_mixer.cpp b/src/media/video/video_mixer.cpp index b283c847a..502b175f0 100644 --- a/src/media/video/video_mixer.cpp +++ b/src/media/video/video_mixer.cpp @@ -208,7 +208,7 @@ VideoMixer::render_frame(VideoFrame& output, const VideoFrame& input, int angle = 0; if (sideData) { auto matrixRotation = reinterpret_cast(sideData->data); - angle = av_display_rotation_get(matrixRotation); + angle = -av_display_rotation_get(matrixRotation); } const constexpr char filterIn[] = "mixin"; if (angle != source->rotation) { diff --git a/src/media/video/video_sender.cpp b/src/media/video/video_sender.cpp index 86ed453f8..3dfc574c1 100644 --- a/src/media/video/video_sender.cpp +++ b/src/media/video/video_sender.cpp @@ -84,7 +84,7 @@ VideoSender::encodeAndSendVideo(VideoFrame& input_frame) #endif int size {0}; uint8_t* side_data = av_packet_get_side_data(packet, AV_PKT_DATA_DISPLAYMATRIX, &size); - auto angle = (side_data == nullptr || size == 0) ? 0 : av_display_rotation_get(reinterpret_cast(side_data)); + auto angle = (side_data == nullptr || size == 0) ? 0 : -av_display_rotation_get(reinterpret_cast(side_data)); if (rotation_ != angle) { rotation_ = angle; if (changeOrientationCallback_) @@ -100,7 +100,7 @@ VideoSender::encodeAndSendVideo(VideoFrame& input_frame) --forceKeyFrame_; AVFrameSideData* side_data = av_frame_get_side_data(input_frame.pointer(), AV_FRAME_DATA_DISPLAYMATRIX); - auto angle = side_data == nullptr ? 0 : av_display_rotation_get(reinterpret_cast(side_data->data)); + auto angle = side_data == nullptr ? 0 : -av_display_rotation_get(reinterpret_cast(side_data->data)); if (rotation_ != angle) { rotation_ = angle; if (changeOrientationCallback_) diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 995d71c21..0061a5aff 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -702,7 +702,7 @@ SIPCall::setVideoOrientation(int rotation) std::string sip_body = "" "" - "" + "" ""; JAMI_DBG("Sending device orientation via SIP INFO"); diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index 7ac7cd66d..78da8ce6c 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -972,9 +972,15 @@ handleMediaControl(SIPCall& call, pjsip_msg_body* body) std::regex_search(body_msg, matched_pattern, ORIENTATION_REGEX); if (matched_pattern.ready() && !matched_pattern.empty() && matched_pattern[1].matched) { - int rotation = std::stoi(matched_pattern[1]); - JAMI_WARN("Rotate video %d deg.", rotation); - call.getVideoRtp().setRotation(rotation); + try { + int rotation = -std::stoi(matched_pattern[1]); + while (rotation <= -180) rotation += 360; + while (rotation > 180) rotation -= 360; + JAMI_WARN("Rotate video %d deg.", rotation); + call.getVideoRtp().setRotation(rotation); + } catch (const std::exception& e) { + JAMI_WARN("Error parsing angle: %s", e.what()); + } return true; } }