Skip to main content
Version: 0.1.x

Manage Roles - Android

Roles with VideoSDK

When doing interactive live streaming maintaining the role of users is quite important. To help manage these roles better, VideoSDK allows a participant with two types of modes:

1. SEND_AND_RECV When a participant is joining with mode set to SEND_AND_RECV, we will be able to publish and consume the media of other participants and also interact with them using the features like chat, poll etc.

2. SIGNALLING_ONLY When a participant is joining with mode set to SIGNALLING_ONLY, that participant is not allowed to publish or consume any media from other participants. Although they can interact with other participants using chat, polls etc.

info

Important Changes Android SDK in Version v0.2.0

  • The following modes have been deprecated:
    • CONFERENCE has been replaced by SEND_AND_RECV
    • VIEWER has been replaced by SIGNALLING_ONLY

Please update your implementation to use the new modes.

⚠️ Compatibility Notice:
To ensure a seamless meeting experience, all participants must use the same SDK version.
Do not mix version v0.2.0 + with older versions, as it may cause significant conflicts.

This image is for education purpose

manage-roles

When to use the Roles?

1. Simple Adaptive Streaming
  • Simple Adaptive Streaming (SAS) is a type of livestreaming that requires minimal interaction between the host and viewers.

  • It is particularly useful for events with a large number of viewers who prefer not to engage with the host.

  • In SAS, each speaker attends a VideoSDK meeting in SEND_AND_RECV mode, while viewers can simply watch the livestream using the playbackHlsUrl or livestreamUrl. Unlike the speakers, viewers do not need to join the meeting in SEND_AND_RECV or SIGNALLING_ONLY mode. This allows for a seamless streaming experience without any unnecessary interruptions or distractions.

    • playbackHlsUrl - Live HLS with playback support
    • livestreamUrl - Live HLS without playback support
note

downstreamUrl is now depecated. Use playbackHlsUrl or livestreamUrl in place of downstreamUrl

This video is for education purpose

2. Adaptive Streaming with increased engagement
  • If you're looking to increase engagement with your audience during a live streaming event, consider using Adaptive Streaming technology. With this approach, you can incorporate interactive features such as polls and conversations, and give viewers the ability to join and leave the livestream as the host decides.

  • To set this up, have all speakers join as SEND_AND_RECV mode participants, while the audience joins as SIGNALLING_ONLY mode participants. This way, everyone can participate in the interactive elements of the live stream and create a more dynamic and engaging experience for all.

This video is for education purpose

Using roles

When you initialize the meeting, you can set the mode of Participant.

class MainActivity : AppCompatActivity() {

fun getToken(): String? {
...
}

fun getMeetingId(token: String?): String? {
...
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

//We will fetch token and meetingId and store it in local variables
val token: String = getToken()
val meetingId = getMeetingId(token)

// initialize the VideoSDK
VideoSDK.initialize(this@MainActivity)

// set token property of VideoSDK
VideoSDK.config(token)

// create a new meeting instance
val meeting: Meeting = VideoSDK.initMeeting(
this@MainActivity, meetingId, "NAME HERE",
true, true, null,
"SEND_AND_RECV", // allowed: SEND_AND_RECV | SIGNALLING_ONLY | RECV_ONLY
false,
null,
null
)

Log.d("VideoSDK", "onCreate: $meetingId")
}
}

Getting Participant Mode

You can identify the participants role by using mode property from Participant class.

override fun onCreate(savedInstanceState: Bundle?) {
//...

val localParticipant = meeting!!.localParticipant
Log.d("VideoSDK", "Participant mode : " + localParticipant.mode)
}

Changing Participant's Mode

Let's say you are hosting a livestream and you want one of your viewer to join the livestream with you. In this case you can change the mode of the participant using the changeMode() of the Meeting class.

findViewById<View>(R.id.btnConferenceMode).setOnClickListener { view: View? ->
// change mode to SEND_AND_RECV
meeting!!.changeMode("SEND_AND_RECV")
}

findViewById<View>(R.id.btnViewerMode).setOnClickListener { view: View? ->
// change mode to SIGNALLING_ONLY
meeting!!.changeMode("SIGNALLING_ONLY")
}

API Reference

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord