addPublishCdnUrl method

Future<ZegoPublisherUpdateCdnUrlResult> addPublishCdnUrl(
  1. String streamID,
  2. String targetURL,
  3. {int? timeout}
)

Adds a target CDN URL to which the stream will be relayed from ZEGO RTC server.

Available since: 1.1.0 Description: Forward audio and video streams from ZEGO RTC servers to custom CDN content distribution networks with high latency but support for high concurrent pull streams. Use cases: 1. It is often used in large-scale live broadcast scenes that do not have particularly high requirements for delay. 2. Since ZEGO RTC server itself can be configured to support CDN(content distribution networks), this function is mainly used by developers who have CDN content distribution services themselves. 3. This function supports dynamic relay to the CDN content distribution network, so developers can use this function as a disaster recovery solution for CDN content distribution services. When to call: After calling the createEngine function to create the engine. Restrictions: When the enablePublishDirectToCDN function is set to true to publish the stream straight to the CDN, then calling this function will have no effect. Caution: Removing URLs retweeted to CDN requires calling removePublishCdnUrl, calling stopPublishingStream will not remove URLs publish to CDN. Related APIs: Remove URLs that are re-pushed to the CDN removePublishCdnUrl.

  • streamID Stream ID.
  • targetURL CDN relay address, supported address format is rtmp, rtmps.
  • timeout Timeout. Callback if it does not start in the time. Default is 0, which means no timeout. Valid range is 5, 600, in seconds. Less than 0 will be reset to 0, 1 to 4 will be reset to 5, and a greater than 600 will be reset to 600.
  • Returns The execution result of update the relay CDN operation.

Implementation

Future<ZegoPublisherUpdateCdnUrlResult> addPublishCdnUrl(
    String streamID, String targetURL,
    {int? timeout}) async {
  return await ZegoExpressImpl.instance
      .addPublishCdnUrl(streamID, targetURL, timeout: timeout);
}