amazon-kinesis-video-streams-producer-sdk-cpp icon indicating copy to clipboard operation
amazon-kinesis-video-streams-producer-sdk-cpp copied to clipboard

[FEATURE] Support putFragmentMetadata from kvssink

Open niyatim23 opened this issue 1 year ago • 1 comments

Issue #, if available: https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/discussions/1031

What was changed? Modify kvssink and sample application to support adding metadata per fragment

Why was it changed? This feature was missing from kvssink and was requested by multiple customers

How was it changed?

  • This feature allows adding multiple metadata tags to fragments until a limit (10 metadata per fragment) is reached. To repeatedly put the metadata while streaming, a timer has been used which triggers a function put-metadata every 2 seconds. This application-level logic can be customized by the customers to be fired on their own set of events / frequency. put-metadata can be modified by the customers to generate metadata tags to be put. Currently, they consume values from a global instance of CustomData whose counter is updated within put-metadata itself. put-metadata also calls put-fragment-metadata, an inline function from gstkvssink.h . The reason for the same is to abstract the details of triggering the event from the customer.
  • put-fragment-metadata generates the GstStructure expected by the GST_EVENT_CUSTOM_DOWNSTREAM and ultimately triggers the GST_EVENT_CUSTOM_DOWNSTREAM that handles the tags and calls the underlying KVS API putFragmentMetadata.
  • When this event is triggered, it checks whether the structure is in the expected format / the fragment_metadata_count has reached the max or not. If it has, it warns the customer about it through the logs without disrupting the streaming.

What testing was done for the changes? Tested the following locally:

  • Tested that the metadata was persisted in the video by checking the video dump with mkvinfo
  • Tested that the metadata marked as persistent is indeed persisted for each fragment of the video
  • Tested that the metadata marked as non-persistent is not persisted for each fragment of the video
  • Tested that the metadata that is to be put, toggles between persistent and non-persistent and the both of them are marked correctly in the video
  • Tested that the streaming continues despite failures in the putFragmentMetadata
  • Tested that the count for the persistent metadata and the current fragment's metadata is maintained correctly and any new incoming metadata is ignored and the API call is skipped after receiving an error from the API putFragmentMetadata
  • mkvinfo on a video dump from the tests (even metadata-keys are persistent, odd ones are non-persistent): mkvinfo-metadata.txt

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

niyatim23 avatar Jan 02 '24 11:01 niyatim23

Codecov Report

Attention: Patch coverage is 0% with 58 lines in your changes are missing coverage. Please review.

Project coverage is 16.27%. Comparing base (eeb392f) to head (db6d18f). Report is 9 commits behind head on develop.

:exclamation: Current head db6d18f differs from pull request most recent head 47d702d. Consider uploading reports for the commit 47d702d to get more accurate results

Files Patch % Lines
samples/kvssink_gstreamer_sample.cpp 0.00% 50 Missing :warning:
src/gstreamer/gstkvssink.cpp 0.00% 8 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1122      +/-   ##
===========================================
- Coverage    16.48%   16.27%   -0.22%     
===========================================
  Files           50       50              
  Lines         7019     7092      +73     
===========================================
- Hits          1157     1154       -3     
- Misses        5862     5938      +76     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jan 02 '24 12:01 codecov-commenter