diff --git a/submodules/Display/Source/ChildWindowHostView.swift b/submodules/Display/Source/ChildWindowHostView.swift index 6cb1998c7e..0d5e5af144 100644 --- a/submodules/Display/Source/ChildWindowHostView.swift +++ b/submodules/Display/Source/ChildWindowHostView.swift @@ -99,15 +99,15 @@ public func childWindowHostView(parent: UIView) -> WindowHostView { } view.invalidateDeferScreenEdgeGestureImpl = { [weak hostView] in - return hostView?.invalidateDeferScreenEdgeGesture?() + hostView?.invalidateDeferScreenEdgeGesture?() } view.invalidatePrefersOnScreenNavigationHiddenImpl = { [weak hostView] in - return hostView?.invalidatePrefersOnScreenNavigationHidden?() + hostView?.invalidatePrefersOnScreenNavigationHidden?() } view.invalidateSupportedOrientationsImpl = { [weak hostView] in - return hostView?.invalidateSupportedOrientations?() + hostView?.invalidateSupportedOrientations?() } view.cancelInteractiveKeyboardGesturesImpl = { [weak hostView] in diff --git a/submodules/Display/Source/NativeWindowHostView.swift b/submodules/Display/Source/NativeWindowHostView.swift index 035d3ac0e7..cde42af983 100644 --- a/submodules/Display/Source/NativeWindowHostView.swift +++ b/submodules/Display/Source/NativeWindowHostView.swift @@ -409,15 +409,15 @@ public func nativeWindowHostView() -> (UIWindow & WindowHost, WindowHostView) { } window.invalidateDeferScreenEdgeGestureImpl = { [weak hostView] in - return hostView?.invalidateDeferScreenEdgeGesture?() + hostView?.invalidateDeferScreenEdgeGesture?() } window.invalidatePrefersOnScreenNavigationHiddenImpl = { [weak hostView] in - return hostView?.invalidatePrefersOnScreenNavigationHidden?() + hostView?.invalidatePrefersOnScreenNavigationHidden?() } window.invalidateSupportedOrientationsImpl = { [weak hostView] in - return hostView?.invalidateSupportedOrientations?() + hostView?.invalidateSupportedOrientations?() } window.cancelInteractiveKeyboardGesturesImpl = { [weak hostView] in diff --git a/submodules/LegacyComponents/Sources/TGClipboardGalleryMixin.m b/submodules/LegacyComponents/Sources/TGClipboardGalleryMixin.m index d41ba25ebc..2e8a48022f 100644 --- a/submodules/LegacyComponents/Sources/TGClipboardGalleryMixin.m +++ b/submodules/LegacyComponents/Sources/TGClipboardGalleryMixin.m @@ -100,7 +100,7 @@ }; [model.interfaceView updateSelectionInterface:selectionContext.count counterVisible:(selectionContext.count > 0) animated:false]; - model.interfaceView.donePressed = ^(TGClipboardGalleryPhotoItem *item) + model.interfaceView.donePressed = ^(id item) { __strong TGClipboardGalleryMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -109,18 +109,18 @@ strongSelf->_galleryModel.dismiss(true, false); if (strongSelf.completeWithItem != nil) - strongSelf.completeWithItem(item); + strongSelf.completeWithItem((TGClipboardGalleryPhotoItem *)item); }; modernGallery.model = model; - modernGallery.itemFocused = ^(TGClipboardGalleryPhotoItem *item) + modernGallery.itemFocused = ^(id item) { __strong TGClipboardGalleryMixin *strongSelf = weakSelf; if (strongSelf != nil && strongSelf.itemFocused != nil) - strongSelf.itemFocused(item); + strongSelf.itemFocused((TGClipboardGalleryPhotoItem *)item); }; - modernGallery.beginTransitionIn = ^UIView *(TGClipboardGalleryPhotoItem *item, TGModernGalleryItemView *itemView) + modernGallery.beginTransitionIn = ^UIView *(id item, TGModernGalleryItemView *itemView) { __strong TGClipboardGalleryMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -130,12 +130,12 @@ strongSelf.willTransitionIn(); if (strongSelf.referenceViewForItem != nil) - return strongSelf.referenceViewForItem(item); + return strongSelf.referenceViewForItem((TGClipboardGalleryPhotoItem *)item); return nil; }; - modernGallery.finishedTransitionIn = ^(__unused TGClipboardGalleryPhotoItem *item, __unused TGModernGalleryItemView *itemView) + modernGallery.finishedTransitionIn = ^(__unused id item, __unused TGModernGalleryItemView *itemView) { __strong TGClipboardGalleryMixin *strongSelf = weakSelf; if (strongSelf == nil) @@ -144,7 +144,7 @@ [strongSelf->_galleryModel.interfaceView setSelectedItemsModel:strongSelf->_galleryModel.selectedItemsModel]; }; - modernGallery.beginTransitionOut = ^UIView *(TGClipboardGalleryPhotoItem *item, TGModernGalleryItemView *itemView) + modernGallery.beginTransitionOut = ^UIView *(id item, TGModernGalleryItemView *itemView) { __strong TGClipboardGalleryMixin *strongSelf = weakSelf; if (strongSelf != nil) @@ -153,7 +153,7 @@ strongSelf.willTransitionOut(); if (strongSelf.referenceViewForItem != nil) - return strongSelf.referenceViewForItem(item); + return strongSelf.referenceViewForItem((TGClipboardGalleryPhotoItem *)item); } return nil; }; diff --git a/submodules/LegacyComponents/Sources/TGClipboardGalleryModel.m b/submodules/LegacyComponents/Sources/TGClipboardGalleryModel.m index 6505f62f3d..4bd5a518f6 100644 --- a/submodules/LegacyComponents/Sources/TGClipboardGalleryModel.m +++ b/submodules/LegacyComponents/Sources/TGClipboardGalleryModel.m @@ -100,7 +100,7 @@ [strongSelf setCurrentItemWithIndex:index]; }; - _interfaceView.captionSet = ^(id item, NSString *caption, NSArray *entities) + _interfaceView.captionSet = ^(id item, NSString *caption, NSArray *entities) { __strong TGClipboardGalleryModel *strongSelf = weakSelf; if (strongSelf == nil || strongSelf.saveItemCaption == nil) diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsController.m b/submodules/LegacyComponents/Sources/TGMediaAssetsController.m index 956d31fb69..24ffeecb78 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsController.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsController.m @@ -359,10 +359,11 @@ NSString *text = nil; __block bool hasPhoto = false; __block bool hasVideo = false; - [strongSelf->_selectionContext enumerateSelectedItems:^(TGMediaAsset *asset) { - if (![asset isKindOfClass:[TGMediaAsset class]]) + [strongSelf->_selectionContext enumerateSelectedItems:^(id asset) { + NSObject *value = (NSObject *)asset; + if (![value isKindOfClass:[TGMediaAsset class]]) return; - if (asset.isVideo) { + if (((TGMediaAsset *)asset).isVideo) { hasVideo = true; } else { hasPhoto = true; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m index f225854879..159db145a1 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m @@ -210,7 +210,7 @@ [strongSelf setCurrentItemWithIndex:index]; }; - _interfaceView.captionSet = ^(id item, NSString *caption, NSArray *entities) + _interfaceView.captionSet = ^(id item, NSString *caption, NSArray *entities) { __strong TGMediaPickerGalleryModel *strongSelf = weakSelf; if (strongSelf == nil || strongSelf.saveItemCaption == nil) diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNode.swift b/submodules/TelegramCallsUI/Sources/CallControllerNode.swift index 01a859d569..dad5145944 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNode.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNode.swift @@ -1274,16 +1274,48 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro insets.left = interpolate(from: expandedInset, to: insets.left, value: 1.0 - self.pictureInPictureTransitionFraction) insets.right = interpolate(from: expandedInset, to: insets.right, value: 1.0 - self.pictureInPictureTransitionFraction) - let previewVideoSide = interpolate(from: 350.0, to: 200.0, value: 1.0 - self.pictureInPictureTransitionFraction) + let previewVideoSide = interpolate(from: 300.0, to: 150.0, value: 1.0 - self.pictureInPictureTransitionFraction) var previewVideoSize = layout.size.aspectFitted(CGSize(width: previewVideoSide, height: previewVideoSide)) previewVideoSize = CGSize(width: 30.0, height: 45.0).aspectFitted(previewVideoSize) if let minimizedVideoNode = self.minimizedVideoNode { - switch minimizedVideoNode.currentOrientation { - case .rotation90, .rotation270: - break - default: - previewVideoSize = CGSize(width: previewVideoSize.height, height: previewVideoSize.width) + var aspect = minimizedVideoNode.currentAspect + var rotationCount = 0 + if minimizedVideoNode === self.outgoingVideoNodeValue { + aspect = 3.0 / 4.0 + } else { + if aspect < 1.0 { + aspect = 3.0 / 4.0 + } else { + aspect = 4.0 / 3.0 + } + + switch minimizedVideoNode.currentOrientation { + case .rotation90, .rotation270: + rotationCount += 1 + default: + break + } + + var mappedDeviceOrientation = self.deviceOrientation + if case .regular = layout.metrics.widthClass, case .regular = layout.metrics.heightClass { + mappedDeviceOrientation = .portrait + } + + switch mappedDeviceOrientation { + case .landscapeLeft, .landscapeRight: + rotationCount += 1 + default: + break + } + + if rotationCount % 2 != 0 { + aspect = 1.0 / aspect + } } + + let unboundVideoSize = CGSize(width: aspect * 10000.0, height: 10000.0) + + previewVideoSize = unboundVideoSize.aspectFitted(CGSize(width: previewVideoSide, height: previewVideoSide)) } let previewVideoY: CGFloat let previewVideoX: CGFloat @@ -1530,7 +1562,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro self.animationForExpandedVideoSnapshotView = nil } minimizedVideoTransition.updateFrame(node: minimizedVideoNode, frame: previewVideoFrame) - minimizedVideoNode.updateLayout(size: previewVideoFrame.size, cornerRadius: interpolate(from: 14.0, to: 24.0, value: self.pictureInPictureTransitionFraction), isOutgoing: minimizedVideoNode === self.outgoingVideoNodeValue, deviceOrientation: .portrait, isCompactLayout: false, transition: minimizedVideoTransition) + minimizedVideoNode.updateLayout(size: previewVideoFrame.size, cornerRadius: interpolate(from: 14.0, to: 24.0, value: self.pictureInPictureTransitionFraction), isOutgoing: minimizedVideoNode === self.outgoingVideoNodeValue, deviceOrientation: mappedDeviceOrientation, isCompactLayout: false, transition: minimizedVideoTransition) if transition.isAnimated && didAppear { minimizedVideoNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.5) } diff --git a/submodules/TelegramCallsUI/Sources/PresentationCall.swift b/submodules/TelegramCallsUI/Sources/PresentationCall.swift index 2c198ddff6..a0b65b282c 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCall.swift @@ -246,6 +246,7 @@ public final class PresentationCallImpl: PresentationCall { private var droppedCall = false private var dropCallKitCallTimer: SwiftSignalKit.Timer? + private var useFrontCamera: Bool = true private var videoCapturer: OngoingCallVideoCapturer? init( @@ -1029,6 +1030,7 @@ public final class PresentationCallImpl: PresentationCall { } public func switchVideoCamera() { - self.videoCapturer?.switchCamera() + self.useFrontCamera = !self.useFrontCamera + self.videoCapturer?.switchVideoInput(isFront: self.useFrontCamera) } } diff --git a/submodules/TelegramVoip/Sources/OngoingCallContext.swift b/submodules/TelegramVoip/Sources/OngoingCallContext.swift index 9a2fdc900f..f5e882882d 100644 --- a/submodules/TelegramVoip/Sources/OngoingCallContext.swift +++ b/submodules/TelegramVoip/Sources/OngoingCallContext.swift @@ -336,8 +336,8 @@ public final class OngoingCallVideoCapturer { self.impl = OngoingCallThreadLocalContextVideoCapturer() } - public func switchCamera() { - self.impl.switchVideoCamera() + public func switchVideoInput(isFront: Bool) { + self.impl.switchVideoInput(isFront) } public func makeOutgoingVideoView(completion: @escaping (OngoingCallContextPresentationCallVideoView?) -> Void) { diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h index dbc526626b..37ba55746f 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoip/OngoingCallThreadLocalContext.h @@ -109,7 +109,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) { - (instancetype _Nonnull)init; -- (void)switchVideoCamera; +- (void)switchVideoInput:(bool)isFront; - (void)setIsVideoEnabled:(bool)isVideoEnabled; - (void)makeOutgoingVideoView:(void (^_Nonnull)(UIView * _Nullable))completion; diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index 93123b6c21..eb14febcf1 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -152,8 +152,8 @@ - (void)dealloc { } -- (void)switchVideoCamera { - _interface->switchCamera(); +- (void)switchVideoInput:(bool)isFront { + _interface->switchToDevice(isFront ? "" : "back"); } - (void)setIsVideoEnabled:(bool)isVideoEnabled { diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index d27912dced..744762e065 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit d27912dcedcd9f223fbdbbb5589b01839c256a8d +Subproject commit 744762e065ddcde3a20c1c434fcc7c456aac3126