onCdnStreamStateChanged property

(void Function(String cdnUrl, int status, int errCode, String errMsg, String extraInfo)?) onCdnStreamStateChanged
final

Callback for Change of RTMP/RTMPS Publishing Status

When you call startPublishMediaStream to publish a stream to the TRTC backend, the SDK will immediately update the command to the cloud server.

If you set the publishing destination (TRTCPublishTarget) to the URL of Tencent Cloud or a third-party CDN, you will be notified of the RTMP/RTMPS publishing status via this callback.

  • Parameters:
    • cdnUrl(String):
    • code(int):
      • The publishing result. 0: Successful; other values: Failed.
    • extraInfo(String):
      • Additional information. For some error codes, there may be additional information to help you troubleshoot the issues.
    • message(String):
      • The publishing information.
    • status(int):
      • The publishing status:
        • 0: The publishing has not started yet or has ended. This value will be returned after you call stopPublishMediaStream.
        • 1: The TRTC server is connecting to the CDN server. If the first attempt fails, the TRTC backend will retry multiple times and will return this value via the callback (every five seconds). After publishing succeeds, the value 2 will be returned. If a server error occurs or publishing is still unsuccessful after 60 seconds, the value 4 will be returned.
        • 2: The TRTC server is publishing to the CDN. This value will be returned if the publishing succeeds.
        • 3: The TRTC server is disconnected from the CDN server and is reconnecting. If a CDN error occurs or publishing is interrupted, the TRTC backend will try to reconnect and resume publishing and will return this value via the callback (every five seconds). After publishing resumes, the value 2 will be returned. If a server error occurs or the attempt to resume publishing is still unsuccessful after 60 seconds, the value 4 will be returned.
        • 4: The TRTC server is disconnected from the CDN server and failed to reconnect within the timeout period. In this case, the publishing is deemed to have failed. You can call updatePublishMediaStream to try again.
        • 5: The TRTC server is disconnecting from the CDN server. After you call stopPublishMediaStream, the SDK will return this value first and then the value 0.

Implementation

final void Function(String cdnUrl, int status, int errCode, String errMsg, String extraInfo)? onCdnStreamStateChanged;