diff --git a/cpp/libs/ossrf_gstreamer_api/lib/src/receiver/st2110_20_receiver_plugin.cpp b/cpp/libs/ossrf_gstreamer_api/lib/src/receiver/st2110_20_receiver_plugin.cpp index f74c2d6..6044305 100644 --- a/cpp/libs/ossrf_gstreamer_api/lib/src/receiver/st2110_20_receiver_plugin.cpp +++ b/cpp/libs/ossrf_gstreamer_api/lib/src/receiver/st2110_20_receiver_plugin.cpp @@ -21,6 +21,13 @@ using namespace bisect; using namespace ossrf::gst::receiver; using namespace ossrf::gst::plugins; +namespace +{ + constexpr auto queue_max_size_time = 200000; + constexpr auto queue_max_size_buffers = 0; + constexpr auto queue_max_size_bytes = 0; +}; // namespace + struct gst_st2110_20_receiver_impl : gst_receiver_plugin_t { receiver_settings s_; @@ -41,11 +48,13 @@ struct gst_st2110_20_receiver_impl : gst_receiver_plugin_t auto* source = gst_element_factory_make("udpsrc", NULL); BST_ENFORCE(source != nullptr, "Failed creating GStreamer element udpsrc"); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), source), "Failed adding udpsrc to the pipeline"); + // Set udp source params g_object_set(G_OBJECT(source), "address", s_.primary.source_ip_address.c_str(), NULL); g_object_set(G_OBJECT(source), "auto-multicast", TRUE, NULL); g_object_set(G_OBJECT(source), "port", s_.primary.source_port, NULL); g_object_set(G_OBJECT(source), "multicast-iface", s_.primary.interface_name.c_str(), NULL); + // Create and set caps for udp source GstCaps* caps = gst_caps_from_string( "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, " @@ -61,12 +70,21 @@ struct gst_st2110_20_receiver_impl : gst_receiver_plugin_t auto* queue1 = gst_element_factory_make("queue", NULL); BST_ENFORCE(queue1 != nullptr, "Failed creating GStreamer element queue"); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), queue1), "Failed adding queue to the pipeline"); + g_object_set(G_OBJECT(queue1), "max-size-time", queue_max_size_time, "max-size-buffers", queue_max_size_buffers, + "max-size-bytes", queue_max_size_bytes, NULL); // Add pipeline rtp depay auto* depay = gst_element_factory_make("rtpvrawdepay", NULL); BST_ENFORCE(depay != nullptr, "Failed creating GStreamer element depay"); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), depay), "Failed adding depay to the pipeline"); + // Add pipeline queue2 + auto* queue2 = gst_element_factory_make("queue", NULL); + BST_ENFORCE(queue2 != nullptr, "Failed creating GStreamer element queue"); + BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), queue2), "Failed adding queue to the pipeline"); + g_object_set(G_OBJECT(queue1), "max-size-time", queue_max_size_time, "max-size-buffers", queue_max_size_buffers, + "max-size-bytes", queue_max_size_bytes, NULL); + // Add pipeline videoconvert auto* videoconvert = gst_element_factory_make("videoconvert", NULL); BST_ENFORCE(videoconvert != nullptr, "Failed creating GStreamer element converter"); @@ -77,8 +95,8 @@ struct gst_st2110_20_receiver_impl : gst_receiver_plugin_t BST_ENFORCE(sink != nullptr, "Failed creating GStreamer element sink"); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), sink), "Failed adding sink to the pipeline"); - // Link elements - BST_ENFORCE(gst_element_link_many(source, jitter_buffer, queue1, depay, videoconvert, sink, NULL), + // Link all elements together + BST_ENFORCE(gst_element_link_many(source, queue1, depay, queue2, videoconvert, sink, NULL), "Failed linking GStreamer video pipeline"); // Setup runner @@ -103,4 +121,4 @@ expected ossrf::gst::plugins::create_gst_st2110_20_plu BST_CHECK(i->create_gstreamer_pipeline()); return i; -} \ No newline at end of file +} diff --git a/cpp/libs/ossrf_gstreamer_api/lib/src/sender/st2110_20_sender_plugin.cpp b/cpp/libs/ossrf_gstreamer_api/lib/src/sender/st2110_20_sender_plugin.cpp index 13d6a96..f7b4801 100644 --- a/cpp/libs/ossrf_gstreamer_api/lib/src/sender/st2110_20_sender_plugin.cpp +++ b/cpp/libs/ossrf_gstreamer_api/lib/src/sender/st2110_20_sender_plugin.cpp @@ -21,6 +21,13 @@ using namespace bisect; using namespace ossrf::gst::sender; using namespace ossrf::gst::plugins; +namespace +{ + constexpr auto queue_max_size_time = 200000; + constexpr auto queue_max_size_buffers = 0; + constexpr auto queue_max_size_bytes = 0; +}; // namespace + struct gst_st2110_20_sender_impl : gst_sender_plugin_t { sender_settings s_; @@ -58,6 +65,8 @@ struct gst_st2110_20_sender_impl : gst_sender_plugin_t // Add pipeline queue1 auto* queue1 = gst_element_factory_make("queue", NULL); BST_ENFORCE(queue1 != nullptr, "Failed creating GStreamer element queue"); + g_object_set(G_OBJECT(queue1), "max-size-time", queue_max_size_time, "max-size-buffers", queue_max_size_buffers, + "max-size-bytes", queue_max_size_bytes, NULL); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), queue1), "Failed adding queue to the pipeline"); // Add pipeline rtpvrawpay @@ -65,11 +74,6 @@ struct gst_st2110_20_sender_impl : gst_sender_plugin_t BST_ENFORCE(rtpvrawpay != nullptr, "Failed creating GStreamer element rtpvrawpay"); BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), rtpvrawpay), "Failed adding rtpvrawpay to the pipeline"); - // Add pipeline queue2 - auto* queue2 = gst_element_factory_make("queue", NULL); - BST_ENFORCE(queue2 != nullptr, "Failed creating GStreamer element queue"); - BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), queue2), "Failed adding queue to the pipeline"); - // Add pipeline udpsink auto* udpsink = gst_element_factory_make("udpsink", NULL); BST_ENFORCE(udpsink != nullptr, "Failed creating GStreamer element udpsink"); @@ -81,7 +85,7 @@ struct gst_st2110_20_sender_impl : gst_sender_plugin_t BST_ENFORCE(gst_bin_add(GST_BIN(pipeline), udpsink), "Failed adding udpsink to the pipeline"); // Link elements - BST_ENFORCE(gst_element_link_many(source, capsfilter, queue1, rtpvrawpay, queue2, udpsink, NULL), + BST_ENFORCE(gst_element_link_many(source, capsfilter, queue1, rtpvrawpay, udpsink, NULL), "Failed linking GStreamer video pipeline"); // Setup runner @@ -105,4 +109,4 @@ ossrf::gst::plugins::create_gst_st2110_20_plugin(sender_settings settings, video BST_CHECK(i->create_gstreamer_pipeline(pattern)); return i; -} \ No newline at end of file +}