Skip to content

Commit 680de1e

Browse files
committed
stability and bug fixes
1 parent 7eb25a5 commit 680de1e

File tree

15 files changed

+255
-167
lines changed

15 files changed

+255
-167
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ This library is licensed under the Amazon Software License.
4545
----
4646
### Release notes
4747

48+
#### Release 1.7.4 (14th Feb 2019)
49+
* Stability and bug fixes.
50+
4851
#### Release 1.7.3 (12th Feb 2019)
4952
* Enforce non-zero TrackUid and SegmentUUID.
5053

kinesis-video-gst-demo/kinesis_video_gstreamer_audio_video_sample_app.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
441441

442442
dropFrame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_CORRUPTED) ||
443443
GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DECODE_ONLY) ||
444+
(GST_BUFFER_FLAGS(buffer) == GST_BUFFER_FLAG_DISCONT) ||
444445
(!GST_BUFFER_PTS_IS_VALID(buffer)); //frame with invalid pts cannot be processed.
445446
if (dropFrame) {
446447
if (!GST_BUFFER_PTS_IS_VALID(buffer)) {

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
348348
isHeader = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_HEADER);
349349
isDroppable = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_CORRUPTED) ||
350350
GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DECODE_ONLY) ||
351+
(GST_BUFFER_FLAGS(buffer) == GST_BUFFER_FLAG_DISCONT) ||
351352
// drop if buffer contains header only and has invalid timestamp
352353
(isHeader && (!GST_BUFFER_PTS_IS_VALID(buffer) || !GST_BUFFER_DTS_IS_VALID(buffer)));
353354

354355
if (!isDroppable) {
355356
buffer_size = gst_buffer_get_size(buffer);
356-
357357
// resize data buffer if not enough storage
358358
if (buffer_size > data->frame_data_size) {
359359
delete [] data->frame_data;

kinesis-video-gstreamer-plugin/plugin-src/gstkvssink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,9 +1097,9 @@ gst_kvs_sink_handle_buffer (GstCollectPads * pads,
10971097
goto CleanUp;
10981098
}
10991099

1100-
//LOG_DEBUG("flags" << GST_BUFFER_FLAGS(buf));
11011100
isDroppable = GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_CORRUPTED) ||
11021101
GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_DECODE_ONLY) ||
1102+
(GST_BUFFER_FLAGS(buf) == GST_BUFFER_FLAG_DISCONT) ||
11031103
(!GST_BUFFER_PTS_IS_VALID(buf)); //frame with invalid pts cannot be processed.
11041104

11051105
if (isDroppable) {

kinesis-video-pic/src/client/src/Stream.cpp

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,12 @@ STATUS createStream(PKinesisVideoClient pKinesisVideoClient, PStreamInfo pStream
202202
pCurPnt += MKV_SEGMENT_UUID_LEN;
203203

204204
// Copy the structures in their entirety
205+
// NOTE: This will copy the raw pointers, however, we will only use it in the duration of the call.
205206
MEMCPY(pCurPnt, pStreamInfo->streamCaps.trackInfoList, trackInfoSize);
206207
pKinesisVideoStream->streamInfo.streamCaps.trackInfoList = (PTrackInfo) pCurPnt;
208+
207209
// Move pCurPnt to the end of pKinesisVideoStream->streamInfo.streamCaps.trackInfoList
208210
pCurPnt = (PBYTE) (pKinesisVideoStream->streamInfo.streamCaps.trackInfoList + pKinesisVideoStream->streamInfo.streamCaps.trackInfoCount);
209-
for(i = 0; i < pKinesisVideoStream->streamInfo.streamCaps.trackInfoCount; ++i) {
210-
PTrackInfo pTrackInfo = &pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i];
211-
if (pStreamInfo->streamCaps.trackInfoList[i].codecPrivateDataSize != 0 && pStreamInfo->streamCaps.trackInfoList[i].codecPrivateData != NULL) {
212-
pTrackInfo->codecPrivateData = (PBYTE) MEMALLOC(pTrackInfo->codecPrivateDataSize);
213-
CHK(pTrackInfo->codecPrivateData != NULL, STATUS_NOT_ENOUGH_MEMORY);
214-
MEMCPY(pTrackInfo->codecPrivateData, pStreamInfo->streamCaps.trackInfoList[i].codecPrivateData, pTrackInfo->codecPrivateDataSize);
215-
}
216-
}
217211

218212
// Calculate the max items in the view
219213
maxViewItems = calculateViewItemCount(&pKinesisVideoStream->streamInfo);
@@ -323,15 +317,6 @@ STATUS freeStream(PKinesisVideoStream pKinesisVideoStream)
323317
// Free the metadata queue
324318
freeStackQueue(pKinesisVideoStream->pMetadataQueue);
325319

326-
// Free the codec private data for all tracks
327-
for (i = 0; i < pKinesisVideoStream->streamInfo.streamCaps.trackInfoCount; ++i) {
328-
if (pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i].codecPrivateData != NULL) {
329-
MEMFREE(pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i].codecPrivateData);
330-
pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i].codecPrivateData = NULL;
331-
}
332-
pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i].codecPrivateDataSize = 0;
333-
}
334-
335320
// Free the eosTracker and eofrTracker data if any
336321
freeMetadataTracker(&pKinesisVideoStream->eosTracker);
337322
freeMetadataTracker(&pKinesisVideoStream->metadataTracker);
@@ -542,6 +527,7 @@ STATUS putFrame(PKinesisVideoStream pKinesisVideoStream, PFrame pFrame) {
542527
break;
543528
}
544529
}
530+
545531
CHK (trackInfoFound, STATUS_MKV_TRACK_INFO_NOT_FOUND);
546532

547533
// Check if the stream has been stopped
@@ -1482,7 +1468,7 @@ STATUS streamFormatChanged(PKinesisVideoStream pKinesisVideoStream, UINT32 codec
14821468
ENTERS();
14831469
STATUS retStatus = STATUS_SUCCESS;
14841470
PKinesisVideoClient pKinesisVideoClient = NULL;
1485-
BOOL streamLocked = FALSE, trackInfoFound = FALSE;
1471+
BOOL streamLocked = FALSE;
14861472
PTrackInfo pTrackInfo = NULL;
14871473
UINT32 i;
14881474

@@ -1510,30 +1496,15 @@ STATUS streamFormatChanged(PKinesisVideoStream pKinesisVideoStream, UINT32 codec
15101496
// Free the existing allocation if any.
15111497
for(i = 0; i < pKinesisVideoStream->streamInfo.streamCaps.trackInfoCount; ++i) {
15121498
if (pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i].trackId == trackId) {
1513-
trackInfoFound = TRUE;
15141499
pTrackInfo = &pKinesisVideoStream->streamInfo.streamCaps.trackInfoList[i];
1515-
if (pTrackInfo->codecPrivateData != NULL) {
1516-
MEMFREE(pTrackInfo->codecPrivateData);
1517-
pTrackInfo->codecPrivateData = NULL;
1518-
pTrackInfo->codecPrivateDataSize = 0;
1519-
}
15201500
break;
15211501
}
15221502
}
1523-
CHK(trackInfoFound, STATUS_MKV_TRACK_INFO_NOT_FOUND);
1524-
1525-
// Set the size first
1526-
// IMPORTANT: The CPD size could be set to 0 to clear any previous CPD.
1527-
pTrackInfo->codecPrivateDataSize = codecPrivateDataSize;
15281503

1529-
// Check if we need to do anything
1530-
if (codecPrivateDataSize != 0) {
1531-
pTrackInfo->codecPrivateData = (PBYTE) MEMALLOC(codecPrivateDataSize);
1532-
CHK(pTrackInfo->codecPrivateData != NULL, STATUS_NOT_ENOUGH_MEMORY);
1504+
CHK(pTrackInfo != NULL, STATUS_MKV_TRACK_INFO_NOT_FOUND);
15331505

1534-
// Copy the bits
1535-
MEMCPY(pTrackInfo->codecPrivateData, codecPrivateData, codecPrivateDataSize);
1536-
}
1506+
pTrackInfo->codecPrivateDataSize = codecPrivateDataSize;
1507+
pTrackInfo->codecPrivateData = codecPrivateData;
15371508

15381509
// Need to free and re-create the packager
15391510
if (pKinesisVideoStream->pMkvGenerator != NULL) {

kinesis-video-pic/src/mkvgen/include/com/amazonaws/kinesis/video/mkvgen/Include.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@ typedef enum {
165165
MKV_STATE_START_BLOCK,
166166
} MKV_STREAM_STATE, *PMKV_STREAM_STATE;
167167

168+
/**
169+
* Track types taken from the MKV specification
170+
*/
168171
typedef enum {
169-
MKV_TRACK_INFO_TYPE_VIDEO,
170-
MKV_TRACK_INFO_TYPE_AUDIO,
172+
MKV_TRACK_INFO_TYPE_VIDEO = (BYTE) 0x01,
173+
MKV_TRACK_INFO_TYPE_AUDIO = (BYTE) 0x02,
174+
MKV_TRACK_INFO_TYPE_UNKOWN = (BYTE) 0x03,
171175
} MKV_TRACK_INFO_TYPE, *PMKV_TRACK_INFO_TYPE;
172176

173177
/**

kinesis-video-pic/src/mkvgen/src/Include_i.h

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,14 @@ extern "C" {
2222
// General defines and data structures
2323
////////////////////////////////////////////////////
2424

25-
/**
26-
* MKV track types
27-
* Default track type for MKV = complex
28-
*/
29-
#define MKV_DEFAULT_TRACK_TYPE 0x03
30-
#define MKV_TRACK_TYPE_VIDEO 0x01
31-
#define MKV_TRACK_TYPE_AUDIO 0x02
32-
33-
/**
34-
* Content type prefixes
35-
*/
36-
#define MKV_CONTENT_TYPE_PREFIX_AUDIO ((PCHAR) "audio/")
37-
#define MKV_CONTENT_TYPE_PREFIX_VIDEO ((PCHAR) "video/")
38-
3925
/**
4026
* Special processing for the types
4127
*/
4228
#define MKV_H264_CONTENT_TYPE ((PCHAR) "video/h264")
4329
#define MKV_H265_CONTENT_TYPE ((PCHAR) "video/h265")
44-
#define MKV_X_MKV_CONTENT_TYPE ((PCHAR) "video/x-matroska")
30+
#define MKV_X_MKV_VIDEO_CONTENT_TYPE ((PCHAR) "video/x-matroska")
31+
#define MKV_X_MKV_AUDIO_CONTENT_TYPE ((PCHAR) "audio/x-matroska")
32+
#define MKV_AAC_CONTENT_TYPE ((PCHAR) "audio/aac")
4533
#define MKV_FOURCC_CODEC_ID ((PCHAR) "V_MS/VFW/FOURCC")
4634

4735
/**
@@ -126,7 +114,7 @@ extern UINT32 gMkvTrackNameBitsSize;
126114
// Number of bytes to skip to get from begin of TrackEntry to TrackNumber
127115
#define MKV_TRACK_NUMBER_OFFSET 7
128116

129-
// Number of bytes to skip to get from begin of TrackEntry to TrackNumber
117+
// Number of bytes to skip to get from begin of TrackEntry to TrackType
130118
#define MKV_TRACK_TYPE_OFFSET 21
131119

132120
// Number of bytes to skip to get from begin of Audio to SamplingFrequency
@@ -256,6 +244,24 @@ typedef enum {
256244
MKV_GENERATOR_STATE_TAGS,
257245
} MKV_GENERATOR_STATE, *PMKV_GENERATOR_STATE;
258246

247+
/**
248+
* MKV track type used internally
249+
*/
250+
typedef enum {
251+
MKV_CONTENT_TYPE_NONE = (UINT64) 0,
252+
MKV_CONTENT_TYPE_UNKNOWN = (1 << 0),
253+
MKV_CONTENT_TYPE_H264 = (1 << 1),
254+
MKV_CONTENT_TYPE_H265 = (1 << 2),
255+
MKV_CONTENT_TYPE_X_MKV_VIDEO = (1 << 3),
256+
MKV_CONTENT_TYPE_X_MKV_AUDIO = (1 << 4),
257+
MKV_CONTENT_TYPE_AAC = (1 << 5),
258+
} MKV_CONTENT_TYPE, *PMKV_CONTENT_TYPE;
259+
260+
/**
261+
* Content type delimiter character
262+
*/
263+
#define MKV_CONTENT_TYPE_DELIMITER ','
264+
259265
/**
260266
* MkvGenerator internal structure
261267
*/
@@ -279,7 +285,7 @@ typedef struct {
279285
UINT64 clusterDuration;
280286

281287
// The content type of the stream
282-
BYTE trackType;
288+
MKV_CONTENT_TYPE contentType;
283289

284290
// Time function entry
285291
GetCurrentTimeFunc getTimeFn;
@@ -362,13 +368,23 @@ UINT32 mkvgenGetFrameOverhead(PStreamMkvGenerator, MKV_STREAM_STATE);
362368
STATUS mkvgenValidateFrame(PStreamMkvGenerator, PFrame, PUINT64, PUINT64, PUINT64, PMKV_STREAM_STATE);
363369

364370
/**
365-
* Returns the MKV track type from the provided content type
371+
* Returns the MKV content type from the provided content type string by tokenizing and matching the string
372+
*
373+
* @PCHAR - content type string to convert
374+
*
375+
* @return - MKV content type corresponding to the content type string
376+
*/
377+
MKV_CONTENT_TYPE mkvgenGetContentTypeFromContentTypeString(PCHAR);
378+
379+
/**
380+
* Returns the MKV content type for a given tokenized string
366381
*
367-
* @PCHAR - content type to convert
382+
* @PCHAR - content type string token to convert
383+
* @UINT32 - the length of the token
368384
*
369-
* @return - MKV track type corresponding to the content type
385+
* @return - MKV content type corresponding to the content type string
370386
*/
371-
BYTE mkvgenGetTrackTypeFromContentType(PCHAR);
387+
MKV_CONTENT_TYPE mkvgenGetContentTypeFromContentTypeTokenString(PCHAR, UINT32);
372388

373389
/**
374390
* EBML encodes a number and stores in the buffer

0 commit comments

Comments
 (0)