IOS Prevent video rotation on device orientation change

1,767 views
Skip to first unread message

Alvaro Gil

unread,
Oct 13, 2015, 10:31:09 AM10/13/15
to discuss-webrtc
Hi,

I would like to disable orientation change if the user has rotated the device during a call.
I am seeing that this method[0] is call after each device orientation change and I would like to be able to set if the determine if the rotation of the video should be made or not at each device orientation change.
It seems that this requires a patch in the code, but if someone else figured out a workaround that I am not seeing, please let me know.

Thanks.

Tadas Straševičius

unread,
Oct 13, 2015, 1:35:45 PM10/13/15
to discuss-webrtc
Try adding:

[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];


Before rendering and also disable rotation in uiviewcontroller.

Alvaro Gil

unread,
Oct 13, 2015, 4:27:45 PM10/13/15
to discuss...@googlegroups.com
Hi Tadas,

Thanks, but I couldn't make it work that way.
Don't know why, since that method should cancel notifications.
An alternative could be removing it with [[NSNotificationCenter
defaultCenter] removeObserver:`source`] but doesn't look like `source`
is the instanced registered to receive notification, and it is the
only object I have access to.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "discuss-webrtc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to discuss-webrt...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/discuss-webrtc/e5d6438a-7b76-4482-a743-dc43ab3a9e38%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Federico Henze

unread,
Dec 2, 2018, 2:08:28 AM12/2/18
to discuss-webrtc
Is there any solution for this?

David Thomas

unread,
Dec 3, 2018, 2:57:41 AM12/3/18
to discuss-webrtc
I had a similar problem to this with an older version of WebRTC.

I don't remember all of the details but I think I patched WebRTC to use the status bar orientation instead of the physical orientation.

What we wanted was for the video not to rotate if the app had disabled rotation, so the video should follow the user interface orientation rather than the device orientation.

I don't have time to look it up, sorry.

Neil Young

unread,
Dec 3, 2018, 3:26:36 AM12/3/18
to discuss-webrtc
Same here. I patched the RTCCameraVideoCapturer in order to achieve the same what David said. The image should always show, what the user is expecting. If you look into a mirror, you are also not expecting your image to rotate.

I also filed a bug report to webrtc, but they think they are right with what they are doing and didn't accept.


Setting the orientation on the frame is intended behaviour. We always send frames landscape on iOS but tagged with rotation. It's then up to the renderer to handle that correctly.

Because "handling that on the renderer" did also not work as expected and showed disturbing images, I decided to patch out that rotation stuff.

Federico Henze

unread,
Dec 5, 2018, 8:26:22 AM12/5/18
to discuss-webrtc
Hi, 

the problem in my case was that the video captured with the front camera was no mirrored. I fix the issue flipping the RTCMTLVideoView

self.localView.transform = CGAffineTransformMakeScale(-1.0, 1.0)  

Neil Young

unread,
Dec 5, 2018, 9:28:33 AM12/5/18
to discuss...@googlegroups.com
With the latest version a CALayer mirroring doesn’t work.  At least not for RTCMTLVideoView. Works for EAGLView. 


And in my case the mirror did not solve the problem, that with the unpatched module a rotation around the axis which goes orthogonally through the phone did not lead to an upside down video.  Now the phone behaves correctly. Like a rotating mirror 

Sent from my iPhone

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages