Skip to main content
Version: 2.0.x

RTMP Livestream - iOS

RTMP is a popular protocol for live streaming video content from a VideoSDK to platforms such as YouTube, Twitch, Facebook, and others.

By providing the platform-specific stream key and stream URL, the VideoSDK can connect to the platform's RTMP server and transmit the live video stream.

VideoSDK allows you to livestream your meeting to platform which support RTMP ingestion just by providing the platform-specific stream key and stream URL, we can connect to the platform's RTMP server and transmit the live video stream.

VideoSDK also allows you to configure the livestream layouts in numerous ways like by simply setting different prebuilt layouts in the configuration or by providing your own custom template to do the livestream according to your layout choice.

This guide will provide an overview of how to implement start and stop RTMP Livestreaming.

startLivestream()

startLivestream() can be used to start a RTMP livestream of the meeting which can be accessed from the Meeting class. This method accepts two parameters:

  • outputs: This parameter accepts a list of LivestreamOutput objects which contains the RTMP url and streamKey of the platforms you want to start the livestream.
class MeetingViewController {

private let platformUrl = "<url-of-the-platform>"
private let privateKey = "<private-key>"

// button to start livestream
@IBAction func startLiveStreamButtonTapped(_ sender: Any) {
self.meeting?.startLivestream(outputs: LivestreamOutput(url: platformUrl, streamKey: privateKey))
}
}

stopLivestream()

  • stopLivestream() is used to stop the meeting livestream which can be accessed from the Meeting class.

Example

class MeetingViewController {
// button to stop livestream
@IBAction func startLiveStreamButtonTapped(_ sender: Any) {
self.meeting?.stopLivestream()
}
}

Event associated with Livestream

  • onLivestreamStateChanged - Whenever meeting livestream state changes, then onLivestreamStateChanged event will trigger.
extension MeetingViewController: MeetingEventListener {
// rtmp-event
func onLivestreamStateChanged(state: LiveStreamState) {
switch(state) {
case .LIVESTREAM_STARTING:
print("livestream starting")

case .LIVESTREAM_STARTED:
print("livestream started")

case .LIVESTREAM_STOPPING:
print("livestream stoping")

case .LIVESTREAM_STOPPED:
print("livestream stopped")
}
}
}

API Reference

The API references for all the methods utilised in this guide are provided below.

Got a Question? Ask us on discord