Skip to content

Commit 909a8fa

Browse files
authored
feat: Add Archive quantizationParameter (#281)
* Bump dependencies * Add quantizationParameter * Bump version: 4.15.1 → 4.16.0
1 parent 132e9c3 commit 909a8fa

File tree

7 files changed

+105
-14
lines changed

7 files changed

+105
-14
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
commit = True
33
tag = False
4-
current_version = 4.15.1
4+
current_version = 4.16.0
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
66
serialize =
77
{major}.{minor}.{patch}-{release}{build}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ When you use Maven as your build tool, you can manage dependencies in the `pom.x
4848
<dependency>
4949
<groupId>com.tokbox</groupId>
5050
<artifactId>opentok-server-sdk</artifactId>
51-
<version>4.15.1</version>
51+
<version>4.16.0</version>
5252
</dependency>
5353
```
5454

@@ -58,7 +58,7 @@ When you use Gradle as your build tool, you can manage dependencies in the `buil
5858

5959
```groovy
6060
dependencies {
61-
compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.15.1'
61+
compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.16.0'
6262
}
6363
```
6464

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212

1313
group = 'com.tokbox'
1414
archivesBaseName = 'opentok-server-sdk'
15-
version = '4.15.1'
15+
version = '4.16.0'
1616

1717
ext.githubPath = "opentok/Opentok-Java-SDK"
1818

@@ -23,18 +23,18 @@ repositories {
2323
dependencies {
2424
testImplementation 'junit:junit:4.13.2'
2525
testImplementation 'org.wiremock:wiremock:3.10.0'
26-
testImplementation 'com.google.guava:guava:33.4.0-jre'
26+
testImplementation 'com.google.guava:guava:33.4.6-jre'
2727
testImplementation 'io.jsonwebtoken:jjwt-api:0.12.6'
2828
testImplementation 'io.jsonwebtoken:jjwt-impl:0.12.6'
2929
testImplementation 'io.jsonwebtoken:jjwt-jackson:0.12.6'
3030

31-
implementation 'com.vonage:jwt:2.0.0'
31+
implementation 'com.vonage:jwt:2.0.1'
3232
implementation 'commons-lang:commons-lang:2.6'
33-
implementation 'commons-codec:commons-codec:1.17.1'
34-
implementation 'io.netty:netty-codec-http:4.1.116.Final'
35-
implementation 'io.netty:netty-handler:4.1.116.Final'
33+
implementation 'commons-codec:commons-codec:1.18.0'
34+
implementation 'io.netty:netty-codec-http:4.1.119.Final'
35+
implementation 'io.netty:netty-handler:4.1.119.Final'
3636
implementation 'org.asynchttpclient:async-http-client:2.12.4'
37-
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
37+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
3838
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
3939
}
4040

@@ -74,7 +74,7 @@ javadoc {
7474
}
7575

7676
jacoco {
77-
toolVersion = "0.8.12"
77+
toolVersion = "0.8.13"
7878
}
7979
jacocoTestReport {
8080
reports {

src/main/java/com/opentok/Archive.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public String toString() {
130130
@JsonProperty private String password;
131131
@JsonProperty private String resolution;
132132
@JsonProperty private String multiArchiveTag;
133+
@JsonProperty private int quantizationParameter;
133134

134135
protected Archive() {
135136
}
@@ -274,6 +275,16 @@ public String getMultiArchiveTag() {
274275
return multiArchiveTag;
275276
}
276277

278+
/**
279+
* Returns the quantization parameter if set for the Archive.
280+
*
281+
* @return The quantization parameter, between 15 and 40.
282+
* @since 4.16.0
283+
*/
284+
public int getQuantizationParameter() {
285+
return quantizationParameter;
286+
}
287+
277288
@Override
278289
public String toString() {
279290
try {

src/main/java/com/opentok/ArchiveProperties.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class ArchiveProperties {
2929
private boolean hasAudio;
3030
private boolean hasVideo;
3131
private Integer maxBitrate;
32+
private Integer quantizationParameter;
3233
private OutputMode outputMode;
3334
private StreamMode streamMode;
3435
private ArchiveLayout layout;
@@ -39,6 +40,7 @@ private ArchiveProperties(Builder builder) {
3940
this.hasAudio = builder.hasAudio;
4041
this.hasVideo = builder.hasVideo;
4142
this.maxBitrate = builder.maxBitrate;
43+
this.quantizationParameter = builder.quantizationParameter;
4244
this.outputMode = builder.outputMode;
4345
this.streamMode = builder.streamMode;
4446
this.layout = builder.layout;
@@ -56,7 +58,7 @@ public static class Builder {
5658
private String multiArchiveTag = null;
5759
private boolean hasAudio = true;
5860
private boolean hasVideo = true;
59-
private Integer maxBitrate;
61+
private Integer maxBitrate, quantizationParameter;
6062
private OutputMode outputMode = OutputMode.COMPOSED;
6163
private StreamMode streamMode = StreamMode.AUTO;
6264
private ArchiveLayout layout = null;
@@ -128,6 +130,22 @@ public Builder maxBitrate(int maxBitrate) {
128130
return this;
129131
}
130132

133+
/**
134+
* Sets the quantization parameter for the archive. Minimum is 15, maximum is 45.
135+
* This property is mutually exclusive with {@linkplain #maxBitrate(int)}, since
136+
* it uses variable bitrate. It is only applicable to composed archives.
137+
*
138+
* @param quantizationParameter The quantization parameter as an int. Smaller values generate higher quality
139+
* and larger archives, larger values generate lower quality and smaller archives.
140+
*
141+
* @return The ArchiveProperties.Builder object with the quantizationParameter setting.
142+
* @since 4.16.0
143+
*/
144+
public Builder quantizationParameter(int quantizationParameter) {
145+
this.quantizationParameter = quantizationParameter;
146+
return this;
147+
}
148+
131149
/**
132150
* Sets the output mode for this archive.
133151
*
@@ -247,6 +265,16 @@ public Integer maxBitrate() {
247265
return maxBitrate;
248266
}
249267

268+
/**
269+
* Gets the quantization parameter for the archive if specified.
270+
*
271+
* @return The quantization parameter, or {@code null} if unspecified (the default).
272+
* @since 4.16.0
273+
*/
274+
public Integer quantizationParameter() {
275+
return quantizationParameter;
276+
}
277+
250278
/**
251279
* The output mode of the archive.
252280
*/
@@ -257,7 +285,9 @@ public OutputMode outputMode() {
257285
/**
258286
* The stream mode of the archive.
259287
*/
260-
public StreamMode streamMode() { return streamMode; }
288+
public StreamMode streamMode() {
289+
return streamMode;
290+
}
261291

262292
/**
263293
* Returns the custom layout of the archive (composed archives only).
@@ -315,6 +345,12 @@ public Map<String, Collection<String>> toMap() {
315345
params.put("maxBitrate", valueList);
316346
}
317347

348+
if (quantizationParameter != null) {
349+
valueList = new ArrayList<>(1);
350+
valueList.add(quantizationParameter.toString());
351+
params.put("quantizationParameter", valueList);
352+
}
353+
318354
return params;
319355
}
320356

src/main/java/com/opentok/constants/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
package com.opentok.constants;
99

1010
public class Version {
11-
public static final String VERSION = "4.15.1";
11+
public static final String VERSION = "4.16.0";
1212
}

src/test/java/com/opentok/OpenTokTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ public void testStartArchive() throws OpenTokException {
10631063
" \"partnerId\" : 123456,\n" +
10641064
" \"reason\" : \"\",\n" +
10651065
" \"sessionId\" : \"SESSIONID\",\n" +
1066+
" \"maxBitrate\" : 3214560,\n" +
10661067
" \"size\" : 0,\n" +
10671068
" \"status\" : \"started\",\n" +
10681069
" \"url\" : null\n" +
@@ -1080,17 +1081,60 @@ public void testStartArchive() throws OpenTokException {
10801081

10811082
assertNotNull(properties.toMap());
10821083
assertEquals(Integer.valueOf(3214560), properties.maxBitrate());
1084+
assertNull(properties.quantizationParameter());
10831085

10841086
Archive archive = sdk.startArchive(sessionId, properties);
10851087
assertNotNull(archive);
10861088
assertEquals(sessionId, archive.getSessionId());
1089+
assertEquals(properties.maxBitrate().intValue(), archive.getMaxBitrate());
1090+
assertEquals(0, archive.getQuantizationParameter());
10871091
assertNotNull(archive.getId());
10881092
verify(postRequestedFor(urlMatching(archivePath)));
10891093
assertTrue(TestHelpers.verifyTokenAuth(apiKey, apiSecret,
10901094
findAll(postRequestedFor(urlMatching(archivePath)))));
10911095
TestHelpers.verifyUserAgent();
10921096
}
10931097

1098+
@Test
1099+
public void testStartArchiveWithQuantizationParameter() throws OpenTokException {
1100+
stubFor(post(urlEqualTo(archivePath))
1101+
.willReturn(aResponse()
1102+
.withStatus(200)
1103+
.withHeader("Content-Type", "application/json")
1104+
.withBody("{\n" +
1105+
" \"createdAt\" : 1395183243556,\n" +
1106+
" \"duration\" : 0,\n" +
1107+
" \"id\" : \"30b3ebf1-ba36-4f5b-8def-6f70d9986fe9\",\n" +
1108+
" \"name\" : \"\",\n" +
1109+
" \"partnerId\" : 123456,\n" +
1110+
" \"reason\" : \"\",\n" +
1111+
" \"sessionId\" : \""+sessionId+"\",\n" +
1112+
" \"size\" : 1023,\n" +
1113+
" \"quantizationParameter\" : \"29\",\n" +
1114+
" \"status\" : \"started\",\n" +
1115+
" \"url\" : \"http://example.org/archive\"\n" +
1116+
" }")));
1117+
1118+
ArchiveProperties properties = new ArchiveProperties.Builder()
1119+
.outputMode(OutputMode.COMPOSED)
1120+
.quantizationParameter(29)
1121+
.build();
1122+
1123+
assertNotNull(properties.toMap());
1124+
assertEquals(Integer.valueOf(29), properties.quantizationParameter());
1125+
assertNull(properties.maxBitrate());
1126+
1127+
Archive archive = sdk.startArchive(sessionId, properties);
1128+
assertNotNull(archive);
1129+
assertEquals(sessionId, archive.getSessionId());
1130+
assertEquals(properties.quantizationParameter().intValue(), archive.getQuantizationParameter());
1131+
assertNotNull(archive.getId());
1132+
verify(postRequestedFor(urlMatching(archivePath)));
1133+
assertTrue(TestHelpers.verifyTokenAuth(apiKey, apiSecret,
1134+
findAll(postRequestedFor(urlMatching(archivePath)))));
1135+
TestHelpers.verifyUserAgent();
1136+
}
1137+
10941138
@Test
10951139
public void testStartArchiveWithScreenshareType() throws OpenTokException {
10961140
String sessionId = "SESSIONID";

0 commit comments

Comments
 (0)