Skip to content

Commit

Permalink
Merge pull request #8 from cbajapan/documentation
Browse files Browse the repository at this point in the history
Updated docs for version 4.2.0
  • Loading branch information
Cartisim authored Mar 22, 2023
2 parents bffae3b + 97ed5de commit 07a6bd4
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 0 deletions.
15 changes: 15 additions & 0 deletions FCSDKiOS/FCSDKiOS_template.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = 'FCSDKiOS'
s.version = 'CHANGE_ME'
s.summary = 'FCSDKiOS XCFramework'
s.homepage = 'https://github.com/cbajapan/swift-fcsdk-ios'

s.author = { 'Name' => 'Communication Business Avenue, Inc.' }
s.license = { :type => 'Commercial', :text => 'Copyright Communication Business Avenue, Inc. Use of this software is subject to the terms and conditions located at https://github.com/cbajapan/swift-fcsdk-ios/blob/main/License.txt'}

s.source = { :http => 'https://swift-sdk.s3.us-east-2.amazonaws.com/client_sdk/FCSDKiOS-CHANGE_ME.xcframework.zip' }

s.platforms = { :ios => "13.0" }

s.vendored_frameworks = 'FCSDKiOS.xcframework'
end
4 changes: 4 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ This Documentation contains what you need in order to build an FCSDKiOS applicat
- **You must be using Swift 5.5 or greater to use use this SDK**

### Articles
<doc:Version-4.2.0>

This article is to guide you through the changes of FCSDKiOS version 4.2.0.

<doc:Version-4.1.0>

This article is to guide you through the changes of FCSDKiOS version 4.1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Starting in FCSDKiOS 4.0.0 we have migrated to a native Swift code base. We have

### Version Changes

<doc:Version-4.2.0>

<doc:Version-4.1.0>

### Imports
Expand Down
93 changes: 93 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/PictureinPicture.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,98 @@
# Picture in Picture

FCSDKiOS offers Picture in Picture support. In order to use this feature you will need to be able to conform to **AVPictureInPictureControllerDelegate** and/or **AVPictureInPictureSampleBufferPlaybackDelegate**. The **SDK** consumer is completely responsible for conforming to these delegates. However you will need to get a layer or view from the **SDK** to present in the **AVPictureInPicture** code.

## Overview

The Picture in Picture feature is set up in the consumer of the **SDK**, however **FCSDKiOS** gives you all of the needed pieces in order to build a PiP app. 2 things are required to use Picture in Picture mode:

1. Your application must be using **FCSDKiOS**'s Local Buffer View
2. Your application must be using **FCSDKiOS**'s Remote Buffer View

If you have conformed to these 2 **UIView**s please see how to set up Picture in Picture below.

### AVCaptureSession
In order to check if your devices support Multitasking Camera Access, when a **LocalBufferView** is created we can get the **AVCaptureSession** from the **LocalBufferView**. If your devices are supported by Apple, you can use the new **AVPictureInPictureVideoCallViewController** provided by Apple. Otherwise, you will need to continue using **AVPictureInPictureController** and request permission from Apple for the proper entitlement. This method only works if you are using **LocalBufferView** for your Local Video UIView.
```swift
@available(iOS 15, *)
@objc final public func captureSession() async -> AVCaptureSession?
```

An example in checking for the method is as follows:
```swift
if captureSession.isMultitaskingCameraAccessSupported {
// Use AVPictureInPictureVideoCallViewController
} else {
// Use AVPictureInPictureController
}
```

### Set PiP Controller
Each **ACBClientCall** object has a `setPipController` method that is required for Picture in Picture. This method informs the **SDK** who the **AVPictureInPictureController** is and allows us to receive its delegate methods. This is required for us to handle the **RemoteBufferView** accordingly when the app activates Picture in Picture.
```swift
@available(iOS 15, *)
@MainActor @objc final public func setPipController(_ controller: AVPictureInPictureController) async
```

Now that you have an understanding of the requirements, please see the example below of how a PiP flow could be written.

```swift
@available(iOS 15.0, *)
var pipController: AVPictureInPictureController!


func showPip(show: Bool) async {
if show {
if AVPictureInPictureController.isPictureInPictureSupported() {
pipController.startPictureInPicture()
} else {
self.logger.info("PIP not Supported")
}
} else {
pipController.stopPictureInPicture()
}
}

func setUpPip() async {
guard let remoteBufferView = remoteBufferView else { return }

if #available(iOS 16.0, *) {
guard let captureSession = captureSession else { return }
if captureSession.isMultitaskingCameraAccessSupported {
let pipVideoCallViewController = AVPictureInPictureVideoCallViewController()
pipVideoCallViewController.preferredContentSize = CGSize(width: 1080, height: 1920)
pipVideoCallViewController.view.addSubview(remoteBufferView)

let source = AVPictureInPictureController.ContentSource(
activeVideoCallSourceView: remoteBufferView,
contentViewController: pipVideoCallViewController)

pipController = AVPictureInPictureController(contentSource: source)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.delegate = self
await self.fcsdkCallService.fcsdkCall?.call?.setPipController(pipController)
} else {
//If we are iOS 16 and we are not an m chip
await aChipLogic()
}
} else {
await aChipLogic()
}
}

func aChipLogic() async {
let layer = remoteBufferView.layer as? AVSampleBufferDisplayLayer
guard let sourceLayer = layer else { return }

let source = AVPictureInPictureController.ContentSource(sampleBufferDisplayLayer: sourceLayer, playbackDelegate: self)

pipController = AVPictureInPictureController(contentSource: source)
pipController.canStartPictureInPictureAutomaticallyFromInline = true
pipController.delegate = self
await self.fcsdkCallService.fcsdkCall?.call?.setPipController(pipController)
}

```

## Available FCSDK Objects
<doc:ACBUCObject>
Expand Down
24 changes: 24 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/Symbols/ACBClientCall.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ Please see <doc:VideoCalls> for an explanation of how to use ACBClientCall
/// The client should always remove the `remoteBufferView()` when finished using the bufferView.
@objc final public func removeBufferView() async

/// The call's ``UIView`` used for displaying local buffer views intended for use in picture in picture/Virtual Background enabled applications
@MainActor @objc final public func localBufferView() async -> UIView?

/// The client should always remove the `removePreviewView()` when finished using the previewView.
@objc final public func removeLocalBufferView() async

/// The AVCaptureSession that the PreviewBufferView provides
@objc final public func captureSession() async -> AVCaptureSession?

/// Feeds the AVPictureInPictureController into FCSDKiOS in order to receive the controller's delegate method notifications.
@MainActor @objc final public func setPipController(_ controller: AVPictureInPictureController) async

/// Feeds the UIImage from the consuming app into the SDK for Video Processing
@objc final public func feedBackgroundImage(_ image: UIImage? = nil, mode: FCSDKiOS.VirtualBackgroundMode = .image) async

/// Removes the Background Image from the Video Processsing flow
@objc final public func removeBackgroundImage() async

/// An Enum that tells FCSDKiOS what mode the Virtual Background should be
@objc public enum VirtualBackgroundMode: Int, Sendable, Equatable, Hashable, RawRepresentable {
case blur
case image
}

/// A boolean value used to tell FCSDK if the client should have remote video when creating the call
@objc final public var hasRemoteVideo: Bool { get }

Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/Symbols/Constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Constant things useful for FCSDK. LoggingLevel is especially helpful for setting

/// The Version of the SDK
@objc public static let SDK_VERSION_NUMBER: String
/// WebSocket connection timeout
@objc public static var WEBSOCKET_CONNECTION_TIMEOUT: Float

override dynamic public init()
}
Expand Down
83 changes: 83 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/Version-4.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Version 4.2.0

This article describes changes in version 4.2.0 of FCSDKiOS

## Overview
Version 4.2.0 reaches a new milestone in terms of Video Calls. We now support Picture in Picture and Virtual Background. The following Topics are the changes that we have made.

### Local Buffer View
This method is designed to create a metal rendered `UIView` for your local video during a video call. This method must be used if you desire to use our **Virtual Background** feature.
When a call is finished the **SDK** consumer is required to clean up the call by calling the `removeLocalBufferView` method.
```swift
@available(iOS 15, *)
@MainActor @objc final public func localBufferView() async -> UIView?
```

```swift
@available(iOS 15, *)
@objc final public func removeLocalBufferView() async
```

### Remote Buffer View
This method is designed to create a metal rendered `UIView` for your remote video during a video call. This method must be used if you desire to use our **Picture in Picture** feature.
When a call is finished the **SDK** consumer is required to clean up the call by calling the `removeBufferView` method.
```swift
@available(iOS 15, *)
@MainActor @objc final public func remoteBufferView() async -> UIView?
```

```swift
@available(iOS 15, *)
@objc final public func removeBufferView() async
```

### AVCaptureSession
In order to check if your devices support Multitasking Camera Access, when a **LocalBufferView** is created we can get the **AVCaptureSession** from the **LocalBufferView**. If your device is supported by Apple, you can use the new **AVPictureInPictureVideoCallViewController** provided by Apple. Otherwise you will need to continue using **AVPictureInPictureController** and request permission from Apple for the proper entitlement. This method only works if you are using **LocalBufferView** for your Local Video UIView.
```swift
@available(iOS 15, *)
@objc final public func captureSession() async -> AVCaptureSession?
```

An example in checking for the method is as follows:
```swift
if captureSession.isMultitaskingCameraAccessSupported {
// Use AVPictureInPictureVideoCallViewController
} else {
// Use AVPictureInPictureController
}
```

### Set PiP Controller
Each **ACBClientCall** object has a `setPipController` method that is required for Picture in Picture. This method informs the **SDK** who the **AVPictureInPictureController** is and allows us to receive its delegate methods. This is required for us to handle the **RemoteBufferView** accordingly when tha app activates Picture in Picture.
```swift
@available(iOS 15, *)
@MainActor @objc final public func setPipController(_ controller: AVPictureInPictureController) async
```

### Feeding a Background Image
In order to use the **Virtual Background** feature the **SDK** consumer is required to feed the **SDK** a UIImage that the **SDK** can use as the virtual background. It is **STRONGLY** encouraged for performance reasons to feed an image that is as small as possible. The SDK consumer is responsible for setting up any UI that stores and presents images for selection. Typically you will want to take the resolution into consideration that the image will be displayed onto.(i.e. the callees video screen). If the consumer does not handle feeding FCSDKiOS an appropriate image size then **FCSDKiOS** will automatically resize the background image to an acceptable size of *CGSize(width: 1280, height: 720)*. If you wish to blur the background instead of using an image you can select **.blur** from the **VirtualBackgroundMode** enum without including a **UIImage** in the image property parameter.

```swift
@available(iOS 15, *)
@objc final public func feedBackgroundImage(_ image: UIImage? = nil, mode: FCSDKiOS.VirtualBackgroundMode = .image) async
```

```swift
@available(iOS 15, *)
@objc final public func removeBackgroundImage() async
```

### Virtual Background Mode
When feeding your background image you can set what mode it should be. There are 2 modes `.image` or `.blur`
```swift
@objc public enum VirtualBackgroundMode : Int, Sendable, Equatable, Hashable, RawRepresentable {
case blur
case image
}
```

### WebSocket Connection Timeout
We have opened up the ability to set the WebSocket connection timeout on the **Constants** object.
```swift
@objc public static var WEBSOCKET_CONNECTION_TIMEOUT: Float
```
67 changes: 67 additions & 0 deletions Sources/SwiftFCSDKiOS/SwiftFCSDKiOS.docc/VirtualBackground.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# VirtualBackground

FCSDKiOS offers virtual background support. This feature offers an option to blur your camera capture's background or simply provide a virtual background image.

## Overview

The Virtual Background feature has been robustly built natively for your performance. Below we describe how to set up Virtual Background.

## Feeding a Background Image
In order to use the **Virtual Background** feature the **SDK** consumer is required to feed the **SDK** a UIImage that the **SDK** can use as the virtual background. It is **STRONGLY** encouraged for performance reasons to feed an image that is as small as possible. The SDK consumer is responsible for setting up any UI that stores and presents images for selection. Typically you will want to take the resolution into consideration that the image will be displayed onto.(i.e. the callees video screen). If the consumer does not handle feeding FCSDKiOS an appropriate image size then **FCSDKiOS** will automatically resize the background image to an acceptable size of *CGSize(width: 1280, height: 720)*. If you wish to blur the background instead of using an image you can select **.blur** from the **VirtualBackgroundMode** enum without including a **UIImage** in the image property parameter.

```swift
@available(iOS 15, *)
@objc final public func feedBackgroundImage(_ image: UIImage? = nil, mode: FCSDKiOS.VirtualBackgroundMode = .image) async
```

```swift
@available(iOS 15, *)
@objc final public func removeBackgroundImage() async
```

## Virtual Background Mode
When feeding your background image you can set what mode it should be. There are 2 modes `.image` or `.blur`
```swift
@objc public enum VirtualBackgroundMode : Int, Sendable, Equatable, Hashable, RawRepresentable {
case blur
case image
}
```


## Available FCSDK Objects
<doc:ACBUCObject>

<doc:ACBUCDelegate>

<doc:ACBUCOptions>

<doc:ACBAudioDevice>

<doc:ACBAudioDeviceManager>

<doc:ACBClientAED>

<doc:ACBClientCall>

<doc:ACBClientCallDelegate>

<doc:ACBClientCallErrorCode>

<doc:ACBClientCallProvisionalResponse>

<doc:ACBClientCallStatus>

<doc:ACBClientPhone>

<doc:ACBMediaDirection>

<doc:ACBTopic>

<doc:ACBVideoCapture>

<doc:AedData>

<doc:TopicData>

<doc:Constants>

0 comments on commit 07a6bd4

Please sign in to comment.