in src/JNI/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp [957:1175]
BOOL KinesisVideoClientWrapper::setCallbacks(JNIEnv* env, jobject thiz)
{
CHECK(env != NULL && thiz != NULL);
// The customData will point to this object
mClientCallbacks.customData = POINTER_TO_HANDLE(this);
// Need the current version of the structure
mClientCallbacks.version = CALLBACKS_CURRENT_VERSION;
// Set the function pointers
mClientCallbacks.getCurrentTimeFn = getCurrentTimeFunc;
mClientCallbacks.getRandomNumberFn = getRandomNumberFunc;
mClientCallbacks.createMutexFn = createMutexFunc;
mClientCallbacks.lockMutexFn = lockMutexFunc;
mClientCallbacks.unlockMutexFn = unlockMutexFunc;
mClientCallbacks.tryLockMutexFn = tryLockMutexFunc;
mClientCallbacks.freeMutexFn = freeMutexFunc;
mClientCallbacks.createConditionVariableFn = createConditionVariableFunc;
mClientCallbacks.signalConditionVariableFn = signalConditionVariableFunc;
mClientCallbacks.broadcastConditionVariableFn = broadcastConditionVariableFunc;
mClientCallbacks.waitConditionVariableFn = waitConditionVariableFunc;
mClientCallbacks.freeConditionVariableFn = freeConditionVariableFunc;
mClientCallbacks.getDeviceCertificateFn = getDeviceCertificateFunc;
mClientCallbacks.getSecurityTokenFn = getSecurityTokenFunc;
mClientCallbacks.getDeviceFingerprintFn = getDeviceFingerprintFunc;
mClientCallbacks.streamUnderflowReportFn = streamUnderflowReportFunc;
mClientCallbacks.storageOverflowPressureFn = storageOverflowPressureFunc;
mClientCallbacks.streamLatencyPressureFn = streamLatencyPressureFunc;
mClientCallbacks.streamConnectionStaleFn = streamConnectionStaleFunc;
mClientCallbacks.fragmentAckReceivedFn = fragmentAckReceivedFunc;
mClientCallbacks.droppedFrameReportFn = droppedFrameReportFunc;
mClientCallbacks.bufferDurationOverflowPressureFn = bufferDurationOverflowPressureFunc;
mClientCallbacks.droppedFragmentReportFn = droppedFragmentReportFunc;
mClientCallbacks.streamErrorReportFn = streamErrorReportFunc;
mClientCallbacks.streamDataAvailableFn = streamDataAvailableFunc;
mClientCallbacks.streamReadyFn = streamReadyFunc;
mClientCallbacks.streamClosedFn = streamClosedFunc;
mClientCallbacks.createStreamFn = createStreamFunc;
mClientCallbacks.describeStreamFn = describeStreamFunc;
mClientCallbacks.getStreamingEndpointFn = getStreamingEndpointFunc;
mClientCallbacks.getStreamingTokenFn = getStreamingTokenFunc;
mClientCallbacks.putStreamFn = putStreamFunc;
mClientCallbacks.tagResourceFn = tagResourceFunc;
mClientCallbacks.clientReadyFn = clientReadyFunc;
mClientCallbacks.createDeviceFn = createDeviceFunc;
mClientCallbacks.deviceCertToTokenFn = deviceCertToTokenFunc;
// TODO: Currently we set the shutdown callbacks to NULL.
// We need to expose these in the near future
mClientCallbacks.clientShutdownFn = NULL;
mClientCallbacks.streamShutdownFn = NULL;
// We do not expose logging functionality to Java
// as the signature of the function does not have "custom_data"
// to properly map to the client object.
// We will use the default logger for Java.
mClientCallbacks.logPrintFn = NULL;
// Extract the method IDs for the callbacks and set a global reference
jclass thizCls = env->GetObjectClass(thiz);
if (thizCls == NULL) {
DLOGE("Failed to get the object class for the JNI object.");
return FALSE;
}
// Setup the environment and the callbacks
if (NULL == (mGlobalJniObjRef = env->NewGlobalRef(thiz))) {
DLOGE("Failed to create a global reference for the JNI object.");
return FALSE;
}
// Extract the method IDs
mGetDeviceCertificateMethodId = env->GetMethodID(thizCls, "getDeviceCertificate", "()Lcom/amazonaws/kinesisvideo/producer/AuthInfo;");
if (mGetDeviceCertificateMethodId == NULL) {
DLOGE("Couldn't find method id getDeviceCertificate");
return FALSE;
}
mGetSecurityTokenMethodId = env->GetMethodID(thizCls, "getSecurityToken", "()Lcom/amazonaws/kinesisvideo/producer/AuthInfo;");
if (mGetSecurityTokenMethodId == NULL) {
DLOGE("Couldn't find method id getSecurityToken");
return FALSE;
}
mGetDeviceFingerprintMethodId = env->GetMethodID(thizCls, "getDeviceFingerprint", "()Ljava/lang/String;");
if (mGetDeviceFingerprintMethodId == NULL) {
DLOGE("Couldn't find method id getDeviceFingerprint");
return FALSE;
}
mStreamUnderflowReportMethodId = env->GetMethodID(thizCls, "streamUnderflowReport", "(J)V");
if (mStreamUnderflowReportMethodId == NULL) {
DLOGE("Couldn't find method id streamUnderflowReport");
return FALSE;
}
mStorageOverflowPressureMethodId = env->GetMethodID(thizCls, "storageOverflowPressure", "(J)V");
if (mStorageOverflowPressureMethodId == NULL) {
DLOGE("Couldn't find method id storageOverflowPressure");
return FALSE;
}
mStreamLatencyPressureMethodId = env->GetMethodID(thizCls, "streamLatencyPressure", "(JJ)V");
if (mStreamLatencyPressureMethodId == NULL) {
DLOGE("Couldn't find method id streamLatencyPressure");
return FALSE;
}
mStreamConnectionStaleMethodId = env->GetMethodID(thizCls, "streamConnectionStale", "(JJ)V");
if (mStreamConnectionStaleMethodId == NULL) {
DLOGE("Couldn't find method id streamConnectionStale");
return FALSE;
}
mFragmentAckReceivedMethodId = env->GetMethodID(thizCls, "fragmentAckReceived", "(JJLcom/amazonaws/kinesisvideo/producer/KinesisVideoFragmentAck;)V");
if (mFragmentAckReceivedMethodId == NULL) {
DLOGE("Couldn't find method id fragmentAckReceived");
return FALSE;
}
mDroppedFrameReportMethodId = env->GetMethodID(thizCls, "droppedFrameReport", "(JJ)V");
if (mDroppedFrameReportMethodId == NULL) {
DLOGE("Couldn't find method id droppedFrameReport");
return FALSE;
}
mBufferDurationOverflowPressureMethodId = env->GetMethodID(thizCls, "bufferDurationOverflowPressure", "(JJ)V");
if (mBufferDurationOverflowPressureMethodId == NULL) {
DLOGE("Couldn't find method id bufferDurationOverflowPressure");
return FALSE;
}
mDroppedFragmentReportMethodId = env->GetMethodID(thizCls, "droppedFragmentReport", "(JJ)V");
if (mDroppedFragmentReportMethodId == NULL) {
DLOGE("Couldn't find method id droppedFragmentReport");
return FALSE;
}
mStreamErrorReportMethodId = env->GetMethodID(thizCls, "streamErrorReport", "(JJJJ)V");
if (mStreamErrorReportMethodId == NULL) {
DLOGE("Couldn't find method id streamErrorReport");
return FALSE;
}
mStreamDataAvailableMethodId = env->GetMethodID(thizCls, "streamDataAvailable", "(JLjava/lang/String;JJJ)V");
if (mStreamDataAvailableMethodId == NULL) {
DLOGE("Couldn't find method id streamDataAvailable");
return FALSE;
}
mStreamReadyMethodId = env->GetMethodID(thizCls, "streamReady", "(J)V");
if (mStreamReadyMethodId == NULL) {
DLOGE("Couldn't find method id streamReady");
return FALSE;
}
mStreamClosedMethodId = env->GetMethodID(thizCls, "streamClosed", "(JJ)V");
if (mStreamClosedMethodId == NULL) {
DLOGE("Couldn't find method id streamClosed");
return FALSE;
}
mCreateStreamMethodId = env->GetMethodID(thizCls, "createStream", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JJJ[BIJ)I");
if (mCreateStreamMethodId == NULL) {
DLOGE("Couldn't find method id createStream");
return FALSE;
}
mDescribeStreamMethodId = env->GetMethodID(thizCls, "describeStream", "(Ljava/lang/String;JJ[BIJ)I");
if (mDescribeStreamMethodId == NULL) {
DLOGE("Couldn't find method id describeStream");
return FALSE;
}
mGetStreamingEndpointMethodId = env->GetMethodID(thizCls, "getStreamingEndpoint", "(Ljava/lang/String;Ljava/lang/String;JJ[BIJ)I");
if (mGetStreamingEndpointMethodId == NULL) {
DLOGE("Couldn't find method id getStreamingEndpoint");
return FALSE;
}
mGetStreamingTokenMethodId = env->GetMethodID(thizCls, "getStreamingToken", "(Ljava/lang/String;JJ[BIJ)I");
if (mGetStreamingTokenMethodId == NULL) {
DLOGE("Couldn't find method id getStreamingToken");
return FALSE;
}
mPutStreamMethodId = env->GetMethodID(thizCls, "putStream", "(Ljava/lang/String;Ljava/lang/String;JZZLjava/lang/String;JJ[BIJ)I");
if (mPutStreamMethodId == NULL) {
DLOGE("Couldn't find method id putStream");
return FALSE;
}
mTagResourceMethodId = env->GetMethodID(thizCls, "tagResource", "(Ljava/lang/String;[Lcom/amazonaws/kinesisvideo/producer/Tag;JJ[BIJ)I");
if (mTagResourceMethodId == NULL) {
DLOGE("Couldn't find method id tagResource");
return FALSE;
}
mClientReadyMethodId = env->GetMethodID(thizCls, "clientReady", "(J)V");
if (mClientReadyMethodId == NULL) {
DLOGE("Couldn't find method id clientReady");
return FALSE;
}
mCreateDeviceMethodId = env->GetMethodID(thizCls, "createDevice", "(Ljava/lang/String;JJ[BIJ)I");
if (mCreateDeviceMethodId == NULL) {
DLOGE("Couldn't find method id createDevice");
return FALSE;
}
mDeviceCertToTokenMethodId = env->GetMethodID(thizCls, "deviceCertToToken", "(Ljava/lang/String;JJ[BIJ)I");
if (mDeviceCertToTokenMethodId == NULL) {
DLOGE("Couldn't find method id deviceCertToToken");
return FALSE;
}
return TRUE;
}