Package io.openvidu.java.client
Class OpenVidu
- java.lang.Object
-
- io.openvidu.java.client.OpenVidu
-
public class OpenVidu extends Object
-
-
Constructor Summary
Constructors Constructor Description OpenVidu(String hostname, String secret)OpenVidu(String hostname, String secret, org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)OpenVidu(String hostname, org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SessioncreateSession()Creates an OpenVidu session with the default settingsSessioncreateSession(SessionProperties properties)Creates an OpenVidu sessionvoiddeleteRecording(String recordingId)Deletes a recording.booleanfetch()Updates every property of every active Session with the current status they have in OpenVidu Server.SessiongetActiveSession(String sessionId)Returns an active session.List<Session>getActiveSessions()Returns the list of active sessions.RecordinggetRecording(String recordingId)Gets an existing recordingList<Recording>listRecordings()Lists all existing recordingsvoidstartBroadcast(String sessionId, String broadcastUrl)Starts the broadcast of aSessionvoidstartBroadcast(String sessionId, String broadcastUrl, RecordingProperties properties)Starts the broadcast of aSessionRecordingstartRecording(String sessionId)Starts the recording of aSessionRecordingstartRecording(String sessionId, RecordingProperties properties)Starts the recording of aSessionRecordingstartRecording(String sessionId, String name)Starts the recording of aSessionvoidstopBroadcast(String sessionId)Stops the broadcast of aSessionRecordingstopRecording(String recordingId)Stops the recording of aSession
-
-
-
Constructor Detail
-
OpenVidu
public OpenVidu(String hostname, String secret)
- Parameters:
hostname- URL where your OpenVidu deployment is up an running. It must be the full URL (e.g.https://12.34.56.78:1234/)secret- Secret configured in your OpenVidu deployment
-
OpenVidu
public OpenVidu(String hostname, String secret, org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
- Parameters:
hostname- URL where your OpenVidu deployment is up an running. It must be the full URL (e.g.https://12.34.56.78:1234/)secret- Secret configured in your OpenVidu deploymentbuilder- An instance of org.apache.hc.client5.http.impl.classic.HttpClientBuilder. This overrides the internal HTTP client in use. This method allows you to custom configure the HTTP client to your needs. This may be interesting for many reasons, including:- Adding custom HTTP headers
- Adding proxy configuration
- Customizing the SSLContext
- Modifying the connection timeouts
- Setting up a cookie store
builderwith a BasicCredentialsProvider built with the paramsecret, which is the default configuration.
-
OpenVidu
public OpenVidu(String hostname, org.apache.hc.client5.http.impl.classic.HttpClientBuilder builder)
- Parameters:
hostname- URL where your OpenVidu deployment is up an running. It must be the full URL (e.g.https://12.34.56.78:1234/)builder- An instance of org.apache.hc.client5.http.impl.classic.HttpClientBuilder. This overrides the internal HTTP client in use. This method allows you to custom configure the HTTP client to your needs. This may be interesting for many reasons, including:- Adding custom HTTP headers
- Adding proxy configuration
- Customizing the SSLContext
- Modifying the connection timeouts
- Setting up a cookie store
-
-
Method Detail
-
createSession
public Session createSession() throws OpenViduJavaClientException, OpenViduHttpException
Creates an OpenVidu session with the default settings- Returns:
- The created session
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException
-
createSession
public Session createSession(SessionProperties properties) throws OpenViduJavaClientException, OpenViduHttpException
Creates an OpenVidu session- Parameters:
properties- The specific configuration for this session- Returns:
- The created session
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API). This method will never return aOpenViduHttpExceptionwith status 409. If a session with the samecustomSessionIdalready exists in OpenVidu Server, aSession.fetch()operation is performed in the background and the updated Session object is returned.
-
startRecording
public Recording startRecording(String sessionId, RecordingProperties properties) throws OpenViduHttpException, OpenViduJavaClientException
Starts the recording of aSession- Parameters:
sessionId- The sessionId of the session you want to start recordingproperties- The configuration for this recording- Returns:
- The new created session
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
startRecording
public Recording startRecording(String sessionId, String name) throws OpenViduJavaClientException, OpenViduHttpException
Starts the recording of aSession- Parameters:
sessionId- The sessionId of the session you want to start recordingname- The name you want to give to the video file. WARNING: this parameter follows an overwriting policy. If you name two recordings the same, the newest MP4 file will overwrite the oldest one- Returns:
- The started recording. If this method successfully returns the Recording object it means that the recording can be stopped with guarantees
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
startRecording
public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException
Starts the recording of aSession- Parameters:
sessionId- The sessionId of the session you want to start recording- Returns:
- The started recording. If this method successfully returns the Recording object it means that the recording can be stopped with guarantees
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
stopRecording
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException
Stops the recording of aSession- Parameters:
recordingId- The id property of the recording you want to stop- Returns:
- The stopped recording
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
getRecording
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException
Gets an existing recording- Parameters:
recordingId- The id property of the recording you want to retrieve- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
listRecordings
public List<Recording> listRecordings() throws OpenViduJavaClientException, OpenViduHttpException
Lists all existing recordings- Returns:
- A
Listwith all existing recordings - Throws:
OpenViduJavaClientExceptionOpenViduHttpException
-
deleteRecording
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException
Deletes a recording. The recording must have statusRecording.Status.stopped,Recording.Status.readyorRecording.Status.failed- Parameters:
recordingId- The id property of the recording you want to delete- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
startBroadcast
public void startBroadcast(String sessionId, String broadcastUrl) throws OpenViduJavaClientException, OpenViduHttpException
Starts the broadcast of aSession- Parameters:
sessionId- The sessionId of the session you want to start broadcastingbroadcastUrl- The URL where to broadcast- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
startBroadcast
public void startBroadcast(String sessionId, String broadcastUrl, RecordingProperties properties) throws OpenViduJavaClientException, OpenViduHttpException
Starts the broadcast of aSession- Parameters:
sessionId- The sessionId of the session you want to start broadcastingbroadcastUrl- The URL where to broadcastproperties- The configuration for this broadcast. It uses a subset of theRecordingProperties:RecordingProperties.Builder.hasAudio(boolean)RecordingProperties.Builder.resolution(String)RecordingProperties.Builder.frameRate(int)RecordingProperties.Builder.recordingLayout(RecordingLayout)RecordingProperties.Builder.customLayout(String)RecordingProperties.Builder.shmSize(long)RecordingProperties.Builder.mediaNode(String)
- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
stopBroadcast
public void stopBroadcast(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException
Stops the broadcast of aSession- Parameters:
sessionId- The sessionId of the session you want to stop broadcasting- Throws:
OpenViduJavaClientExceptionOpenViduHttpException- The status code carries a specific meaningOpenViduHttpException.getStatus()(see REST API)
-
getActiveSessions
public List<Session> getActiveSessions()
Returns the list of active sessions. This value will remain unchanged since the last time methodfetch()was called. Exceptions to this rule are:- Calling
OpenVidu.createSessionautomatically adds the new Session object to the local collection. - Calling
Session.fetch()updates that specific Session status - Calling
Session.close()automatically removes the Session from the list of active Sessions - Calling
Session.forceDisconnect(Connection)automatically updates the inner affected connections for that specific Session - Calling
Session.forceUnpublish(Publisher)automatically updates the inner affected connections for that specific Session - Calling
Session.updateConnection(String, ConnectionProperties)automatically updates the inner affected connection for that specific Session - Calling
startRecording(String)andstopRecording(String)automatically updates the recording status of the Session (Session.isBeingRecorded())
To get the list of active sessions with their current actual value, you must call firstfetch()and thengetActiveSessions() - Calling
-
getActiveSession
public Session getActiveSession(String sessionId)
Returns an active session. This method has the same behavior and restrictions asgetActiveSessions(), but it just returns a single Session instead of the complete list of Sessions- Parameters:
sessionId-- Returns:
-
fetch
public boolean fetch() throws OpenViduJavaClientException, OpenViduHttpExceptionUpdates every property of every active Session with the current status they have in OpenVidu Server. After calling this method you can access the updated list of active sessions by callinggetActiveSessions()- Returns:
- true if any Session status has changed with respect to the server, false if not. This applies to any property or sub-property of any of the sessions locally stored in OpenVidu Java Client
- Throws:
OpenViduHttpExceptionOpenViduJavaClientException
-
-