Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ${{ matrix.platform.os }}

env:
BRANCH_NAME: develop
BRANCH_NAME: jni-clientinfo

steps:
- name: Checkout the repository
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
cm-file
.DS_Store
target
out/
src/main/resources/META-INF/*
logs
hs_err_pid*.log

*.log
*.log.*
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public interface KinesisVideoProducer {
* Creates Kinesis Video stream
*
* @param streamInfo Stream information {@link StreamInfo} object
* @param streamCallbacks Optional stream callnbacks {@link StreamCallbacks}
* @param streamCallbacks Optional stream callbacks {@link StreamCallbacks}
* @return The newly created stream
* @throws ProducerException
*/
Expand All @@ -76,7 +76,7 @@ KinesisVideoProducerStream createStream(final @Nonnull StreamInfo streamInfo,
* Creates Kinesis Video stream synchronously
*
* @param streamInfo Stream information {@link StreamInfo} object
* @param streamCallbacks Optional stream callnbacks {@link StreamCallbacks}
* @param streamCallbacks Optional stream callbacks {@link StreamCallbacks}
* @return The newly created stream
* @throws ProducerException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class NativeKinesisVideoProducerJni implements KinesisVideoProducer {
/**
* The expected library version.
*/
public static final String EXPECTED_LIBRARY_VERSION = "2.0";
public static final String EXPECTED_LIBRARY_VERSION = "2.1";

/**
* The manifest handle will be set after call to parse()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.amazonaws.kinesisvideo.producer;

public enum AutomaticStreamingFlags {
AUTOMATIC_STREAMING_INTERMITTENT_PRODUCER(0), AUTOMATIC_STREAMING_ALWAYS_CONTINUOUS(256);
private final int streamingFlagValue;

private AutomaticStreamingFlags(int streamingFlagValue) {
this.streamingFlagValue = streamingFlagValue;
}

public int getStreamingFlagValue() {
return streamingFlagValue;
}
}
91 changes: 69 additions & 22 deletions src/main/java/com/amazonaws/kinesisvideo/producer/ClientInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,49 @@ public class ClientInfo {
/**
* Current version for the structure as defined in the native code
*/

public static final int CLIENT_INFO_CURRENT_VERSION = 3;
public static final int DEFAULT_LOG_LEVEL = 4;

public static enum AutomaticStreamingFlags {
AUTOMATIC_STREAMING_INTERMITTENT_PRODUCER(0), AUTOMATIC_STREAMING_ALWAYS_CONTINUOUS(256);
private final int streamingFlagValue;

private AutomaticStreamingFlags(int streamingFlagValue) {
this.streamingFlagValue = streamingFlagValue;
}

public int getStreamingFlagValue() {
return streamingFlagValue;
}

}

private final int mVersion;
private final long mCreateClientTimeout;
private final long mCreateStreamTimeout;
private final long mStopStreamTimeout;
private final long mOfflineBufferAvailabilityTimeout;
private final int mLogLevel;

private final int mLoggerLogLevel;
private final boolean mLogMetric;
private final AutomaticStreamingFlags mAutomaticStreamingFlags;

private final long mServiceCallCompletionTimeout;
private final long mServiceCallConnectionTimeout;

/**
* NOTE: The below members are not supported for setting/getting in Java. These will be set to
* default values in the JNI and C layers.
*/
private final long mMetricLoggingPeriod;
private final long mReservedCallbackPeriod;
private final KvsRetryStrategy mKvsRetryStrategy;
private final KvsRetryStrategyCallbacks mKvsRetryStrategyCallbacks;


public ClientInfo() {
mVersion = CLIENT_INFO_CURRENT_VERSION;
mCreateClientTimeout = 0L;
mCreateStreamTimeout = 0L;
mStopStreamTimeout = 0L;
mOfflineBufferAvailabilityTimeout = 0L;
mLogLevel = DEFAULT_LOG_LEVEL;
mLoggerLogLevel = DEFAULT_LOG_LEVEL;
mLogMetric = true;
mAutomaticStreamingFlags = AutomaticStreamingFlags.AUTOMATIC_STREAMING_INTERMITTENT_PRODUCER;
mServiceCallCompletionTimeout = 0L;
mServiceCallConnectionTimeout = 0L;
mMetricLoggingPeriod = 0;
mReservedCallbackPeriod = 0;
mKvsRetryStrategyCallbacks = new DefaultKvsRetryStrategyCallbacks();
mKvsRetryStrategy = new KvsRetryStrategy();
}

public ClientInfo(final long createClientTimeout, final long createStreamTimeout, final long stopStreamTimeout,
Expand All @@ -68,11 +72,34 @@ public ClientInfo(final long createClientTimeout, final long createStreamTimeout
mCreateStreamTimeout = createStreamTimeout;
mStopStreamTimeout = stopStreamTimeout;
mOfflineBufferAvailabilityTimeout = offlineBufferAvailabilityTimeout;
mLogLevel = logLevel;
mLoggerLogLevel = logLevel;
mLogMetric = logMetric;
mAutomaticStreamingFlags = flag;
mServiceCallCompletionTimeout = 0L;
mServiceCallConnectionTimeout = 0L;
mMetricLoggingPeriod = 0;
mReservedCallbackPeriod = 0;
mKvsRetryStrategyCallbacks = new DefaultKvsRetryStrategyCallbacks();
mKvsRetryStrategy = new KvsRetryStrategy(); }

public ClientInfo(final long createClientTimeout, final long createStreamTimeout, final long stopStreamTimeout,
final long offlineBufferAvailabilityTimeout, final long serviceCallConnectionTimeou,
final long serviceCallCompletionTimeout, final int logLevel,
final boolean logMetric, final AutomaticStreamingFlags flag) {
mVersion = CLIENT_INFO_CURRENT_VERSION;
mCreateClientTimeout = createClientTimeout;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be consistent with the native with suffix as ms? or seconds?

mCreateStreamTimeout = createStreamTimeout;
mStopStreamTimeout = stopStreamTimeout;
mOfflineBufferAvailabilityTimeout = offlineBufferAvailabilityTimeout;
mLoggerLogLevel = logLevel;
mLogMetric = logMetric;
mAutomaticStreamingFlags = flag;
mServiceCallCompletionTimeout = serviceCallCompletionTimeout;
mServiceCallConnectionTimeout = serviceCallConnectionTimeout;
mServiceCallConnectionTimeout = serviceCallConnectionTimeou;
mMetricLoggingPeriod = 0;
mReservedCallbackPeriod = 0;
mKvsRetryStrategyCallbacks = new DefaultKvsRetryStrategyCallbacks();
mKvsRetryStrategy = new KvsRetryStrategy();
}

public int getVersion() {
Expand All @@ -95,8 +122,16 @@ public long getOfflineBufferAvailabilityTimeout() {
return mOfflineBufferAvailabilityTimeout;
}

public long getServiceCallCompletionTimeout() {
return mServiceCallCompletionTimeout;
}

public long getServiceCallConnectionTimeout() {
return mServiceCallConnectionTimeout;
}

public int getLoggerLogLevel() {
return mLogLevel;
return mLoggerLogLevel;
}

public boolean getLogMetric() {
Expand All @@ -107,11 +142,23 @@ public int getAutomaticStreamingFlags() {
return mAutomaticStreamingFlags.getStreamingFlagValue();
}

public long getServiceCompletionTimeout() {
return mServiceCallCompletionTimeout;
public long getMetricLoggingPeriod() {
return mMetricLoggingPeriod;
}

public long getServiceConnectionTimeout() {
return mServiceCallConnectionTimeout;
public long getReservedCallbackPeriod() {
return mReservedCallbackPeriod;
}

public KvsRetryStrategy getKvsRetryStrategy() {
return mKvsRetryStrategy;
}

/**
* NOTE: The below getters are not supported for setting/getting in Java. These will return
* null to be initialized to default/null values in the JNI and C layers.
*/
public KvsRetryStrategyCallbacks getKvsRetryStrategyCallbacks() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.amazonaws.kinesisvideo.producer;

import javax.annotation.Nullable;

public class DefaultKvsRetryStrategyCallbacks implements KvsRetryStrategyCallbacks {

@Override
public void createRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy) throws ProducerException {
// no-op
}

@Override
public void getCurrentRetryAttemptNumberFn(KvsRetryStrategy kvsRetryStrategy, int retryCount) throws ProducerException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem right

// no-op
}

@Override
public void freeRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy) throws ProducerException {
// no-op
}

@Override
public void executeRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy, long retryWaitTime) throws ProducerException {
// no-op
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.amazonaws.kinesisvideo.producer;

public class KvsRetryStrategy {

private final long mRetryStrategy;
private final long mRetryStrategyConfig;
private final KvsRetryStrategyType mKvsRetryStrategyType;

public KvsRetryStrategy() {
mRetryStrategy = 0;
mRetryStrategyConfig = 0;
mKvsRetryStrategyType = KvsRetryStrategyType.EXPONENTIAL_BACKOFF_WAIT;
}

/**
* NOTE: The below getters are not supported for setting/getting in Java. These will return
* null to be initialized to default/null values in the JNI and C layers.
*/
public long getRetryStrategy() {
return 0;
}

public long getRetryStrategyConfig() {
return 0;
}

public int getRetryStrategyType() {
return mKvsRetryStrategyType.getKvsRetryStrategyType();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.amazonaws.kinesisvideo.producer;

/**
* This interface holds the retry strategy callback functions.
*
* NOTE: This should follow the structure defined in PIC's /kvspic-src/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h
*
*/
public interface KvsRetryStrategyCallbacks {

void createRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy) throws ProducerException;
void getCurrentRetryAttemptNumberFn(KvsRetryStrategy kvsRetryStrategy, int retryCount) throws ProducerException;
void freeRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy) throws ProducerException;
void executeRetryStrategyFn(KvsRetryStrategy kvsRetryStrategy, long retryWaitTime) throws ProducerException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.amazonaws.kinesisvideo.producer;

public enum KvsRetryStrategyType {
DISABLED(0), EXPONENTIAL_BACKOFF_WAIT(1);
private final int kvsRetryStrategyTypeValue;

private KvsRetryStrategyType(int kvsRetryStrategyTypeValue) {
this.kvsRetryStrategyTypeValue = kvsRetryStrategyTypeValue;
}

public int getKvsRetryStrategyType() {
return kvsRetryStrategyTypeValue;
}
}
Loading