赞
踩
KVS WebRTC SDK C
- # WebRTC C语言版本
- git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git
KVS WebRTC SDK C++
- # WebRTC C++语言版本
- git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
KVS Producer SDK C
git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
KVS PIC
git clone https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
安装编译环境
在Ubuntu与树莓派系统下你可以通过以下命令一键安装:
- #Ubuntu
- sudo apt-get install pkg-config cmake libcap2 libcap-dev -y
-
- #MacOS
- brew install cmake pkg-config srtp
然后在已经 CheckOut 的根目录下创建一个名叫 build
的子目录,然后进入该目录并执行 CMake 命令
- mkdir -p amazon-kinesis-video-streams-webrtc-sdk-c/build
- cd amazon-kinesis-video-streams-webrtc-sdk-c/build
- cmake ..
源码已经提供了一个使用 GStreamer
的案例来采集与编码视频流,然后也通过这个库发送出去。只有当 pkg-config 发现系统上安装了GStreamer时,才会去这么构建。
- #MacOS
- brew install gstreamer gst-plugins-base gst-plugins-good
如果你希望进行交叉编译,那么在构建库及其所有依赖项时 CC
、CXX
是必须的。与此同时,你还需要设置: BUILD_OPENSSL_PLATFORM
、BUILD_LIBSRTP_HOST_PLATFORM
、BUILD_LIBSRTP_DESTINATION_PLATFORM
如果在cmake的时候设置了 -DBUILD_STATIC_LIBS=TRUE
,那么所有依赖库以及 KVS WebRTC 库都将被编译成静态库。
选用MbedTLS,弃用OpenSSL
- GIT_REPOSITORY https://github.com/ARMmbed/mbedtls.git
- GIT_TAG v2.25.0
生成的头文件
- mbedtls/xxx.h
- psa/xxx.h
生成库文件(CMake静态库链接必须按此顺序):
- libmbedx509.a
- libmbedtls.a
- libmbedcrypto.a
其中,需要修复CMakeLists.txt的问题:
推荐选用
- GIT_REPOSITORY https://github.com/warmcat/libwebsockets.git
- GIT_TAG v4.2.2
生成的头文件:
- libwebsockets/xxx.h
- libwebsockets.h
生成库文件:
- libwebsockets.a
必须引用
- GIT_REPOSITORY https://github.com/cisco/libsrtp.git
- GIT_TAG bd0f27ec0e299ad101a396dde3f7c90d48efc8fc
生成的头文件:
- srtp2/xxx.h
生成库文件:
- libsrtp2.a
必须引用
- GIT_REPOSITORY https://github.com/sctplab/usrsctp.git
- GIT_TAG 1ade45cbadfd19298d2c47dc538962d4425ad2dd
生成的头文件
- usrsctp.h
生成库文件:
- libusrsctp.a
- GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
- GIT_TAG afc15aff555090424d6b92ef316116e85004a479
编译方法:
cmake .. -DBUILD_STATIC=ON -DBUILD_COMMON_LWS=ON -DBUILD_COMMON_CURL=OFF -DUSE_OPENSSL=OFF -DUSE_MBEDTLS=ON
生成头文件
- com/xxx.h
生成库文件:
- libkvspic.a
- libkvspicClient.a
- libkvspicState.a
- libkvspicUtils.a
- GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git
- GIT_TAG c7fce9e06021452ff3c42dc70c8360606b22ad53
生成的头文件
- lws_config.h
生成库文件:
- libkvsCommonLws.a
编译方法:
- cmake .. \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_MAKE_PROGRAM=make \
- -DCMAKE_C_COMPILER=gcc \
- -DCMAKE_CXX_COMPILER=g++ \
- -DBUILD_STATIC_LIBS=ON \
- -DUSE_OPENSSL=OFF \
- -DUSE_MBEDTLS=ON \
- -DENABLE_SIGNALING_CLIENT=OFF
- make
生成头文件
- com/xxx.h
生成库文件:
- libkvsWebrtcClient.a
- libkvsWebrtcSignalingClient.a(移出)
当我们不希望再使用Amazon自带的信令模块时,我们就不得不进行裁剪。好在KVS WebRTC代码的独立性很强,裁剪的过程中遇到的困难并不多。
首先,我们需要修改CMakeLists.txt
- option(ENABLE_SIGNALING_CLIENT "Enables signaling client" OFF) # 自定义添加的开关
-
- # building websockets
- # ---- 在这里移除掉Websocket库的依赖,由上层自己去选用信令形式
- if (ENABLE_SIGNALING_CLIENT)
- set(BUILD_ARGS
- -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
- -DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
- -DUSE_OPENSSL=${USE_OPENSSL}
- -DUSE_MBEDTLS=${USE_MBEDTLS}
- #-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} #暂时不需要
- -DMBEDTLS_INCLUDE_DIRS=${MBEDTLS_INCLUDE_DIRS} #指定MBEDTLS时必须指定
- -DMBEDTLS_LIBRARIES=${MBEDTLS_LIBRARIES}) #指定MBEDTLS时必须指定
- build_dependency(websockets ${BUILD_ARGS})
- endif ()
-
- # building kvsCommonLws also builds kvspic
- # ---- 在这里移除掉Websocket库的依赖,由上层自己去选用信令形式
- set(BUILD_ARGS
- -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- -DUSE_OPENSSL=${USE_OPENSSL}
- -DUSE_MBEDTLS=${USE_MBEDTLS}
- -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
- -DBUILD_COMMON_LWS=${ENABLE_SIGNALING_CLIENT} #如果不启用Websocket,也没必要启用LWS了
- -DMBEDTLS_INCLUDE_DIRS=${MBEDTLS_INCLUDE_DIRS} #指定MBEDTLS时必须指定
- -DMBEDTLS_LIBRARIES=${MBEDTLS_LIBRARIES}) #指定MBEDTLS时必须指定
- build_dependency(kvsCommonLws ${BUILD_ARGS})
-
- # 如果不启用Websocket,那么也不会进行依赖检查
- if (ENABLE_SIGNALING_CLIENT)
- if (WIN32)
- SET(LIBWEBSOCKETS_LIBRARIES "websockets.lib")
- else ()
- pkg_check_modules(LIBWEBSOCKETS REQUIRED libwebsockets)
- endif ()
- else ()
-
- # 添加宏定义
- if (ENABLE_SIGNALING_CLIENT)
- add_definitions(-DENABLE_SIGNALING_CLIENT)
- endif ()
-
- # 不再需要包容Signaling目录下的c文件了
- if (ENABLE_SIGNALING_CLIENT)
- file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c")
- endif ()
-
- # 不需要再编译libkvsWebrtcSignalingClient.a库了
- if (ENABLE_SIGNALING_CLIENT)
- add_library(kvsWebrtcSignalingClient ${LINKAGE} ${WEBRTC_SIGNALING_CLIENT_SOURCE_FILES})
- target_link_libraries(
- kvsWebrtcSignalingClient
- PUBLIC
- kvsCommonLws
- ${LIBWEBSOCKETS_LIBRARIES}
- PRIVATE kvspicUtils
- kvspicState
- ${CMAKE_THREAD_LIBS_INIT}
- ${EXTRA_DEPS}
- ${OPENSSL_SSL_LIBRARY}
- ${OPENSSL_CRYPTO_LIBRARY}
- ${GPERFTOOLS_MALLOC_LIBRARIES}
- ${GPERFTOOLS_PROFILER_LIBRARIES}
- ${MBEDTLS_LIBRARIES})
- endif ()
-
- if (ENABLE_SIGNALING_CLIENT)
- install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- )
- else ()
- install(TARGETS kvsWebrtcClient
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- )
- endif ()
-
- # 如果不支持SignalingClient,那么这些案例也没必要编译了
- if (BUILD_SAMPLE)
- if (ENABLE_SIGNALING_CLIENT)
- # copy sample frames to build folder, in case developer runs sample program with command `samples/kvsWebrtcClientMaster` from `build` dir.
- file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/opusSampleFrames" DESTINATION .)
- file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples/h264SampleFrames" DESTINATION .)
- add_subdirectory(samples)
- endif ()
- endif ()
然后修改头文件src/source/Include_i.h
- // Websocket
- #if defined ENABLE_SIGNALING_CLIENT
- #include <libwebsockets.h>
- #else
- #include <poll.h> //Ice模块依赖
- #endif
-
- // Signaling
- #if defined(ENABLE_SIGNALING_CLIENT)
- #include "Signaling/FileCache.h"
- #include "Signaling/Signaling.h"
- #include "Signaling/ChannelInfo.h"
- #include "Signaling/StateMachine.h"
- #include "Signaling/LwsApiCalls.h"
- #endif
CMakeLists.txt
- target_include_directories(${PROJECT_NAME} PRIVATE
- ${PROJECT_SOURCE_DIR}/src
- ${PROJECT_SOURCE_DIR}/include
- ${PROJECT_SOURCE_DIR}/include/com/amazonaws
- )
CMakeLists.txt
- list(APPEND KVS_WEBRTC_LIBRARY
- ${PROJECT_SOURCE_DIR}/lib/libkvsWebrtcClient.a
- ${PROJECT_SOURCE_DIR}/lib/libkvspic.a
- #${PROJECT_SOURCE_DIR}/lib/libkvspicClient.a
- #${PROJECT_SOURCE_DIR}/lib/libkvspicState.a
- #${PROJECT_SOURCE_DIR}/lib/libkvspicUtils.a
- )
- list(APPEND MBEDTLS_LIBRARY
- ${PROJECT_SOURCE_DIR}/lib/libmbedtls.a
- ${PROJECT_SOURCE_DIR}/lib/libmbedcrypto.a
- ${PROJECT_SOURCE_DIR}/lib/libmbedx509.a
- )
- list(APPEND SRTP_LIBRARY
- ${PROJECT_SOURCE_DIR}/lib/libsrtp2.a
- )
- list(APPEND USRSCTP_LIBRARY
- ${PROJECT_SOURCE_DIR}/lib/libusrsctp.a
- )
- target_link_libraries(${PROJECT_NAME} PUBLIC
- ${KVS_WEBRTC_LIBRARY}
- ${MBEDTLS_LIBRARY}
- ${SRTP_LIBRARY}
- ${USRSCTP_LIBRARY}
- )
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。