CloudHub Docs
Download Documents

RTC


CloudHub JSSDK

Base

init

Initializes a Client Object

This method initializes the client object.

init(appId: string, options?:object, onSuccess?: function, onFailure?: function): void

// example:
client.init(appId, {}, function() {
  console.log("client initialized");
}, function(err) {
  console.log("client init failed", err);
});
ParametersTypeDescription
appIdstringPass in the App ID for your project.
optionsobjectConfiguration item.
onSuccessfunctionThe callback when the method succeeds.
onFailurefunctionThe callback when the method fails.

renewToken

Renews the Token

This method renews your token.

If the Token mechanism is enabled, the token used after a while will be invalid. Trigger Client.on(‘token-privilege-will-expire’) When the callback is called to reagent, then the method updates token, otherwise the SDK cannot establish a connection with the server.

renewToken(token:string, onSuccess?:function, onFailure?:function): void

// example:
client.renewToken(<token>,  function(){
  console.info("renewToken success");
}, function(errflag){
  console.error("renewToken fail", errflag);
});
ParametersTypeDescription
tokenstringIncoming Token from your service side
1. cloudHub recommends that you use a valid token (high security requirements) to join the channel.
2. For the build of token, see Token build documentation.
3. If you need to use a valid token (high security requirements) to join the channel, contact cloudHub’s business personnel to turn it on.
4. Token has an expiration time and is received Client.on(‘token-privilege-will-expire’)Update Token after the callback.
5. token There is an expiration time, received Client.on(‘request-token’)After the callback, join the channel with the new token.
onSuccessfunctionThe callback when the method succeeds.
onFailurefunctionThe callback when the method fails.The callback parameter carries the errflag parameter. errflag has the following values:* “ERR_INVALID_TOKEN” Not valid token* “ERR_TOKEN_EXPIRED” token Expired * “ERR_REFUSED” Other errors

Note: Token is generated by a combination of authkey, secretkey, channel, userid, and expiretime, so make sure that the newly generated token uses the authkey, secretkey, channel, and userid unchanged.

event

off

Unbinds Events

This method removes the events attached by the Client.on() method.

off(eventType: string, listener: function): void

// example:
client.on("stream-published", function processStreamPublished(evt) {
  console.log("Stream Published");
  evt.stream.play("divId");
  client.off("stream-published", processStreamPublished);
}
ParametersTypeDescription
eventTypestringThe event to be removed.
listenerfunctionThe function to be removed.

on

Make event binding.

For more information about the events that currently support binding and the role of the events Client event documentation

on(eventType: string, listener: function): void

// example:
client.on('first-audio-frame-decode', function (evt) {
  // The callback of the first frame of the remote audio has been decoded.
  // This callback is triggered when the local subscription to the remote stream is successful and the first frame of audio decoding is completed. 
  console.log('first-audio-frame-decode', evt);
})
ParametersTypeDescription
eventTypestringThe event to bind
listenerfunctionThe event listener to bind

offAll

Unbind all events under Type.

offAll(eventType: string): void

// example:
client.offAll("stream-network-quality");

channel

setChannelConfig

Set channel configuration, you can modify the ‘coding mode’ and ‘channel usage scene’ before entering the channel

client.setChannelConfig({
    codec: 'vp8',
    mode: 'live',
});
ParametersTypeDescription
codecstringOptional, encoded in “vp8” and “h264” and defaulted to “vp8”.
Note:: 1 channel can only support 1 encoding method, and the 1st user entering the channel determines how the channel is encoded.
modestringOptional, channel usage scenarios, there are communication scenes rtc and live scenes live, the default is rtc.
live: Live scene with two user roles, the host and the audience, which can be set up through the Client.setClementRole method. The host can send and receive voice/video streams, while viewers can only receive voice/video and cannot send.
rtc: A communication scenario for common one-on-one calls or group chats where any user in a channel can send or receive voice/video streams.
Note::
1)Only 1 usage scenario can be supported for 1 channel, and the channel usage scenario is determined by the 1st user entering the channel.
2)We recommend that 1 channel always use only 1 usage scenario, do not use 1 channel today, use live scene tomorrow, and use the new channel if you need to replace the scene.
3)The communication scenario (“rtc”) does not allow access to too many users, the default channel 1 channel under the communication scenario (“rtc”) allows 100 people to enter, and if you need to adjust the number of users contact cloudHub business personnel.
4)Specify the usage scenario for the channel by specifying mode when createClient.

joinChannel

Join cloudHubRTC channels.

This method allows users to join the CloudHubRTC channel. When the method is successfully called to join the channel, it is triggered locally Client.on(“signal-connected”) and Client.on(“signal-connection-state-change”) Callback.

In a communication scenario, the remote side is triggered Client.on(“peer-join”) Callback

In a live scenario, the user role that joins the channel is the anchor and the remote end is triggered Client.on(“peer-join”) Callback, if it is the audience, the far end does not trigger Client.on(“peer-join”) Callback.

joinChannel(token: string | null, channelId: string, uid: string | null, options?: object, onSuccess?: function, onFailure?: function): void

// example:
client.joinChannel(<token>, "1024", "userid", {}, function(uid) {
  console.log("client" + uid + "joined channel");
  // Create a local stream
  //……
}, function(err) {
  console.error("client join failed", err);
  // Error handling
});
ParametersTypeDescription
tokenstringIncoming Token from your service side
1. cloudHub recommends that you use a valid token (high security requirements) to join the channel.
2. For the build of token, see Token build documentation.
3. If you need to use a valid token (high security requirements) to join the channel, contact cloudHub’s business personnel to turn it on.
4. Token has an expiration time and is received Client.on(‘token-privilege-will-expire’)Update Token after the callback.
5. token There is an expiration time, received Client.on(‘request-token’)After the callback, join the channel with the new token.
channelIdstringThe string that identifies the call channel supports the following character set range:
* 26 lowercase letters a-z
* 26 capital letters A-Z
* 10 numbers 0-9
* Special characters:-_
Note: We recommend that 1 channel always use only 1 usage scenario, do not use 1 channel in today’s communication scene, use live scene tomorrow, and use the new channel if you need to replace the scene.
uidstringSpecifies the user’s ID. High security requirements: Incoming Token from your service side.
Note: ASCII characters, which need to be guaranteed to be unique. If you do not specify (that is, set to null/undefined) or set to 0, the SDK automatically assigns one and returns it in the onSuccess callback method.
optionsobjectConfiguration items, as follows:
userproperties?:object User-defined properties.
For example, a nickname is passed on to a nickname:{nickname:“My name”}
onSuccessfunctionThe method calls the callback function that was executed when it succeeded, and the callback carries the argument uid uid:string 用户 id
onFailurefunctionFailed callback, callback parameter errflag、message。
* message: error message.
* errflag: Error identification, possible errors are as follows:
  1. “CHANNEL_NO_SPECIFICATION”: parameter channel Non-compliant and contains unsupported characters.
  2. “INVALID_ARG”: Invalid parameters.
  3. “CLIENT_NOT_INIT”: There is no initialization Client。
  4. “EMPTY_SIGNAL_ADDR_LIST”: There is no signaling server address to connect to.
  5. “JOIN_CHANNEL_FAIL”: Failed to join the channel.
  6. “JOIN_AUTH_FAIL”: Joining the channel to verify permissions failed.
  7. “CHANNEL_MODE_MISMATCH”:Channel modes don’t match, for example, the channel scene is a call scene (mode is live), but CreateClient is passed on as a live scene (for rtc).
  8. “ERR_INVALID_APP_ID”: Invalid appId.
  9. “ERR_INVALID_TOKEN”: Invalid token.
  10. “ERR_TOKEN_EXPIRED”: token Expired.
  11. “ERR_ENTERPRISE_CONCURRENT_POINTS_EXCEED_LIMIT”: Enterprise concurransion points exceed the limit.
  12. “ERR_REFUSED”: Other errors.

Note:

leaveChannel

Leave the CloudHubRTC channel.

When the method is called to leave the channel, it is triggered locally Client.on(“signal-connection-state-change”) Callback.

In a communication scenario, the remote side is triggered Client.on(“peer-leave”) Callback.

In a live scenario, the user role that leaves the channel is the anchor and the remote end is triggered Client.on(“peer-leave”) Callback, if the audience is far from the distal end Client.on(“peer-leave”) Callback.

leaveChannel(): void

// example:
client.leaveChannel()

Audio and video

publish

Publish the local audio and video stream.

This method is issued to the server.

After issuing audio and video streams, the local will trigger Client.on(“stream-published”) Torch; distal trigger Client.on(“stream-added”) Callback.

In the live broadcast scene, if the user’s role is the audience (audience),Automatically switch into an anchor when calling Publish(host) Role, Local trigger Client.on(“client-role-changed”) Tune, distal trigger Client.on(“peer-join”).

publish(stream: Stream, options?:object, onFailure?: function): void

// example:
client.publish(stream, {}, function(err) {
  console.log(err);
  // Code logic to handle release failures
})
ParametersTypeDescription
streamStreamLocal audio and video flow object
optionsobjectReserved configuration items, currently pass {}
onFailurefunctionMethods The callback function performed when the call fails, the possible errors are as follows:
* “STREAM_ALREADY_PUBLISHED”: The stream has been released.
* “INVALID_LOCAL_STREAM”:Incoming stream format illegally.
* “STREAM_NOT_INITED”: Local flow is not initialized.
* “SIGNAL_NOT_CONNECT”: Not currently not in the channel, it may be no channel or network fluctuation caused temporary disconnection.
* “PUBLISH_STREAM_LIMIT”: The maximum number of lotuses issued is exceeded.
* “PUBLISH_NOT_PERMISSION”: No permission release.
* “PUB_SETREMOTEDESC_FAIL”:Browser setRemoteDescription Failed, about setRemoteDescription
Note: Trigger Client.on(‘stream-publish-failure’) The callback, the callback trigger indicates that this stream failed, and the SDK will not automatically re-release.

Note:

subscribe

Subscribe to remote audio and video streams.

This method receives remote audio and video streams from the server.

After subscribing to the remote audio and video stream, the Client.on(“stream-subscribed”) callback will be triggered locally. If the subscription stream contains audio, it will also trigger Client.on(“first-audio-frame-decode”) callback; if the subscription stream contains video, it will also trigger Client.on(“first-video-frame-decode”) Callback.

subscribe(stream: Stream, options?:object, onFailure?: function): void

// example:
client.subscribe(stream, {}, function(err) {
    console.error("stream subscribe failed", err);
    // Code logic to handle subscription failures
})
ParametersTypeDescription
streamStreamRemote audio and video stream object
optionsobjectReserved configuration items, just pass {} now
onFailurefunctionThe callback function to be executed when the method fails. Here are some common errors:
  1. “STREAM_ALREADY_SUBSCRIBED”: The stream is already subscribed.
  2. “STREAM_NOT_YET_PUBLISHED”: The specified stream has not been published yet.
  3. “INVALID_REMOTE_STREAM”: The format of the incoming stream is illegal.
  4. “SIGNAL_NOT_CONNECT”: Not currently in the channel. It may be that you have not joined the channel or the network is temporarily disconnected due to network fluctuations.
  5. “SUBSCRIBE_NOT_PERMISSION”: No permission to subscribe.
  6. “SUB_SETREMOTEDESC_FAIL”: Browser setRemoteDescription failed, About setRemoteDescription
Note: will trigger the Client.on(‘stream-subscribe-failure’) callback. If the callback is triggered, it means the subscription has failed and the SDK will not automatically Re-subscribe.

Note:

unpublish

Unpublish local audio and video streams.

This method cancels the release of local audio and video streams. After unpublishing the audio and video stream, the remote site will trigger the Client.on(“stream-removed”) callback, and the local site will trigger the Client.on(“stream-unpublished”) callback.

In the live broadcast scenario, if the user’s role is the host, after calling unpublish, if there is no local stream release, it will automatically switch to the audience role, and the local will trigger Client.on(“client-role-changed”) Callback, the remote end will trigger Client.on(“peer-leave”).

unpublish(stream: Stream, options?:object, onSuccess?: function, onFailure?: function): void

// example:
client.unpublish(stream, {}, function(){
  console.log("unpublish success");
  }, function(err) {
    console.log(err);
    //……
})
ParametersTypeDescription
streamStreamLocal audio and video stream object.
optionsobjectReserved configuration items, just pass {} now
onSuccessfunctionUnpublished successfully.
onFailurefunctionThe callback function to be executed when the method fails, the following are some possible errors:
  1. “STREAM_NOT_YET_PUBLISHED”: The specified stream has not been published yet.
  2. “INVALID_LOCAL_STREAM”: The format of the incoming stream is illegal.
  3. “SIGNAL_NOT_CONNECT”: Not currently in the channel, it may be that you have not joined the channel or the network fluctuates causing the connection to be temporarily disconnected.

unsubscribe

Unsubscribe the remote audio and video stream.

unsubscribe(stream: Stream, options?:object, onSuccess?: function, onFailure?: function): void

// example:
client.unsubscribe(stream, {}, function(){
console.log("unsubscribe success");
}, function(err) {
    console.log(err);
    //……
})
ParametersTypeDescription
streamStreamRemote audio and video stream object.
optionsobjectReserved configuration items, just pass {} now
onSuccessfunctionSuccessfully canceled the subscription.
onFailurefunctionThe callback function to be executed when the method fails. Here are some possible errors:
  1. “INVALID_REMOTE_STREAM”: The format of the incoming stream object is illegal.
  2. “SIGNAL_NOT_CONNECT”: Currently not in the channel, it may be that you have not joined or the network fluctuates causing the connection to be temporarily disconnected.
  3. “NO_SUCH_REMOTE_STREAM”: The remote stream to be unsubscribed was not found.
  4. “STREAM_NOT_YET_SUBSCRIBED”: There is no subscription for this stream.

getRemoteAudioStats

Obtain audio statistics of the remote subscribed stream.

getRemoteAudioStats(onCallback: function): void

// example:
client.getRemoteAudioStats((remoteAudioStatsMap) => {
  console.log("remoteAudioStatsMap", remoteAudioStatsMap);
});

enableAudioVolumeIndicator

Enable speaker volume alert.

This method allows the SDK to periodically return the volume reminder of the published/subscribed stream.

After enabling this method, the SDK will trigger the “stream-volume-indicator” callback to return the volume prompt every interval milliseconds, regardless of whether there is anyone speaking in the channel. Only return volume prompts whose stream Type is video (stream.getType() === “video”)

enableAudioVolumeIndicator(interval?:number): void

// example:
client.enableAudioVolumeIndicator(2000); // Triggers "volume-indicator" every two seconds retrace
client.on("stream-volume-indicator", function(evt){
    console.log("stream-volume-indicator", evt);
});
ParametersTypeDescription
intervalnumberHow long to trigger the “stream-volume-indicator” callback to return the volume prompt, the unit is milliseconds, and the default is 300.
Note: When the interval is-1, it means that the speaker volume prompt is not enabled.

getLocalAudioStats

Obtain audio statistics of the locally published stream.

getLocalAudioStats(onCallback: function): void

//example:
client.getLocalAudioStats((localAudioStats) => {
  console.log("localAudioStats:", localAudioStats);
});
ParametersTypeDescription
onCallbackfunctionContains the callback of the audio statistics data of the local release stream. The callback parameter carries the LocalAudioStatsMap.
LocalAudioStatsMap: For details, see CloudHubRTC data object document LocalAudioStatsMap description

Note:

getLocalVideoStats

getLocalVideoStats(onCallback: function): void

//example:
client.getLocalVideoStats((localVideoStats) => {
    console.log("localVideoStats:", localVideoStats);
});

Get the video statistics of the local publishing stream.

ParametersTypeDescription
onCallbackfunctionContains the callback of the video statistics data of the local release stream. The callback parameter carries the LocalVideoStatsMap.
LocalVideoStatsMap: For details, see LocalVideoStatsMap description of CloudHubRTC data object document

Note:

getRemoteVideoStats

Method function: Obtain the video statistics data of the remote subscribed stream.

getRemoteVideoStats(onCallback: function): void
// example:
client.getRemoteVideoStats((remoteVideoStatsMap) => {
  console.log("remoteVideoStatsMap", remoteVideoStatsMap);
});
ParametersTypeDescription
onCallbackfunctionContains the callback of the audio statistics data of the remote subscription stream. The callback parameter carries the RemoteVideoStatsMap. RemoteVideoStatsMap: For details, see RemoteVideoStatsMap description of CloudHubRTC data object document

Note:

enableMultiStream

Method function: Whether to enable multi-stream mode.

enableMultiStream(bEnable:boolean): void

// example:
client.enableMultiStream(true)
ParametersTypeDescription
bEnablebooleanWhether to enable multi-stream mode.
  1. true: use multi-stream mode
  2. false: use single-stream mode

Note:

information

sendChatMsg

Method function: Send chat messages. Client.on(“recv-chat-msg”) callback will be triggered after receiving the chat message.

sendChatMsg(message:string, toId: string, extraData?:object): void

// example:
client.sendChatMsg("this is chat msg", CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER, {"key1":"value1", "key2":"value2"});
ParametersTypeDescription
messagestringThe sent chat message.
toIdstringSpecify who to send to, the default is YSRTC.CONSTANTS.MSG_TO_ALLUSER.

Note:

pubMsg

Send a signaling message. Client.on(“recv-pub-msg”) callback will be triggered after receiving “send signaling message”.

pubMsg(msgName: string, msgId:string, toId:string, data:object, save?:boolean,associatedMsgID?:string): void

//example:
client.pubMsg("msgname", "msgid", CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER, {testdata: 1}, true);
ParametersTypeDescription
msgNamestringSignaling name.
msgIdstringSignaling message ID.
toIdstringSpecify who to send to, the default is CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER. For the possible values ​​of toId, please see “Constant Declaration and Supplementary Explanation——Send Message
dataobjectSignaling data.
savebooleanWhether to save the signaling, the default is false.
Note: 1. If the message is not saved, you do not need to use delMsg to delete the message 2. If the message is not saved, the message will only be notified to people in the channel, and those who come in later Will not receive this message
associatedMsgIDstringThe associated message ID, the default is “”.
Note: 1. Assuming that a message is associated with a message whose msgId is “parent-msg”, then when the “parent-msg” message is deleted, the a message is also deleted Delete, the signaling server will push the “parent-msg” message to be deleted, but will not push a message to be deleted (ie: deleting the parent node will only push the deleted message of the parent node, not the deleted child node Message, the client needs to remove the child node’s message after receiving the notification of the parent node’s delete message). For example, when msgId is “child-msg” and associated with msgId is “parent-msg” and the message with msgId is “parent-msg” is deleted, the client will receive a delete message notification with msgId as “parent-msg” (ie : Client.on(“recv-del-msg”) callback) will be triggered without receiving the delete message notification with msgId as “child-msg”.

Note: In the live broadcast scene, it is recommended that only some people (hosts or authorized viewers, etc.) be able to send pubMsg, and not everyone can actively send pubMsg [for example: a channel with 100,000 people and an audience of 99,000 people, then these people There should not be the ability to actively send pubMsg, but the anchor should be authorized to a certain audience, this audience can send pubMsg].

delMsg

Delete the signaling message. Client.on(“recv-del-msg”) callback will be triggered after receiving the “delete signaling message”.

delMsg(msgName: string, msgId:string, toId:string): void

// example:
client.delMsg("msgname", "msgid", CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER);
ParametersTypeDescription
msgNamestringSignaling name.
msgIdstringSignaling message ID.
toIdstringSpecify who to send to, the default is CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER.
For the possible values of toId, please see “Constant Declaration and Supplementary Description-Sending Message”

Note: In the live broadcast scene, it is recommended that only some people (hosts or authorized viewers, etc.) be able to send delMsg, and not everyone can actively send delMsg [for example: a channel with 100,000 people and an audience of 99,000 people, then these people There should not be the ability to actively send delMsg, but the anchor should be authorized to a certain audience, this audience can send delMsg].

Signaling

getSignalConnectionState

getSignalConnectionState(): string

Obtain the connection status between the SDK and the signaling server. Calling this method will return the connection status between the SDK and the signaling server. There are 3 types of connection status between the SDK and the signaling server:

Note:

ParametersTypeDescription
onCallbackfunctionContains the callback of the audio statistics data of the remote subscription stream. The callback parameter carries RemoteAudioStatsMap.
RemoteAudioStatsMap: For details, see the RemoteAudioStatsMap description of “CloudHubRTC Data Object Document”

Note:

User

evictUser

Kick the user out of the channel.

evictUser(uid:string, reason?:string): void
// example:
client.evictUser("uid", "reason");
ParametersTypeDescription
uidstringID of the user to be kicked out of the channel
reasonstringReason for kicking out the channel

setProperty

Change the user’s custom user attributes. This method changes the properties of a user and notifies the specified user in the channel of the property change. The specified user will receive the Client.on(“user-properties-update”) callback.

setProperty(uid: string, properties: object, toId?: string): void

// example:
client.setProperty("userid", {key1:value1}, CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER);
ParametersTypeDescription
uidstringID of the user whose attribute was changed
propertiesobjectThe changed user properties object.
toIdstringSpecify who to send to, the default is CloudHubRTC.CONSTANTS.MSG_TO_ALLUSER. The possible values of toId can be found in “Constant Declaration and Supplementary Description-Sending Message”

Note:

setClientRole

Set user roles.

This method is only applicable to live broadcast scenes.

In the live broadcast scenario, you can call this method to set the user role.

Before joining the channel, users can set their own roles through this method.

After joining the channel, the user can switch roles through this method:

If you call this method to switch user roles after joining a channel, after the switch is successful, Client.on(“client-role-changed”) callback will be triggered locally; and Client.on(“peer-join”) or Client will be triggered remotely .on(“peer-leave”) callback.

setClientRole(role:string, onCallback?:function): void

// example:
client.setClientRole("host", function(errinfo) {
  if (!errinfo) {
    console.log("setClientRole success");
  } else {
    console.log("setClientRole error", errinfo);
  }
});
ParametersTypeDescription
rolestringUser role, roles are “audience”
onCallbackfunctionCallback function, the function carries the parameter errinfo, if errinfo is null/undefined, it means the setting is successful, otherwise the setting fails.

Note: This method cannot be used in communication scenarios (mode set to rtc). By default, all users are in the host role.

Recording

startServerRecord

Start server-side recording.

The recording function needs to be turned on by contacting cloudHub business personnel. If it is not turned on, it will not be possible to call this interface to record. Will trigger the Client.on(“server-record-state-change”) callback.

startServerRecord(config?:object): void
// example:
client.startServerRecord({});
ParametersTypeDescription
configobjectRecording configuration items, the configuration items are as follows:
   recordChat?:boolean Whether to record chat messages, the default is false.

Note: If you call startServerRecord twice (that is, call startServerRecord again without calling stopServerRecord), the first call will prevail.

stopServerRecord

Stop server-side recording.

Will trigger the Client.on(“server-record-state-change”) callback.

stopServerRecord(): void
// example:
client.stopServerRecord();

pauseServerRecord

Method function: Pause server-side recording.

Will trigger the Client.on(“server-record-state-change”) callback.

pauseServerRecord(): void

//  example:
client.pauseServerRecord();
ParametersTypeDescription
urlstringIngest URL.

resumeServerRecord

Resume server-side recording.

Will trigger the Client.on(“server-record-state-change”) callback.

resumeServerRecord(): void

//  example:
client.resumeServerRecord();
ParametersTypeDescription
urlstringIngest URL.

Push Stream

addPublishStreamUrl

Increase the bypass push address.

addPublishStreamUrl(url:string): void

//  example:
client.removePublishStreamUrl("xxxx");
ParametersTypeDescription
urlstringIngest URL.

removePublishStreamUrl

Delete the bypass streaming address.

removePublishStreamUrl(url:string): void
ParametersTypeDescription
urlstringIngest URL.

setLiveTranscoding

Set up live streaming and transcoding.

setLiveTranscoding(liveTranscoding:LiveTranscoding): void

//  example:
var liveTranscoding = {
    "width": 640,
    "height": 360,
    "videoBitrate": 400,
    "videoFramerate": 15,
    "audioSampleRate": 48000,
    "audioBitrate": 48,
    "audioChannels": 1,
    "audioCodecProfile": 0,
    "videoGop": 30,
    "videoCodecProfile": 100,
    "streamCount": 1,
    "backgroundColor": 0x000000,
    "transcodingStreams": [{
      "x": 0,
      "y": 0,
      "width": 640,
      "height": 360,
      "zOrder": 0,
      "uid": "123456",
      "type": "video",
      "sourceID": "default_source_id"
    }]
  };
client.setLiveTranscoding(liveTranscoding);
ParametersTypeDescription
liveTranscodingLiveTranscoding(object)Settings for live transcoding. For details about LiveTranscoding, please refer to LiveTranscoding documentation Note: The liveTranscoding passed in each call to the setLiveTranscoding interface will overwrite the previous liveTranscoding.

startChannelMediaRelay

Start cross-channel media stream forwarding.

startChannelMediaRelay(channelMediaRelayConfig:ChannelMediaRelayConfig): void

//  example:
var channelMediaRelayConfig = client.produceChannelMediaRelayConfig();
  channelMediaRelayConfig.setDestChannelInfo(
    "destChannelName",
    {
      uid: "Relay_myChannelName_Requester_myuid"
    }
  );
client.startChannelMediaRelay(channelMediaRelayConfig);
ParametersTypeDescription
channelMediaRelayConfigChannelMediaRelayConfigCross-channel media forwarding configuration class instance. For details about ChannelMediaRelayConfig, please refer to ChannelMediaRelayConfig Description. Note: The channelMediaRelayConfig instance is generated by calling produceChannelMediaRelayConfig.

Note: For events related to the stream forwarding state, please see the event description of client.on(“channel-media-relay-state”)

updateChannelMediaRelay

Update cross-channel media stream forwarding.

updateChannelMediaRelay(channelMediaRelayConfig:ChannelMediaRelayConfig): void

// example:
channelMediaRelayConfig.setDestChannelInfo(
    "destChannelName2",
    {
        uid: "Relay_myChannelName_Requester_myuid"
    }
);
client.updateChannelMediaRelay(channelMediaRelayConfig);
ParametersTypeDescription
channelMediaRelayConfigChannelMediaRelayConfigCross-channel media forwarding configuration class instance. For details about ChannelMediaRelayConfig, please refer to ChannelMediaRelayConfig Description”. Note: The channelMediaRelayConfig instance calls produceChannelMediaRelayConfig to generate.

Note: For events related to the stream forwarding state, please see the event description of client.on(“channel-media-relay-state”)

stopChannelMediaRelay

Method effect: Stop the cross-channel media stream forwarding.

stopChannelMediaRelay(): void

// example:
client.stopChannelMediaRelay();

Note: For events related to the stream forwarding state, please see the event description of client.on(“channel-media-relay-state”)

produceChannelMediaRelayConfig

Production cross-channel media forwarding configuration examples. For details about ChannelMediaRelayConfig, see ChannelMediaRelayConfig

produceChannelMediaRelayConfig(): void

// example:
var channelMediaRelayConfig = client.produceChannelMediaRelayConfig();