awslabs / amazon-kinesis-video-streams-producer-sdk-cpp

Amazon Kinesis Video Streams Producer SDK for C++ is for developers to install and customize for their connected camera and other devices to securely stream video, audio, and time-encoded data to Kinesis Video Streams.
Apache License 2.0
379 stars 334 forks source link

kvssink soft start/stop support #1153

Open stefankiesz opened 8 months ago

stefankiesz commented 8 months ago

Issue #, if available:

What was changed?

Why was it changed?

How was it changed?

The following is the flow of the new intermittent sample:

  1. Play the pipeline.
  2. Start a new thread to handle the start/stop mechanism at a specified interval.
  3. Wait for the playing interval to finish using a conditional variable to allow for early exit with sigint.
  4. Stop the stream by sending an EOS message on the pipeline.
  5. Wait for a return EOS message to come on the bus once kvssink receives the EOS (this is on the separate, bus/main_loop thread).
  6. Send a flush start event on the pipeline. This removes the EOS from sticking on the elements, but they still remain in a stopped state.
  7. Wait for the paused interval to finish using a conditional variable to allow for early exit with sigint.
  8. Send a flush stop event on the pipeline to resume streaming.

What testing was done for the changes?

Testing for data loss was conducted by streaming footage of a running stop watch at a start/stop period of less than a fragment (6, 8, and 10 second intervals were tested). The time segment captured by the ingested KVS stream was compared to the desired start/stop increments. All fragments were within 100ms of the expected duration, except for the first fragments of streams which were ~300ms shorter than expected, likely due to time taken constructing resources.

Screenshot



Testing was also conducted with longer increments of 2min playing and 5min paused. The stream continued to stop and start with no issues. Below shows 1 hour of such a test with the orange-colored timeline showing where there were ingested fragments.

Screenshot



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