Skip to content

Commit

Permalink
Update PIC with duplicate fix (#295)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jdelapla authored Mar 24, 2022
1 parent 6d9d47c commit 79da5b6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ sudo: true
branches:
only:
- master
- develop

cache:
- directories:
Expand Down
2 changes: 1 addition & 1 deletion CMake/Dependencies/libkvspic-CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include(ExternalProject)
# clone repo only
ExternalProject_Add(libkvspic-download
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
GIT_TAG 04fdbdffa929f7390b946493ce8a995fb09c0ceb
GIT_TAG c8325887faa3a4a296c4367b281c778be69875b6
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-build"
CMAKE_ARGS
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ The last three arguments are optional. By default,
* `audio-codec` is `aac`

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

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.

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.
If you want to enable KVS events in fragment metadata and automatically add an event on every key frame, add a 5th input.
"notification" for a notification event.
"image" for an image generation event.
"both" for both. Otherwise leave it blank
This feature is found only in the audio/video sample, but can be written into the video only sample as well.

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

Expand Down
34 changes: 30 additions & 4 deletions samples/KvsAudioVideoStreamingSample.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#define FILE_LOGGING_BUFFER_SIZE (100 * 1024)
#define MAX_NUMBER_OF_LOG_FILES 5

#define KEYFRAME_EVENT_INTERVAL 200

UINT8 gEventsEnabled = 0;
UINT16 gKeyFrameCount = 0;

typedef struct {
PBYTE buffer;
Expand Down Expand Up @@ -71,10 +74,27 @@ PVOID putVideoFrameRoutine(PVOID args)
startUpLatency = (DOUBLE)(GETTIME() - data->startTime) / (DOUBLE) HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
DLOGD("Start up latency: %lf ms", startUpLatency);
data->firstFrame = FALSE;
if(gEventsEnabled) {
//generate an image and notification event at the start of the video stream.
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
}
else if (frame.flags == FRAME_FLAG_KEY_FRAME) {
if(gKeyFrameCount%KEYFRAME_EVENT_INTERVAL == 0)
{
//reset to 0 to avoid overflow in long running applications
gKeyFrameCount = 0;
switch (gEventsEnabled) {
case 1:
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION, NULL);
break;
case 2:
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
break;
case 3:
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
break;
default:
break;
}
}
gKeyFrameCount++;
}

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

if (argc == 6) {
if (STRCMP(argv[5], "1")){
if (!STRCMP(argv[5], "both")){
gEventsEnabled = 3;
}
if (!STRCMP(argv[5], "image")){
gEventsEnabled = 2;
}
if (!STRCMP(argv[5], "notification")){
gEventsEnabled = 1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions tst/ProducerClientBasicTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,13 @@ TEST_F(ProducerClientBasicTest, cachingEndpointProvider_Returns_EndpointFromCach
EXPECT_TRUE(mProducerStopped) << "Producer thread failed to stop cleanly";

// Expect the number of calls
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mPutStreamFnCount);
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mPutStreamFnCount);
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
EXPECT_EQ(0, mCurlCreateStreamCount);
EXPECT_EQ(0, mCurlDescribeStreamCount);
EXPECT_EQ(0, mCurlTagResourceCount);
EXPECT_EQ(1 * TEST_STREAM_COUNT, mCurlGetDataEndpointCount);
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mCurlPutMediaCount);
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mCurlPutMediaCount);

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

0 comments on commit 79da5b6

Please sign in to comment.