Skip to content

Commit 0cb572f

Browse files
authored
fix(sample): move putEventMetadata after putFrame (#1019)
1 parent e99e7e9 commit 0cb572f

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

samples/kvs_gstreamer_sample.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,13 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
401401
if (!gst_buffer_map(buffer, &info, GST_MAP_READ)){
402402
goto CleanUp;
403403
}
404-
if (CHECK_FRAME_FLAG_KEY_FRAME(kinesis_video_flags)) {
405-
data->kinesis_video_stream->putEventMetadata(STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
406-
}
407404

408405
put_frame(data->kinesis_video_stream, info.data, info.size, std::chrono::nanoseconds(buffer->pts),
409406
std::chrono::nanoseconds(buffer->dts), kinesis_video_flags);
407+
408+
if (CHECK_FRAME_FLAG_KEY_FRAME(kinesis_video_flags)) {
409+
data->kinesis_video_stream->putEventMetadata(STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
410+
}
410411
}
411412

412413
CleanUp:

src/KinesisVideoStream.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool KinesisVideoStream::start(const std::string& hexEncodedCodecPrivateData, ui
6666
STATUS status;
6767

6868
if (STATUS_FAILED(status = hexDecode((PCHAR) pStrCpd, 0, NULL, &size))) {
69-
LOG_ERROR("Failed to get the size of the buffer for hex decoding the codec private data with: " << status);
69+
LOG_ERROR("Failed to get the size of the buffer for hex decoding the codec private data with: 0x" << std::hex << status);
7070
return false;
7171
}
7272

@@ -78,7 +78,7 @@ bool KinesisVideoStream::start(const std::string& hexEncodedCodecPrivateData, ui
7878
}
7979

8080
if (STATUS_FAILED(status = hexDecode((PCHAR) pStrCpd, 0, pBuffer, &size))) {
81-
LOG_ERROR("Failed to hex decode the codec private data with: " << status);
81+
LOG_ERROR("Failed to hex decode the codec private data with: 0x" << std::hex << status);
8282
::free(pBuffer);
8383
return false;
8484
}
@@ -97,7 +97,7 @@ bool KinesisVideoStream::start(const unsigned char* codecPrivateData, size_t cod
9797

9898
if (STATUS_FAILED(status = kinesisVideoStreamFormatChanged(stream_handle_, (UINT32) codecPrivateDataSize,
9999
(PBYTE) codecPrivateData, (UINT64) trackId))) {
100-
LOG_ERROR("Failed to set the codec private data with: " << status);
100+
LOG_ERROR("Failed to set the codec private data with: 0x" << std::hex << status);
101101
return false;
102102
}
103103

@@ -115,7 +115,7 @@ bool KinesisVideoStream::resetConnection() {
115115
STATUS status = STATUS_SUCCESS;
116116

117117
if (STATUS_FAILED(status = kinesisVideoStreamResetConnection(stream_handle_))) {
118-
LOG_ERROR("Failed to reset the connection with: " << status);
118+
LOG_ERROR("Failed to reset the connection with: 0x" << std::hex << status);
119119
return false;
120120
}
121121

@@ -126,7 +126,7 @@ bool KinesisVideoStream::resetStream() {
126126
STATUS status = STATUS_SUCCESS;
127127

128128
if (STATUS_FAILED(status = kinesisVideoStreamResetStream(stream_handle_))) {
129-
LOG_ERROR("Failed to reset the stream with: " << status);
129+
LOG_ERROR("Failed to reset the stream with: 0x" << std::hex << status);
130130
return false;
131131
}
132132

@@ -144,7 +144,7 @@ bool KinesisVideoStream::stop() {
144144
STATUS status;
145145

146146
if (STATUS_FAILED(status = stopKinesisVideoStream(stream_handle_))) {
147-
LOG_ERROR("Failed to stop the stream with: " << status);
147+
LOG_ERROR("Failed to stop the stream with: 0x" << std::hex << status);
148148
return false;
149149
}
150150

@@ -155,7 +155,7 @@ bool KinesisVideoStream::stopSync() {
155155
STATUS status;
156156

157157
if (STATUS_FAILED(status = stopKinesisVideoStreamSync(stream_handle_))) {
158-
LOG_ERROR("Failed to stop the stream with: " << status);
158+
LOG_ERROR("Failed to stop the stream with: 0x" << std::hex << status);
159159
return false;
160160
}
161161

@@ -164,31 +164,31 @@ bool KinesisVideoStream::stopSync() {
164164

165165
KinesisVideoStreamMetrics KinesisVideoStream::getMetrics() const {
166166
STATUS status = ::getKinesisVideoStreamMetrics(stream_handle_, (PStreamMetrics) stream_metrics_.getRawMetrics());
167-
LOG_AND_THROW_IF(STATUS_FAILED(status), "Failed to get stream metrics with: " << status);
167+
LOG_AND_THROW_IF(STATUS_FAILED(status), "Failed to get stream metrics with: 0x" << std::hex << status);
168168

169169
return stream_metrics_;
170170
}
171171

172-
bool KinesisVideoStream::putFragmentMetadata(const std::string &name, const std::string &value, bool persistent){
172+
bool KinesisVideoStream::putFragmentMetadata(const std::string &name, const std::string &value, bool persistent) {
173173
const char* pMetadataName = name.c_str();
174174
const char* pMetadataValue = value.c_str();
175175
STATUS status = ::putKinesisVideoFragmentMetadata(stream_handle_, (PCHAR) pMetadataName, (PCHAR) pMetadataValue, persistent);
176176
if (STATUS_FAILED(status)) {
177-
LOG_ERROR("Failed to insert fragment metadata with: " << status);
177+
LOG_ERROR("Failed to insert fragment metadata with: 0x" << std::hex << status);
178178
return false;
179179
}
180180

181181
return true;
182182
}
183183

184-
bool KinesisVideoStream::putEventMetadata(uint32_t event, PStreamEventMetadata pStreamEventMetadata)
185-
{
186-
184+
bool KinesisVideoStream::putEventMetadata(uint32_t event, PStreamEventMetadata pStreamEventMetadata) {
187185
STATUS status = ::putKinesisVideoEventMetadata(stream_handle_, event, pStreamEventMetadata);
186+
188187
if (STATUS_FAILED(status)) {
189-
LOG_ERROR("Failed to insert event metadata with: " << status);
188+
LOG_ERROR("Failed to insert event metadata with: 0x" << std::hex << status);
190189
return false;
191190
}
191+
192192
return true;
193193
}
194194

0 commit comments

Comments
 (0)