Live Screen Broadcast with ReplayKit

WWDC 2018

Posted by Den on September 12, 2018 · 9 mins read
Live Screen Broadcast with ReplayKit

Live Screen Broadcast with ReplayKit

WWDC 2018

Live Screen Broadcast with ReplayKit

WWDC 2018

ReplayKit

  • Capture
    - Screen visuals
    - App audio
    - Microphone input
  • Record and share
  • Broadcast live
  • HD quality capture
  • Low latency
  • Low performance impact
  • Minimal power usage
  • Privacy safeguards

Live Broadcast

  • Broadcast live to 3rd party broadcast services (ex. Facebook)
  • Stream audio and visuals directly from device
  • Provide commentary with microphone and camera (iOS)
  • Content is secure and only accessible to the broadcast service
  • Usage examples
    - Stream gameplay to Mobcrush or YouTube
    - Mirror screen on a WebEx call
    - Work with customer support via TeamViewerQS
    - Stream a drawing app to Facebook

ReplayKit vs ReplayKit 2

In-App Broadcast

  • Your app or game
    - Provides the content — visuals and audio
    - Starts and stops the boardcast
  • Broadcaster app
    - Provides sign-in and upload extensions
    - Streams content to their network

iOS System Broadcast

  • Broadcasts all onscreen activity (and sounds)
  • Start and stop from Control Center
  • Systemwide, continuous session
    - Home screen
    - Moving app to app
  • Build-in to iOS 11 and above

System Broadcast Picker

  • Your app can initiate an iOS system broadcast session
  • Simple 1-button UI
  • No compromises for privacy
  • Secure architecture
  • New in iOS 12

preferredExtension

  • Pair broadcast picker to a particular extension
  • Assign bundle identifier of your extension
  • Initialize before view is presented

RPSystemBroadcastPickerView

  • Brings up system broadcast picker
  • Allows to configure broadcast picker
  • Doesn’t own any state of the session

Broadcast App and Extension

  • Broadcast Application
    - Account sign-in, broadcast title
  • Broadcast Upload Extension
    - Encode samples, upload to service

Broadcast Upload Extension

  • Receives audio and video samples
  • Encodes and uploads video stream
  • Handles device orientation changes
  • Annotates broadcast with app information

Broadcast Extension Template

Broadcast Lifecycle

Handling Sign-In and Broadcast Setup

Broadcast application

Initialization

Handling broadcastStarted

Processing Media Samples

Handling Application Information

Handling ‘ broadcastFinished ’

Handling Sign-In

Protecting Content

UIScreen.isCaptured

  • Prevent capturing of audio and video content of your app
  • Stop media playback or displaying sensitive content
    - Check value of UIScreen.captured
    - Register for UIScreenCapturedDidChangeNotification
    - Check UIScreen.screens.count to allow screen mirroring