Link Search Menu Expand Document

livedigital SDK usage

  1. See Integration for integration instructions. Further steps assume you have successfully integrated the SDK and host application project can be built as normally.

  2. Choose or create a class in your app that will be the main livedigital services client. Let’s call it LivedigitalClient.

  3. In the beginning of LivedigitalClient.swift file, import the SDK module:

     import LiveDigitalSDK
  4. Create an instance of the livedigital services engine and store it as a property in your client class:

         private let engine: LiveDigitalEngine
         private var channelSession: ChannelSession?
         private var videoSource: VideoSource?
         private var audioSource: AudioSource?
         init() {
             let creds = AppCredentials(
                     id: "put_your_app_id_here",
                     secret: "put_your_app_secret_here")
             self.engine = StockLiveDigitalEngine(appCredentials: creds)
  5. Implement engine’s and session’s delegate protocols to handle appropriate events:

     extension LivedigitalClient: LiveDigitalEngineDelegate { ... }
     extension LivedigitalClient: ChannelSessionDelegate { ... }

    To see other peers in channel, your app should handle next events and take care of displaying peer video views:

     func peerJoined(_ peer: Peer) {
         // Show peer as an active member of channel.
     func peerDisconnected(_ peerId: PeerId) {
         // Hide peer from active members list/.
     func peerAddedVideoView(peer: Peer, videoView: UIView) {
         // Display and layout the `videoView`.
         // This view will render video stream that `peer` broadcasts.
  6. Prepare for microphone and camera usage. AppInfo.plist file must include non-empty values for NSMicrophoneUsageDescription and NSCameraUsageDescription keys. Your app is responsible for requesting user permissions to use microphone and camera. You may use next calls to show system requests:

     AVAudioSession.sharedInstance().requestRecordPermission { ... }
     AVCaptureDevice.requestAccess(for: .video) { ... }

    Next steps assume that user has granted microphone and camera permissions.

  7. Join to a channel by starting channel session and becoming its delegate:

     let channelId = ChannelId(value: "put_your_channel_id_here")
     let channelSession = engine.connectToChannel(channelId)
     channelSession.delegate = self
     self.channelSession = channelSession
  8. Start broadcasting audio and video to the channel:

     let videoSource = engine.startVideoSource()
     self.videoSource = videoSource
     // Display `videoSource.localVideoView`
     // somewhere to show camera preview.
     let audioSource = engine.startAudioSource()
     self.audioSource = audioSource
  9. You will need at least two separate devices to test audio/video conferences appropriately. But for more convenient debug process, you may use next flag to make quick tests with just a single device:

     channelSession.shouldShowLocalPeer = true