diff --git a/src/pipeline_manager.cpp b/src/pipeline_manager.cpp index 4f51686..e049fdf 100644 --- a/src/pipeline_manager.cpp +++ b/src/pipeline_manager.cpp @@ -16,9 +16,8 @@ std::chrono::time_point PipelineManager::PipelineManager() { ; } PipelineManager::PipelineManager(int num_sources, char** url_camera) -: csv_fp("csv_fps.csv") - { - if (!csv_fp.is_open()) { + : csv_fp("csv_fps.csv") { + if (!csv_fp.is_open()) { std::cerr << "Failed to open csv_fp csv file.\n"; throw std::runtime_error("Failed to open csv_fps_buffer_probe.csv"); } @@ -69,18 +68,16 @@ char* createName(const char* str, int num) { return result; } -void PipelineManager::set_row_csv_fps(const std::string& name, double fps){ +void PipelineManager::set_row_csv_fps(const std::string& name, double fps) { if (!csv_fp.is_open()) { std::cerr << "Failed to write: stream not open for " << name << "\n"; return; - } - else{ + } else { csv_fp << name << "," << fps << "\n"; std::cout << "Wrote: " << name << " = " << fps << "\n"; - } + } } - GstPadProbeReturn PipelineManager::osd_sink_pad_buffer_probe( GstPad* pad, GstPadProbeInfo* info, gpointer user_data) { (void)pad; // This explicitly marks it as unused @@ -166,7 +163,8 @@ GstPadProbeReturn PipelineManager::buffer_probe(GstPad* pad, long long elapsed = std::chrono::duration_cast( current_time_buffer_probe - last_time_buffer_probe) .count(); - fps_buffer_probe = (double)(frame_count_buffer_probe * 1000 / (double)elapsed); + fps_buffer_probe = + (double)(frame_count_buffer_probe * 1000 / (double)elapsed); if (elapsed >= 1000) { // Update every second g_print("FPS_buffer_probe: %.2f\n", fps_buffer_probe); frame_count_buffer_probe = 0; @@ -201,7 +199,7 @@ bool PipelineManager::playing_pipeline(int num_sources, char** url_camera) { gst_element_set_state(pipeline, GST_STATE_PLAYING); GstStateChangeReturn ret = gst_element_set_state(pipeline, GST_STATE_PLAYING); - if(ret == GST_STATE_CHANGE_FAILURE) { + if (ret == GST_STATE_CHANGE_FAILURE) { g_printerr("Unable to set pipeline to playing.\n"); gst_object_unref(pipeline); return false; @@ -316,11 +314,11 @@ bool PipelineManager::create_pipeline_elements(int num_sources, for (guint i = 0; i < (guint)num_sources; i++) { GstElement* source_bin; - // GstElement *source_bin = create_uridecode_bin (i, + // GstElement *source_bin = create_nvurisrc_bin (i, // const_cast(first_video.c_str())); - g_print("Trying to create uridecode_bin for %s \n", url_camera[i + 1]); + g_print("Trying to create nvurisrc_bin for %s \n", url_camera[i + 1]); - source_bin = SourceBin::create_uridecode_bin( + source_bin = SourceBin::create_nvurisrc_bin( i, url_camera[i + 1], streammux_manager->streammux, prop); if (!source_bin) { g_printerr("Failed to create source bin for %s. Exiting.\n", diff --git a/src/source_bin.cpp b/src/source_bin.cpp index 99207e0..b21becf 100644 --- a/src/source_bin.cpp +++ b/src/source_bin.cpp @@ -86,20 +86,20 @@ void SourceBin::cb_newpad(GstElement *decodebin, GstPad *pad, } // Definition of static function -GstElement *SourceBin::create_uridecode_bin(guint index, gchar *filename, - GstElement *streammux, - cudaDeviceProp prop) { +GstElement *SourceBin::create_nvurisrc_bin(guint index, gchar *filename, + GstElement *streammux, + cudaDeviceProp prop) { GstElement *decodebin = NULL; gchar decodebin_name[16] = {}; // Create data structure for callbacks StreamData *stream_data = new StreamData{(int)index, streammux, prop}; - // g_print ("creating uridecodebin for [%s]\n", filename); - g_print("Creating uridecodebin for stream_id %d or stream %s \n", index, + // g_print ("creating nvurisrcbin for [%s]\n", filename); + g_print("Creating nvurisrcbin for stream_id %d or stream %s \n", index, filename); // g_source_id_list[index] = index; g_snprintf(decodebin_name, 15, "source-bin-%02d", index); - decodebin = gst_element_factory_make("uridecodebin", decodebin_name); + decodebin = gst_element_factory_make("nvurisrcbin", decodebin_name); g_object_set(G_OBJECT(decodebin), "uri", filename, NULL); g_signal_connect(G_OBJECT(decodebin), "pad-added", G_CALLBACK(cb_newpad), stream_data); //&g_source_id_list[index] diff --git a/src/source_bin.hpp b/src/source_bin.hpp index 76876b0..ca4052e 100644 --- a/src/source_bin.hpp +++ b/src/source_bin.hpp @@ -21,8 +21,8 @@ class SourceBin { static void decodebin_child_added(GstChildProxy *, GObject *, gchar *, gpointer); static void cb_newpad(GstElement *, GstPad *, gpointer, gboolean *); - static GstElement *create_uridecode_bin(guint, gchar *, GstElement *, - cudaDeviceProp prop); + static GstElement *create_nvurisrc_bin(guint, gchar *, GstElement *, + cudaDeviceProp prop); private: // Static data member (if needed)