Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rtsp_rebroadcast.cpp removed hard coded IP and made it an argu… #26

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions rtsp-rebroadcast/rtsp_rebroadcast.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include <string>
#include <iostream>

// RTSP re-broadcast using gstreamer.
//
Expand All @@ -11,10 +12,15 @@
// https://github.com/JonasVautherin/px4-gazebo-headless/tree/master/sitl_rtsp_proxy

int main(int argc, char* argv[]) {
gst_init(&argc, &argv);
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <ip_address>" << std::endl;
return 1;
}

GMainLoop* main_loop = g_main_loop_new(NULL, false);
std::string ip_address = argv[1];

gst_init(&argc, &argv);
GMainLoop* main_loop = g_main_loop_new(NULL, false);
if (!gst_debug_is_active()) {
gst_debug_set_active(TRUE);
gst_debug_set_default_threshold(GST_LEVEL_WARNING);
Expand All @@ -23,20 +29,18 @@ int main(int argc, char* argv[]) {
GstRTSPServer* server = gst_rtsp_server_new();
g_object_set(server, "service", "8554", NULL);

static constexpr auto launch_string =
"rtspsrc location=rtsp://192.168.144.25:8554/main.264 latency=0 "
"! rtph265depay "
"! rtph265pay name=pay0 pt=96";
std::string launch_string = "rtspsrc location=rtsp://" + ip_address + ":8554/live latency=0 ! rtph264depay ! rtph264pay name=pay0 pt=96 mtu=1380";

GstRTSPMediaFactory* factory = gst_rtsp_media_factory_new();
gst_rtsp_media_factory_set_launch(factory, launch_string);
gst_rtsp_media_factory_set_launch(factory, launch_string.c_str());
gst_rtsp_media_factory_set_shared(factory, true);

GstRTSPMountPoints* mount_points = gst_rtsp_server_get_mount_points(server);
gst_rtsp_mount_points_add_factory(mount_points, "/live", factory);
g_object_unref(mount_points);

gst_rtsp_server_attach(server, NULL);

g_main_loop_run(main_loop);

return 0;
}
Loading