in src/JNI/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp [280:337]
STREAM_HANDLE KinesisVideoClientWrapper::createKinesisVideoStream(jobject streamInfo)
{
STATUS retStatus = STATUS_SUCCESS;
STREAM_HANDLE streamHandle = INVALID_STREAM_HANDLE_VALUE;
UINT32 i;
JNIEnv *env;
StreamInfo kinesisVideoStreamInfo;
mJvm->GetEnv((PVOID*) &env, JNI_VERSION_1_6);
if (!IS_VALID_CLIENT_HANDLE(mClientHandle))
{
DLOGE("Invalid client object");
throwNativeException(env, EXCEPTION_NAME, "Invalid call after the client is freed.", STATUS_INVALID_OPERATION);
goto CleanUp;
}
// Convert the StreamInfo object
MEMSET(&kinesisVideoStreamInfo, 0x00, SIZEOF(kinesisVideoStreamInfo));
if (!setStreamInfo(env, streamInfo, &kinesisVideoStreamInfo))
{
DLOGE("Failed converting stream info object.");
throwNativeException(env, EXCEPTION_NAME, "Failed converting stream info object.", STATUS_INVALID_OPERATION);
goto CleanUp;
}
if (STATUS_FAILED(retStatus = ::createKinesisVideoStream(mClientHandle, &kinesisVideoStreamInfo, &streamHandle)))
{
DLOGE("Failed to create a stream with status code 0x%08x", retStatus);
throwNativeException(env, EXCEPTION_NAME, "Failed to create a stream.", retStatus);
goto CleanUp;
}
CleanUp:
// Release the Segment UUID memory if any
if (kinesisVideoStreamInfo.streamCaps.segmentUuid != NULL) {
MEMFREE(kinesisVideoStreamInfo.streamCaps.segmentUuid);
kinesisVideoStreamInfo.streamCaps.segmentUuid = NULL;
}
// Release the temporary memory allocated for cpd
for (i = 0; i < kinesisVideoStreamInfo.streamCaps.trackInfoCount; ++i) {
if (kinesisVideoStreamInfo.streamCaps.trackInfoList[i].codecPrivateData != NULL) {
MEMFREE(kinesisVideoStreamInfo.streamCaps.trackInfoList[i].codecPrivateData);
kinesisVideoStreamInfo.streamCaps.trackInfoList[i].codecPrivateData = NULL;
kinesisVideoStreamInfo.streamCaps.trackInfoList[i].codecPrivateDataSize = 0;
}
}
if (kinesisVideoStreamInfo.streamCaps.trackInfoList != NULL) {
MEMFREE(kinesisVideoStreamInfo.streamCaps.trackInfoList);
kinesisVideoStreamInfo.streamCaps.trackInfoList = NULL;
kinesisVideoStreamInfo.streamCaps.trackInfoCount = 0;
}
releaseTags(kinesisVideoStreamInfo.tags);
return streamHandle;
}