当前位置: 首页 > 工具软件 > Janus-gateway > 使用案例 >

janus-gateway用cmake实现

田曜瑞
2023-12-01

 假如janus-gateway需要添加ffmpeg的支持,可以参考下面的实现方式,用CMakeList.txt 实现

cmake_minimum_required(VERSION 2.8)
project(janus)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB_PKG glib-2.0)

if (GLIB_PKG_FOUND)
    message(Found glib-2.0)
    include_directories(${GLIB_PKG_INCLUDE_DIRS})
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_definitions(-DCONFDIR="/opt/janus/etc/janus"
        -DTRANSPORTDIR="/opt/janus/lib/janus/transports"
        -DPLUGINDIR="/opt/janus/lib/janus/plugins"
        -DEVENTDIR="/opt/janus/lib/janus/events"
        -DLOGGERDIR="/opt/janus/lib/janus/loggers"
        -DPACKAGE_NAME=\"Janus\ WebRTC\ Server\"
        -DPACKAGE_TARNAME=\"janus-gateway\"
        -DPACKAGE_VERSION=\"0.10.10\"
        -DPACKAGE_STRING=\"Janus\ WebRTC\ Server\ 0.10.10\"
        -DPACKAGE_BUGREPORT=\"https://github.com/meetecho/janus-gateway\"
        -DPACKAGE_URL=\"https://janus.conf.meetecho.com\"
        -DPACKAGE=\"janus-gateway\" -DVERSION=\"0.10.10\"
        -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
        -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
        -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1
        -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1
        -D__EXTENSIONS__=1 -D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D_POSIX_PTHREAD_SEMANTICS=1
        -D_TANDEM_SOURCE=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAS_DTLS_WINDOW_SIZE=1
        -DHAVE_SRTP_AESGCM=1 -DHAVE_PORTRANGE=1 -DHAVE_LIBNICE_TCP=1
        -DHAVE_SRTP_2=1 -DHAVE_SCTP=1 -DHAVE_LIBCURL=1 -DHAVE_TURNRESTAPI=1 -DHAVE_SAMPLEEVH=1
        -DHAVE_WEBSOCKETS=1 -DHAVE_LIBWEBSOCKETS_PEER_SIMPLE=1 -DHAVE_WSEVH=1 
        -DHAVE_PFUNIX=1 -DHAVE_LIBOGG=1
        #        -DHAVE_CLOSE_ASYNC=1
        )

include_directories(
        /usr/include
        /usr/include/nice
        /usr/include/p11-kit-1
        /usr/include/gupnp-igd-1.0
        /usr/include/gupnp-1.2
        /usr/include/uuid
        /usr/include/gssdp-1.2
        /usr/include/libsoup-2.4
        /usr/include/libxml2
        /usr/include/libmount
        /usr/include/blkid
        /usr/include/glib-2.0
        /usr/lib/x86_64-linux-gnu/glib-2.0/include
        /usr/include/x86_64-linux-gnu
)
include_directories(./loggers/ ./plugins/duktape-deps ./postprocessing ./transports ./ )

link_directories(/usr/local/ffmpeg/lib)

set(SOURCE_FILES
        ./janus.c ./janus.h
        ./config.h ./config.c
        ./debug.h
        ./dtls.c ./dtls.h
        ./auth.c ./auth.h
        ./apierror.c ./apierror.h
        ./dtls-bio.c ./dtls-bio.h
        ./ice.c ./ice.h
        ./events.c ./events.h
        ./ip-utils.c ./ip-utils.h
        ./log.c ./log.h
        ./mutex.h
        ./record.c ./record.h
        ./rtcp.c ./rtcp.h
        ./rtpsrtp.h
        ./rtp.c ./rtp.h
        ./sctp.c ./sctp.h
        ./sdp.c ./sctp.h
        ./sdp-utils.c ./sdp-utils.h
        ./turnrest.c ./turnrest.h
        ./utils.c ./utils.h
        ./version.h ./version.c
        ./refcount.h
        ./cmdline.c ./cmdline.h
        ./apierror.h
        ./config.h
        ./mutex.h
        ./record.h ./record.c
        ./rtp.h ./rtp.c
        ./sdp-utils.h ./ip-utils.h
        ./text2pcap.h ./text2pcap.c
        ./live.h ./live.c
        ./plugins/plugin.h ./plugins/plugin.c
        ./transports/transport.h ./transports/transport.c
        )

add_library(janus_videoroom SHARED ./plugins/janus_videoroom.c)
add_library(janus_recordplay SHARED ./plugins/janus_recordplay.c)
add_library(janus_audiobridge SHARED ./plugins/janus_audiobridge.c)
add_library(janus_streaming SHARED ./plugins/janus_streaming.c)
add_library(janus_videocall SHARED ./plugins/janus_videocall.c)
add_library(janus_textroom SHARED ./plugins/janus_textroom.c)
add_library(janus_websockets SHARED ./transports/janus_websockets.c)
add_library(janus_http SHARED ./transports/janus_http.c)
add_library(janus_pfunix SHARED ./transports/janus_pfunix.c)
add_library(janus_gelfevh SHARED ./events/janus_gelfevh.c)
add_library(janus_sampleevh SHARED ./events/janus_sampleevh.c)
add_library(janus_wsevh SHARED ./events/janus_wsevh.c)

aux_source_directory(./loggers/ SOURCE_FILES)
add_definitions("-g -O0")

add_executable(janus ${SOURCE_FILES})
target_link_libraries(janus pthread srtp2
        m dl usrsctp pthread
        glib-2.0 jansson crypto dl ogg z curl avutil avcodec avformat
        config nice gio-2.0 gobject-2.0 glib-2.0 jansson ssl crypto z
        websockets opus)

target_link_libraries(janus libavutil.a libavcodec.a libavformat.a libfdk-aac.a)

 

 类似资料: