{"id":19845436,"url":"https://github.com/opentok/opentok-java-sdk","last_synced_at":"2025-04-05T02:08:55.508Z","repository":{"id":1745722,"uuid":"2571648","full_name":"opentok/Opentok-Java-SDK","owner":"opentok","description":"OpenTok Server SDK for Java","archived":false,"fork":false,"pushed_at":"2025-03-14T06:31:41.000Z","size":2800,"stargazers_count":27,"open_issues_count":5,"forks_count":64,"subscribers_count":67,"default_branch":"main","last_synced_at":"2025-03-29T01:09:49.256Z","etag":null,"topics":["java","opentok","opentok-archiving","opentok-java-sdk","tokbox","video-api"],"latest_commit_sha":null,"homepage":"https://tokbox.com/developer","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-10-13T19:02:03.000Z","updated_at":"2025-01-06T10:48:36.000Z","dependencies_parsed_at":"2023-07-05T18:01:39.925Z","dependency_job_id":"0c2edc5f-d88c-48aa-98f3-14160d1cd66e","html_url":"https://github.com/opentok/Opentok-Java-SDK","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentok%2FOpentok-Java-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentok%2FOpentok-Java-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentok%2FOpentok-Java-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentok%2FOpentok-Java-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentok","download_url":"https://codeload.github.com/opentok/Opentok-Java-SDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","opentok","opentok-archiving","opentok-java-sdk","tokbox","video-api"],"created_at":"2024-11-12T13:07:51.326Z","updated_at":"2025-04-05T02:08:55.501Z","avatar_url":"https://github.com/opentok.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenTok Java SDK\n\n![Java](https://img.shields.io/badge/java-8%2B-blue)\n[![Maven Release](https://maven-badges.herokuapp.com/maven-central/com.tokbox/opentok-server-sdk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.tokbox/opentok-server-sdk)\n[![Build Status](https://github.com/opentok/Opentok-Java-SDK/actions/workflows/build.yml/badge.svg)](https://github.com/opentok/Opentok-Java-SDK/actions/workflows/build.yml\")\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE.txt)\n\n\u003cimg src=\"https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg\" height=\"48px\" alt=\"Tokbox is now known as Vonage\" /\u003e\n\nThe OpenTok Java SDK provides methods for:\n\n* Generating [sessions](https://tokbox.com/developer/guides/create-session/) and\n  [tokens](https://tokbox.com/developer/guides/create-token/) for\n  [OpenTok](https://www.vonage.com/communications-apis/video/) applications\n* Working with OpenTok [archives](https://tokbox.com/developer/guides/archiving)\n* Working with OpenTok [live streaming broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/)\n* Working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip)\n* [Sending signals to clients connected to a session](https://tokbox.com/developer/guides/signaling/)\n* [Disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/)\n* [Forcing clients in a session to disconnect or mute published audio](https://tokbox.com/developer/guides/moderation/)\n* Working with [Experience Composers](https://tokbox.com/developer/guides/experience-composer)\n* Working with [Audio Connectors](/https://tokbox.com/developer/guides/audio-connector)\n\n## Note!\n\nThis library is designed to work with the Tokbox/OpenTok platform, part of the Vonage Video API. If you are looking to use the Vonage Video API and using the Vonage Customer Dashboard, you will want to install the [Vonage Server SDK for Java](https://github.com/Vonage/vonage-java-sdk), which includes support for the Vonage Video API.\n\nNot sure which exact platform you are using? Take a look at [this guide](https://api.support.vonage.com/hc/en-us/articles/10817774782492).\n\nIf you are using the Tokbox platform, do not worry! The Tokbox platform is not going away, and this library will continue to be updated. While we encourage customers to check out the new Unified platform, there is no rush to switch. Both platforms run the exact same infrastructure and capabilities, with the main difference is a unified billing interface and easier access to [Vonage’s other CPaaS APIs](https://www.vonage.com/communications-apis/).\n\nIf you are new to the Vonage Video API, head on over to the [Vonage Customer Dashboard](https://dashboard.vonage.com) to sign up for a developer account and check out the [Vonage Server SDK for Java](https://github.com/Vonage/vonage-java-sdk).\n\n\n## Installation\n\n### Maven Central (recommended):\n\nThe [Maven Central](http://central.sonatype.org/) repository helps manage dependencies for JVM\nbased projects. It can be used via several build tools, including Maven and Gradle.\n\n#### Maven\n\nWhen you use Maven as your build tool, you can manage dependencies in the `pom.xml` file:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.tokbox\u003c/groupId\u003e\n    \u003cartifactId\u003eopentok-server-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e4.16.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle\n\nWhen you use Gradle as your build tool, you can manage dependencies in the `build.gradle` file:\n\n```groovy\ndependencies {\n  compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.16.0'\n}\n```\n\n### Manually:\n\nDownload the jar file for the latest release from the\n[Releases](https://github.com/opentok/opentok-java-sdk/releases) page. Include it in the classpath\nfor your own project by\n[using the JDK directly](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html)\nor in your IDE of choice.\n\n## Usage\n\n### Initializing\n\nImport the required classes in any class where it will be used. Then initialize a `com.opentok.OpenTok`\nobject with your own API Key and API Secret.\n\n```java\nimport com.opentok.OpenTok;\n\n// inside a class or method...\nint apiKey = 000000; // YOUR API KEY\nString apiSecret = \"YOUR API SECRET\";\nOpenTok opentok = new OpenTok(apiKey, apiSecret)\n```\n\n#### Advanced configuration options\n\nYou can use `OpenTok.Builder` to set advanced options. This class\nincludes the following methods:\n\n- `.requestTimeout(int)` -- Call this to specify the timeout for HTTP requests\n  (in seconds). The default timeout is 60 seconds.\n\n- `.proxy(Proxy)` -- Using a `java.net.Proxy` object, you can configure a proxy server\n  that the HTTP client will use when call the OpenTok REST API.\n\nCall the `OpenTok.Builder()` constructor, passing in your API key and secret,\nto instantiate an `OpenTok.Builder` object. Then call the `requestTimeout()`\nor `proxy()` methods (or both). Then call the `build()` method to return an\nOpenTok object. \n\nFor example, the following code instantiates an OpenTok object, with the\ndefault timeout set to 10 seconds:\n\n```java\nint apiKey = 12345; // YOUR API KEY\nString apiSecret = \"YOUR API SECRET\";\nint timeout = 10;\n\nOpenTok opentok = new OpenTok.Builder(apiKey, apiSecret)\n  .requestTimeout(timeout)\n  .build();\n```\n\n#### The close() method\n\nMake sure you call the `OpenTok.close()` method when you are done,\nto prevent leaked file descriptors:\n\n```java\nopentok.close();\n```\n\n### Creating Sessions\n\nTo create an OpenTok Session, use the `OpenTok` instance’s `createSession(SessionProperties properties)`\nmethod. The `properties` parameter is optional and it is used to specify two things:\n\n- Whether the session uses the OpenTok Media Router\n- A location hint for the OpenTok server.\n- Whether the session is automatically archived.\n\nAn instance can be initialized using the `com.opentok.SessionProperties.Builder` class.\nThe `sessionId` property of the returned `com.opentok.Session` instance, which you can read using\nthe `getSessionId()` method, is useful to get an identifier that can be saved to a persistent store\n(such as a database).\n\n```java\nimport com.opentok.MediaMode;\nimport com.opentok.ArchiveMode;\nimport com.opentok.Session;\nimport com.opentok.SessionProperties;\n\n// A session that attempts to stream media directly between clients:\nSession session = opentok.createSession();\n\n// A session that uses the OpenTok Media Router:\nSession session = opentok.createSession(new SessionProperties.Builder()\n  .mediaMode(MediaMode.ROUTED)\n  .build());\n\n// A Session with a location hint:\nSession session = opentok.createSession(new SessionProperties.Builder()\n  .location(\"12.34.56.78\")\n  .build());\n\n// A session that is automatically archived (it must used the routed media mode)\nSession session = opentok.createSession(new SessionProperties.Builder()\n  .mediaMode(MediaMode.ROUTED)\n  .archiveMode(ArchiveMode.ALWAYS)\n  .build());\n\n// Store this sessionId in the database for later use:\nString sessionId = session.getSessionId();\n```\n\n### Generating Tokens\n\nOnce a Session is created, you can start generating Tokens for clients to use when connecting to it.\nYou can generate a token either by calling an `com.opentok.OpenTok` instance's\n`generateToken(String sessionId, TokenOptions options)` method, or by calling a `com.opentok.Session`\ninstance's `generateToken(TokenOptions options)` method after creating it. The `options` parameter\nis optional and it is used to set the role, expire time, and connection data of the token. An\ninstance can be initialized using the `TokenOptions.Builder` class.\n\n```java\nimport com.opentok.TokenOptions;\nimport com.opentok.Role;\n\n// Generate a token from just a sessionId (fetched from a database)\nString token = opentok.generateToken(sessionId);\n// Generate a token by calling the method on the Session (returned from createSession)\nString token = session.generateToken();\n\n// Set some options in a token\nString token = session.generateToken(new TokenOptions.Builder()\n  .role(Role.MODERATOR)\n  .expireTime((System.currentTimeMillis() / 1000L) + (7 * 24 * 60 * 60)) // in one week\n  .data(\"name=Johnny\")\n  .build());\n```\n\n### Working with Archives\n\nYou can only archive sessions that use the OpenTok Media Router\n(sessions with the media mode set to routed).\n\nYou can start the recording of an OpenTok Session using a `com.opentok.OpenTok` instance's\n`startArchive(String sessionId, String name)` method. This will return a `com.opentok.Archive` instance.\nThe parameter `name` is optional and used to assign a name for the Archive. Note that you can\nonly start an Archive on a Session that has clients connected.\n\n```java\nimport com.opentok.Archive;\n\n// A simple Archive (without a name)\nArchive archive = opentok.startArchive(sessionId, null);\n\n// Store this archiveId in the database for later use\nString archiveId = archive.getId();\n```\n\nYou can also disable audio or video recording by calling the `hasAudio(false)` or `hasVideo(false)`\nmethods of an `ArchiveProperties` builder, and passing the built object into the\n`OpenTok.startArchive(String sessionId, ArchiveProperties properties)` method:\n\n```java\nimport com.opentok.Archive;\nimport com.opentok.ArchiveProperties;\n\n// Start an audio-only archive\nArchive archive = opentok.startArchive(sessionId, new ArchiveProperties.Builder()\n  .hasVideo(false)\n  .build());\n\n// Store this archiveId in the database for later use\nString archiveId = archive.getId();\n```\n\nSetting the output mode to `Archive.OutputMode.INDIVIDUAL` setting causes each stream in the archive\nto be recorded to its own individual file:\n\n```java\nimport com.opentok.Archive;\nimport com.opentok.ArchiveProperties;\n\nArchive archive = opentok.startArchive(sessionId, new ArchiveProperties.Builder()\n  .outputMode(Archive.OutputMode.INDIVIDUAL)\n  .build());\n\n// Store this archiveId in the database for later use\nString archiveId = archive.getId();\n```\n\nThe `Archive.OutputMode.COMPOSED` option is the default value for `outputMode`. It archives all streams to be recorded to a single (composed) file.\n\nYou can only specify the `resolution` for composed archives using the `ArchiveProperties` builder. If you set the `resolution` property and also set the `outputMode` property to `Archive.OutputMode.INDIVIDUAL`, the method will throw an `InvalidArgumentException`.\n\nThe accepted values for `resolution` are:\n\n- `\"640x480\"` (SD, the default)\n- `\"1280x720\"` (HD)\n  \u003e Please note that setting any other value for the `resolution` property will result in an exception.\n\n```java\nimport com.opentok.ArchiveProperties;\n\nArchiveProperties properties = new ArchiveProperties.Builder().resolution(\"1280x720\").build();\n```\n\nYou can stop the recording of a started Archive using a `com.opentok.Archive` instance's\n`stopArchive(String archiveId)` method.\n\n```java\n// Stop an Archive from an archiveId (fetched from database)\nArchive archive = opentok.stopArchive(archiveId);\n```\n\nTo get an `com.opentok.Archive` instance (and all the information about it) from an `archiveId`, use\na `com.opentok.OpenTok` instance's `getArchive(String archiveId)` method.\n\n```java\nArchive archive = opentok.getArchive(String archiveId);\n```\n\nTo delete an Archive, you can call a `com.opentok.OpenTok` instance's `deleteArchive(String archiveId)`\nmethod.\n\n```java\n// Delete an Archive from an archiveId (fetched from database)\nopentok.deleteArchive(archiveId);\n```\n\nYou can also get a list of all the Archives you've created (up to 1000) with your API Key. This is\ndone using a `com.opentok.OpenTok` instance's `listArchives(int offset, int count)` method. You may optionally\npaginate the Archives you receive using the offset and count parameters. This will return a\n`List\u003cArchive\u003e` type. An `InvalidArgumentException` will be thrown if the offset or count are\nnegative or if the count is greater than 1000.\n\n```java\n// Get a list with the first 1000 archives created by the API Key\nList\u003cArchive\u003e archives = opentok.listArchives();\n\n// Get a list of the first 50 archives created by the API Key\nList\u003cArchive\u003e archives = opentok.listArchives(0, 50);\n\n// Get a list of the next 50 archives\nList\u003cArchive\u003e archives = opentok.listArchives(50, 50);\n```\n\nYou can also fetch the list of archives for a specific session ID , and optionally\nuse the offset and count parameters as described above.\n\n```java\n// Get a list with the first 1000 archives for a specific session)\nArchiveList archives = opentok.listArchives(sessionId);\n\n// Get a list of the first 50 archives  for a specific session\nArchiveList archives = sdk.listArchives(sessionId, 0, 50);\n\n// Get a list of the next 50 archives for a specific session\nArchiveList archives = sdk.listArchives(sessionId, 50, 50);\n```\n\nNote that you can also create an automatically archived session, by passing `ArchiveMode.ALWAYS`\ninto the `archiveMode()` method of the `SessionProperties.Builder` object you use to build the\n`sessionProperties` parameter passed into the `OpenTok.createSession()` method (see \"Creating\nSessions,\" above).\n\nFor composed archives, you can dynamically set the archive layout (while the archive is being recorded) using the `OpenTok.setArchiveLayout(String archiveId, ArchiveProperties properties)`\nmethod. See [Customizing the video layout for composed\narchives](https://tokbox.com/developer/guides/archiving/layout-control.html) for more information. Use the `ArchiveProperties` builder as follows:\n\n```java\nArchiveProperties properties = new ArchiveProperties.Builder()\n    .layout(new ArchiveLayout(ArchiveLayout.Type.VERTICAL))\n    .build();\nopentok.setArchiveLayout(archiveId, properties);\n```\n\nFor custom layouts the builder looks like:\n\n```java\nArchiveProperties properties = new ArchiveProperties.Builder()\n.layout(new ArchiveLayout(ArchiveLayout.Type.CUSTOM, \"stream { position: absolute; }\"))\n.build();\n```\n\nYou can set the initial layout class for a client's streams by setting the `layout`\noption when you create the token for the client, using the\n`OpenTok.generateToken(String sessionId, TokenOptions options)` method. And you can\nalso change the layout classes of a stream as follows:\n\n```java\nStreamProperties streamProps = new StreamProperties.Builder()\n  .id(streamId)\n  .addLayoutClass(\"full\")\n  .addLayoutClass(\"focus\")\n  .build();\nStreamListProperties properties = new StreamListProperties.Builder()\n  .addStreamProperties(streamProps)\n  .build();\nopentok.setStreamLayouts(sessionId, properties);\n```\n\nIf you want to change the layout of multiple streams, create a StreamProperties object\nfor each stream, and add them to the StreamListProperties object as follows:\n\n```java\nStreamListProperties properties = new StreamListProperties.Builder()\n  .addStreamProperties(streamProps1)\n  .addStreamProperties(streamProps2)\n  .build();\nopentok.setStreamLayouts(sessionId, properties);\n```\n\nFor more information on archiving, see the\n[OpenTok archiving](https://tokbox.com/developer/guides/archiving/) developer guide.\n\n### Disconnecting Clients\n\nYour application server can disconnect a client from an OpenTok session by calling the `forceDisconnect(sessionId, connectionId)`\nmethod of the `com.opentok.OpenTok` instance.\n\n```java\nopentok.forceDisconnect(sessionId, connectionId);\n```\n\nThe `connectionId` parameter is used to specify the connection ID of a client connection to the session.\n\nFor more information on the force disconnect functionality and exception codes, please see the [REST API documentation](https://tokbox.com/developer/rest/#forceDisconnect).\n\n### Forcing clients in a session to mute published audio\n\nYou can force the publisher of a specific stream to stop publishing audio using the \n`Opentok.forceMuteStream(String sessionId, String streamId)`method.\n\nYou can force the publisher of all streams in a session (except for an optional list of streams)\nto stop publishing audio using the `Opentok.forceMuteAll(String sessionId, MuteAllProperties properties)`\nmethod. You can then disable the mute state of the session by calling the\n`Opentok.disableForceMute(String sessionId)` method.\n\nFor more information, see\n[Muting the audio of streams in a session](https://tokbox.com/developer/guides/moderation/#force_mute).\n\n### Signaling\n\nYou can send signals to all the connections in a session or to a specific connection:\n\n- `public void signal(String sessionId, SignalProperties props) throws OpenTokException , RequestException, InvalidArgumentException`\n\n- `public void signal(String sessionId, String connectionId, SignalProperties props) throws OpenTokException , RequestException , InvalidArgumentException`\n\nThe `SignalProperties` builder helps you to construct the signal data and type:\n\n```java\nSignalProperties properties = new SignalProperties.Builder()\n  .type(\"test\")\n  .data(\"This is a test string\")\n  .build();\n\nopentok.signal(sessionId, properties);\nopentok.signal(sessionId, connectionId, properties);\n```\n\nMake sure that the `type` string does not exceed the maximum length (128 bytes)\nand the `data` string does not exceed the maximum length (8 kB).\nThe `SignalProperties` builder does not currently check for these limitations.\n\nFor more information on signaling and exception codes, refer to the documentation for the\n[OpenTok signaling](https://tokbox.com/developer/rest/#send_signal) REST method.\n\n### Broadcasting\n\nYou can broadcast OpenTok publishing streams to an HLS (HTTP live streaming) or\nto RTMP streams. To successfully start broadcasting a session, at least one client must be\nconnected to the session.\nThe live streaming broadcast can target one HLS endpoint and up to five\nRTMP servers simultaneously for a session. You can only start live streaming\nfor sessions that use the OpenTok Media Router (with the media mode set to routed);\nyou cannot use live streaming with sessions that have the media mode set to relayed.\n(See the [OpenTok Media Router and media\nmodes](https://tokbox.com/developer/guides/create-session/#media-mode) developer guide).\n\nYou can start a broadcast using the `OpenTok.startBroadcast(sessionId, properties)` method,\nwhere the `properties` field is a `BroadcastProperties` object. Initalize a `BroadcastProperties`\nobject as follows (see the [Opentok Broadcast](https://tokbox.com/developer/rest/#start_broadcast)\nREST method for more details):\n\n```java\nBroadcastProperties properties = new BroadcastProperties.Builder()\n        .hasHls(true)\n        .addRtmpProperties(rtmpProps)\n        .addRtmpProperties(rtmpNextProps)\n        .maxDuration(1000)\n        .resolution(\"640x480\")\n        .layout(layout)\n        .build();\n\n// The Rtmp properties can be build using RtmpProperties as shown below\nRtmpProperties rtmpProps = new RtmpProperties.Builder()\n        .id(\"foo\")\n        .serverUrl(\"rtmp://myfooserver/myfooapp\")\n        .streamName(\"myfoostream\").build();\n\n//The layout object is initialized as follows:\nBroadcastLayout layout = new BroadcastLayout(BroadcastLayout.Type.PIP);\n```\n\nFinally, start a broadcast as shown below:\n\n```java\nBroadcast broadcast = opentok.startBroadcast(sessionId, properties)\n```\n\nThe `Broadcast` object returned has the following info:\n\n```java\nString broadcastId;\nString sessionId;\nint projectId;\nlong createdAt;\nlong updatedAt;\nString resolution;\nString status;\nList\u003cRtmp\u003e rtmpList = new ArrayList\u003c\u003e();  //not more than 5\nString hls;    // HLS url\n\n// The Rtmp class mimics the RtmpProperties\n```\n\nTo stop a broadcast use:\n\n```java\nBroadcast broadcast = opentok.stopBroadcast(broadcastId);\n```\n\nTo get more information about a live streaming broadcast, use:\n\n```java\nBroadcast broadcast = opentok.getBroadcast(broadcastId);\n```\n\nThe information returned is in the `Broadcast` object and consists of HLS and/or Rtmp URLs,\nalong with the session ID, resolution, etc.\n\nYou can also change the\n[layout](https://tokbox.com/developer/guides/broadcast/live-streaming/#configuring-video-layout-for-opentok-live-streaming-broadcasts)\nof a live broadcast dynamically using:\n\n```java\nopentok.setBroadcastLayout(broadcastId, properties);\n\n//properties can be\nBroadcastProperties properties = new BroadcastProperties.Builder()\n          .layout(new BroadcastLayout(BroadcastLayout.Type.VERTICAL))\n          .build();\n```\n\nTo dynamically change the layout class of an individual stream, use\n\n```java\nStreamProperties streamProps = new StreamProperties.Builder()\n          .id(streamId)\n          .addLayoutClass(\"full\")\n          .addLayoutClass(\"focus\")\n          .build();\nStreamListProperties properties = new StreamListProperties.Builder()\n          .addStreamProperties(streamProps)\n          .build();\nopentok.setStreamLayouts(sessionId, properties);\n```\n\n### Working with Streams\n\nYou can get information about a stream by calling the `getStream(sessionId, streamId)` method\nof the `com.opentok.OpenTok` instance.\n\n```java\n// Get stream info from just a sessionId (fetched from a database)\nStream stream = opentok.getStream(sessionId, streamId);\n\n// Stream Properties\nstream.getId(); // string with the stream ID\nstream.getVideoType(); // string with the video type\nstream.getName(); // string with the name\nstream.layoutClassList(); // List with the layout class list\n```\n\nYou can get information about all of the streams in a session by calling the `listStreams(sessionId)` method of the `com.opentok.OpenTok` instance.\n\n```java\n\n// Get list of strems from just a sessionId (fetched from a database)\nStreamList streamList = opentok.listStreams(sessionId);\n\nstreamList.getTotalCount(); // total count\n```\n\n### Working with SIP Interconnect\n\nYou can add an audio-only stream from an external third party SIP gateway using the SIP\nInterconnect feature. This requires a SIP URI, the session ID you wish to add the audio-only\nstream to, and a token to connect to that session ID.\n\nTo connect your SIP platform to an OpenTok session, call the\n`OpenTok.dial(String sessionId, String token, SipProperties properties)` method.\nThe audio from your end of the SIP call is added to the OpenTok session as an audio-only stream.\nThe OpenTok Media Router mixes audio from other streams in the session and sends the mixed audio\nto your SIP endpoint. The call ends when your SIP server sends a BYE message (to terminate\nthe call). You can also end a call using the `OpenTok.forceDisconnect(sessionId, connectionId)`\nmethod to disconnect the SIP client from the session (see [Disconnecting clients](#disconnecting-clients)).\n\nThe OpenTok SIP gateway automatically ends a call after 5 minutes of inactivity\n(5 minutes without media received). Also, as a security measure,\nthe OpenTok SIP gateway closes any SIP call that lasts longer than 6 hours.\n\nThe SIP interconnect feature requires that you use an OpenTok session that uses the\nOpenTok Media Router (a session with the media mode set to routed).\n\nTo connect an OpenTok session to a SIP gateway:\n\n```java\nSipProperties properties = new SipProperties.Builder()\n         .sipUri(\"sip:user@sip.partner.com;transport=tls\")\n         .from(\"from@example.com\")\n         .headersJsonStartingWithXDash(headerJson)\n         .userName(\"username\")\n         .password(\"password\")\n         .secure(true)\n         .build();\n\n Sip sip = opentok.dial(sessionId, token, properties);\n```\n\n### Working with Experience Composers\n\nYou can start an [Experience Composer](https://tokbox.com/developer/guides/experience-composer)\nby calling the `OpenTok.startRender(String sessionId, String token, RenderProperties properties)`\nmethod:\n\n```java\nRenderProperties properties = new RenderProperties.Builder()\n         .url(\"http://example.com/path-to-page/\")\n         .build();\n\nRender render = opentok.startRender(sessionId, token, properties);\n```\n\nYou can stop an Experience Composer by calling the `OpenTok.stopRender(String renderId)` method.\n\nYou can get information about Experience Composers by calling the `OpenTok.getRender(String renderId)`,\n`OpenTok.listRenders()` or `OpenTok.listRenders(Integer offset, Integer count)` methods.\n\n### Working with Audio Connector\n\nYou can start an [Audio Connector stream](https://tokbox.com/developer/guides/audio-connector)\nby calling the `OpenTok.connectAudioStream(String sessionId, String token, AudioConnectorProperties properties)`\nmethod:\n\n```java\nAudioConnectorProperties properties = new AudioConnectorProperties.Builder(\"wss://service.com/ws-endpoint\")\n        .addStreams(\"streamId-1\", \"streamId-2\")\n        .addHeader(\"X-CustomHeader-Key\", \"headerValue\")\n        .build();\n\nAudioConnector ac = opentok.connectAudioStream(sessionId, token, properties);\n```\n\n\n## Samples\n\nThere are two sample applications included with the SDK. To get going as fast as possible, clone the whole\nrepository and follow the Walkthroughs:\n\n- [HelloWorld](sample/HelloWorld/README.md)\n- [Archiving](sample/Archiving/README.md)\n\n## Documentation\n\nReference documentation is available at\n\u003chttps://tokbox.com/developer/sdks/java/reference/index.html\u003e.\n\n## Requirements\n\nYou need an OpenTok API key and API secret, which you can obtain by logging into your\n[Vonage Video API account](https://tokbox.com/account).\n\nThe OpenTok Java SDK requires JDK 8 or greater to compile. Runtime requires Java SE 8 or greater.\nThis project is tested on both OpenJDK and Oracle implementations.\n\nFor Java 7 please use OpenTok Java SDK v3.\n\n## Release Notes\n\nSee the [Releases](https://github.com/opentok/opentok-java-sdk/releases) page for details\nabout each release.\n\n## Important changes since v2.2.0\n\n**Changes in v2.2.1:**\n\nThe default setting for the `createSession()` method is to create a session with the media mode set\nto relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router\n(with the media mode set to routed in v2.2.0, or with p2p.preference=\"disabled\" in previous\nversions). In a relayed session, clients will attempt to send streams directly between each other\n(peer to peer); and if clients cannot connect due to firewall restrictions, the session uses the\nOpenTok TURN server to relay audio-video streams.\n\n**Changes in v2.2.0:**\n\nThis version of the SDK includes support for working with OpenTok archives.\n\nThis version of the SDK includes a number of improvements in the API design. These include a number\nof API changes. See the OpenTok 2.2 SDK Reference for details on the new API.\n\nThe API_Config class has been removed. Store your OpenTok API key and API secret in code outside of the SDK files.\n\nThe `create_session()` method has been renamed `createSession()`. Also, the method has changed to\ntake one parameter: a SessionProperties object. You now generate a SessionProperties object using a Builder pattern.\n\nThe `generate_token()` method has been renamed `generateToken()`. Also, the method has changed to\ntake two parameters: the session ID and a TokenOptions object.\n\n## Development and Contributing\n\nInterested in contributing? We :heart: pull requests! See the [Development](DEVELOPING.md) and\n[Contribution](CONTRIBUTING.md) guidelines.\n\n## Getting Help\n\nWe love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:\n\n- Open an issue on this repository\n- See \u003chttps://support.tokbox.com/\u003e for support options\n- Tweet at us! We're [@VonageDev on Twitter](https://twitter.com/VonageDev)\n- Or [join the Vonage Developer Community Slack](https://developer.nexmo.com/community/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentok%2Fopentok-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentok%2Fopentok-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentok%2Fopentok-java-sdk/lists"}