After successfully joining a channel and starting the audio and video streaming, a user can stop sending the stream to this channel or stop receiving the stream from this channel.
Stop/resume sending the local stream
Call the following methods to stop or resume sending the local stream:
agora_rtc_mute_local_audio
: Stop or resume sending the audio stream.agora_rtc_mute_local_video
: Stop or resume sending the video stream.You can pass channel_name
of a specified channel to stop sending the stream to this channel, or set channel_name
as NULL for all channels.
agora_rtc_mute_local_audio ("my_first_channel", 1); // Stop sending audio
agora_rtc_mute_local_video ("my_first_channel", 1); // Stop sending video
agora_rtc_mute_local_audio ("my_first_channel", 0); // Start sending audio
agora_rtc_mute_local_video ("my_first_channel", 0); // Start sending video
Indicate whether or not the sender stops sending streams
After the sender stops sending his/her streams by calling the agora_rtc_mute_local_audio
or agora_rtc_mute_local_video
methods, the SDK triggers the following callbacks to inform the receiver:
on_user_mute_audio
: Whether or not the sender stops sending his/her audio.on_user_mute_video
: Whether or not the sender stops sending his/her video.static void OnUserMuteAudio (const char *channel, uint32_t uid, int muted)
{
std::cout << __FUNCTION__ << std::endl;
}
static void OnUserMuteVideo (const char *channel, uint32_t uid, int muted)
{
std::cout << __FUNCTION__ << std::endl;
}
static const agora_rtc_event_handler_t listener = {
.on_user_mute_audio = OnUserMuteAudio,
.on_user_mute_video = OnUserMuteVideo,
// ...
};
Stop/resume receiving the remote stream
Call the following methods to stop or resume receiving the remote stream:
agora_rtc_mute_remote_audio
: Stop or resume receiving the audio stream.agora_rtc_mute_remote_video
: Stop or resume receiving the video stream.You can pass channel_name of a specified channel and uid of a specified user to stop receiving the stream from this user in this channel, or set uid
and channel_name
as NULL for all users and all channels.
const uint32_t remote_uid = 666;
// Stop receiving audio from a remote user
agora_rtc_mute_remote_audio ("my_first_channel", remote_uid, 1);
// Stop receiving video from a remote user
agora_rtc_mute_remote_video ("my_first_channel", remote_uid, 1);
// Start receiving audio from a remote user
agora_rtc_mute_remote_audio ("my_first_channel", remote_uid, 0);
// Start receiving video from a remote user
agora_rtc_mute_remote_video ("my_first_channel", remote_uid, 0);