Skip to content

feat: Add Archive quantizationParameter #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
commit = True
tag = False
current_version = 4.15.1
current_version = 4.16.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{build}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ When you use Maven as your build tool, you can manage dependencies in the `pom.x
<dependency>
<groupId>com.tokbox</groupId>
<artifactId>opentok-server-sdk</artifactId>
<version>4.15.1</version>
<version>4.16.0</version>
</dependency>
```

Expand All @@ -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'
}
```

Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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'
}

Expand Down Expand Up @@ -74,7 +74,7 @@ javadoc {
}

jacoco {
toolVersion = "0.8.12"
toolVersion = "0.8.13"
}
jacocoTestReport {
reports {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/opentok/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down Expand Up @@ -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 {
Expand Down
40 changes: 38 additions & 2 deletions src/main/java/com/opentok/ArchiveProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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).
Expand Down Expand Up @@ -315,6 +345,12 @@ public Map<String, Collection<String>> toMap() {
params.put("maxBitrate", valueList);
}

if (quantizationParameter != null) {
valueList = new ArrayList<>(1);
valueList.add(quantizationParameter.toString());
params.put("quantizationParameter", valueList);
}

return params;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/opentok/constants/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
44 changes: 44 additions & 0 deletions src/test/java/com/opentok/OpenTokTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand All @@ -1080,17 +1081,60 @@ 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,
findAll(postRequestedFor(urlMatching(archivePath)))));
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";
Expand Down
Loading