### Build and Run SmolRTSP Example Server Source: https://github.com/openipc/smolrtsp/blob/master/README.md Compile and run the example server. This requires CMake and a build directory. The server can be accessed using ffplay. ```bash $ mkdir examples/build $ cd examples/build $ cmake .. && cmake --build . $ sudo ./server ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Initializes the CMake project, specifying the minimum required version and the programming language. ```cmake cmake_minimum_required(VERSION 3.16) project(examples LANGUAGES C) ``` -------------------------------- ### Linking Libraries and Include Directories Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Links the 'server' executable against necessary libraries (smolrtsp, smolrtsp-libevent, LibEvent) and sets include directories. ```cmake target_link_libraries(server smolrtsp smolrtsp-libevent ${LIBEVENT_LIBRARIES}) target_include_directories(server PRIVATE ${LIBEVENT_INCLUDE_DIR}) ``` -------------------------------- ### Play RTSP Stream with ffplay Source: https://github.com/openipc/smolrtsp/blob/master/README.md Connect to the running SmolRTSP server using ffplay to play the stream. Ensure the server is accessible at localhost. ```bash $ ffplay rtsp://localhost ``` -------------------------------- ### Full Macro Expansion Option Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Configures a build option to enable showing full macro expansion backtraces. Defaults to OFF. ```cmake option(SMOLRTSP_FULL_MACRO_EXPANSION "Show full macro expansion backtraces" OFF) ``` -------------------------------- ### Embed Media Assets (xxd) Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Uses the 'xxd' command to convert media files into C header files for embedding into the executable. ```cmake execute_process(COMMAND xxd -i ../media/audio.g711a ../media/audio.g711a.h) execute_process(COMMAND xxd -i ../media/video.h264 ../media/video.h264.h) ``` -------------------------------- ### FetchContent for SmolRTSP in CMake Source: https://github.com/openipc/smolrtsp/blob/master/README.md Integrate SmolRTSP into your CMake project using FetchContent. Ensure you specify the correct version tag. ```cmake include(FetchContent) FetchContent_Declare( smolrtsp URL https://github.com/OpenIPC/smolrtsp/archive/refs/tags/v1.2.3.tar.gz # v1.2.3 ) FetchContent_MakeAvailable(smolrtsp) target_link_libraries(MyProject smolrtsp) ``` -------------------------------- ### Linker Options Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Applies linker options, such as the address sanitizer, to the 'server' target. ```cmake target_link_options(server PRIVATE -fsanitize=address) ``` -------------------------------- ### Include Build Subdirectory Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Includes the build subdirectory, likely containing common build configurations or targets. ```cmake add_subdirectory(.. build) ``` -------------------------------- ### FetchContent for Smolrtsp-libevent Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Declares and makes available the smolrtsp-libevent dependency using FetchContent from a Git repository. ```cmake include(FetchContent) FetchContent_Declare( smolrtsp-libevent GIT_REPOSITORY https://github.com/OpenIPC/smolrtsp-libevent.git GIT_TAG 369b1a38688122521552dee6023fcbdb9cf6aa6b ) FetchContent_MakeAvailable(smolrtsp-libevent) ``` -------------------------------- ### C Standard Version Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Sets the C standard to C99 for the 'server' target, ensuring compliance with modern C features. ```cmake set_target_properties(server PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED ON) ``` -------------------------------- ### Executable Target Definition Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Defines the main executable target named 'server' and specifies its source file. ```cmake add_executable(server server.c) ``` -------------------------------- ### Conditionally Embed Media Assets (xxd) Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Conditionally embeds additional media files (JPEG XS, AV1, VVC) using 'xxd' if their respective options are enabled. ```cmake if(ENABLE_JPEGXS) execute_process(COMMAND xxd -i ../media/video.jxs ../media/video.jxs.h) endif() if(ENABLE_AV1) execute_process(COMMAND xxd -i ../media/video.av1 ../media/video.av1.h) endif() if(ENABLE_VVC) execute_process(COMMAND xxd -i ../media/video.h266 ../media/video.h266.h) endif() ``` -------------------------------- ### Set C Standard Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Configures the C standard for the project target to C99 and enforces it as the required standard. ```cmake set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED ON) ``` -------------------------------- ### Per-Codec Compile-Time Knobs Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Defines compile-time options for individual codecs. All options default to ON to maintain existing behavior. Downstream projects can disable unused codecs to reduce binary size. ```cmake # Per-codec compile-time knobs. All default ON to preserve existing behaviour; # downstream projects can switch off whatever the deployed hardware can't # produce/consume to shrink the binary. At least one of the NAL codecs ``` -------------------------------- ### Project Definition Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Defines the project name and the programming languages it uses. Here, the project is named 'smolrtsp' and uses the C language. ```cmake project(smolrtsp LANGUAGES C) ``` -------------------------------- ### Build Shared Library Option Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Configures a build option to control whether a shared library is built. Defaults to OFF. ```cmake option(SMOLRTSP_SHARED "Build a shared library" OFF) ``` -------------------------------- ### Feature Toggles (Options) Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Defines boolean options to enable or disable specific features like JPEG XS, AV1, or VVC demo streams. ```cmake option(ENABLE_JPEGXS "Advertise a JPEG XS demo stream (RFC 9134) in addition to H.264" OFF) option(ENABLE_AV1 "Advertise an AV1 demo stream (AOMedia AV1 RTP) in addition to H.264" OFF) option(ENABLE_VVC "Advertise an H.266 / VVC demo stream (RFC 9328) in addition to H.264" OFF) ``` -------------------------------- ### Precompile Headers Configuration Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Configures precompiled headers by listing essential header files and conditionally appending codec-specific NAL headers based on build flags. This is applied to the project target with PRIVATE scope. ```cmake set(SMOLRTSP_PCH include/smolrtsp/types/error.h include/smolrtsp/nal.h include/smolrtsp/writer.h include/smolrtsp/transport.h include/smolrtsp/droppable.h include/smolrtsp/controller.h include/smolrtsp/rtp_transport.h include/smolrtsp/util.h) if(SMOLRTSP_WITH_H264) list(APPEND SMOLRTSP_PCH include/smolrtsp/nal/h264.h) endif() if(SMOLRTSP_WITH_H265) list(APPEND SMOLRTSP_PCH include/smolrtsp/nal/h265.h) endif() if(SMOLRTSP_WITH_H266) list(APPEND SMOLRTSP_PCH include/smolrtsp/nal/h266.h) endif() target_precompile_headers(${PROJECT_NAME} PRIVATE ${SMOLRTSP_PCH}) ``` -------------------------------- ### Set Public Include Directories Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Sets the public include directory for the project target to 'include'. This makes the project's headers accessible to consumers. ```cmake target_include_directories(${PROJECT_NAME} PUBLIC include) ``` -------------------------------- ### Find and Require LibEvent Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Locates and requires the LibEvent library, which is a dependency for the project. ```cmake find_package(LibEvent REQUIRED) ``` -------------------------------- ### Module Path Configuration Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Appends a custom module path to CMAKE_MODULE_PATH, allowing CMake to find custom modules. ```cmake list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Specifies the minimum required version of CMake for the project. Ensures compatibility with required features. ```cmake cmake_minimum_required(VERSION 3.16) ``` -------------------------------- ### Conditional Compile Definitions Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Adds compile definitions to the 'server' target based on the enabled feature options (JPEGXS, AV1, VVC). ```cmake if(ENABLE_JPEGXS) target_compile_definitions(server PRIVATE ENABLE_JPEGXS) endif() if(ENABLE_AV1) target_compile_definitions(server PRIVATE ENABLE_AV1) endif() if(ENABLE_VVC) target_compile_definitions(server PRIVATE ENABLE_VVC) endif() ``` -------------------------------- ### Propagate Codec Definitions Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt This snippet iterates through supported codecs and propagates per-codec definitions to consumers using PUBLIC scope. This ensures that headers which also branch on these defines stay in sync. ```cmake foreach(_codec H264 H265 H266 AV1 JPEG JPEGXS) if(SMOLRTSP_WITH_${_codec}) target_compile_definitions(${PROJECT_NAME} PUBLIC SMOLRTSP_WITH_${_codec}) endif() endforeach() ``` -------------------------------- ### Conditional Compiler Options Source: https://github.com/openipc/smolrtsp/blob/master/examples/CMakeLists.txt Applies specific compiler options (warnings, address sanitizer) based on the C compiler ID (Clang or GNU). ```cmake if(CMAKE_C_COMPILER_ID STREQUAL "Clang") target_compile_options(server PRIVATE -Wall -Wextra -fsanitize=address) elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") target_compile_options(server PRIVATE -Wall -Wextra -fsanitize=address -Wno-misleading-indentation) endif() ``` -------------------------------- ### CMake Policy for Download Extract Timestamp Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Sets the CMP0135 policy to NEW for CMake versions 3.24.0 and greater. This addresses warnings related to DOWNLOAD_EXTRACT_TIMESTAMP. ```cmake if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() ``` -------------------------------- ### Link Public Libraries Source: https://github.com/openipc/smolrtsp/blob/master/CMakeLists.txt Links the specified libraries (slice99, metalang99, datatype99, interface99) to the project target with PUBLIC scope. This makes these libraries available to consumers of the target. ```cmake target_link_libraries(${PROJECT_NAME} PUBLIC slice99 metalang99 datatype99 interface99) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.