Skip to content

Commit 116b904

Browse files
committed
fix bug where producer cannot recover from STATUS_STORE_OUT_OF_MEMORY after network outage
1 parent 75087f5 commit 116b904

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ This library is licensed under the Apache License, 2.0.
7070
----
7171
### Release notes
7272

73+
#### Release 2.0.2 (17th Oct 2019)
74+
* fix bug where producer cannot recover from STATUS_STORE_OUT_OF_MEMORY after network outage
75+
7376
#### Release 2.0.1 (25th Jul 2019)
7477
* C-Producer - Updates
7578
* Rotating file logger (small feature).

kinesis-video-c-producer/src/source/Version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616
/**
1717
* IMPORTANT!!! This is the current version of the SDK which needs to be maintained
1818
*/
19-
#define AWS_SDK_KVS_PRODUCER_VERSION_STRING (PCHAR) "2.0.1"
19+
#define AWS_SDK_KVS_PRODUCER_VERSION_STRING (PCHAR) "2.0.2"
2020

2121
/**
2222
* Default user agent string

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

+13-12
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,6 @@ STATUS putFrame(PKinesisVideoStream pKinesisVideoStream, PFrame pFrame)
810810
pKinesisVideoClient->base.lock);
811811
clientLocked = TRUE;
812812

813-
// Allocate storage for the frame
814-
if (!IS_VALID_ALLOCATION_HANDLE(allocHandle)) {
815-
CHK_STATUS(heapAlloc(pKinesisVideoClient->pHeap, overallSize, &allocHandle));
816-
}
817-
818813
// Ensure we have space and if not then bail
819814
CHK(IS_VALID_ALLOCATION_HANDLE(allocHandle), STATUS_STORE_OUT_OF_MEMORY);
820815

@@ -1541,7 +1536,8 @@ STATUS getStreamMetrics(PKinesisVideoStream pKinesisVideoStream, PStreamMetrics
15411536
}
15421537

15431538
/**
1544-
* Await for the frame availability in OFFLINE mode.
1539+
* Check if there is enough content store for the frame. If not, block waiting if in OFFLINE mode, otherwise return with
1540+
* INVALID_ALLOCATION_HANDLE.
15451541
*
15461542
* IMPORTANT: The assumption is that both the stream IS locked but
15471543
* the client is NOT locked.
@@ -1561,8 +1557,7 @@ STATUS waitForAvailability(PKinesisVideoStream pKinesisVideoStream, UINT32 alloc
15611557
PKinesisVideoClient pKinesisVideoClient = pKinesisVideoStream->pKinesisVideoClient;
15621558
BOOL streamLocked = TRUE;
15631559

1564-
// Quick check if we need to do any awaiting
1565-
CHK(IS_OFFLINE_STREAMING_MODE(pKinesisVideoStream->streamInfo.streamCaps.streamingType), STATUS_SUCCESS);
1560+
15661561

15671562
while (TRUE) {
15681563
// Check if we have enough space to proceed - the stream should be locked
@@ -1571,6 +1566,9 @@ STATUS waitForAvailability(PKinesisVideoStream pKinesisVideoStream, UINT32 alloc
15711566
// Early return if available
15721567
CHK(!IS_VALID_ALLOCATION_HANDLE(*pAllocationHandle), STATUS_SUCCESS);
15731568

1569+
// if no space available, wait only if in OFFLINE mode
1570+
CHK(IS_OFFLINE_STREAMING_MODE(pKinesisVideoStream->streamInfo.streamCaps.streamingType), STATUS_SUCCESS);
1571+
15741572
// Long path which will await for the availability notification or cancellation
15751573
CHK_STATUS(pKinesisVideoClient->clientCallbacks.waitConditionVariableFn(pKinesisVideoClient->clientCallbacks.customData,
15761574
pKinesisVideoStream->bufferAvailabilityCondition,
@@ -1612,11 +1610,14 @@ STATUS checkForAvailability(PKinesisVideoStream pKinesisVideoStream, UINT32 allo
16121610
// Set to invalid whether we failed to allocate or we don't have content view availability
16131611
*pAllocationHandle = INVALID_ALLOCATION_HANDLE_VALUE;
16141612

1615-
// Check to see if we have availability in the content view. This will set the availability
1616-
CHK_STATUS(contentViewCheckAvailability(pKinesisVideoStream->pView, NULL, &availability));
1613+
// check view availability only if in offline mode
1614+
if (IS_OFFLINE_STREAMING_MODE(pKinesisVideoStream->streamInfo.streamCaps.streamingType)) {
1615+
// Check to see if we have availability in the content view. This will set the availability
1616+
CHK_STATUS(contentViewCheckAvailability(pKinesisVideoStream->pView, NULL, &availability));
16171617

1618-
// Early return if no view availability
1619-
CHK(availability, STATUS_SUCCESS);
1618+
// Early return if no view availability
1619+
CHK(availability, STATUS_SUCCESS);
1620+
}
16201621

16211622
// Lock the client
16221623
pKinesisVideoClient->clientCallbacks.lockMutexFn(pKinesisVideoClient->clientCallbacks.customData, pKinesisVideoClient->base.lock);

kinesis-video-pic/src/client/tst/StreamApiFunctionalityTest.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,13 @@ TEST_F(StreamApiFunctionalityTest, putFrame_StorageOverflow)
362362
PBYTE pData = (PBYTE) MEMALLOC(frameSize);
363363
UINT64 timestamp;
364364
Frame frame;
365+
UINT32 frameCount = (TEST_DEVICE_STORAGE_SIZE / frameSize) - 2; // minus two frameSize for watermark.
365366

366367
// Create and ready a stream
367368
ReadyStream();
368369

369370
// Make sure we drop the first frame which should be the key frame
370-
for (i = 0, timestamp = 0; i < TEST_DEVICE_STORAGE_SIZE / frameSize; timestamp += TEST_LONG_FRAME_DURATION, i++) {
371+
for (i = 0, timestamp = 0; i < frameCount; timestamp += TEST_LONG_FRAME_DURATION, i++) {
371372
frame.index = i;
372373
frame.decodingTs = timestamp;
373374
frame.presentationTs = timestamp;

0 commit comments

Comments
 (0)