addPublishStreamUrl method Null safety

Future<void> addPublishStreamUrl(
  1. String url,
  2. bool transcodingEnabled

Publishes the local stream to the CDN.

This method call triggers the RtcChannelEventHandler.rtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN.


  • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Push Streams to CDN.
  • Ensure that the user joins a channel before calling this method.
  • This method can only be called by a broadcaster in a ChannelProfile.LiveBroadcasting channel .
  • This method adds only one stream HTTP/HTTPS URL address each time it is called.

Parameter url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.

Parameter transcodingEnabled Sets whether transcoding is enabled/disabled. If you set this parameter as true, ensure that you call the RtcChannel.setLiveTranscoding method before this method.

  • true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple broadcasters in CDN live.
  • false: Disable transcoding.


Future<void> addPublishStreamUrl(String url, bool transcodingEnabled) {
  return _invokeMethod('addPublishStreamUrl', {
    'url': url,
    'transcodingEnabled': transcodingEnabled,