1
1
# OpenTok Java SDK
2
2
3
- ** TODO** : change this to opentok fork instead of aoberoi
4
-
5
- [ ![ Build Status] ( https://travis-ci.org/aoberoi/Opentok-Java-SDK.svg?branch=modernization )] ( https://travis-ci.org/aoberoi/Opentok-Java-SDK )
3
+ [ ![ Build Status] ( https://travis-ci.org/opentok/Opentok-Java-SDK.svg )] ( https://travis-ci.org/opentok/Opentok-Java-SDK )
6
4
7
5
The OpenTok Java SDK lets you generate
8
6
[ sessions] ( http://tokbox.com/opentok/tutorials/create-session/ ) and
9
7
[ tokens] ( http://tokbox.com/opentok/tutorials/create-token/ ) for [ OpenTok] ( http://www.tokbox.com/ )
10
- applications that run on the JVM. This version of the SDK also includes support for working with OpenTok
11
- 2.0 archives.
8
+ applications that run on the JVM. This version of the SDK also includes support for working
9
+ with [ OpenTok 2.0 archives] ( http://tokbox.com/#archiving ) .
10
+
11
+ If you are updating from a previous version of this SDK, see
12
+ [ Important changes since v2.2.0] ( #important-changes-since-v220 ) .
13
+
12
14
13
15
# Installation
14
16
@@ -23,9 +25,9 @@ When you use Maven as your build tool, you can manage dependencies in the `pom.x
23
25
24
26
``` xml
25
27
<dependency >
26
- <groupId >com.opentok </groupId >
28
+ <groupId >com.tokbox </groupId >
27
29
<artifactId >opentok-server-sdk</artifactId >
28
- <version >2.2.0 </version >
30
+ <version >2.2.2 </version >
29
31
</dependency >
30
32
```
31
33
@@ -35,13 +37,17 @@ When you use Gradle as your build tool, you can manage dependencies in the `buil
35
37
36
38
``` groovy
37
39
dependencies {
38
- compile group: 'com.opentok ', name: 'opentok-server-sdk', version: '2.2.0 '
40
+ compile group: 'com.tokbox ', name: 'opentok-server-sdk', version: '2.2.2 '
39
41
}
40
42
```
41
43
42
44
## Manually:
43
45
44
- ** TODO** : download from releases page?
46
+ Download the jar file for the latest release from the
47
+ [ Releases] ( https://github.com/opentok/opentok-java-sdk/releases ) page. Include it in the classpath
48
+ for your own project by
49
+ [ using the JDK directly] ( http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html )
50
+ or in your IDE of choice.
45
51
46
52
# Usage
47
53
@@ -62,28 +68,35 @@ OpenTok opentok = new OpenTok(apiKey, apiSecret)
62
68
## Creating Sessions
63
69
64
70
To create an OpenTok Session, use the ` OpenTok ` instance's ` createSession(SessionProperties properties) `
65
- method. The ` properties ` parameter is optional and it is used to specify whether you are creating a
66
- p2p Session and specifying a location hint. An instance can be initialized using the
67
- ` com.opentok.SessionProperties.Builder ` class. The ` sessionId ` property of the returned ` com.opentok.Session `
68
- instance, which you can read using the ` getSessionId() ` method, is useful to get a sessionId that can
69
- be saved to a persistent store (e.g. database).
71
+ method. The ` properties ` parameter is optional and it is used to specify two things:
72
+
73
+ * Whether the session uses the OpenTok Media Router
74
+ * A location hint for the OpenTok server.
75
+
76
+ An instance can be initialized using the ` com.opentok.SessionProperties.Builder ` class.
77
+ The ` sessionId ` property of the returned ` com.opentok.Session ` instance, which you can read using
78
+ the ` getSessionId() ` method, is useful to get an identifier that can be saved to a persistent store
79
+ (such as a database).
70
80
71
81
``` java
82
+ import com.opentok.MediaMode ;
72
83
import com.opentok.Session ;
73
84
import com.opentok.SessionProperties ;
74
85
75
- // Just a plain Session
86
+ // A session that attempts to stream media directly between clients:
76
87
Session session = opentok. createSession();
77
- // A p2p Session
88
+
89
+ // A session that uses the OpenTok Media Router:
78
90
Session session = opentok. createSession(new SessionProperties .Builder ()
79
- .p2p( true )
91
+ .mediaMode( MediaMode . ROUTED )
80
92
.build());
81
- // A Session with a location hint
93
+
94
+ // A Session with a location hint:
82
95
Session session = opentok. createSession(new SessionProperties .Builder ()
83
96
.location(" 12.34.56.78" )
84
97
.build());
85
98
86
- // Store this sessionId in the database for later use
99
+ // Store this sessionId in the database for later use:
87
100
String sessionId = session. getSessionId();
88
101
```
89
102
@@ -98,7 +111,7 @@ instance can be initialized using the `TokenOptions.Builder` class.
98
111
99
112
``` java
100
113
import com.opentok.TokenOptions ;
101
- import com.opentok.Roles ;
114
+ import com.opentok.Role ;
102
115
103
116
// Generate a token from just a sessionId (fetched from a database)
104
117
String token = opentok. generateToken(sessionId);
@@ -107,7 +120,7 @@ String token = session.generateToken();
107
120
108
121
// Set some options in a token
109
122
String token = session. generateToken(new TokenOptions .Builder ()
110
- .role(Roles . MODERATOR )
123
+ .role(Role . MODERATOR )
111
124
.expireTime((System . currentTimeMillis() / 1000L ) + (7 * 24 * 60 * 60 )) // in one week
112
125
.data(" name=Johnny" )
113
126
.build());
@@ -169,9 +182,18 @@ List<Archive> archives = opentok.listArchives(0, 50);
169
182
List<Archive > archives = opentok. listArchives(50 , 50 );
170
183
```
171
184
185
+ # Samples
186
+
187
+ There are two sample applications included with the SDK. To get going as fast as possible, clone the whole
188
+ repository and follow the Walkthroughs:
189
+
190
+ * [ HelloWorld] ( sample/HelloWorld/README.md )
191
+ * [ Archiving] ( sample/Archiving/README.md )
192
+
172
193
# Documentation
173
194
174
- ** TODO** : Reference documentation is available at < http://opentok.github.io/opentok-java-sdk/ >
195
+ Reference documentation is available at < http://www.tokbox.com/opentok/libraries/server/java/reference/index.html > and in the
196
+ docs directory of the SDK.
175
197
176
198
# Requirements
177
199
@@ -180,26 +202,47 @@ You need an OpenTok API key and API secret, which you can obtain at <https://das
180
202
The OpenTok Java SDK requires JDK 6 or greater to compile. Runtime requires Java SE 6 or greater.
181
203
This project is tested on both OpenJDK and Oracle implementations.
182
204
205
+
183
206
# Release Notes
184
207
185
- ** TODO ** : See the [ Releases] ( https://github.com/opentok/opentok-java-sdk/releases ) page for details
208
+ See the [ Releases] ( https://github.com/opentok/opentok-java-sdk/releases ) page for details
186
209
about each release.
187
210
188
- ## Important changes in v2.0
211
+ # Important changes since v2.2.0
212
+
213
+ ** Changes in v2.2.1:**
214
+
215
+ The default setting for the ` createSession() ` method is to create a session with the media mode set
216
+ to relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router
217
+ (with the media mode set to routed in v2.2.0, or with p2p.preference="disabled" in previous
218
+ versions). In a relayed session, clients will attempt to send streams directly between each other
219
+ (peer to peer); and if clients cannot connect due to firewall restrictions, the session uses the
220
+ OpenTok TURN server to relay audio-video streams.
221
+
222
+ ** Changes in v2.2.0:**
189
223
190
224
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
191
225
work with OpenTok 1.0 archives.)
192
226
227
+ This version of the SDK includes a number of improvements in the API design. These include a number
228
+ of API changes. See the OpenTok 2.2 SDK Reference for details on the new API.
229
+
230
+ The API_Config class has been removed. Store your OpenTok API key and API secret in code outside of the SDK files.
231
+
232
+ The ` create_session() ` method has been renamed ` createSession() ` . Also, the method has changed to
233
+ take one parameter: a SessionProperties object. You now generate a SessionProperties object using a Builder pattern.
234
+
235
+ The ` generate_token() ` method has been renamed ` generateToken() ` . Also, the method has changed to
236
+ take two parameters: the session ID and a TokenOptions object.
237
+
193
238
# Development and Contributing
194
239
195
- Interested in contributing? We <3 pull requests! File a new
196
- [ Issue] ( https://github.com/opentok/opentok-java-sdk/issues ) or take a look at the existing ones. If
197
- you are going to send us a pull request, please try to run the test suite first and also include
198
- tests for your changes.
240
+ Interested in contributing? We :heart : pull requests! See the [ Development] ( DEVELOPING.md ) and
241
+ [ Contribution] ( CONTRIBUTING.md ) guidelines.
199
242
200
243
# Support
201
244
202
- See < http ://tokbox.com/opentok/support/ > for all our support options.
245
+ See < https ://support. tokbox.com> for all our support options.
203
246
204
247
Find a bug? File it on the [ Issues] ( https://github.com/opentok/opentok-java-sdk/issues ) page. Hint:
205
248
test cases are really helpful!
0 commit comments