diff --git a/CMakeLists.txt b/CMakeLists.txt index ade4442..9bc0b61 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(gstreamer-rtsp-ssl-example LANGUAGES C) +project(rtsp_server LANGUAGES C) find_package(PkgConfig REQUIRED) pkg_check_modules(GSTLIBS REQUIRED @@ -15,7 +15,7 @@ pkg_check_modules(GSTREAMER REQUIRED gstreamer-rtsp-server-1.0) include_directories(${GSTREAMER_INCLUDE_DIRS}) -link_directories(${GSTREAMER_LIBRARIES}) +link_directories(${GSTREAMER_LIBRARY_DIRS}) # Update the source file path add_executable(rtsp_server src/rtsp_server.c) diff --git a/README.md b/README.md index b28e9c2..404c55e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RTSP Server A lightweight **RTSP (Real Time Streaming Protocol) server** written in **C** using **GStreamer** and **libgstrtspserver**. -This project demonstrates how to set up a simple video streaming service that clients like VLC or FFplay can connect for redering the video. +This project demonstrates how to set up a simple video streaming service that clients like VLC or FFplay can connect to for rendering video. **Note** The pipeline currently supports video file only but can easily be updated to add audio plugin elements. --- @@ -108,13 +108,14 @@ cmake -DCMAKE_INSTALL_PREFIX=/opt/rtsp .. ### 🧰 Option 2: Build Using Makefile -For a simple build using the provided `Makefile`, run: +For a simple build using the provided `src/Makefile`, run: ```bash +cd src make ``` -This generates the `rtsp_server` binary in the same directory. +This generates the `rtsp_server` binary in the `src/` directory. To clean up: ```bash diff --git a/src/rtsp_server.c b/src/rtsp_server.c index 6b6c7f8..23fc3e9 100644 --- a/src/rtsp_server.c +++ b/src/rtsp_server.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -44,6 +45,11 @@ int main(int argc, char *argv[]) { return -1; } + if (!g_file_test(argv[1], G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + g_printerr("Error: '%s' is not a readable file.\n", argv[1]); + return -1; + } + GMainLoop *loop; GstRTSPServer *server; GstRTSPMountPoints *mounts; @@ -59,11 +65,13 @@ int main(int argc, char *argv[]) { mounts = gst_rtsp_server_get_mount_points(server); factory = gst_rtsp_media_factory_new(); + gchar *escaped_filepath = g_strescape(filepath, NULL); gchar *pipeline_str = g_strdup_printf( - "( filesrc location=%s ! qtdemux name=demux " + "( filesrc location=\"%s\" ! qtdemux name=demux " "demux.video_0 ! queue ! avdec_h264 ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96 )", - filepath); + escaped_filepath); gst_rtsp_media_factory_set_launch(factory, pipeline_str); + g_free(escaped_filepath); g_free(pipeline_str); gst_rtsp_media_factory_set_shared(factory, TRUE); @@ -78,4 +86,3 @@ int main(int argc, char *argv[]) { g_main_loop_run(loop); return 0; } -