Broadcast Using RTMP
Real-Time Messenger Protocol (RTMP) is an online streaming protocol that was created to distribute media. Originally designed for streaming with Adobe’s Flash player, RTMP is still used as an ingest protocol for some streaming services. For example, RTMP can be used to deliver LiveSwitch media to online streaming platforms like Twitch, Facebook Live, or YouTube Live.
LiveSwitch’s RTMP implementation supports delivery of its MCU audio and video output to an RTMP ingest service. The following codecs are supported:
RTMP supports up to five upstream participants.
To use RTMP to broadcast on your channel, do the following:
- Enable and configure RTMP from the LiveSwitch Console for your Application or Channel.
- To start the RTMP stream on your channel, do one of the following:
Note
About the code examples on this page:
- For .NET MAUI and Unity, use the C# code.
- For macOS, use the iOS code.
Start or Stop an RTMP Broadcast on an Active Channel
Use the LiveSwitch SDK to start or stop an RTMP broadcast on an active channel with RTMP configured. Ensure that you have a subscription that authorizes RTMP and you have set the RTMP URL and Stream Key on the console.
// Prior to registration, ensure that you create a channel claim with the CanUpdate property set to true.
var channelClaims = new[] { new ChannelClaim(ChannelId) { CanUpdate = true } };
// Create a registration token with your ChannelClaims then call `client.register(token)`.
// Create a new ChannelConfig, and set EnableRtmp to true.
var channelConfig = new ChannelConfig();
channelConfig.EnableRtmp = true;
// Send the update - the channel object here is returned when calling `client.register(token)`.
channel.Update(channelConfig);
// To stop the RTMP stream, set EnableRtmp to false and send the update
channelConfig.EnableRtmp = false;
channel.Update(channelConfig);
// Prior to registration, ensure that you create a channel claim with the CanUpdate property set to true.
final ChannelClaim[] channelClaims = new ChannelClaim[]{new ChannelClaim(channelId)};
channelClaims[0].setCanUpdate(true);
// Create a registration token with your ChannelClaims then call `client.register(token)`.
// Create a new ChannelConfig, and set enableRtmp to true.
final ChannelConfig channelConfig = new ChannelConfig();
channelConfig.setEnableRtmp(NullableBoolean.trueValue());
// Send the update - the channel object here is returned when calling `client.register(token)`.
channel.update(channelConfig);
// To stop the RTMP stream, set enableRtmp to false and send the update
channelConfig.setEnableRtmp(NullableBoolean.falseValue());
channel.update(channelConfig);
// Prior to registration, ensure that you create a channel claim with the CanUpdate property set to true.
let theClaim: FMLiveSwitchChannelClaim = FMLiveSwitchChannelClaim.init()
theClaim.setId(_channelId)
theClaim.setCanUpdate(true);
let channelClaims: NSMutableArray = []
claims.add(theClaim)
// Create a registration token with your ChannelClaims then call `_client?.register(withToken: theToken)`.
// Create a new ChannelConfig, and set enableRtmp to true.
let channelConfig = FMLiveSwitchChannelConfig.init();
channelConfig?.setEnableRtmp(FMLiveSwitchNullableBool.fromValue(true));
// Send the update - the _channel object here is returned when calling `_client?.register(withToken: theToken)`.
_channel?.update(withNewConfig: channelConfig);
// To stop the RTMP stream, set enableRtmp to false and send the update
channelConfig?.setEnableRtmp(FMLiveSwitchNullableBool.fromValue(false));
_channel?.update(withNewConfig: channelConfig);
// Prior to registration, ensure that you create a channel claim with the CanUpdate property set to true.
const channelClaims = [new fm.liveswitch.ChannelClaim(channelId)];
channelClaims[0].setCanUpdate(true);
// Create a registration token with your ChannelClaims then call `client.register(token)`.
// Create a new ChannelConfig, and set enableRtmp to true.
const channelConfig = new fm.liveswitch.ChannelConfig();
channelConfig.setEnableRtmp(true);
// Send the update - the channel object here is returned when calling `client.register(token)`.
channel.update(channelConfig);
// To stop the RTMP stream, set enableRtmp to false and send the update
channelConfig.setEnableRtmp(false);
channel.update(channelConfig);