Skip to content

100mslive/100ms-ios-broadcast-sdk

Repository files navigation

Cocoapods iOS License Documentation Discord TestFlight Email

🎉 100ms iOS Broadcast extension SDK 🚀

HMSBroadcastExtensionSDK is made specifically to be used in the iOS broadcast upload extension target. After importing the SDK, you use HMSScreenRenderer class to process the sample buffer coming from RPBroadcastSampleHandler. These samples are then presented in your main meeting app as screen recording track.

🚂 How to import

Using Swift Package Manager

You can use Swift Package Manager (use https://github.com/100mslive/100ms-ios-broadcast-sdk.git as the package source)

Add HMSBroadcastExtensionSDK to your main app target from Swift Package Manager. Then add HMSBroadcastExtensionSDK to your iOS broadcast upload extension target.

Using Cocoapods

Get the HMSBroadcastExtensionSDK via Cocoapods. Add the pod 'HMSBroadcastExtensionSDK' to your broadcast upload extension target in Podfile as follows:

# Podfile

platform :ios, '12.0'

target 'MainApp' do
  pod 'HMSSDK'
end

target 'HMSScreenShare' do
  pod 'HMSBroadcastExtensionSDK'
end

How to share iOS screen?

You create an iOS broadcast upload extension. It uses Apple's ReplayKit framework to record the device screen and delivers frame samples to your broadcast extension. You can share not ony your own app but also the entire device sceeen including other apps on the device.

How to use HMSBroadcastExtensionSDK to share iOS screen with other participants in the room?

iOS broadcast extension provides you with CMSampleBuffers that you can process using HMSBroadcastExtensionSDK. This enabled you to share the screen with other participants in the room in your main app that uses HMSSDK.

How to create Replaykit Broadcast extension?

  1. Create a Broadcast Upload Extension target that is embeded in your app project target.
  2. You create a subclass of RPBroadcastSampleHandler and override processSampleBuffer funtion. This gives you access to the CMSampleBuffer provided by the Replaykit framework.

How to configure your main app and extension to enable screen sharing

  1. Configure an App Group for your main app. Choose the same App Group for your broadcast extension target.
  2. In your main app set the app group string to the hmssdk instance like below:
    hmssdk.appGroup = "group.live.100ms.videoapp"
  1. In your broadcast extension import HMSBroadcastExtensionSDK
    import HMSBroadcastExtensionSDK
  1. Create an instance of HMSScreenRenderer passing the app group string like below:
  let screenRenderer = HMSScreenRenderer(appGroup: "group.live.100ms.videoapp")

HMSScreenRenderer uses this app group string to talk to your main app.

How to share screen in meeting

In your broadcast extension you create a subclass of RPBroadcastSampleHandler class. This class handles screen frame samples produced by Replaykit. Replaykit delivers these frame as CMSampleBuffer to processSampleBuffer function.

In your processSampleBuffer function call process function on your screenRenderer instance passing the CMSampleBuffer like below:

  screenRenderer.process(sampleBuffer)

How to invalidate the connection between main app and extension when user stops screen recording

When user stops screen sharing broadcastFinished function is called on your RPBroadcastSampleHandler class. At that point call invalidate on your screenRenderer instance to stop sceen sharing.

    override func broadcastFinished() {
        // User has requested to finish the broadcast.
        self.screenRenderer.invalidate()
    }

👀 To see an example iOS broadcast upload extension implementation for screen sharing using 100ms Broadcast extension SDK, checkout our Example project.

📲 Download the 100ms fully featured Sample iOS app here: https://testflight.apple.com/join/dhUSE7N8

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •