整个demo为:
可以选择多个编码方式:
cmake_minimum_required(VERSION 3.5)
project(untitled LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(
"D:/webrtc/webrtc-checkout/src"
"D:/webrtc/webrtc-checkout/src/out/release/obj"
"D:/webrtc/webrtc-checkout/src/third_party/abseil-cpp"
"D:/webrtc/webrtc-checkout/src/third_party/libyuv/include"
"D:/webrtc/webrtc-checkout/src/third_party/jsoncpp/source/include"
"D:/webrtc/webrtc-checkout/src/third_party/jsoncpp/generated"
)
include_directories(./)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
add_definitions(
-D_ITERATOR_DEBUG_LEVEL=2
-DUSE_AURA=1
-DWEBRTC_USE_H264
-D_HAS_EXCEPTIONS=0
-D__STD_C
-D_CRT_RAND_S
-D_CRT_SECURE_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
-D_ATL_NO_OPENGL
-D_WINDOWS
-DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS
-DPSAPI_VERSION=2
-DWIN32
-D_SECURE_ATL
-DWINUWP
-D__WRL_NO_DEFAULT_LIB__
-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP
-DWIN10=_WIN32_WINNT_WIN10
-DWIN32_LEAN_AND_MEAN
-DNOMINMAX
-D_UNICODE
-DUNICODE
-DNTDDI_VERSION=NTDDI_WIN10_RS2
-D_WIN32_WINNT=0x0A00
-DWINVER=0x0A00
-DNDEBUG
-DNVALGRIND
-DDYNAMIC_ANNOTATIONS_ENABLED=0
-DWEBRTC_ENABLE_PROTOBUF=0
-DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE
-DRTC_ENABLE_VP9
-DHAVE_SCTP
-DWEBRTC_LIBRARY_IMPL
-DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0
-DWEBRTC_WIN
-DABSL_ALLOCATOR_NOTHROW=1
-DQT_DEPRECATED_WARNINGS
-DQT_NO_KEYWORDS
-DHAVE_SCTP
-DWEBRTC_VIDEO_CAPTURE_WINRT)
find_package(Qt5 COMPONENTS Widgets Network REQUIRED)
include_directories("D:/webrtc/webrtc-checkout/src/third_party/jsoncpp/source/install/include")
include_directories("D:/webrtc/webrtc-checkout/src/third_party/libyuv/include")
link_directories("D:/webrtc/webrtc-checkout/src/out/release/obj" "D:/webrtc/webrtc-checkout/src/third_party/jsoncpp/source/install/lib")
include_directories("D:/webrtc/webrtc-checkout/src/third_party/abseil-cpp/install/include")
add_executable(untitled
main.cpp conductor.cc defaults.cc peer_connection_client.cc test_video_capturer.cc vcm_capturer.cc
mainwindow.cpp D:/webrtc/webrtc-checkout/src/rtc_base/strings/json.cc
mainwindow.h
mainwindow.ui
)
file(GLOB_RECURSE MY_FILES "D:/webrtc/webrtc-checkout/src/third_party/abseil-cpp/install/lib/*.lib")
message(${MY_FILES})
target_link_libraries(untitled
PRIVATE
WS2_32 secur32.lib winmm.lib dmoguids.lib wmcodecdspuuid.lib msdmo.lib Strmiids.lib Iphlpapi.lib ${MY_FILES} )
target_link_libraries(untitled PRIVATE Qt5::Widgets Qt5::Network jsoncpp.lib D:/webrtc/webrtc-checkout/src/out/release/obj/webrtc.lib)
其中h264在cmake中要加上-DWEBRTC_USE_H264,编译时的参数为
gn gen out/release --ide=vs --args="is_debug=true use_custom_libcxx=false rtc_enable_protobuf=false target_cpu=\"x64\" enable_iterator_debugging=true symbol_level=2 is_clang=true rtc_include_tests=true rtc_use_h264=true ffmpeg_branding=\"Chrome\" proprietary_codecs=true"
需要打开webrtc选项。这个demo的下载链接为