addPublishStreamUrl method Null safety

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

Publishes the local stream to a specified CDN streaming URL.

After calling this method, you can push media streams in RTMP or RTMPS protocol to the CDN. The addPublishStreamUrl method call triggers the RtcEngineEventHandler.rtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN.

Note

  • Ensure that you enable the RTMP Converter service before using this function. See Prerequisites in Push Streams to CDN.
  • This method applies to LiveBroadcasting only.
  • Ensure that the user joins a channel before calling this method.
  • This method adds only one **CDN streaming URL **each time it is called.
  • Agora supports pushing media streams in RTMPS protocol to the CDN only when you enable transcoding.

Parameter url The CDN streaming URL in the RTMP or RTMPS 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 setLiveTranscoding method before this method.

See RtcEngine.setLiveTranscoding

  • 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 hosts in CDN live.
  • false: Disable transcoding.

Implementation

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