Streaming
Introduces methods and callbacks related to streaming.
startRtmpStreamWithoutTranscoding
Starts Media Push without transcoding.
virtual int startRtmpStreamWithoutTranscoding(const char* url) = 0;
You can call this method to push an audio or video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the Media Push.
- Ensure that you enable the media push service before using this function.
- Call this method after joining a channel.
- Only hosts in the LIVE_BROADCASTING profile can call this method.
- If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.
Parameters
- url
- The address of media push. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.
Returns
- 0: Success.
- < 0: Failure.
startRtmpStreamWithTranscoding
Starts Media Push and sets the transcoding configuration.
virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding) = 0;
You can call this method to push an audio or video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the Media Push.
- Ensure that you enable the media push service before using this function.
- Call this method after joining a channel.
- Only hosts in the LIVE_BROADCASTING profile can call this method.
- If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.
Parameters
- url
- The address of media push. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.
- transcoding
-
The transcoding configuration for media push. See LiveTranscoding.
Returns
- 0: Success.
- < 0: Failure.
stopRtmpStream
Stops pushing media streams to a CDN.
virtual int stopRtmpStream(const char* url) = 0;
You can call this method to stop the live stream on the specified CDN address. This method can stop pushing media streams to only one CDN address at a time, so if you need to stop pushing streams to multiple addresses, call this method multiple times.
After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
Parameters
- url
- The address of media push. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.
Returns
- 0: Success.
- < 0: Failure.
updateChannelMediaRelay
Updates the channels for media stream relay.
virtual int updateChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) = 0;
After the media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call this method.
After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback with the RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL (7) state code.
onChannelMediaRelayStateChanged (RELAY_STATE_RUNNING, RELAY_OK)
; otherwise, the method call fails.Parameters
- configuration
- The configuration of the media stream relay. For more details, see ChannelMediaRelayConfiguration.
Returns
- 0: Success.
- < 0: Failure.
updateLocalTranscoderConfiguration
Update the local video mixing configuration.
virtual int updateLocalTranscoderConfiguration(const LocalTranscoderConfiguration& config) = 0;
After calling startLocalVideoTranscoder, call this method if you want to update the local video mixing configuration.
Parameters
- config
- Configuration of the local video mixing, see LocalTranscoderConfiguration.
Returns
- 0: Success.
- < 0: Failure.
updateRtmpTranscoding
Updates the transcoding configuration.
virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding) = 0;
After you start pushing media streams to CDN with transcoding, you can dynamically update the transcoding configuration according to the scenario. The SDK triggers the onTranscodingUpdated callback after the transcoding configuration is updated.
Parameters
- transcoding
-
The transcoding configuration for media push. See LiveTranscoding.
Returns
- 0: Success.
- < 0: Failure.
onRtmpStreamingEvent
Reports events during the media push.
virtual void onRtmpStreamingEvent(const char* url, RTMP_STREAMING_EVENT eventCode) { (void)url; (void)eventCode; }
Parameters
- url
- The URL of media push.
- eventCode
- The event code of media push. See RTMP_STREAMING_EVENT.
onRtmpStreamingStateChanged
Occurs when the media push state changes.
virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state, RTMP_STREAM_PUBLISH_ERROR_TYPE errCode) { (void)url; (void)state; (void)errCode; }
When the media push state changes, the SDK triggers this callback and reports the URL address and the current state of the media push. This callback indicates the state of the media push. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the error code parameter.
Parameters
- url
-
The URL address where the state of the media push changes.
- state
- The current state of the media push. See RTMP_STREAM_PUBLISH_STATE.
- errCode
- The detailed error information for the media push. See RTMP_STREAM_PUBLISH_ERROR_TYPE.
onTranscodingUpdated
Occurs when the publisher's transcoding is updated.
virtual void onTranscodingUpdated()
When the LiveTranscoding class in the setLiveTranscoding method updates, the SDK triggers the onTranscodingUpdated callback to report the update information.