@@ -53,6 +53,14 @@ void sigint_handler(int sigint) {
5353 }
5454}
5555
56+ bool check_element (GstElement* element, const char * name) {
57+ if (!element) {
58+ LOG_ERROR (" [KVS sample] Failed to create element: " << name);
59+ return false ;
60+ }
61+ return true ;
62+ }
63+
5664static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) {
5765 GMainLoop *loop = (GMainLoop *) ((CustomData *)data)->main_loop ;
5866 GstElement *pipeline = (GstElement *) ((CustomData *)data)->pipeline ;
@@ -280,17 +288,17 @@ int main(int argc, char *argv[]) {
280288
281289
282290 /* Check that GStreamer elements were all successfully created */
283-
284- if (!kvssink) {
285- LOG_ERROR (" [KVS sample] Failed to create kvssink element" );
291+ if (!check_element (pipeline, " pipeline" ) ||
292+ !check_element (source, " source" ) ||
293+ !check_element (clock_overlay, " clock_overlay" ) ||
294+ !check_element (video_convert, " video_convert" ) ||
295+ !check_element (source_filter, " source_filter" ) ||
296+ !check_element (encoder, " encoder" ) ||
297+ !check_element (sink_filter, " sink_filter" ) ||
298+ !check_element (kvssink, " kvssink" )) {
286299 return -1 ;
287300 }
288-
289- if (!pipeline || !source || !clock_overlay || !video_convert || !source_filter || !encoder || !sink_filter) {
290- LOG_ERROR (" [KVS sample] Not all GStreamer elements could be created." );
291- return -1 ;
292- }
293-
301+
294302 // Populate data struct.
295303 customData.main_loop = main_loop;
296304 customData.pipeline = pipeline;
0 commit comments