Class : EnxStream

A Stream carries different types of media. Audio, Video, and Data. This stream gets transferred towards remote endpoints through Enablex Media Servers where it’s played and interacted with.

There are essentially 2 types of streams, viz.

  1. Local Stream: A Stream which a Client endpoint initiates and transfers over the network.
  2. Remote Stream: A Stream which a Client endpoint receives from others over the network.

Methods:

Method Name Description
attachRenderer(EnxPlayerView enxplayerview) To attach a stream on PlayerView.
detachRenderer() To detach a stream from PlayerView.
muteSelfAudio(boolean status) To mute/unmute published stream audio.
muteSelfVideo(boolean status) To stop/start published stream video.
hardMuteAudio(String clientId) To mute remote stream audio. Only for moderator use.
hardunMuteAudio(String clientId) To unmute remote stream audio. Only for moderator use.
hardMuteVideo(String clientId) To mute remote stream video. Only for moderator use.
hardUnMuteVideo(String clientId) To unmute remote stream video. Only for moderator use.
sendData(String txtMessage, String senderName) To send data at stream level.
getId() To get stream id.
isLocal() To check local stream.
switchCamera() To switch camera rear to front and vice-versa.
hasAudio() Indicates if the stream has audio tracks.
hasVideo() Indicates if the stream has video tracks.
hasData() Indicates if the stream has data activated.
hasScreen() Indicates if the stream has been shared.
getAttributes() To get attributes of stream as JSON.
getMedia() To get audio and video tracks.
getState() To get current state of stream.
isAudioActive() To get current state of audio.
isVideoActive() To get current state of video.



Stream observer :

Stream requires an Observer. While creating an instance of EnxRtc class, you need to pass a reference to Stream Observer instance.

Callbacks for Stream Observer
Callbacks Description
onAudioEvent(JSONObject jsonObject) Receive on perform audio actions on the streams.
onVideoEvent(JSONObject jsonObject) Receive on perform video actions on the streams.
onReceivedData(JSONObject jsonObject) Receive when other clients send messages.
onRemoteStreamAudioMute(JSONObject jsonObject) All Participants receives If the remote user mute own audio.
onRemoteStreamAudioUnMute(JSONObject jsonObject) All Participants receives If the remote user unmute own audio.


HardMute Audio observer:

In order to receive the Hard Mute / Hard Unmute audio events on single stream set muteAudioStream observer. LocalStream.setMuteAudioStreamObserver(current-class-instance) Callbacks for Mute Audio Stream Observer
Callbacks Description
onHardMutedAudio(JSONObject jsonObject) Receive when moderator mute the single audio stream. This is for moderator only.
onHardUnMutedAudio(JSONObject jsonObject) Receive when moderator unmute the single audio stream. This is for moderator only.
onReceivedHardMuteAudio(JSONObject jsonObject) Participant receives when moderator mute the that audio stream. This is for Participant only.
onReceivedHardUnMuteAudio(JSONObject jsonObject) Participant receives when moderator unmute the that audio stream. This is for Participant only.


HardMute Video observer:

In order to receive the Hard Mute / Hard Unmute video events on single stream set muteVideoStream observer. LocalStream.setMuteVideoStreamObserver(current-class-instance) Callbacks for Mute Video Stream Observer
Callbacks Description
onHardMutedVideo(JSONObject jsonObject) Receive when moderator mute the single video stream. This is for moderator only.
onHardUnMutedVideo(JSONObject jsonObject) Receive when moderator unmute the single video stream. This is for moderator only.
onReceivedHardMuteVideo(JSONObject jsonObject) Participant receive when moderator mute the that video stream. This is for Participant only.
onReceivedHardUnMuteVideo(JSONObject jsonObject) Participant receive when moderator unmute the that video stream. This is for Participant only.




Attach Video Render

To attach stream on enxPlayerView.

public synchronized void attachRenderer(EnxPlayerView enxPlayerView)

Parameter:
Parameters Description
enxPlayerView enxPlayerView object on which stream is attached to render video.


Detach Video Render

This API is used to remove stream from enxPlayerView.

public synchronized void detachRenderer()




Mute self Audio

This API stop sending user Audio to the Room during the session.

To mute audio use below method by passing false as a parameter.
public void muteSelfAudio(boolean value)

Parameter:
Parameters Description
true For mute.
Callback: public void onAudioEvent(JsonObject jsonobject)

Where jsonOject is: { "msg":"message", "errorCode":0 } Callback : Receive all other users public void onRemoteStreamAudioMute(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0086645a-463b-4c72-ba1a-0b3c808b97c0", "msg":"user muted audio" }



UnMute self Audio

This API start sending user Audio to the Room during the session.

To unmute audio use below method by passing true as a parameter.
public void muteSelfAudio(boolean value)

Parameter:
Parameters Description
false For unmute.
Callback: public void onAudioEvent(JsonObject jsonobject)

Where jsonOject is: { "msg":"message", "errorCode":0 } Callback : Receive all other users public void onRemoteStreamAudioUnMute(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0086645a-463b-4c72-ba1a-0b3c808b97c0", "msg":"user unmuted audio" }



Hard Mute User :

These APIs help hard-mute a user in the room at runtime. These API calls are only available to users with role "Moderator". When a user is being put on hard-mute, their audio stream is stopped.

public void hardMuteAudio(String clientId)

Parameter:
  • clientId: It could be string
Callback :

public void onHardMutedAudio(JSONObject jsonObject)

Where jsonOject is: { "result" : 0 }


Participant Callbacks: public void onReceivedHardMuteAudio(JSONObject jsonObject)

Where jsonOject is: { "result":0, "clientId":"0a39350b-fba9-4f43-9559-673d2e43eb48", "msg":"user audio hard muted" }



Hard Unmute User :

These APIs help hard-unmute a user in the room at runtime. These API calls are only available to users with role "Moderator". When a user is being put off hard-mute, their audio stream is stopped. When the user is put off hard-mute, the user audio is set to last known audio-state.


public void hardUnMuteAudio(String clientId)

Parameter:
clientId: It could be string

Moderator Callback

public void onHardUnMutedAudio(JSONObject jsonObject)

Where jsonOject is: { "result" : "0" }

Participant Callbacks:

public void onReceivedHardUnMuteAudio(JSONObject jsonObject)

Where jsonOject is: { "result":0, "clientId":"0a39350b-fba9-4f43-9559-673d2e43eb48", "msg":"user audio hard unmuted" }





Stop Video

These API stop sending user Video to the Room during the session.

To stop video use below method by passing true as a parameter.
public void muteSelfVideo(boolean value)

Parameter:
Parameters Description
true For stop video
Callback: public void onVideoEvent(JsonObject jsonobject)

Where jsonObject is: { "msg":"message", "errorCode":0 }

Callback: Receive all other users public void onRemoteStreamVideoMute(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0086645a-463b-4c72-ba1a-0b3c808b97c0", "msg":"user muted video" }



Start Video

These API start sending user video to the Room during the session.

To start video use below method by passing false as a parameter.
public void muteSelfVideo(boolean value)

Parameter:
Parameters Description
false For start video
Callback: public void onVideoEvent(JsonObject jsonobject)

Where jsonObject is: { "msg":"message", "errorCode":0 }

Callback : Receive all other users public void onRemoteStreamVideoUnMute(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0086645a-463b-4c72-ba1a-0b3c808b97c0", "msg":"user unmuted video" }

Hard Mute Video :

This API help hard-mute video in the room at runtime. This API calls are only available to users with role "Moderator". When a user video is being put on hard-mute, their video stream is stopped

public void hardMuteVideo(String clientId)

Parameter:
    clientId: It could be string
Callback :

public void onHardMutedVideo(JSONObject jsonObject)

Where jsonObject is: { "result" : 0 }

Participant Callbacks: public void onReceivedHardMuteVideo(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0a39350b-fba9-4f43-9559-673d2e43eb48", "msg":"user video hard muted" }



Hard Unmute Video :

This APIs help hard-unmute video in the room at runtime. This API calls are only available to users with role "Moderator". When a user video is being put off hard-mute, their video stream is start , until it’s reversed. When the user is put off hard-mute, the user video is set to last known video-state.

public void hardUnMuteVideo(String clientId)

Parameter:
clientId: It could be string

Moderator Callback : public void onHardUnMutedVideo(JSONObject jsonObject)

Where jsonObject is: { "result" : "0" } Participant Callback:

public void onReceivedHardUnMuteVideo(JSONObject jsonObject)

Where jsonObject is: { "result":0, "clientId":"0a39350b-fba9-4f43-9559-673d2e43eb48", "msg":"user video hard unmuted" }





Switch Camera

To switch camera during the session.

public void switchCamera()



Send / Receive Message

This is used for sending/broadcasting text-message to all users and showing messages as received from others. The receive-message API sets-up event-listeners to receive a message as they are broadcasted.

Note! Currently EnableX only supports Broadcast method of Messaging between users in a room.

Send Message


public void sendData(String txtMessage, String senderName) Parameter:
Parameters Description
Message It’s a string message.
senderName It’s a user name.
Return: None

Receive Message

Callbacks:
public void onReceivedData(JsonObject jsonobject) Where Response chatMessage is Json Type:

{ "id": 45442563, "msg": { "message": "Hello", "from": "Shashank", "type": "public", "timestamp": "1536319344844" } }



Get Stream Id

To get stream id during the session.

public String getId()





Check Stream

To check stream is local or remote during the session.

public boolean isLocal()



hasAudio

Indicates if the media stream has audio tracks.

public boolean hasAudio()

Return : Boolean value.




hasVideo

Indicates if the media stream has video tracks.

public boolean hasVideo()

Return : Boolean value.




hasData

Indicates if the stream has data activated.

public boolean hasData()

Return : Boolean value.





hasScreen

Indicates if the screen is shared or not.

public boolean hasScreen()

Return : Boolean value.




Get Attributes

To get attributes of stream as JSON.

public JSONObject getAttributes()

Return : jsonobject.




Get Media

To get audio and video tracks.

public MediaStream getMedia()

Return : MediaStream Object




Get State

To get current state of stream.

public String getState()

Return : Stream State String Object

Where String will be any of these value: UNKNOWN, OPENING, ACTIVE, CLOSING, DESTROYED, LOCAL, BLOCKED




Get State of Audio

To get current state of Audio.

public boolean isAudioActive()


Get State of Video

To get current state of Video.

public boolean isVideoActive()