Skip to content

Commit

Permalink
Combine client and server projects
Browse files Browse the repository at this point in the history
  • Loading branch information
patcarter883 committed Nov 23, 2023
1 parent 9e41df4 commit 90c2231
Show file tree
Hide file tree
Showing 25 changed files with 2,433 additions and 101 deletions.
10 changes: 10 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[submodule "extern/rist-cpp"]
path = extern/rist-cpp
url = https://github.com/patcarter883/rist-cpp.git
branch = swxtch
[submodule "extern/rpclib"]
path = extern/rpclib
url = https://github.com/rpclib/rpclib.git
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/Microsoft/vcpkg.git
131 changes: 112 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,140 @@
cmake_minimum_required(VERSION 3.14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(cmake/prelude.cmake)

project(
ndi-rist
VERSION 0.1.0
DESCRIPTION "Short description"
HOMEPAGE_URL "https://example.com/"
DESCRIPTION "NDI to RTMP streamer using AV1 over MPEGTS"
HOMEPAGE_URL "https://github.com/patcarter883/ndi-rist-encoder-cpp.git"
LANGUAGES CXX
)

include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)

find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive --remote
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

# ---- Declare library ----

add_library(
ndi-rist_lib OBJECT
source/lib.cpp
)
# add_library(
# ndi-rist_lib OBJECT
# source/lib.cpp
# )

target_include_directories(
ndi-rist_lib ${warning_guard}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>"
)
# target_include_directories(
# ndi-rist_lib ${warning_guard}
# PUBLIC
# "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>"
# )

# target_compile_features(ndi-rist_lib PUBLIC cxx_std_20)

# find_package(fmt REQUIRED)
# target_link_libraries(ndi-rist_lib PRIVATE fmt::fmt)

IF (WIN32)

target_compile_features(ndi-rist_lib PUBLIC cxx_std_20)
find_package(GStreamer REQUIRED)
find_package (Threads)

find_package(fmt REQUIRED)
target_link_libraries(ndi-rist_lib PRIVATE fmt::fmt)
ELSE()
find_package(PkgConfig REQUIRED)
pkg_search_module(gstreamer REQUIRED IMPORTED_TARGET gstreamer-1.0>=1.4)
pkg_search_module(gstreamer-sdp REQUIRED IMPORTED_TARGET gstreamer-sdp-1.0>=1.4)
pkg_search_module(gstreamer-rtp REQUIRED IMPORTED_TARGET gstreamer-rtp-1.0>=1.4)
pkg_search_module(gstreamer-app REQUIRED IMPORTED_TARGET gstreamer-app-1.0>=1.4)
pkg_search_module(gstreamer-video REQUIRED IMPORTED_TARGET gstreamer-video-1.0>=1.4)

ENDIF()

find_package(NDI REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(FLTK CONFIG REQUIRED)
add_subdirectory(extern/rpclib)
add_subdirectory(extern/rist-cpp)

# ---- Declare executable ----

add_executable(ndi-rist_exe source/main.cpp)
add_executable(ndi-rist::exe ALIAS ndi-rist_exe)
add_executable(ndi-rist-encoder_exe WIN32 source/ndi-rist-encoder.cpp source/Url.h source/Url.cc)
add_executable(ndi-rist-encoder::exe ALIAS ndi-rist-encoder_exe)

set_property(TARGET ndi-rist-encoder_exe PROPERTY OUTPUT_NAME ndi-rist-encoder)

target_compile_features(ndi-rist-encoder_exe PRIVATE cxx_std_20)

target_include_directories(ndi-rist-encoder_exe PUBLIC ${FLTK_INCLUDE_DIRS})
target_include_directories(ndi-rist-encoder_exe PUBLIC ${GSTREAMER_INCLUDE_DIRS})
target_include_directories(ndi-rist-encoder_exe PRIVATE ${NDI_INCLUDE_DIRS})

target_link_libraries(ndi-rist-encoder_exe PRIVATE fmt::fmt rpc)
target_link_libraries(ndi-rist-encoder_exe PRIVATE fltk fltk_gl fltk_forms fltk_images)
target_link_libraries(ndi-rist-encoder_exe PRIVATE ${NDI_LIBRARIES})

IF (WIN32)

target_link_libraries(ndi-rist-encoder_exe PRIVATE ${GSTREAMER_LIBRARIES})
target_link_libraries(ndi-rist-encoder_exe PRIVATE Threads::Threads)

ELSE()

target_link_libraries(ndi-rist-encoder_exe PRIVATE
PkgConfig::gstreamer
PkgConfig::gstreamer-sdp
PkgConfig::gstreamer-rtp
PkgConfig::gstreamer-app
PkgConfig::gstreamer-video)
ENDIF()

target_link_libraries(ndi-rist-encoder_exe PRIVATE rpc ristnet)

add_dependencies(ndi-rist-encoder_exe ristnet rpc)

# ---- Declare executable ----

add_executable(ndi-rist-server_exe WIN32 source/ndi-rist-server.cpp source/ndi-rist-encoder.h)
add_executable(ndi-rist-server::exe ALIAS ndi-rist-server_exe)

set_property(TARGET ndi-rist-server_exe PROPERTY OUTPUT_NAME ndi-rist-server)

target_compile_features(ndi-rist-server_exe PRIVATE cxx_std_20)

target_include_directories(ndi-rist-server_exe PUBLIC ${GSTREAMER_INCLUDE_DIRS})
target_include_directories(ndi-rist-server_exe PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extern/rist-cpp/)
target_include_directories(ndi-rist-server_exe PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extern/rist-cpp/rist/inc/ ${CMAKE_CURRENT_SOURCE_DIR}/extern/rist-cpp/rist/include/ ${CMAKE_CURRENT_SOURCE_DIR}/extern/rist-cpp/rist/include/librist ${CMAKE_CURRENT_SOURCE_DIR}/extern/rist-cpp/rist/build/include/librist)

IF (WIN32)

target_link_libraries(ndi-rist-server_exe PRIVATE ${GSTREAMER_LIBRARIES})
target_link_libraries(ndi-rist-server_exe PRIVATE Threads::Threads)

set_property(TARGET ndi-rist_exe PROPERTY OUTPUT_NAME ndi-rist)
ELSE()

target_compile_features(ndi-rist_exe PRIVATE cxx_std_20)
target_link_libraries(ndi-rist-server_exe PRIVATE
PkgConfig::gstreamer
PkgConfig::gstreamer-sdp
PkgConfig::gstreamer-rtp
PkgConfig::gstreamer-app
PkgConfig::gstreamer-video)
ENDIF()

target_link_libraries(ndi-rist_exe PRIVATE ndi-rist_lib)
target_link_libraries(ndi-rist-server_exe PRIVATE rpc ristnet)

add_dependencies(ndi-rist-server_exe rpc ristnet)
# ---- Install rules ----

if(NOT CMAKE_SKIP_INSTALL_RULES)
Expand Down
7 changes: 4 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
"hidden": true,
"cacheVariables": {
"ndi-rist_DEVELOPER_MODE": "ON",
"VCPKG_MANIFEST_FEATURES": "test"
"VCPKG_MANIFEST_FEATURES": "test",
"BUILD_TESTING": "OFF"
}
},
{
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
Expand Down Expand Up @@ -57,7 +58,7 @@
"description": "These flags are supported by both GCC and Clang",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast",
"CMAKE_CXX_FLAGS": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast",
"CMAKE_EXE_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now",
"CMAKE_SHARED_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now"
}
Expand Down
26 changes: 26 additions & 0 deletions cmake/FindGStreamer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(GSTREAMER_FOUND FALSE)

if (WIN32)

set(GSTREAMER_DIR $ENV{GSTREAMER_1_0_ROOT_MSVC_X86_64})

if (EXISTS ${GSTREAMER_DIR}/include/gstreamer-1.0/gst/gst.h)
set(GSTREAMER_FOUND TRUE)
set(GSTREAMER_VERSION_STRING 1.0 CACHE STRING "")
set(GSTREAMER_INCLUDE_DIRS
${GSTREAMER_DIR}/include/gstreamer-1.0/
${GSTREAMER_DIR}/include/glib-2.0/
${GSTREAMER_DIR}/lib/glib-2.0/include/
${GSTREAMER_DIR}/lib/gstreamer-1.0/include/
${GSTREAMER_DIR}/include/libxml2/
CACHE STRING ""
)

file(GLOB gst_lib_files ${GSTREAMER_DIR}/lib/*.lib)
set(GSTREAMER_LIBRARIES ${gst_lib_files} CACHE STRING "")

mark_as_advanced(GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES)

endif()

endif()
59 changes: 59 additions & 0 deletions cmake/FindNDI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
if(WIN32)
if(DEFINED ENV{NDI_SDK_DIR})
set(NDI_FOUND TRUE)
set(NDI_DIR $ENV{NDI_SDK_DIR})
string(REPLACE "\\" "/" NDI_DIR "${NDI_DIR}")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(NDI_ARCH "x86")
else()
set(NDI_ARCH "x64")
endif()
set(NDI_INCLUDE_DIR "${NDI_DIR}/Include")
set(NDI_LIBRARY_DIR "${NDI_DIR}/Lib/${NDI_ARCH}")
set(NDI_LICENSE_DIR "${NDI_DIR}/Bin/${NDI_ARCH}")
set(NDI_LIBS "Processing.NDI.Lib.${NDI_ARCH}")
else()
set(NDI_FOUND FALSE)
endif()
elseif(APPLE)
if(EXISTS "/Library/NDI SDK for Apple/include/Processing.NDI.Lib.h")
set(NDI_FOUND TRUE)
set(NDI_DIR "/Library/NDI SDK for Apple")
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib/macOS")
set(NDI_LICENSE_DIR "${NDI_DIR}/licenses")
file(GLOB NDI_LIBS "${NDI_LIBRARY_DIR}/*.dylib")
else()
set(NDI_FOUND FALSE)
endif()
elseif(UNIX)
if(EXISTS "${NDI_SDK_DIR}/include/Processing.NDI.Lib.h")
set(NDI_FOUND TRUE)
set(NDI_DIR ${NDI_SDK_DIR})
if(NOT NDI_ARCH)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(NDI_ARCH "aarch64-rpi4-linux-gnueabi")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(NDI_ARCH "i686-linux-gnu")
else()
set(NDI_ARCH "x86_64-linux-gnu")
endif()
endif()
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib/${NDI_ARCH}")
set(NDI_LICENSE_DIR "${NDI_DIR}/licenses")
set(NDI_LIBS "ndi")
elseif(EXISTS "/usr/include/Processing.NDI.Lib.h")
set(NDI_FOUND TRUE)
set(NDI_DIR "/usr")
set(NDI_INCLUDE_DIR "${NDI_DIR}/include")
set(NDI_LIBRARY_DIR "${NDI_DIR}/lib")
set(NDI_LICENSE_DIR "${NDI_DIR}/share/licenses/ndi-sdk")
set(NDI_LIBS "ndi")
else()
set(NDI_FOUND FALSE)
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NDI DEFAULT_MSG NDI_DIR ${NDI_FOUND})
Loading

0 comments on commit 90c2231

Please sign in to comment.