Skip to content

Commit d9f6837

Browse files
committed
Create a new function for backwards compat, address comments
1 parent 9aaf9e8 commit d9f6837

10 files changed

+48
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ outputs
1111
tags
1212
dependency
1313
.vs
14+
.vscode/

samples/kvs_gstreamer_audio_video_sample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
501501
create_kinesis_video_frame(&frame, std::chrono::nanoseconds(buffer->pts), std::chrono::nanoseconds(buffer->dts),
502502
kinesis_video_flags, info.data, info.size, track_id);
503503

504-
data->kinesis_video_stream->putFrame(frame);
504+
data->kinesis_video_stream->statusPutFrame(frame);
505505

506506
// Sample to demonstrate how event metadata tags can be generated for fragment(s)
507507
// Ref: https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/notifications.html

samples/kvs_gstreamer_multistream_sample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ void create_kinesis_video_frame(Frame *frame, const nanoseconds &pts, const nano
196196
frame->trackId = DEFAULT_TRACK_ID;
197197
}
198198

199-
bool put_frame(shared_ptr<KinesisVideoStream> kinesis_video_stream, void *data, size_t len, const nanoseconds &pts,
199+
STATUS put_frame(shared_ptr<KinesisVideoStream> kinesis_video_stream, void *data, size_t len, const nanoseconds &pts,
200200
const nanoseconds &dts, FRAME_FLAGS flags) {
201201
Frame frame;
202202
create_kinesis_video_frame(&frame, pts, dts, flags, data, len);
203-
return kinesis_video_stream->putFrame(frame);
203+
return kinesis_video_stream->statusPutFrame(frame);
204204
}
205205

206206
static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {

samples/kvs_gstreamer_sample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ void create_kinesis_video_frame(Frame *frame, const nanoseconds &pts, const nano
323323
frame->trackId = DEFAULT_TRACK_ID;
324324
}
325325

326-
bool put_frame(shared_ptr<KinesisVideoStream> kinesis_video_stream, void *data, size_t len, const nanoseconds &pts, const nanoseconds &dts, FRAME_FLAGS flags) {
326+
STATUS put_frame(shared_ptr<KinesisVideoStream> kinesis_video_stream, void *data, size_t len, const nanoseconds &pts, const nanoseconds &dts, FRAME_FLAGS flags) {
327327
Frame frame;
328328
create_kinesis_video_frame(&frame, pts, dts, flags, data, len);
329-
return kinesis_video_stream->putFrame(frame);
329+
return kinesis_video_stream->statusPutFrame(frame);
330330
}
331331

332332
static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {

src/KinesisVideoStream.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ KinesisVideoStream::KinesisVideoStream(const KinesisVideoProducer& kinesis_video
1919
}
2020
}
2121

22-
STATUS KinesisVideoStream::putFrame(KinesisVideoFrame& frame) const {
22+
// Added statusPutFrame function but leaving the putFrame function as is to still return a bool for backward compatibility.
23+
bool KinesisVideoStream::putFrame(KinesisVideoFrame& frame) const {
24+
STATUS status = statusPutFrame(frame);
25+
if (STATUS_FAILED(status)) {
26+
return false;
27+
}
28+
29+
return true;
30+
}
31+
32+
STATUS KinesisVideoStream::statusPutFrame(KinesisVideoFrame& frame) const {
2333
if (debug_dump_frame_info_) {
2434
LOG_DEBUG("[" << this->stream_name_ << "] pts: " << frame.presentationTs << ", dts: " << frame.decodingTs << ", duration: " << frame.duration << ", size: " << frame.size << ", trackId: " << frame.trackId
2535
<< ", isKey: " << CHECK_FRAME_FLAG_KEY_FRAME(frame.flags));

src/KinesisVideoStream.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ class KinesisVideoStream {
6060
* @param frame The frame to be packaged and streamed.
6161
* @return true if the encoder accepted the frame and false otherwise.
6262
*/
63-
STATUS putFrame(KinesisVideoFrame& frame) const;
63+
bool putFrame(KinesisVideoFrame& frame) const;
64+
65+
/**
66+
* Does putFrame, but returns a STATUS rather than a failure/success bool.
67+
*
68+
* @param frame The frame to be packaged and streamed.
69+
* @return STATUS of the putKinesisVideoFrame call.
70+
*/
71+
STATUS statusPutFrame(KinesisVideoFrame& frame) const;
6472

6573
/**
6674
* Gets the stream metrics.

src/common/PutFrameHelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PutFrameHelper::PutFrameHelper(
2121
}
2222

2323
void PutFrameHelper::putFrameMultiTrack(Frame frame, bool isVideo) {
24-
if (!kinesis_video_stream->putFrame(frame)) {
24+
if (kinesis_video_stream->statusPutFrame(frame) != STATUS_SUCCESS) {
2525
put_frame_status = false;
2626
LOG_WARN("Failed to put normal frame");
2727
}
@@ -46,7 +46,7 @@ bool PutFrameHelper::putFrameFailed() {
4646

4747
void PutFrameHelper::putEofr() {
4848
Frame frame = EOFR_FRAME_INITIALIZER;
49-
if (!kinesis_video_stream->putFrame(frame)) {
49+
if (kinesis_video_stream->statusPutFrame(frame) != STATUS_SUCCESS) {
5050
put_frame_status = false;
5151
LOG_WARN("Failed to put eofr frame");
5252
}

src/gstreamer/gstkvssink.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,9 @@ put_frame(std::shared_ptr<KvsSinkCustomData> data, void *frame_data, size_t len,
12511251
Frame frame;
12521252

12531253
create_kinesis_video_frame(&frame, pts, dts, flags, frame_data, len, track_id, index);
1254-
put_frame_status = data->kinesis_video_stream->putFrame(frame);
1255-
if(data->get_metrics && STATUS_SUCCEEDED(put_frame_status)) {
1256-
if(CHECK_FRAME_FLAG_KEY_FRAME(flags) || data->on_first_frame){
1254+
put_frame_status = data->kinesis_video_stream->statusPutFrame(frame);
1255+
if (data->get_metrics && STATUS_SUCCEEDED(put_frame_status)) {
1256+
if (CHECK_FRAME_FLAG_KEY_FRAME(flags) || data->on_first_frame) {
12571257
KvsSinkMetric *kvs_sink_metric = new KvsSinkMetric();
12581258
kvs_sink_metric->stream_metrics = data->kinesis_video_stream->getMetrics();
12591259
kvs_sink_metric->client_metrics = data->kinesis_video_producer->getMetrics();

tst/ProducerApiTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ PVOID ProducerTestBase::basicProducerRoutine(KinesisVideoStream* kinesis_video_s
114114
// Simulate EoFr first
115115
if (frame.index % 50 == 0 && frame.index != 0) {
116116
Frame eofr = EOFR_FRAME_INITIALIZER;
117-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(eofr));
117+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(eofr));
118118
}
119119
#endif
120120

121-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
121+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
122122

123123
// Sleep a while for non-offline modes
124124
if (streaming_type != STREAMING_TYPE_OFFLINE) {
@@ -308,7 +308,7 @@ TEST_F(ProducerApiTest, create_produce_start_stop_stream)
308308
<< ", Dts: " << frame.decodingTs
309309
<< ", Pts: " << frame.presentationTs);
310310

311-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
311+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
312312

313313
THREAD_SLEEP(frame_duration_);
314314
}
@@ -374,7 +374,7 @@ TEST_F(ProducerApiTest, create_produce_start_stop_stream_endpoint_cached)
374374
<< ", Dts: " << frame.decodingTs
375375
<< ", Pts: " << frame.presentationTs);
376376

377-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
377+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
378378

379379
THREAD_SLEEP(frame_duration_);
380380
}
@@ -440,7 +440,7 @@ TEST_F(ProducerApiTest, create_produce_start_stop_stream_all_cached)
440440
<< ", Dts: " << frame.decodingTs
441441
<< ", Pts: " << frame.presentationTs);
442442

443-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
443+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
444444

445445
THREAD_SLEEP(frame_duration_);
446446
}
@@ -506,7 +506,7 @@ TEST_F(ProducerApiTest, create_produce_start_stop_reset_stream_endpoint_cached)
506506
<< ", Dts: " << frame.decodingTs
507507
<< ", Pts: " << frame.presentationTs);
508508

509-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
509+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
510510

511511
THREAD_SLEEP(frame_duration_);
512512
}
@@ -574,7 +574,7 @@ TEST_F(ProducerApiTest, create_produce_start_stop_reset_stream_all_cached)
574574
<< ", Dts: " << frame.decodingTs
575575
<< ", Pts: " << frame.presentationTs);
576576

577-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
577+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
578578

579579
THREAD_SLEEP(frame_duration_);
580580
}

tst/ProducerFunctionalityTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ TEST_F(ProducerFunctionalityTest, offline_upload_limited_buffer_duration) {
6868
<< ", Dts: " << frame.decodingTs
6969
<< ", Pts: " << frame.presentationTs);
7070

71-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
71+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
7272
timestamp += frame_duration_;
7373
}
7474

@@ -127,7 +127,7 @@ TEST_F(ProducerFunctionalityTest, offline_upload_limited_storage) {
127127
<< ", Dts: " << frame.decodingTs
128128
<< ", Pts: " << frame.presentationTs);
129129

130-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
130+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
131131
timestamp += frame_duration_;
132132
}
133133

@@ -192,7 +192,7 @@ TEST_F(ProducerFunctionalityTest, intermittent_file_upload) {
192192
<< ", Dts: " << frame.decodingTs
193193
<< ", Pts: " << frame.presentationTs);
194194

195-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
195+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
196196
timestamp += frame_duration_;
197197

198198
// pause at the last frame of each clip
@@ -257,7 +257,7 @@ TEST_F(ProducerFunctionalityTest, high_fragment_rate_file_upload) {
257257
<< ", Dts: " << frame.decodingTs
258258
<< ", Pts: " << frame.presentationTs);
259259

260-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
260+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
261261
timestamp += frame_duration_;
262262
}
263263

@@ -316,7 +316,7 @@ TEST_F(ProducerFunctionalityTest, offline_mode_token_rotation_block_on_space) {
316316
<< ", Dts: " << frame.decodingTs
317317
<< ", Pts: " << frame.presentationTs);
318318

319-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
319+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
320320
timestamp += frame_duration_;
321321
}
322322

@@ -376,7 +376,7 @@ TEST_F(ProducerFunctionalityTest, realtime_intermittent_no_latency_pressure_eofr
376376

377377
// Pause on the 5th
378378
if (i == 5 * key_frame_interval_) {
379-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(eofr));
379+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(eofr));
380380

381381
// Make sure we hit the connection idle timeout
382382
THREAD_SLEEP(60 * HUNDREDS_OF_NANOS_IN_A_SECOND);
@@ -398,7 +398,7 @@ TEST_F(ProducerFunctionalityTest, realtime_intermittent_no_latency_pressure_eofr
398398
<< ", Dts: " << frame.decodingTs
399399
<< ", Pts: " << frame.presentationTs);
400400

401-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
401+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
402402
timestamp += frame_duration_;
403403

404404
THREAD_SLEEP(30 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND);
@@ -483,7 +483,7 @@ TEST_F(ProducerFunctionalityTest, DISABLED_realtime_intermittent_no_latency_pres
483483
<< ", Dts: " << frame.decodingTs
484484
<< ", Pts: " << frame.presentationTs);
485485

486-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
486+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
487487
timestamp += frame_duration_;
488488

489489
THREAD_SLEEP(30 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND);
@@ -579,7 +579,7 @@ TEST_F(ProducerFunctionalityTest, realtime_intermittent_latency_pressure) {
579579
<< ", Dts: " << frame.decodingTs
580580
<< ", Pts: " << frame.presentationTs);
581581

582-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
582+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
583583

584584
THREAD_SLEEP(frame_duration_);
585585
}
@@ -664,7 +664,7 @@ TEST_F(ProducerFunctionalityTest, realtime_auto_intermittent_latency_pressure) {
664664
<< ", Dts: " << frame.decodingTs
665665
<< ", Pts: " << frame.presentationTs);
666666

667-
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->putFrame(frame));
667+
EXPECT_EQ(STATUS_SUCCESS, kinesis_video_stream->statusPutFrame(frame));
668668

669669
THREAD_SLEEP(frame_duration_);
670670
}

0 commit comments

Comments
 (0)