Cross-channel PK
Function description
Cross-channel PK means that the host’s media stream can be forwarded to multiple live channels at the same time, so that the host can interact with other hosts in real time across channels. scene. in:
- All anchors in the channel can see each other and hear each other’s voices.
- Viewers in the channel can see all the anchors and hear the anchor’s voice. Because of its real-time and interactive nature, this function is especially suitable for live broadcast scenes such as Lianmai PK and online chorus.When, it effectively absorbs powder.
Sample project
We provide an open source cross-channel PK forwarding example project, you can go to download and refer to the source code.
iOS: [CloudHub-Active] android:[CloudHub-Active]
Implementation
Before implementing the cross-channel PK function, please make sure that you have implemented the basic real-time audio and video functions in the project. For details, please refer to the following document: Interactive Live Broadcast
CloudHub SDK has the following cross-channel media stream forwarding interface, which supports forwarding the media stream in the source channel to up to 4 target channels.The function of connecting microphones across live broadcast rooms:
startChannelMediaRelay
updateChannelMediaRelay
stopChannelMediaRelay
During the cross-channel media stream forwarding process, the SDK will report the media stream through the onChannelMediaRelayStateChanged
callbackFor forwarding status and events, you can refer to the following status codes or event codes to implement related business logic
status code | describe |
---|---|
CloudHub_RELAY_STATE_IDLE | 0:DK is being initialized |
CloudHub_RELAY_STATE_CONNECTING | 1: SDK tries to cross channels |
CloudHub_RELAY_STATE_RUNNING | 2:The host of the source channel successfully added to the target channel |
CloudHub_RELAY_STATE_FAILURE | 3:An exception occurred, detailed error information prompted in the code |
API
Android reference
iOS reference
web reference
Development considerations
This function supports forwarding of media streams to 4 target channels at most. During the forwarding process, if you want to add or delete the target channel, you can adjustUse the
updateChannelMediaRelay
method.This function does not support String user ID
When setting the source channel information, make sure that the uid must be 0, and the uid used to generate the token must also be 0.
After successfully calling the
startChannelMediaRelay
method, if you want to call the method again, you must call it first ThestopChannelMediaRelay
method exits the current forwarding state