in gst/gst-kvs-plugin/src/KvsProducer.c [68:167]
STATUS initKinesisVideoStream(PGstKvsPlugin pGstPlugin)
{
STATUS retStatus = STATUS_SUCCESS;
GstTags gstTags;
CHK(pGstPlugin != NULL, STATUS_NULL_ARG);
CHK_STATUS(gstStructToTags(pGstPlugin->gstParams.streamTags, &gstTags));
// If doing offline mode file uploading, and the user wants to use a specific file start time,
// then force absolute fragment time. Since we will be adding the file_start_time to the timestamp
// of each frame to make each frame's timestamp absolute. Assuming each frame's timestamp is relative
// (i.e. starting from 0)
if (pGstPlugin->gstParams.streamingType == STREAMING_TYPE_OFFLINE && pGstPlugin->gstParams.fileStartTime != 0) {
pGstPlugin->gstParams.absoluteFragmentTimecodes = TRUE;
// Store the base of the PTS which will be the file start time.
// NOTE: file start time is given in seconds.
pGstPlugin->basePts = pGstPlugin->gstParams.fileStartTime / HUNDREDS_OF_NANOS_IN_A_SECOND;
}
switch (pGstPlugin->mediaType) {
case GST_PLUGIN_MEDIA_TYPE_AUDIO_VIDEO:
pGstPlugin->gstParams.frameRate = MAX(pGstPlugin->gstParams.frameRate, DEFAULT_STREAM_FRAMERATE_HIGH_DENSITY);
CHK_STATUS(createRealtimeAudioVideoStreamInfoProvider(
pGstPlugin->gstParams.streamName, pGstPlugin->gstParams.retentionPeriodInHours * HUNDREDS_OF_NANOS_IN_AN_HOUR,
pGstPlugin->gstParams.bufferDurationInSeconds * HUNDREDS_OF_NANOS_IN_A_SECOND, &pGstPlugin->kvsContext.pStreamInfo));
break;
case GST_PLUGIN_MEDIA_TYPE_AUDIO_ONLY:
g_free(pGstPlugin->gstParams.codecId);
pGstPlugin->gstParams.codecId = pGstPlugin->audioCodecId;
pGstPlugin->gstParams.keyFrameFragmentation = FALSE;
pGstPlugin->gstParams.frameRate = MAX(pGstPlugin->gstParams.frameRate, DEFAULT_STREAM_FRAMERATE_HIGH_DENSITY);
// Explicit fall-through
case GST_PLUGIN_MEDIA_TYPE_VIDEO_ONLY:
CHK_STATUS(createRealtimeVideoStreamInfoProvider(
pGstPlugin->gstParams.streamName, pGstPlugin->gstParams.retentionPeriodInHours * HUNDREDS_OF_NANOS_IN_AN_HOUR,
pGstPlugin->gstParams.bufferDurationInSeconds * HUNDREDS_OF_NANOS_IN_A_SECOND, &pGstPlugin->kvsContext.pStreamInfo));
break;
}
pGstPlugin->kvsContext.pStreamInfo->tagCount = gstTags.tagCount;
pGstPlugin->kvsContext.pStreamInfo->tags = gstTags.tags;
STRNCPY(pGstPlugin->kvsContext.pStreamInfo->kmsKeyId, pGstPlugin->gstParams.kmsKeyId, MAX_ARN_LEN);
pGstPlugin->kvsContext.pStreamInfo->streamCaps.streamingType = pGstPlugin->gstParams.streamingType;
STRNCPY(pGstPlugin->kvsContext.pStreamInfo->streamCaps.contentType, pGstPlugin->gstParams.contentType, MAX_CONTENT_TYPE_LEN);
// Need to reset the NAL adaptation flags as we take care of it later with the first frame
pGstPlugin->kvsContext.pStreamInfo->streamCaps.nalAdaptationFlags = NAL_ADAPTATION_FLAG_NONE;
// Override only if specified
if (pGstPlugin->gstParams.maxLatencyInSeconds != DEFAULT_MAX_LATENCY_SECONDS) {
pGstPlugin->kvsContext.pStreamInfo->streamCaps.maxLatency = pGstPlugin->gstParams.maxLatencyInSeconds * HUNDREDS_OF_NANOS_IN_A_SECOND;
}
pGstPlugin->kvsContext.pStreamInfo->streamCaps.fragmentDuration =
pGstPlugin->gstParams.fragmentDurationInMillis * HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.timecodeScale = pGstPlugin->gstParams.timeCodeScaleInMillis * HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.keyFrameFragmentation = pGstPlugin->gstParams.keyFrameFragmentation;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.frameTimecodes = pGstPlugin->gstParams.frameTimecodes;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.absoluteFragmentTimes = pGstPlugin->gstParams.absoluteFragmentTimecodes;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.fragmentAcks = pGstPlugin->gstParams.fragmentAcks;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.recoverOnError = pGstPlugin->gstParams.restartOnErrors;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.frameRate = pGstPlugin->gstParams.frameRate;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.avgBandwidthBps = pGstPlugin->gstParams.avgBandwidthBps;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.recalculateMetrics = pGstPlugin->gstParams.recalculateMetrics;
pGstPlugin->kvsContext.pStreamInfo->streamCaps.nalAdaptationFlags = NAL_ADAPTATION_FLAG_NONE;
// Override only if specified
if (pGstPlugin->gstParams.replayDurationInSeconds != DEFAULT_REPLAY_DURATION_SECONDS) {
pGstPlugin->kvsContext.pStreamInfo->streamCaps.replayDuration = pGstPlugin->gstParams.replayDurationInSeconds * HUNDREDS_OF_NANOS_IN_A_SECOND;
}
// Override only if specified
if (pGstPlugin->gstParams.connectionStalenessInSeconds != DEFAULT_CONNECTION_STALENESS_SECONDS) {
pGstPlugin->kvsContext.pStreamInfo->streamCaps.connectionStalenessDuration =
pGstPlugin->gstParams.connectionStalenessInSeconds * HUNDREDS_OF_NANOS_IN_A_SECOND;
}
// Replace the video codecId
STRNCPY(pGstPlugin->kvsContext.pStreamInfo->streamCaps.trackInfoList[0].codecId, pGstPlugin->gstParams.codecId, MKV_MAX_CODEC_ID_LEN);
// Deal with audio
if (pGstPlugin->mediaType == GST_PLUGIN_MEDIA_TYPE_AUDIO_VIDEO) {
STRNCPY(pGstPlugin->kvsContext.pStreamInfo->streamCaps.trackInfoList[1].codecId, pGstPlugin->audioCodecId, MKV_MAX_CODEC_ID_LEN);
}
CHK_STATUS(
createKinesisVideoStreamSync(pGstPlugin->kvsContext.clientHandle, pGstPlugin->kvsContext.pStreamInfo, &pGstPlugin->kvsContext.streamHandle));
pGstPlugin->frameCount = 0;
DLOGI("Stream is ready");
CleanUp:
return retStatus;
}