openvidu-java-client API

This is a Java library wrapping OpenVidu REST API

Installation 🔗

See dependency at Maven Central.

openvidu-java-client SDK requires Java 11 or higher

Documentation 🔗

JavaDoc documentation

Code samples 🔗

Create a Session 🔗

OpenVidu openvidu = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
SessionProperties properties = new SessionProperties.Builder().build();
Session session = openVidu.createSession(properties);

Create a Connection 🔗

ConnectionProperties connectionProperties = new ConnectionProperties.Builder()
Connection connection = session.createConnection(connectionProperties);
String token = connection.getToken(); // Send this string to the client side

Update a Connection 🔗

This feature is part of OpenVidu PRO and ENTERPRISE editions.
ConnectionProperties connectionProperties = new ConnectionProperties.Builder()
String connectionId = connection.getConnectionId();
session.updateConnection(connectionId, connectionProperties);

Publish an IP camera 🔗

ConnectionProperties connectionProperties = new ConnectionProperties.Builder()
// "session" being a Session object
Connection ipcamConnection = session.createConnection(connectionProperties);

Fetch Session status 🔗

// Fetch all session info from OpenVidu Server
List<Session> activeSessions = openvidu.getActiveSessions();

// Fetch one session info from OpenVidu Server
List<Connection> activeConnections = session.getActiveConnections();

Close a Session 🔗


Destroy a Connection 🔗

// Find the desired Connection object in the list returned by Session.getActiveConnections()

Unpublish a stream 🔗

// Find the desired Publisher object in the list returned by Connection.getPublishers()

Manage recordings 🔗

// Start recording
String sessionId = session.getSessionId();
RecordingProperties properties = new RecordingProperties.Builder().build();
Recording recordingStarted = openVidu.startRecording(sessionId, properties);

// Stop recording
String recordingId = recordingStarted.getId();
Recording recordingStopped = openvidu.stopRecording(recordingId);

// Get recording
Recording recordingRetrieved = openvidu.getRecording(recordingId);

// List recordings
List<Recording> recordingList = openVidu.listRecordings();

// Delete recording