diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 4ad21ec..43dfd8b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = False -current_version = 4.15.1 +current_version = 4.16.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? serialize = {major}.{minor}.{patch}-{release}{build} diff --git a/README.md b/README.md index 9eaf0dd..2e3f0ad 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ When you use Maven as your build tool, you can manage dependencies in the `pom.x com.tokbox opentok-server-sdk - 4.15.1 + 4.16.0 ``` @@ -58,7 +58,7 @@ When you use Gradle as your build tool, you can manage dependencies in the `buil ```groovy dependencies { - compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.15.1' + compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.16.0' } ``` diff --git a/build.gradle b/build.gradle index 533b346..665d486 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { group = 'com.tokbox' archivesBaseName = 'opentok-server-sdk' -version = '4.15.1' +version = '4.16.0' ext.githubPath = "opentok/Opentok-Java-SDK" @@ -23,18 +23,18 @@ repositories { dependencies { testImplementation 'junit:junit:4.13.2' testImplementation 'org.wiremock:wiremock:3.10.0' - testImplementation 'com.google.guava:guava:33.4.0-jre' + testImplementation 'com.google.guava:guava:33.4.6-jre' testImplementation 'io.jsonwebtoken:jjwt-api:0.12.6' testImplementation 'io.jsonwebtoken:jjwt-impl:0.12.6' testImplementation 'io.jsonwebtoken:jjwt-jackson:0.12.6' - implementation 'com.vonage:jwt:2.0.0' + implementation 'com.vonage:jwt:2.0.1' implementation 'commons-lang:commons-lang:2.6' - implementation 'commons-codec:commons-codec:1.17.1' - implementation 'io.netty:netty-codec-http:4.1.116.Final' - implementation 'io.netty:netty-handler:4.1.116.Final' + implementation 'commons-codec:commons-codec:1.18.0' + implementation 'io.netty:netty-codec-http:4.1.119.Final' + implementation 'io.netty:netty-handler:4.1.119.Final' implementation 'org.asynchttpclient:async-http-client:2.12.4' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3' implementation 'org.bitbucket.b_c:jose4j:0.9.6' } @@ -74,7 +74,7 @@ javadoc { } jacoco { - toolVersion = "0.8.12" + toolVersion = "0.8.13" } jacocoTestReport { reports { diff --git a/src/main/java/com/opentok/Archive.java b/src/main/java/com/opentok/Archive.java index 38148ce..9f2251b 100644 --- a/src/main/java/com/opentok/Archive.java +++ b/src/main/java/com/opentok/Archive.java @@ -130,6 +130,7 @@ public String toString() { @JsonProperty private String password; @JsonProperty private String resolution; @JsonProperty private String multiArchiveTag; + @JsonProperty private int quantizationParameter; protected Archive() { } @@ -274,6 +275,16 @@ public String getMultiArchiveTag() { return multiArchiveTag; } + /** + * Returns the quantization parameter if set for the Archive. + * + * @return The quantization parameter, between 15 and 40. + * @since 4.16.0 + */ + public int getQuantizationParameter() { + return quantizationParameter; + } + @Override public String toString() { try { diff --git a/src/main/java/com/opentok/ArchiveProperties.java b/src/main/java/com/opentok/ArchiveProperties.java index 9c3abe3..fbb5e13 100644 --- a/src/main/java/com/opentok/ArchiveProperties.java +++ b/src/main/java/com/opentok/ArchiveProperties.java @@ -29,6 +29,7 @@ public class ArchiveProperties { private boolean hasAudio; private boolean hasVideo; private Integer maxBitrate; + private Integer quantizationParameter; private OutputMode outputMode; private StreamMode streamMode; private ArchiveLayout layout; @@ -39,6 +40,7 @@ private ArchiveProperties(Builder builder) { this.hasAudio = builder.hasAudio; this.hasVideo = builder.hasVideo; this.maxBitrate = builder.maxBitrate; + this.quantizationParameter = builder.quantizationParameter; this.outputMode = builder.outputMode; this.streamMode = builder.streamMode; this.layout = builder.layout; @@ -56,7 +58,7 @@ public static class Builder { private String multiArchiveTag = null; private boolean hasAudio = true; private boolean hasVideo = true; - private Integer maxBitrate; + private Integer maxBitrate, quantizationParameter; private OutputMode outputMode = OutputMode.COMPOSED; private StreamMode streamMode = StreamMode.AUTO; private ArchiveLayout layout = null; @@ -128,6 +130,22 @@ public Builder maxBitrate(int maxBitrate) { return this; } + /** + * Sets the quantization parameter for the archive. Minimum is 15, maximum is 45. + * This property is mutually exclusive with {@linkplain #maxBitrate(int)}, since + * it uses variable bitrate. It is only applicable to composed archives. + * + * @param quantizationParameter The quantization parameter as an int. Smaller values generate higher quality + * and larger archives, larger values generate lower quality and smaller archives. + * + * @return The ArchiveProperties.Builder object with the quantizationParameter setting. + * @since 4.16.0 + */ + public Builder quantizationParameter(int quantizationParameter) { + this.quantizationParameter = quantizationParameter; + return this; + } + /** * Sets the output mode for this archive. * @@ -247,6 +265,16 @@ public Integer maxBitrate() { return maxBitrate; } + /** + * Gets the quantization parameter for the archive if specified. + * + * @return The quantization parameter, or {@code null} if unspecified (the default). + * @since 4.16.0 + */ + public Integer quantizationParameter() { + return quantizationParameter; + } + /** * The output mode of the archive. */ @@ -257,7 +285,9 @@ public OutputMode outputMode() { /** * The stream mode of the archive. */ - public StreamMode streamMode() { return streamMode; } + public StreamMode streamMode() { + return streamMode; + } /** * Returns the custom layout of the archive (composed archives only). @@ -315,6 +345,12 @@ public Map> toMap() { params.put("maxBitrate", valueList); } + if (quantizationParameter != null) { + valueList = new ArrayList<>(1); + valueList.add(quantizationParameter.toString()); + params.put("quantizationParameter", valueList); + } + return params; } diff --git a/src/main/java/com/opentok/constants/Version.java b/src/main/java/com/opentok/constants/Version.java index 016b4e1..731a053 100644 --- a/src/main/java/com/opentok/constants/Version.java +++ b/src/main/java/com/opentok/constants/Version.java @@ -8,5 +8,5 @@ package com.opentok.constants; public class Version { - public static final String VERSION = "4.15.1"; + public static final String VERSION = "4.16.0"; } diff --git a/src/test/java/com/opentok/OpenTokTest.java b/src/test/java/com/opentok/OpenTokTest.java index 6125880..86f8a94 100644 --- a/src/test/java/com/opentok/OpenTokTest.java +++ b/src/test/java/com/opentok/OpenTokTest.java @@ -1063,6 +1063,7 @@ public void testStartArchive() throws OpenTokException { " \"partnerId\" : 123456,\n" + " \"reason\" : \"\",\n" + " \"sessionId\" : \"SESSIONID\",\n" + + " \"maxBitrate\" : 3214560,\n" + " \"size\" : 0,\n" + " \"status\" : \"started\",\n" + " \"url\" : null\n" + @@ -1080,10 +1081,13 @@ public void testStartArchive() throws OpenTokException { assertNotNull(properties.toMap()); assertEquals(Integer.valueOf(3214560), properties.maxBitrate()); + assertNull(properties.quantizationParameter()); Archive archive = sdk.startArchive(sessionId, properties); assertNotNull(archive); assertEquals(sessionId, archive.getSessionId()); + assertEquals(properties.maxBitrate().intValue(), archive.getMaxBitrate()); + assertEquals(0, archive.getQuantizationParameter()); assertNotNull(archive.getId()); verify(postRequestedFor(urlMatching(archivePath))); assertTrue(TestHelpers.verifyTokenAuth(apiKey, apiSecret, @@ -1091,6 +1095,46 @@ public void testStartArchive() throws OpenTokException { TestHelpers.verifyUserAgent(); } + @Test + public void testStartArchiveWithQuantizationParameter() throws OpenTokException { + stubFor(post(urlEqualTo(archivePath)) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody("{\n" + + " \"createdAt\" : 1395183243556,\n" + + " \"duration\" : 0,\n" + + " \"id\" : \"30b3ebf1-ba36-4f5b-8def-6f70d9986fe9\",\n" + + " \"name\" : \"\",\n" + + " \"partnerId\" : 123456,\n" + + " \"reason\" : \"\",\n" + + " \"sessionId\" : \""+sessionId+"\",\n" + + " \"size\" : 1023,\n" + + " \"quantizationParameter\" : \"29\",\n" + + " \"status\" : \"started\",\n" + + " \"url\" : \"http://example.org/archive\"\n" + + " }"))); + + ArchiveProperties properties = new ArchiveProperties.Builder() + .outputMode(OutputMode.COMPOSED) + .quantizationParameter(29) + .build(); + + assertNotNull(properties.toMap()); + assertEquals(Integer.valueOf(29), properties.quantizationParameter()); + assertNull(properties.maxBitrate()); + + Archive archive = sdk.startArchive(sessionId, properties); + assertNotNull(archive); + assertEquals(sessionId, archive.getSessionId()); + assertEquals(properties.quantizationParameter().intValue(), archive.getQuantizationParameter()); + assertNotNull(archive.getId()); + verify(postRequestedFor(urlMatching(archivePath))); + assertTrue(TestHelpers.verifyTokenAuth(apiKey, apiSecret, + findAll(postRequestedFor(urlMatching(archivePath))))); + TestHelpers.verifyUserAgent(); + } + @Test public void testStartArchiveWithScreenshareType() throws OpenTokException { String sessionId = "SESSIONID";