java.lang.Object

com.opentok.OpenTok


public class OpenTok extends Object

Contains methods for creating OpenTok sessions, generating tokens, and working with archives.

To create a new OpenTok object, call the OpenTok constructor with your OpenTok API key and the API secret for your Vonage Video API account. Do not publicly share your API secret. You will use it with the OpenTok constructor (only on your web server) to create OpenTok sessions.

Be sure to include the entire OpenTok server SDK on your web server.

Nested Class Summary

Nested Classes

Modifier and Type

Class

Description

static class

OpenTok.Builder

Used to create an OpenTok object with advanced settings.

Constructor Summary

Constructors

Constructor

Description

OpenTok(int apiKey, String apiSecret)

Creates an OpenTok object.

OpenTok(String applicationId, Path privateKeyPath)

Creates an OpenTok object for use with the Vonage Video API.

Method Summary

All MethodsInstance MethodsConcrete Methods

Modifier and Type

Method

Description

void

addArchiveStream(String archiveId, String streamId, boolean hasAudio, boolean hasVideo)

Adds a stream to an OpenTok archive.

void

addBroadcastStream(String broadcastId, String streamId, boolean hasAudio, boolean hasVideo)

Adds a stream to an Opentok broadcast.

void

close()

Call this method when you are done using the OpenTok object, to prevent leaked file descriptors.

AudioConnector

connectAudioStream(String sessionId, String token, AudioConnectorProperties properties)

Send audio from a Vonage Video API session to a WebSocket.

Session

createSession()

Creates an OpenTok session with the default settings:

Session

createSession(SessionProperties properties)

Creates a new OpenTok session.

void

deleteArchive(String archiveId)

Deletes an OpenTok archive.

Sip

dial(String sessionId, String token, SipProperties properties)

Dials a SIP gateway to connect it an OpenTok session.

void

disableForceMute(String sessionId)

Disables the active mute state of the session.

void

forceDisconnect(String sessionId, String connectionId)

Disconnect a client from an OpenTok session

void

forceMuteAll(String sessionId, MuteAllProperties properties)

Forces all streams (except for an optional array of streams) in a session to mute published audio.

void

forceMuteStream(String sessionId, String streamId)

Force the publisher of a specific stream to mute its audio.

String

generateToken(String sessionId)

Creates a token for connecting to an OpenTok session, using the default settings.

String

generateToken(String sessionId, TokenOptions tokenOptions)

Creates a token for connecting to an OpenTok session.

Archive

getArchive(String archiveId)

Gets an Archive object for the given archive ID.

Broadcast

getBroadcast(String broadcastId)

Gets an Broadcast object for the given broadcast ID.

Render

getRender(String renderId)

Gets a Render object, with details on an Experience Composer.

Stream

getStream(String sessionId, String streamId)

Gets a Stream object for the given session ID and stream ID.

ArchiveList

listArchives()

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

ArchiveList

listArchives(int offset, int count)

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

ArchiveList

listArchives(String sessionId)

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

ArchiveList

listArchives(String sessionId, int offset, int count)

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

List<Render>

listRenders()

Gets a list of Render objects, representing Experience Composers associated with the OpenTok project.

List<Render>

listRenders(Integer offset, Integer count)

Gets a list of Render objects, representing a list of Experience Composers associated with the OpenTok project.

StreamList

listStreams(String sessionId)

Gets a list of Stream objects for the given session ID.

void

playDTMF(String sessionId, String dtmfDigits)

Send DTMF digits to all clients in a session.

void

playDTMF(String sessionId, String connectionId, String dtmfDigits)

Send DTMF digits a specific client in a session.

void

removeArchiveStream(String archiveId, String streamId)

Removes a stream from an Opentok archive.

void

removeBroadcastStream(String broadcastId, String streamId)

Removes a stream from an Opentok broadcast.

void

setArchiveLayout(String archiveId, ArchiveProperties properties)

Sets the layout type for a composed archive.

void

setBroadcastLayout(String broadcastId, BroadcastProperties properties)

Sets the layout type for the broadcast.

void

setStreamLayouts(String sessionId, StreamListProperties properties)

Sets the layout class list for streams in a session.

void

signal(String sessionId, SignalProperties props)

Sends a signal to all clients connected to a session.

void

signal(String sessionId, String connectionId, SignalProperties props)

Sends a signal to a specific client connected to a session.

Archive

startArchive(String sessionId)

Archive

startArchive(String sessionId, ArchiveProperties properties)

Starts archiving an OpenTok session.

Archive

startArchive(String sessionId, String name)

Broadcast

startBroadcast(String sessionId, BroadcastProperties properties)

Starts a live streaming broadcast for an OpenTok session.

Caption

startCaptions(String sessionId, String token, CaptionProperties properties)

Use the Live Captions API to transcribe audio streams and generate real-time captions for your application.

Render

startRender(String sessionId, String token, RenderProperties properties)

Starts an Experience Composer render for an OpenTok session.

Archive

stopArchive(String archiveId)

Stops an OpenTok archive that is being recorded.

Broadcast

stopBroadcast(String broadcastId)

Stops a live streaming broadcast of an OpenTok session.

void

stopCaptions(String captionsId)

Use this method to stop live captions for a session.

void

stopRender(String renderId)

Stops an Experience Composer of an OpenTok session.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

OpenTok

public OpenTok(int apiKey, String apiSecret)

Creates an OpenTok object.

Parameters: : apiKey - Your OpenTok API key. (See your Vonage Video API account page.) : apiSecret - Your OpenTok API secret. (See your Vonage Video API account page.)

OpenTok

public OpenTok(String applicationId, Path privateKeyPath)

Creates an OpenTok object for use with the Vonage Video API. This is intended as a short-term step towards full migration to Vonage. See the Java SDK transition guide for details.

Parameters: : applicationId - Your Vonage application UUID with video capabilities enabled. : privateKeyPath - Absolute path to the private key for your application.

Since: : 4.15.0

Method Details

generateToken

public String generateToken(String sessionId, TokenOptions tokenOptions) throws OpenTokException

Creates a token for connecting to an OpenTok session. In order to authenticate a user connecting to an OpenTok session, the client passes a token when connecting to the session.

The following example shows how to obtain a token that has a role of "subscriber" and that has a connection metadata string:


 import com.opentok.Role;
 import com.opentok.TokenOptions;

 class Test {
     public static void main(String args[]) throws OpenTokException {
         int API_KEY = 0; // Replace with your OpenTok API key (see https://tokbox.com/account).
         String API_SECRET = ""; // Replace with your OpenTok API secret.
         OpenTok sdk = new OpenTok(API_KEY, API_SECRET);

         //Generate a basic session. Or you could use an existing session ID.
         String sessionId = System.out.println(sdk.createSession());

         // Replace with meaningful metadata for the connection.
         String connectionMetadata = "username=Bob,userLevel=4";

         // Use the Role value appropriate for the user.
         String role = Role.SUBSCRIBER;

         // Generate a token:
         TokenOptions options = new TokenOptions.Buider().role(role).data(connectionMetadata).build();
         String token = sdk.generateToken(sessionId, options);
         System.out.println(token);
     }
 }

For testing, you can also generate tokens by logging in to your Vonage Video API account.

Parameters: : sessionId - The session ID corresponding to the session to which the user will connect. : tokenOptions - This TokenOptions object defines options for the token. These include the following:

- The role of the token (subscriber, publisher, or moderator)
- The expiration time of the token
- Connection data describing the end-user

Returns: : The token string.

Throws: : OpenTokException

generateToken

public String generateToken(String sessionId) throws OpenTokException

Creates a token for connecting to an OpenTok session, using the default settings. The default settings are the following:

  • The token is assigned the role of publisher.
  • The token expires 24 hours after it is created.
  • The token includes no connection data.

The following example shows how to generate a token that has the default settings:


 import com.opentok.OpenTok;

 class Test {
     public static void main(String argv[]) throws OpenTokException {
         int API_KEY = 0; // Replace with your OpenTok API key (see https://tokbox.com/account).
         String API_SECRET = ""; // Replace with your OpenTok API secret.
         OpenTok sdk = new OpenTok(API_KEY, API_SECRET);

         //Generate a basic session. Or you could use an existing session ID.
         String sessionId = System.out.println(sdk.createSession().getSessionId());

         String token = sdk.generateToken(sessionId);
         System.out.println(token);
     }
 }

Parameters: : sessionId - The session ID corresponding to the session to which the user will connect.

Returns: : The token string.

Throws: : OpenTokException

See Also: : - generateToken(String, TokenOptions)

createSession

public Session createSession(SessionProperties properties) throws OpenTokException

Creates a new OpenTok session.

For example, when using the OpenTok.js library, use the session ID when calling the OT.initSession() method (to initialize an OpenTok session).

OpenTok sessions do not expire. However, authentication tokens do expire (see the generateToken(String, TokenOptions) method). Also note that sessions cannot explicitly be destroyed.

A session ID string can be up to 255 characters long.

Calling this method results in an OpenTokException in the event of an error. Check the error message for details.

The following code creates a session that attempts to send streams directly between clients (falling back to use the OpenTok TURN server to relay streams if the clients cannot connect):


 import com.opentok.MediaMode;
 import com.opentok.OpenTok;
 import com.opentok.Session;
 import com.opentok.SessionProperties;

 class Test {
     public static void main(String argv[]) throws OpenTokException {
         int API_KEY = 0; // Replace with your OpenTok API key.
         String API_SECRET = ""; // Replace with your OpenTok API secret.
         OpenTok sdk = new OpenTok(API_KEY, API_SECRET);

         SessionProperties sp = new SessionProperties().Builder()
           .mediaMode(MediaMode.RELAYED).build();

         Session session = sdk.createSession(sp);
         System.out.println(session.getSessionId());
     }
 }

You can also create a session using the OpenTok REST API or or by logging in to your Vonage Video API account.

Parameters: : properties - This SessionProperties object defines options for the session. These include the following:

- Whether the session's streams will be transmitted directly between peers or
  using the OpenTok Media Router.
- A location hint for the location of the OpenTok server to use for the session.

Returns: : A Session object representing the new session. Call the getSessionId() method of the Session object to get the session ID, which uniquely identifies the session. You will use this session ID in the client SDKs to identify the session.

Throws: : OpenTokException

createSession

public Session createSession() throws OpenTokException

Creates an OpenTok session with the default settings:

  • The media mode is "relayed". The session will attempt to transmit streams directly between clients. If two clients cannot send and receive each others' streams, due to firewalls on the clients' networks, their streams will be relayed using the OpenTok TURN Server.
  • The session uses the first client connecting to determine the location of the OpenTok server to use.

The following example creates a session that uses the default settings:


 import com.opentok.OpenTok;
 import com.opentok.SessionProperties;

 class Test {
     public static void main(String argv[]) throws OpenTokException {
         int API_KEY = 0; // Replace with your OpenTok API key.
         String API_SECRET = ""; // Replace with your OpenTok API secret.
         OpenTok sdk = new OpenTok(API_KEY, API_SECRET);

         String sessionId = sdk.createSession();
         System.out.println(sessionId);
     }
 }

Returns: : A Session object representing the new session. Call the getSessionId() method of the Session object to get the session ID, which uniquely identifies the session. You will use this session ID in the client SDKs to identify the session.

Throws: : OpenTokException

See Also: : - createSession(SessionProperties)

signal

public void signal(String sessionId, SignalProperties props) throws OpenTokException

Sends a signal to all clients connected to a session.

For more information, see the Signaling developer guide.

Parameters: : sessionId - The session ID. : props - The SignalProperties object that defines the data and type of the signal.

Throws: : OpenTokException

signal

public void signal(String sessionId, String connectionId, SignalProperties props) throws OpenTokException

Sends a signal to a specific client connected to a session.

For more information, see the Signaling developer guide.

Parameters: : sessionId - The session ID. : connectionId - The connection ID of the client to receive the signal. : props - The SignalProperties object that defines the data and type of the signal.

Throws: : OpenTokException

getArchive

public Archive getArchive(String archiveId) throws OpenTokException

Gets an Archive object for the given archive ID.

Parameters: : archiveId - The archive ID.

Returns: : The Archive object.

Throws: : OpenTokException

listArchives

public ArchiveList listArchives() throws OpenTokException

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key. This list is limited to 1000 archives starting with the first archive recorded. For a specific range of archives, call listArchives(int offset, int count).

Returns: : A List of Archive objects.

Throws: : OpenTokException

listArchives

public ArchiveList listArchives(String sessionId) throws OpenTokException

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

Parameters: : sessionId - The sessionid of the session which started or automatically enabled archiving. If the session is null or empty it will be omitted.

Returns: : A List of Archive objects.

Throws: : OpenTokException

listArchives

public ArchiveList listArchives(int offset, int count) throws OpenTokException

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

Parameters: : offset - The index offset of the first archive. 0 is offset of the most recently started archive. 1 is the offset of the archive that started prior to the most recent archive. : count - The number of archives to be returned. The maximum number of archives returned is 1000.

Returns: : A List of Archive objects.

Throws: : OpenTokException

listArchives

public ArchiveList listArchives(String sessionId, int offset, int count) throws OpenTokException

Returns a List of Archive objects, representing archives that are both both completed and in-progress, for your API key.

Parameters: : offset - The index offset of the first archive. 0 is offset of the most recently started archive. 1 is the offset of the archive that started prior to the most recent archive. : count - The number of archives to be returned. The maximum number of archives returned is 1000. : sessionId - The sessionid of the session which started or automatically enabled archiving.

Returns: : A List of Archive objects.

Throws: : OpenTokException

startArchive

public Archive startArchive(String sessionId, ArchiveProperties properties) throws OpenTokException

Starts archiving an OpenTok session. This version of the startArchive() method lets you disable audio or video recording.

Clients must be actively connected to the OpenTok session for you to successfully start recording an archive.

You can only record one archive at a time for a given session. You can only record archives of sessions that use the OpenTok Media Router (sessions with the media mode set to routed); you cannot archive sessions with the media mode set to relayed.

For more information on archiving, see the OpenTok archiving developer guide.

Parameters: : sessionId - The session ID of the OpenTok session to archive. : properties - This ArchiveProperties object defines options for the archive.

Returns: : The Archive object. This object includes properties defining the archive, including the archive ID.

Throws: : OpenTokException

startArchive

public Archive startArchive(String sessionId) throws OpenTokException

Throws: : OpenTokException

startArchive

public Archive startArchive(String sessionId, String name) throws OpenTokException

Throws: : OpenTokException

stopArchive

public Archive stopArchive(String archiveId) throws OpenTokException

Stops an OpenTok archive that is being recorded.

Archives automatically stop recording after 120 minutes or when all clients have disconnected from the session being archived.

Parameters: : archiveId - The archive ID of the archive you want to stop recording.

Returns: : The Archive object corresponding to the archive being stopped.

Throws: : OpenTokException

deleteArchive

public void deleteArchive(String archiveId) throws OpenTokException

Deletes an OpenTok archive.

You can only delete an archive which has a status of "available" or "uploaded". Deleting an archive removes its record from the list of archives. For an "available" archive, it also removes the archive file, making it unavailable for download.

Parameters: : archiveId - The archive ID of the archive you want to delete.

Throws: : OpenTokException

addArchiveStream

public void addArchiveStream(String archiveId, String streamId, boolean hasAudio, boolean hasVideo) throws OpenTokException

Adds a stream to an OpenTok archive.

This method only works for an archive that has a Archive.StreamMode set to StreamMode.MANUAL.

You can call this method repeatedly with the same stream ID to enable and disable audio or video, based on the hasAudio and hasVideo parameter values.

Parameters: : archiveId - The archive ID. : streamId - The stream ID. : hasAudio - Whether the stream should have audio enabled in the archive. : hasVideo - Whether the stream should have video enabled in the archive.

Throws: : OpenTokException

removeArchiveStream

public void removeArchiveStream(String archiveId, String streamId) throws OpenTokException

Removes a stream from an Opentok archive.

This method only works for an archive that has a Archive.StreamMode set to StreamMode.MANUAL.

Parameters: : archiveId - The archive ID. : streamId - The stream ID.

Throws: : OpenTokException

setArchiveLayout

public void setArchiveLayout(String archiveId, ArchiveProperties properties) throws OpenTokException

Sets the layout type for a composed archive. For a description of layout types, see Customizing the video layout for composed archives.

Parameters: : archiveId - {String} The archive ID. : properties - The ArchiveProperties object defining the archive layout.

Throws: : OpenTokException

startBroadcast

public Broadcast startBroadcast(String sessionId, BroadcastProperties properties) throws OpenTokException

Starts a live streaming broadcast for an OpenTok session. This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.

To successfully start broadcasting a session, at least one client must be connected to the session.

You can only have one active live streaming broadcast at a time for a session (however, having more than one would not be useful). The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simulteneously for a session. You can only start live streaming for sessions that use the OpenTok Media Router (with the media mode set to routed); you cannot use live streaming with sessions that have the media mode set to relayed OpenTok Media Router. See The OpenTok Media Router and media modes.

For more information on broadcasting, see the Broadcast developer guide.

Parameters: : sessionId - The session ID of the OpenTok session to broadcast. : properties - The BroadcastProperties object defines options for the broadcast.

Returns: : The Broadcast object. This object includes properties defining the broadcast, including the broadcast ID.

Throws: : OpenTokException

stopBroadcast

public Broadcast stopBroadcast(String broadcastId) throws OpenTokException

Stops a live streaming broadcast of an OpenTok session. Note that broadcasts automatically stop 120 minutes after they are started.

For more information on broadcasting, see the Broadcast developer guide.

Parameters: : broadcastId - The broadcast ID of the broadcasting session

Returns: : The Broadcast object. This object includes properties defining the archive, including the archive ID.

Throws: : OpenTokException

getBroadcast

public Broadcast getBroadcast(String broadcastId) throws OpenTokException

Gets an Broadcast object for the given broadcast ID.

Parameters: : broadcastId - The broadcast ID.

Returns: : The Broadcast object.

Throws: : OpenTokException

setBroadcastLayout

public void setBroadcastLayout(String broadcastId, BroadcastProperties properties) throws OpenTokException

Sets the layout type for the broadcast. For a description of layout types, see Configuring video layout for OpenTok live streaming broadcasts.

Parameters: : broadcastId - {String} The broadcast ID. : properties - This BroadcastProperties object that defines layout options for the broadcast.

Throws: : OpenTokException

addBroadcastStream

public void addBroadcastStream(String broadcastId, String streamId, boolean hasAudio, boolean hasVideo) throws OpenTokException

Adds a stream to an Opentok broadcast.

This method only works for an archive that has a Archive.StreamMode set to StreamMode.MANUAL.

You can call this method repeatedly with the same stream ID to enable and disable audio or video, based on the hasAudio and hasVideo parameter values.

Parameters: : broadcastId - The broadcast ID. : streamId - The stream ID. : hasAudio - Whether the stream should have audio enabled in the broadcast. : hasVideo - Whether the stream should have video enabled in the broadcast.

Throws: : OpenTokException

removeBroadcastStream

public void removeBroadcastStream(String broadcastId, String streamId) throws OpenTokException

Removes a stream from an Opentok broadcast.

This method only works for an archive that has a Archive.StreamMode set to StreamMode.MANUAL.

Parameters: : broadcastId - The broadcast ID. : streamId - The stream ID.

Throws: : OpenTokException

setStreamLayouts

public void setStreamLayouts(String sessionId, StreamListProperties properties) throws OpenTokException

Sets the layout class list for streams in a session. Layout classes are used in the layout for composed archives and live streaming broadcasts. For more information, see Customizing the video layout for composed archives and Configuring video layout for OpenTok live streaming broadcasts.

You can set the initial layout class list for streams published by a client when you generate used by the client. See the generateToken(String, TokenOptions) method.

Parameters: : sessionId - {String} The session ID of the session the streams belong to. : properties - This StreamListProperties object defines class lists for one or more streams in the session.

Throws: : OpenTokException

forceDisconnect

public void forceDisconnect(String sessionId, String connectionId) throws OpenTokException

Disconnect a client from an OpenTok session

Use this API to forcibly terminate a connection of a session.

Parameters: : sessionId - The session ID of the connection : connectionId - The connection ID to disconnect

Throws: : OpenTokException

forceMuteStream

public void forceMuteStream(String sessionId, String streamId) throws OpenTokException

Force the publisher of a specific stream to mute its audio.

For more information, see Muting the audio of streams in a session.

Parameters: : sessionId - The session ID. : streamId - The stream ID.

Throws: : OpenTokException

See Also: : - forceMuteAll(String, MuteAllProperties)

forceMuteAll

public void forceMuteAll(String sessionId, MuteAllProperties properties) throws OpenTokException

Forces all streams (except for an optional array of streams) in a session to mute published audio.

In addition to existing streams, any streams that are published after the call to this method are published with audio muted. You can remove the mute state of a session by calling the OpenTok.disableForceMute() method.

For more information, see Muting the audio of streams in a session.

Parameters: : sessionId - The session ID. : properties - Defines a list of stream IDs for streams that should be excluded from the mute action.

Throws: : OpenTokException

See Also: : - forceMuteStream(String, String) - disableForceMute(String)

disableForceMute

public void disableForceMute(String sessionId) throws OpenTokException

Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.

After you call the OpenTok.forceMuteAll() method, any streams published after the call are published with audio muted. When you call the OpenTok.disableForceMute() method, future streams published to the session are not muted (but any existing muted streams remain muted).

Parameters: : sessionId - The session ID.

Throws: : OpenTokException

See Also: : - forceMuteAll(String, MuteAllProperties)

getStream

public Stream getStream(String sessionId, String streamId) throws OpenTokException

Gets a Stream object for the given session ID and stream ID.

Parameters: : sessionId - The session ID. : streamId - The stream ID.

Returns: : The Stream object.

Throws: : OpenTokException

listStreams

public StreamList listStreams(String sessionId) throws OpenTokException

Gets a list of Stream objects for the given session ID.

Parameters: : sessionId - The session ID.

Returns: : The list of Stream objects.

Throws: : OpenTokException

dial

public Sip dial(String sessionId, String token, SipProperties properties) throws OpenTokException

Dials a SIP gateway to connect it an OpenTok session.

Parameters: : sessionId - The session ID. : token - OpenTok token to be used for the participant being called. You can add token data to identify that the participant is on a SIP endpoint or for other identifying data, such as phone numbers. (The OpenTok client libraries include properties for inspecting the connection data for a client connected to a session.) See the Token Creation developer guide. : properties - The SipProperties object defining options for the SIP call.

Returns: : The Sip object.

Throws: : OpenTokException

playDTMF

public void playDTMF(String sessionId, String dtmfDigits) throws OpenTokException

Send DTMF digits to all clients in a session.

Parameters: : sessionId - The session ID. : dtmfDigits - The string of DTMF digits to send. This can include 0-9, "*", "#", and "p". A p indicates a pause of 500ms (if you need to add a delay in sending the digits).

Throws: : OpenTokException

playDTMF

public void playDTMF(String sessionId, String connectionId, String dtmfDigits) throws OpenTokException

Send DTMF digits a specific client in a session.

Parameters: : sessionId - The session ID. : connectionId - The session ID of the client to receive the DTMF digits. : dtmfDigits - The string of DTMF digits to send. This can include 0-9, "*", "#", and "p". A p indicates a pause of 500ms (if you need to add a delay in sending the digits).

Throws: : OpenTokException

connectAudioStream

public AudioConnector connectAudioStream(String sessionId, String token, AudioConnectorProperties properties) throws OpenTokException

Send audio from a Vonage Video API session to a WebSocket. For more information, see the Audio Connector developer guide.

Parameters: : sessionId - The session ID. : token - The OpenTok token to be used for the Audio Connector connection to the OpenTok session. You can add token data to identify that the connection is the Audio Connector endpoint or for other identifying data. : properties - The ConnectProperties object defines options used in the request to the Audio Connector API endpoint.

Returns: : The Audio Connect response object from the server.

Throws: : OpenTokException

startRender

public Render startRender(String sessionId, String token, RenderProperties properties) throws OpenTokException

Starts an Experience Composer render for an OpenTok session. For more information, see the Experience Composer developer guide.

Parameters: : sessionId - The session ID. : properties - The RenderProperties object defining the properties for the Render call.

Returns: : The Render response object.

Throws: : OpenTokException

getRender

public Render getRender(String renderId) throws OpenTokException

Gets a Render object, with details on an Experience Composer.

Parameters: : renderId - The ID of the Experience Composer to retrieve.

Returns: : The Render response object associated with the provided ID.

Throws: : OpenTokException

stopRender

public void stopRender(String renderId) throws OpenTokException

Stops an Experience Composer of an OpenTok session. Note that by default Experience Composers automatically stop 2 hours after they are started. You can also set a different maxDuration value when you create the Experience Composer. When the Experience Composer ends, an event is posted to the callback URL, if you have configured one for the project.

Parameters: : renderId - The ID of the Experience Composer to stop.

Throws: : OpenTokException

listRenders

public List<Render> listRenders() throws OpenTokException

Gets a list of Render objects, representing Experience Composers associated with the OpenTok project.

Returns: : The list of Render objects.

Throws: : OpenTokException

listRenders

public List<Render> listRenders(Integer offset, Integer count) throws OpenTokException

Gets a list of Render objects, representing a list of Experience Composers associated with the OpenTok project.

Parameters: : offset - (optional) Start offset in the list of existing Renders. : count - (optional) Number of Renders to retrieve starting at offset. Maximum 1000.

Returns: : The list of Render objects.

Throws: : OpenTokException

startCaptions

public Caption startCaptions(String sessionId, String token, CaptionProperties properties) throws OpenTokException

Use the Live Captions API to transcribe audio streams and generate real-time captions for your application. Live Captions is enabled by default for all projects, and it is a usage-based product. The Live Captions feature is only supported in routed sessions (sessions that use the OpenTok Media Router). You can send up to 50 audio streams from a single Vonage session at a time to the transcription service for captions.

Parameters: : sessionId - The session ID of the OpenTok session. The audio from Publishers publishing into this session will be used to generate the captions. : token - A valid OpenTok token with role set to Moderator. : properties - The CaptionProperties object defining optional properties of the live captioning.

Returns: : A Caption response containing the captions ID for this call.

Throws: : OpenTokException

stopCaptions

public void stopCaptions(String captionsId) throws OpenTokException

Use this method to stop live captions for a session.

Parameters: : captionsId - The unique ID for the audio captioning session, as obtained from Caption.getCaptionsId().

Throws: : OpenTokException

close

public void close()

Call this method when you are done using the OpenTok object, to prevent leaked file descriptors.