Commit 7fcfbba6 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

fix: device rotation

Switch input function does not work at the beginning on the call,
that cause  producing wrong video output if device orientation was
changed between calls.
This patch use call manager to change video output.

Change-Id: Ia3f33cf8dfbaaca6eacf0f601b1a8e098a6d0825
Gitlab: #28
parent e1593f20
......@@ -33,5 +33,6 @@
- (void)writeOutgoingFrameWithImage:(UIImage*)image;
- (void)setDecodingAccelerated:(BOOL)state;
- (void)switchInput:(NSString*)deviceName;
- (void)switchInput:(NSString*)deviceName forCall:(NSString*) callID;
@end
......@@ -21,6 +21,7 @@
#import "VideoAdapter.h"
#import "Utils.h"
#import "dring/videomanager_interface.h"
#import "dring/callmanager_interface.h"
#import "Ring-Swift.h"
#include <pthread.h>
#include <functional>
......@@ -199,6 +200,10 @@ static id <VideoAdapterDelegate> _delegate;
DRing::switchInput(std::string([deviceName UTF8String]));
}
- (void)switchInput:(NSString*)deviceName forCall:(NSString*) callID {
DRing::switchInput(std::string([callID UTF8String]), std::string([deviceName UTF8String]));
}
#pragma mark PresenceAdapterDelegate
+ (id <VideoAdapterDelegate>)delegate {
......
......@@ -97,7 +97,7 @@ class CallViewModel: Stateable, ViewModel {
return call.state == .over || call.state == .failure
}).map({ [weak self] hide in
if hide {
self?.videoService.setCameraOrientation(orientation: UIDevice.current.orientation)
self?.videoService.setCameraOrientation(orientation: UIDevice.current.orientation, callID: nil)
}
return hide
})
......@@ -301,8 +301,10 @@ class CallViewModel: Stateable, ViewModel {
return call.callId == self?.call?.callId
}).map({ call in
return call.state == .current
}).subscribe(onNext: { [weak self] _ in
self?.videoService.setCameraOrientation(orientation: UIDevice.current.orientation)
}).subscribe(onNext: { [weak self] call in
self?.videoService
.setCameraOrientation(orientation: UIDevice.current.orientation,
callID: self?.call?.callId)
}).disposed(by: self.disposeBag)
}
......@@ -411,6 +413,7 @@ class CallViewModel: Stateable, ViewModel {
}
func setCameraOrientation(orientation: UIDeviceOrientation) {
videoService.setCameraOrientation(orientation: orientation)
videoService.setCameraOrientation(orientation: orientation,
callID: self.call?.callId)
}
}
......@@ -25,5 +25,5 @@
func stopCapture()
func writeFrame(withImage image: UIImage?)
func setDecodingAccelerated(withState state: Bool)
func switchInput(toDevice device: String)
func switchInput(toDevice device: String, callID: String?)
}
......@@ -336,7 +336,7 @@ class VideoService: FrameExtractorDelegate {
}).disposed(by: self.disposeBag)
}
func setCameraOrientation(orientation: UIDeviceOrientation) {
func setCameraOrientation(orientation: UIDeviceOrientation, callID: String?) {
var newOrientation: AVCaptureVideoOrientation
switch orientation {
case .portrait:
......@@ -358,7 +358,7 @@ class VideoService: FrameExtractorDelegate {
let deviceName: String =
(orientation == .landscapeLeft || orientation == .landscapeRight) ?
self.camera.nameLandscape : self.camera.namePortrait
self.switchInput(toDevice: self.camera.nameCamera + deviceName)
self.switchInput(toDevice: self.camera.nameCamera + deviceName, callID: callID)
self.camera.rotateCamera(orientation: newOrientation)
.subscribe(onCompleted: { [unowned self] in
self.log.debug("new camera orientation isPortrait: \(orientation.isPortrait)")
......@@ -369,7 +369,11 @@ class VideoService: FrameExtractorDelegate {
}
extension VideoService: VideoAdapterDelegate {
func switchInput(toDevice device: String) {
func switchInput(toDevice device: String, callID: String?) {
if let call = callID {
videoAdapter.switchInput(device, forCall: call)
return
}
videoAdapter.switchInput(device)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment