awslabs / amazon-kinesis-video-streams-webrtc-sdk-ios

iOS SDK for interfacing with the Amazon Kinesis Video Streams Signaling Service.
Apache License 2.0
63 stars 28 forks source link
camera cocoapods peer-streaming swift video-streaming webrtc-sdk xcode

Amazon Kinesis Video iOS WebRTC Sample

[![Build Status](https://img.shields.io/github/actions/workflow/status/awslabs/amazon-kinesis-video-streams-webrtc-sdk-ios/ci.yml)](https://img.shields.io/github/actions/workflow/status/awslabs/amazon-kinesis-video-streams-webrtc-sdk-ios/ci.yml) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [//]: # (Todo: re-enable this once code cov is setup) [//]: # (([![Coverage Status](https://codecov.io/gh/awslabs/amazon-kinesis-video-streams-webrtc-sdk-ios/branch/master/graph/badge.svg)](https://codecov.io/gh/awslabs/amazon-kinesis-video-streams-webrtc-sdk-ios)))

This sample demonstrates the Amazon Kinesis Video Streams and Kinesis Video Signaling framework found in the AWS Mobile SDK for iOS with Google WebRTC.

For more information, see What Is Amazon Kinesis Video Streams with WebRTC and WebRTC SDK for iOS. You can learn more about Google WebRTC's native API's here.

Requirements

Download the WebRTC SDK in iOS

To download the WebRTC SDK in iOS, run the following command:

git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-ios.git

Using XCode to build the project

  1. Install XCode. You can install XCode from https://developer.apple.com/download/all/

  2. The AWS Mobile SDK for iOS is available through CocoaPods. If CocoaPods is not installed, install it using the following command. Note that Ruby will also be installed, as it is a dependency of Cocoapods.

    brew install cocoapods
    pod setup
  3. The following cocoa pod dependencies are included in the Podfile and need to be pod install'ed:

    • Starscream
    • Common Crytpo
    • WebRTC.framework: this is the GoogleWebRTC module framework package (bit code disabled).
    • AWSMobileClient
    • AWSCognito
    • AWSKinesisVideo
    • AWSKinesisVideoSignaling

    Change directories to the directory containing the Podfile and run the install command:

    cd amazon-kinesis-video-streams-webrtc-sdk-ios/Swift
    pod cache clean --all
    pod install --repo-update
  4. Create an Amazon Cognito User Pool. Follow steps 2-3 in the AWS KVS Android WebRTC Repo.

  5. To open the project, you can choose between these two methods:

    1. Open XCode, select "Open a project or file", and choose AWSKinesisVideoWebRTCDemoApp.xcworkspace, OR
    2. Run the following command from the Swift folder.
      xed .
  6. Open KvsiOSApp/Constants.swift. Set CognitoIdentityUserPoolRegion, CognitoIdentityUserPoolId, CognitoIdentityUserPoolAppClientId, CognitoIdentityUserPoolAppClientSecret and CognitoIdentityPoolId to the values obtained in step 3.

    Example Constants.swift ```swift let cognitoIdentityUserPoolRegion = AWSRegionType.USWest2 let cognitoIdentityUserPoolId = "us-west-2_qRsTuVwXy" let cognitoIdentityUserPoolAppClientId = "0123456789abcdefghijklmnop" let cognitoIdentityUserPoolAppClientSecret = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno" let cognitoIdentityPoolId = "us-west-2:01234567-89ab-cdef-0123-456789abcdef" ```

    Open KvsiOSApp/awsconfiguration.json and replace the "REPLACEME" values with the values obtained earlier.

    Example awsconfiguration.json ```json { "Version": "1.0", "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "us-west-2:01234567-89ab-cdef-0123-456789abcdef", "Region": "us-west-2" } } }, "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "AppClientSecret": "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno", "AppClientId": "0123456789abcdefghijklmnop", "PoolId": "us-west-2_qRsTuVwXy", "Region": "us-west-2" } } } ```
  7. To build and run, click the play button at the top of the XCode UI.

Run the iOS Sample Application

Building the iOS sample application installs the AWSKinesisVideoWebRTCDemoApp on your iOS device. Using this app, you can verify live audio/video streaming between mobile, web and IoT device clients (camera). The procedure below describes some of these scenarios.

Complete the following steps:

  1. On your iOS device, open AWSKinesisVideoWebRTCDemoApp and login using the AWS user credentials from Set Up an AWS Account and Create an Administrator. (Note: Cognito settings can be tuned through your Cognito User Pool in the AWS management Console)
  2. On successful sign-in, the channel configuration view is displayed where the channel-name, client-id (optional) and region-name have to be configured.

Run the Integration Tests

  1. To run the integration tests, the test user has to be created with the appropriate test password as in the AWSKinesisVideoWebRTCDemoAppUITests/TestConstants.swift file.
Note
Peer to Peer Streaming between two iOS devices: master and viewer:
Peer to Peer Streaming between Embedded SDK master and iOS device:
Peer to Peer Streaming between iOS device as master and Web browser as viewer:
Note

Troubleshooting

Scripting Bridge could not launch application /Applications/Xcode.app Check that `XCode.app` is in your `Applications` folder.


No such module 'AWSCognitoIdentityProvider' Open the project by selecting the `.xcworkspace` file or using the `xed .` command, not the `.xcodeproj` file.


Could not build module 'UIKit' Try reinstalling XCode, restarting your MAC, and reinstalling the Pods. Run the following commands from the same directory containing the [Podfile](Swift). ``` rm -rf ~/Library/Caches/CocoaPods rm -rf Pods rm -rf ~/Library/Developer/Xcode/DerivedData pod deintegrate rm -f Podfile.lock pod setup pod install --repo-update ``` Then, run a clean build in XCode by going to `Product > Clean Build Folder` (or using ⌘+⇧+K) before clicking the play button.


Could not find module 'AWSMobileClient' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator Open Build settings. * In XCode, switch to the file viewer, scroll down and double-click on the Pods with the XCode symbol next to it. At the top, switch the tab to `Build settings`, and check that `All` and `Combined` are selected. In the `Architectures > Architectures` setting, add `x86_64`. Alternatively, you can try enabling Rosetta: `Finder > Applications > XCode > Get Info > ✓ Enable Rosetta`


Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid region type.' Double check that [Constants.swift](Swift/KVSiOSApp/Constants.swift) contains a valid region. See [AWSRegionType](https://aws-amplify.github.io/aws-sdk-ios/docs/reference/AWSCore/Enums/AWSRegionType.html) for more info.


Unable to create channel. Please validate all the input fields Check that the values in `Constants.swift` and `awsconfiguration.json` are set correctly. See the examples above to ensure your values match the same format. Additionally, check that the IAM role has the appropriate `kinesisvideo` permissions.

License

This library is licensed under the Apache 2.0 License.