public class RoomManager
extends java.lang.Object
Constructor and Description |
---|
RoomManager(RoomHandler roomHandler,
KurentoClientProvider kcProvider)
Provides an instance of the room manager by setting a room handler and the
KurentoClient provider. |
Modifier and Type | Method and Description |
---|---|
void |
addMediaElement(java.lang.String participantId,
MediaElement element)
Applies a media element (filter, recorder, mixer, etc.) to media that is currently streaming or
that might get streamed sometime in the future.
|
void |
addMediaElement(java.lang.String participantId,
MediaElement element,
MediaType type)
Applies a media element (filter, recorder, mixer, etc.) to media that is currently streaming or
that might get streamed sometime in the future.
|
void |
close()
Closes all resources.
|
java.util.Set<UserParticipant> |
closeRoom(java.lang.String roomName)
Closes an existing room by releasing all resources that were allocated for the room.
|
void |
createRoom(KurentoClientSessionInfo kcSessionInfo)
Creates a room if it doesn't already exist.
|
java.lang.String |
generatePublishOffer(java.lang.String participantId)
Represents a client's request to initiate the media connection from the server-side (generate
the SDP offer and send it back to the client) and must be followed by processing the SDP answer
from the client in order to establish the streaming.
|
UserParticipant |
getParticipantInfo(java.lang.String participantId)
Searches for the participant using her identifier and returns the corresponding
UserParticipant POJO. |
java.lang.String |
getParticipantName(java.lang.String participantId)
Finds the participant's username.
|
java.util.Set<UserParticipant> |
getParticipants(java.lang.String roomName)
Returns all the participants inside a room.
|
java.util.Set<UserParticipant> |
getPeerPublishers(java.lang.String participantId)
Returns the peer's publishers (participants from which the peer is receiving media).
|
java.util.Set<UserParticipant> |
getPeerSubscribers(java.lang.String participantId)
Returns the peer's subscribers (participants towards the peer is streaming media).
|
MediaPipeline |
getPipeline(java.lang.String participantId)
Returns the media pipeline used by the participant.
|
java.util.Set<UserParticipant> |
getPublishers(java.lang.String roomName)
Returns all the publishers (participants streaming their media) inside a room.
|
java.lang.String |
getRoomName(java.lang.String participantId)
Finds the room's name of a given participant.
|
java.util.Set<java.lang.String> |
getRooms()
Returns all currently active (opened) rooms.
|
java.util.Set<UserParticipant> |
getSubscribers(java.lang.String roomName)
Returns all the subscribers (participants subscribed to a least one stream of another user)
inside a room.
|
boolean |
isClosed() |
boolean |
isPublisherStreaming(java.lang.String participantId)
Checks if a participant is currently streaming media.
|
java.util.Set<UserParticipant> |
joinRoom(java.lang.String userName,
java.lang.String roomName,
boolean dataChannels,
boolean webParticipant,
KurentoClientSessionInfo kcSessionInfo,
java.lang.String participantId)
Represents a client's request to join a room.
|
java.util.Set<UserParticipant> |
leaveRoom(java.lang.String participantId)
Represents a client's notification that she's leaving the room.
|
void |
mutePublishedMedia(MutedMediaType muteType,
java.lang.String participantId)
Mutes the streamed media of this publisher in a selective manner.
|
void |
muteSubscribedMedia(java.lang.String remoteName,
MutedMediaType muteType,
java.lang.String participantId)
Mutes the incoming media stream from the remote publisher in a selective manner.
|
void |
onIceCandidate(java.lang.String endpointName,
java.lang.String candidate,
int sdpMLineIndex,
java.lang.String sdpMid,
java.lang.String participantId)
Request that carries info about an ICE candidate gathered on the client side.
|
java.lang.String |
publishMedia(java.lang.String participantId,
boolean isOffer,
java.lang.String sdp,
boolean doLoopback,
MediaElement... mediaElements)
Same as
publishMedia(String, boolean, String, MediaElement, MediaType, boolean, MediaElement...)
, using as loopback the published stream and no specific type of loopback connection. |
java.lang.String |
publishMedia(java.lang.String participantId,
boolean isOffer,
java.lang.String sdp,
MediaElement loopbackAlternativeSrc,
MediaType loopbackConnectionType,
boolean doLoopback,
MediaElement... mediaElements)
Represents a client's request to start streaming her local media to anyone inside the room.
|
java.lang.String |
publishMedia(java.lang.String participantId,
java.lang.String sdp,
boolean doLoopback,
MediaElement... mediaElements)
Same as
publishMedia(String, boolean, String, MediaElement, MediaType, boolean, MediaElement...)
where the sdp String is an offer generated by the remote peer, the published stream will be
used for loopback (if required) and no specific type of loopback connection. |
void |
removeMediaElement(java.lang.String participantId,
MediaElement element)
Disconnects and removes media element (filter, recorder, etc.) from a media stream.
|
java.lang.String |
subscribe(java.lang.String remoteName,
java.lang.String sdpOffer,
java.lang.String participantId)
Represents a client's request to receive media from room participants that published their
media.
|
void |
unmutePublishedMedia(java.lang.String participantId)
Reverts the effects of the mute operation.
|
void |
unmuteSubscribedMedia(java.lang.String remoteName,
java.lang.String participantId)
Reverts any previous mute operation.
|
void |
unpublishMedia(java.lang.String participantId)
Represents a client's request to stop publishing her media stream.
|
void |
unsubscribe(java.lang.String remoteName,
java.lang.String participantId)
Represents a client's request to stop receiving media from the remote peer.
|
void |
updateFilter(java.lang.String roomId,
java.lang.String filterId) |
public RoomManager(RoomHandler roomHandler, KurentoClientProvider kcProvider)
KurentoClient
provider.roomHandler
- the room handler implementationkcProvider
- enables the manager to obtain Kurento Client instancespublic java.util.Set<UserParticipant> joinRoom(java.lang.String userName, java.lang.String roomName, boolean dataChannels, boolean webParticipant, KurentoClientSessionInfo kcSessionInfo, java.lang.String participantId) throws RoomException
userName
- name or identifier of the user in the room. Will be used to identify
her WebRTC media
peer (from the client-side).roomName
- name or identifier of the roomdataChannels
- enables data channels (if webParticipant)webParticipant
- if true, the internal media endpoints will use the
trickle ICE
mechanism when establishing connections with external media peers (
WebRtcEndpoint
); if false, the media endpoint
will be a
RtpEndpoint
, with no ICE implementationwebParticipant
- kcSessionInfo
- sessionInfo bean to be used to create the room in case it doesn't
exist (if null, the
room will not be created)participantId
- identifier of the participantUserParticipant
, can be empty if firstRoomException
- on error while joining (like the room is not found or is closing)public java.util.Set<UserParticipant> leaveRoom(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantUserParticipant
, if empty this method has closed
the roomRoomException
- on error leaving the roompublic java.lang.String publishMedia(java.lang.String participantId, boolean isOffer, java.lang.String sdp, MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType, boolean doLoopback, MediaElement... mediaElements) throws RoomException
Dev advice: Send notifications to the existing participants in the room to
inform about the new stream that has been published. Answer to the peer's request by sending it
the SDP response (answer or updated offer) generated by the WebRTC endpoint on the server.
participantId
- identifier of the participantisOffer
- if true, the sdp is an offer from remote, otherwise is the
answer to the offer
generated previously by the server endpointsdp
- SDP String offer or answer,
that's been generated by
the client's WebRTC peerloopbackAlternativeSrc
- instead of connecting the endpoint to itself, use this
MediaElement
as sourceloopbackConnectionType
- the connection type for the loopback; if null, will stream
both audio and video mediadoLoopback
- loopback flagmediaElements
- variable array of media elements (filters, recorders, etc.)
that are connected between
the source WebRTC endpoint and the subscriber endpointsRoomException
- on errorpublic java.lang.String publishMedia(java.lang.String participantId, java.lang.String sdp, boolean doLoopback, MediaElement... mediaElements) throws RoomException
publishMedia(String, boolean, String, MediaElement, MediaType, boolean, MediaElement...)
where the sdp String is an offer generated by the remote peer, the published stream will be
used for loopback (if required) and no specific type of loopback connection.RoomException
#publishMedia(String, boolean, String, boolean, MediaElement, MediaElement...)
public java.lang.String publishMedia(java.lang.String participantId, boolean isOffer, java.lang.String sdp, boolean doLoopback, MediaElement... mediaElements) throws RoomException
publishMedia(String, boolean, String, MediaElement, MediaType, boolean, MediaElement...)
, using as loopback the published stream and no specific type of loopback connection.RoomException
#publishMedia(String, boolean, String, boolean, MediaElement, MediaElement...)
public java.lang.String generatePublishOffer(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- on errorpublishMedia(String, String, boolean, MediaElement...)
public void unpublishMedia(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- on errorpublic java.lang.String subscribe(java.lang.String remoteName, java.lang.String sdpOffer, java.lang.String participantId) throws RoomException
remoteName
- identification of the remote stream which is effectively the peer's
name (participant)sdpOffer
- SDP offer String generated by the client's WebRTC peerparticipantId
- identifier of the participantRoomException
- on errorpublic void unsubscribe(java.lang.String remoteName, java.lang.String participantId) throws RoomException
remoteName
- identification of the remote stream which is effectively the peer's
name (participant)participantId
- identifier of the participantRoomException
- on errorpublic void onIceCandidate(java.lang.String endpointName, java.lang.String candidate, int sdpMLineIndex, java.lang.String sdpMid, java.lang.String participantId) throws RoomException
endpointName
- the name of the peer whose ICE candidate was gatheredcandidate
- the candidate attribute informationsdpMLineIndex
- the index (starting at zero) of the m-line in the SDP this candidate is
associated
withsdpMid
- media stream identification, "audio" or "video", for the m-line this
candidate is
associated withparticipantId
- identifier of the participantRoomException
- on errorpublic void addMediaElement(java.lang.String participantId, MediaElement element) throws RoomException
participantId
- identifier of the owner of the streamelement
- media element to be addedRoomException
- in case the participant doesn't exist, has been closed or on error
when applying the
filterpublic void addMediaElement(java.lang.String participantId, MediaElement element, MediaType type) throws RoomException
participantId
- identifier of the owner of the streamelement
- media element to be addedtype
- the connection type (null is accepted, has the same result as calling
addMediaElement(String, MediaElement)
)RoomException
- in case the participant doesn't exist, has been closed or on error
when applying the filterpublic void removeMediaElement(java.lang.String participantId, MediaElement element) throws RoomException
participantId
- identifier of the participantelement
- media element to be removedRoomException
- in case the participant doesn't exist, has been closed or on error
when removing the
filterpublic void mutePublishedMedia(MutedMediaType muteType, java.lang.String participantId) throws RoomException
muteType
- which leg should be disconnected (audio, video or both)participantId
- identifier of the participantRoomException
- in case the participant doesn't exist, has been closed, is not
publishing or on error
when performing the mute operationpublic void unmutePublishedMedia(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- in case the participant doesn't exist, has been closed, is not
publishing or on error
when reverting the mute operationpublic void muteSubscribedMedia(java.lang.String remoteName, MutedMediaType muteType, java.lang.String participantId) throws RoomException
remoteName
- identification of the remote stream which is effectively the peer's
name (participant)muteType
- which leg should be disconnected (audio, video or both)participantId
- identifier of the participantRoomException
- in case the participant doesn't exist, has been closed, is not
publishing or on error
when performing the mute operationpublic void unmuteSubscribedMedia(java.lang.String remoteName, java.lang.String participantId) throws RoomException
remoteName
- identification of the remote stream which is effectively the peer's
name (participant)participantId
- identifier of the participantRoomException
- in case the participant doesn't exist, has been closed or on error
when reverting the
mute operation@PreDestroy public void close()
closeRoom(String)
public boolean isClosed()
close()
has been calledpublic java.util.Set<java.lang.String> getRooms()
public java.util.Set<UserParticipant> getParticipants(java.lang.String roomName) throws RoomException
roomName
- name or identifier of the roomUserParticipant
POJOS (an instance contains the participant's identifier
and her user name)RoomException
- in case the room doesn't existpublic java.util.Set<UserParticipant> getPublishers(java.lang.String roomName) throws RoomException
roomName
- name or identifier of the roomUserParticipant
POJOS representing the existing publishersRoomException
- in case the room doesn't existpublic java.util.Set<UserParticipant> getSubscribers(java.lang.String roomName) throws RoomException
roomName
- name or identifier of the roomUserParticipant
POJOS representing the existing subscribersRoomException
- in case the room doesn't existpublic java.util.Set<UserParticipant> getPeerPublishers(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantUserParticipant
POJOS representing the publishers this participant is
currently subscribed toRoomException
- in case the participant doesn't existpublic java.util.Set<UserParticipant> getPeerSubscribers(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantUserParticipant
POJOS representing the participants subscribed to this
peerRoomException
- in case the participant doesn't existpublic boolean isPublisherStreaming(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- in case the participant doesn't exist or has been closedpublic void createRoom(KurentoClientSessionInfo kcSessionInfo) throws RoomException
kcSessionInfo
- bean that will be passed to the KurentoClientProvider
in order
to obtain the
KurentoClient
that will be used by the roomRoomException
- in case of error while creating the roompublic java.util.Set<UserParticipant> closeRoom(java.lang.String roomName) throws RoomException
roomName
- name or identifier of the roomUserParticipant
POJOS representing the room's participantsRoomException
- in case the room doesn't exist or has been already closedpublic MediaPipeline getPipeline(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- in case the participant doesn't existpublic java.lang.String getRoomName(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- in case the participant doesn't existpublic java.lang.String getParticipantName(java.lang.String participantId) throws RoomException
participantId
- identifier of the participantRoomException
- in case the participant doesn't existpublic UserParticipant getParticipantInfo(java.lang.String participantId) throws RoomException
UserParticipant
POJO.participantId
- identifier of the participantUserParticipant
POJO containing the participant's name and identifierRoomException
- in case the participant doesn't existpublic void updateFilter(java.lang.String roomId, java.lang.String filterId)