Skip to content

Commit fb69a68

Browse files
author
Jaesung
authored
Merge pull request #16 from sendbird/feature/jaesung/flip-camera
Add camera flipping feature
2 parents d1de887 + 3f25f0e commit fb69a68

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

QuickStart.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@
533533
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
534534
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
535535
CODE_SIGN_STYLE = Automatic;
536-
CURRENT_PROJECT_VERSION = 1;
536+
CURRENT_PROJECT_VERSION = 12;
537537
DEVELOPMENT_TEAM = RM4A5PXTUX;
538538
FRAMEWORK_SEARCH_PATHS = (
539539
"$(inherited)",
@@ -545,7 +545,7 @@
545545
"$(inherited)",
546546
"@executable_path/Frameworks",
547547
);
548-
MARKETING_VERSION = 0.9.0;
548+
MARKETING_VERSION = 1.0.0;
549549
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
550550
PRODUCT_NAME = "SendBird Calls";
551551
SWIFT_VERSION = 5.0;
@@ -561,7 +561,7 @@
561561
CODE_SIGN_ENTITLEMENTS = QuickStart/QuickStart.entitlements;
562562
CODE_SIGN_IDENTITY = "Apple Development";
563563
CODE_SIGN_STYLE = Automatic;
564-
CURRENT_PROJECT_VERSION = 1;
564+
CURRENT_PROJECT_VERSION = 12;
565565
DEVELOPMENT_TEAM = RM4A5PXTUX;
566566
FRAMEWORK_SEARCH_PATHS = (
567567
"$(inherited)",
@@ -573,7 +573,7 @@
573573
"$(inherited)",
574574
"@executable_path/Frameworks",
575575
);
576-
MARKETING_VERSION = 0.9.0;
576+
MARKETING_VERSION = 1.0.0;
577577
PRODUCT_BUNDLE_IDENTIFIER = com.sendbird.calls.quickstart;
578578
PRODUCT_NAME = "SendBird Calls";
579579
PROVISIONING_PROFILE_SPECIFIER = "";

QuickStart/AppDelegate+CXProviderDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension AppDelegate: CXProviderDelegate {
3232
}
3333

3434
// MARK: SendBirdCalls - DirectCall.accept()
35-
let callOptions = CallOptions(isAudioEnabled: true, isVideoEnabled: call.isVideoCall)
35+
let callOptions = CallOptions(isAudioEnabled: true, isVideoEnabled: call.isVideoCall, useFrontCamera: true)
3636
let acceptParams = AcceptParams(callOptions: callOptions)
3737
call.accept(with: acceptParams)
3838

QuickStart/Dial/DialViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extension DialViewController {
102102
self.startLoading()
103103

104104
// MARK: SendBirdCall.dial()
105-
let callOptions = CallOptions(isAudioEnabled: true, isVideoEnabled: true)
105+
let callOptions = CallOptions(isAudioEnabled: true, isVideoEnabled: true, useFrontCamera: true)
106106
let dialParams = DialParams(calleeId: calleeId, isVideoCall: true, callOptions: callOptions, customItems: [:])
107107

108108
SendBirdCall.dial(with: dialParams) { call, error in

QuickStart/Dial/VideoCallViewController.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,21 @@ class VideoCallViewController: UIViewController, DirectCallDataSource {
124124

125125
// MARK: - IBActions
126126
@IBAction func didTapFilpCamera() {
127-
self.presentErrorAlert(message: "Camera selection is not supported in Calls \(SendBirdCall.sdkVersion)")
127+
let availableCapturers = self.call.availableVideoDevices
128+
guard let oppositeCamera = availableCapturers.first(where: { $0.position != self.call.currentVideoDevice?.position }) else {
129+
self.presentErrorAlert(message: "Failed to flip camera. Please retry.")
130+
return
131+
}
132+
self.call.selectVideoDevice(oppositeCamera) { error in
133+
guard error == nil else {
134+
DispatchQueue.main.async { [weak self] in
135+
guard let self = self else { return }
136+
self.presentErrorAlert(message: error?.localizedDescription ?? "")
137+
}
138+
return
139+
}
140+
self.mirrorLocalVideoView()
141+
}
128142
}
129143

130144
@IBAction func didTapAudioOnOff(_ sender: UIButton) {

QuickStart/View/Base.lproj/Main.storyboard

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,16 @@
994994
</userDefinedRuntimeAttribute>
995995
</userDefinedRuntimeAttributes>
996996
</imageView>
997-
<button hidden="YES" opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wW2-pq-7E5">
997+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7qS-YE-bhu">
998+
<rect key="frame" x="16" y="60" width="96" height="160"/>
999+
<color key="backgroundColor" red="0.6588235294117647" green="0.6588235294117647" blue="0.6588235294117647" alpha="1" colorSpace="calibratedRGB"/>
1000+
<userDefinedRuntimeAttributes>
1001+
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
1002+
<real key="value" value="8"/>
1003+
</userDefinedRuntimeAttribute>
1004+
</userDefinedRuntimeAttributes>
1005+
</view>
1006+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wW2-pq-7E5">
9981007
<rect key="frame" x="342" y="60" width="48" height="48"/>
9991008
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
10001009
<constraints>
@@ -1012,15 +1021,6 @@
10121021
<action selector="didTapFilpCamera" destination="Suw-Gg-jyg" eventType="touchUpInside" id="7Yw-YA-1Wh"/>
10131022
</connections>
10141023
</button>
1015-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7qS-YE-bhu">
1016-
<rect key="frame" x="16" y="60" width="96" height="160"/>
1017-
<color key="backgroundColor" red="0.6588235294117647" green="0.6588235294117647" blue="0.6588235294117647" alpha="1" colorSpace="calibratedRGB"/>
1018-
<userDefinedRuntimeAttributes>
1019-
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
1020-
<real key="value" value="8"/>
1021-
</userDefinedRuntimeAttribute>
1022-
</userDefinedRuntimeAttributes>
1023-
</view>
10241024
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="402226" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FCX-ZN-pc3">
10251025
<rect key="frame" x="24" y="184" width="366" height="29"/>
10261026
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="24"/>

0 commit comments

Comments
 (0)