Skip to content

Commit 79da5b6

Browse files
authored
Update PIC with duplicate fix (#295)
* Update PIC with duplicate fix * fix unit test * remove travis from devleop * fixed sample for images * Updated sample for more variety * Made event sample more infrequent to prevent server troubles
1 parent 6d9d47c commit 79da5b6

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ sudo: true
44
branches:
55
only:
66
- master
7-
- develop
87

98
cache:
109
- directories:

CMake/Dependencies/libkvspic-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include(ExternalProject)
77
# clone repo only
88
ExternalProject_Add(libkvspic-download
99
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
10-
GIT_TAG 04fdbdffa929f7390b946493ce8a995fb09c0ceb
10+
GIT_TAG c8325887faa3a4a296c4367b281c778be69875b6
1111
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-src"
1212
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-build"
1313
CMAKE_ARGS

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ The last three arguments are optional. By default,
8888
* `audio-codec` is `aac`
8989

9090
If you want to use the sample for `PCM_ALAW/G.711` frames, run
91-
`./kvsAudioVideoStreamingSample <channel-name> <streaming_duration> <sample_location> alaw 0`
91+
`./kvsAudioVideoStreamingSample <channel-name> <streaming_duration> <sample_location> alaw`
9292

9393
This will stream the video/audio files from the `samples/h264SampleFrames` and `samples/aacSampleFrames` or `samples/alawSampleFrames` (as per the choice of audio codec in the last argument) respectively.
9494

95-
If you want to enable KVS events in fragment metadata, change the 5th parameter from 0 -> 1. This feature is found only in the audio/video sample, but can be written into the video only sample as well.
95+
If you want to enable KVS events in fragment metadata and automatically add an event on every key frame, add a 5th input.
96+
"notification" for a notification event.
97+
"image" for an image generation event.
98+
"both" for both. Otherwise leave it blank
99+
This feature is found only in the audio/video sample, but can be written into the video only sample as well.
96100

97101
For video only, run `./kvsVideoOnlyStreamingSample <channel-name>`
98102

samples/KvsAudioVideoStreamingSample.c

+30-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
#define FILE_LOGGING_BUFFER_SIZE (100 * 1024)
2323
#define MAX_NUMBER_OF_LOG_FILES 5
2424

25+
#define KEYFRAME_EVENT_INTERVAL 200
26+
2527
UINT8 gEventsEnabled = 0;
28+
UINT16 gKeyFrameCount = 0;
2629

2730
typedef struct {
2831
PBYTE buffer;
@@ -71,10 +74,27 @@ PVOID putVideoFrameRoutine(PVOID args)
7174
startUpLatency = (DOUBLE)(GETTIME() - data->startTime) / (DOUBLE) HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
7275
DLOGD("Start up latency: %lf ms", startUpLatency);
7376
data->firstFrame = FALSE;
74-
if(gEventsEnabled) {
75-
//generate an image and notification event at the start of the video stream.
76-
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
77+
}
78+
else if (frame.flags == FRAME_FLAG_KEY_FRAME) {
79+
if(gKeyFrameCount%KEYFRAME_EVENT_INTERVAL == 0)
80+
{
81+
//reset to 0 to avoid overflow in long running applications
82+
gKeyFrameCount = 0;
83+
switch (gEventsEnabled) {
84+
case 1:
85+
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION, NULL);
86+
break;
87+
case 2:
88+
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
89+
break;
90+
case 3:
91+
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
92+
break;
93+
default:
94+
break;
95+
}
7796
}
97+
gKeyFrameCount++;
7898
}
7999

80100
ATOMIC_STORE_BOOL(&data->firstVideoFramePut, TRUE);
@@ -189,7 +209,13 @@ INT32 main(INT32 argc, CHAR* argv[])
189209
STRNCPY(audioCodec, AUDIO_CODEC_NAME_AAC, STRLEN(AUDIO_CODEC_NAME_AAC)); //aac audio by default
190210

191211
if (argc == 6) {
192-
if (STRCMP(argv[5], "1")){
212+
if (!STRCMP(argv[5], "both")){
213+
gEventsEnabled = 3;
214+
}
215+
if (!STRCMP(argv[5], "image")){
216+
gEventsEnabled = 2;
217+
}
218+
if (!STRCMP(argv[5], "notification")){
193219
gEventsEnabled = 1;
194220
}
195221
}

tst/ProducerClientBasicTest.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,13 @@ TEST_F(ProducerClientBasicTest, cachingEndpointProvider_Returns_EndpointFromCach
679679
EXPECT_TRUE(mProducerStopped) << "Producer thread failed to stop cleanly";
680680

681681
// Expect the number of calls
682-
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mPutStreamFnCount);
683-
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
682+
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mPutStreamFnCount);
683+
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
684684
EXPECT_EQ(0, mCurlCreateStreamCount);
685685
EXPECT_EQ(0, mCurlDescribeStreamCount);
686686
EXPECT_EQ(0, mCurlTagResourceCount);
687687
EXPECT_EQ(1 * TEST_STREAM_COUNT, mCurlGetDataEndpointCount);
688-
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mCurlPutMediaCount);
688+
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mCurlPutMediaCount);
689689

690690
// We will block for some time due to an incorrect implementation of the awaiting code
691691
// NOTE: The proper implementation should use synchronization primitives to await for the

0 commit comments

Comments
 (0)