@@ -16,11 +16,11 @@ LOGGER_TAG("com.amazonaws.kinesis.video.gstreamer");
1616
1717
1818// Modify these parameters to configure the buffer and event streaming behavior.
19- #define CAMERA_EVENT_LIVE_STREAM_DURATION_SECONDS 20 // Duration of live streaming to KVS upon an event.
20- #define CAMERA_EVENT_COOLDOWN_SECONDS 30 // How long for the event scheduler to wait between triggering events.
21- #define STREAM_BUFFER_DURATION_SECONDS 10 // How long to store buffered GoPs for. It is guaranteed that the buffer will be at least this long,
19+ #define CAMERA_EVENT_LIVE_STREAM_DURATION_SECONDS 30 // Duration of live streaming to KVS upon an event.
20+ #define CAMERA_EVENT_COOLDOWN_SECONDS 90 // How long for the event scheduler to wait between triggering events.
21+ #define STREAM_BUFFER_DURATION_SECONDS 30 // How long to store buffered GoPs for. It is guaranteed that the buffer will be at least this long,
2222 // but the buffer may be longer to contain the I-frame associated with buffered P-frames.
23-
23+
2424// Stream definition parameters.
2525#define DEFAULT_RETENTION_PERIOD_HOURS 2
2626#define DEFAULT_KMS_KEY_ID " "
@@ -193,12 +193,10 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
193193 STATUS curr_stream_status = data->stream_status .load ();
194194 GstSample *sample = nullptr ;
195195 GstMapInfo info;
196- struct timeval tv;
197- guint64 now_ms;
196+ uint64_t now_ms;
198197
199- // Get current time.
200- gettimeofday (&tv, NULL );
201- now_ms = (guint64)tv.tv_sec * 1000 + (tv.tv_usec / 1000 );
198+ // Get current time.
199+ now_ms = (uint64_t ) std::chrono::duration_cast<std::chrono::milliseconds>(systemCurrentTime ().time_since_epoch ()).count ();
202200
203201 if (STATUS_FAILED (curr_stream_status)) {
204202 LOG_ERROR (" Received stream error: " << curr_stream_status);
@@ -611,6 +609,7 @@ int init_and_run_gstreamer_pipeline(int argc, char* argv[], CustomData *data) {
611609 // Free resources.
612610 gst_element_set_state (pipeline, GST_STATE_NULL);
613611 gst_object_unref (pipeline);
612+ g_source_remove (bus_watch_id);
614613 g_main_loop_unref (main_loop);
615614 main_loop = NULL ;
616615 return 0 ;
0 commit comments