startPublishMediaStream abstract method
- TRTCPublishTarget target,
- TRTCStreamEncoderParam param,
- TRTCStreamMixingConfig config
Publish a stream
After this API is called, the TRTC server will relay the stream of the local user to a CDN (after transcoding or without transcoding), or transcode and publish the stream to a TRTC room.
You can use the TRTCPublishMode parameter in TRTCPublishTarget to specify the publishing mode.
Parameters:
-
config(TRTCStreamMixingConfig):
- The On-Cloud MixTranscoding settings. This parameter is invalid in the relay-to-CDN mode. It is required if you transcode and publish the stream to a CDN or to a TRTC room.
-
params(TRTCStreamEncoderParam):
- The encoding settings. This parameter is required if you transcode and publish the stream to a CDN or to a TRTC room. If you relay to a CDN without transcoding, to improve the relaying stability and playback compatibility, we also recommend you set this parameter.
-
target(TRTCPublishTarget):
- The publishing destination. You can relay the stream to a CDN (after transcoding or without transcoding) or transcode and publish the stream to a TRTC room.
Note
The SDK will send a task ID to you via the TRTCCloudListener.onStartPublishMediaStream callback.
You can start a publishing task only once and cannot initiate two tasks that use the same publishing mode and publishing CDN URL. Note the task ID returned, which you need to pass to updatePublishMediaStream to modify the publishing parameters or stopPublishMediaStream to stop the task.
You can specify up to 10 CDN URLs in
target
. You will be charged only once for transcoding even if you relay to multiple CDNs.To avoid causing errors, do not specify the same URLs for different publishing tasks executed at the same time. We recommend you add "sdkappid_roomid_userid_main" to URLs to distinguish them from one another and avoid application conflicts.
Implementation
void startPublishMediaStream(TRTCPublishTarget target, TRTCStreamEncoderParam param, TRTCStreamMixingConfig config);