forked from grandi23/cpp_media_server-1
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
402 lines (390 loc) · 14.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
cmake_minimum_required(VERSION 3.7.1)
project(cpp_media_server)
project(cpp_media_server VERSION 1.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_OUTPUT_BASE ${CMAKE_BINARY_DIR}/output)
set(BUILD_OUTPUT_BASE ${CMAKE_BINARY_DIR}/output)
set(PREFIX_DIR "${BUILD_OUTPUT_BASE}")
set(INSTALL_RPATH "${PREFIX_DIR}/lib")
option(ENABLE_FFMPEG "Enable FFmpeg" true)
# set output static libary
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/lib)
function(set_file_group prefix)
message(STATUS "set_file_group " ${prefix} " " ${ARGC})
foreach(FILE IN LISTS ARGN 1)
# Get the directory of the source file
get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)
# Remove common directory prefix to make the group
string(REPLACE "${prefix}" "" GROUP "${PARENT_DIR}")
# Make sure we are using windows slashes
string(REPLACE "/" "\\" GROUP "${GROUP}")
# Group into "Source Files" and "Header Files"
#if ("${FILE}" MATCHES ".*\\.cpp")
# set(GROUP "Source Files${GROUP}")
#elseif("${FILE}" MATCHES ".*\\.h")
# set(GROUP "Header Files${GROUP}")
#endif()
#message(STATUS ${GROUP} " : " ${FILE})
source_group("${GROUP}" FILES "${FILE}")
endforeach()
endfunction()
# set include path
include_directories(src
src/net
src/net/http
src/net/rtmp
src/net/websocket
src/net/websocket/wsimple
src/net/tcp
src/net/stun
src/net/httpflv
src/net/rtprtcp
src/net/hls
src/net/webrtc
src/net/webrtc/libwebrtc
src/transcode
src/format
src/format/flv
src/utils
src/utils/av
3rdparty/libsdptransform/include
3rdparty/libsrtp/include
3rdparty/libsrtp/crypto/include
3rdparty/libuv/include
${OPENSSL_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/output/include
${CMAKE_BINARY_DIR}/output/include/srtp2
${CMAKE_BINARY_DIR}/output/include/openssl
/usr/local/include)
# set lib path
IF (WIN32)
find_package(OpenSSL)
if(OpenSSL_FOUND)
message(STATUS "found openssl:${OPENSSL_INCLUDE_DIR}")
set(LIBS OpenSSL::SSL OpenSSL::Crypto)
else()
set(LIBS ssl crypto)
endif()
if (ENABLE_FFMPEG)
# 根据实际情况,修改ffmpeg的安装路径,注意大于4.4的版本不行
SET(FFMPEG_ROOT_DIR D:/Work/ffmpeg/v4.3)
message(STATUS "found ffmpeg:${FFMPEG_ROOT_DIR}")
include_directories(${FFMPEG_ROOT_DIR}/include)
link_directories(${FFMPEG_ROOT_DIR}/lib)
endif()
else()
# set pkgconfig path
set(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/output/lib/pkgconfig")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wno-deprecated -Wno-deprecated-declarations -Wno-reorder -Wall -fexceptions -frtti -D__STDC_FORMAT_MACROS -fPIC")
#link_directories(${CMAKE_BINARY_DIR}/output/lib /usr/local/lib64 /usr/local/lib)
link_directories(${CMAKE_BINARY_DIR}/output/lib /usr/local/lib64 /usr/local/lib)
set(LIBS ssl crypto)
ENDIF()
add_subdirectory(3rdparty)
#add_executable(echo_demo
# src/net/tcp/echo_demo.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp)
#
#IF (APPLE)
#target_link_libraries(echo_demo dl z m ssl crypto pthread uv)
#ELSEIF (UNIX)
#target_link_libraries(echo_demo rt dl z m ssl crypto pthread uv)
#ENDIF ()
#
#add_executable(flv_demux_demo
# ./src/format/flv/flv_demux.cpp
# ./src/format/flv/flv_demux_demo.cpp
# ./src/utils/logger.cpp
# ./src/utils/data_buffer.cpp
# ./src/utils/byte_stream.cpp)
#IF (APPLE)
#target_link_libraries(flv_demux_demo pthread dl z m)
#ELSEIF (UNIX)
#target_link_libraries(flv_demux_demo pthread rt dl z m)
#ENDIF ()
#
#add_executable(flv_mux_demo
# src/format/flv/flv_mux.cpp
# src/format/flv/flv_demux.cpp
# src/format/flv/flv_mux_demo.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp
# src/utils/byte_stream.cpp)
#IF (APPLE)
#target_link_libraries(flv_mux_demo pthread dl z m)
#ELSEIF (UNIX)
#target_link_libraries(flv_mux_demo pthread rt dl z m)
#ENDIF ()
#
#add_executable(mpegts_demux_demo
# src/format/mpegts/mpegts_demux_demo.cpp
# src/format/mpegts/mpegts_demux.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp
# src/utils/byte_stream.cpp)
#IF (APPLE)
#target_link_libraries(mpegts_demux_demo pthread dl z m)
#ELSEIF (UNIX)
#target_link_libraries(mpegts_demux_demo pthread rt dl z m)
#ENDIF ()
#
#add_executable(mpegts_mux_demo
# src/format/mpegts/mpegts_mux_demo.cpp
# src/format/mpegts/mpegts_mux.cpp
# src/format/flv/flv_demux.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp
# src/utils/byte_stream.cpp)
#IF (APPLE)
#target_link_libraries(mpegts_mux_demo pthread dl z m)
#ELSEIF (UNIX)
#target_link_libraries(mpegts_mux_demo pthread rt dl z m)
#ENDIF ()
#
#add_executable(http_server_demo
# src/net/http/http_server_demo.cpp
# src/net/http/http_server.cpp
# src/net/http/http_session.cpp
# src/utils/data_buffer.cpp
# src/utils/logger.cpp)
#IF (APPLE)
#target_link_libraries(http_server_demo dl z m ssl crypto pthread uv)
#ELSEIF (UNIX)
#target_link_libraries(http_server_demo rt dl z m ssl crypto pthread uv)
#ENDIF ()
#
#add_executable(https_server_demo
# src/net/http/https_server_demo.cpp
# src/net/http/http_server.cpp
# src/net/http/http_session.cpp
# src/utils/data_buffer.cpp
# src/utils/logger.cpp)
#IF (APPLE)
#target_link_libraries(https_server_demo dl z m ssl crypto pthread uv)
#ELSEIF (UNIX)
#target_link_libraries(https_server_demo rt dl z m ssl crypto pthread uv)
#ENDIF ()
#
#add_executable(rtmp_play_demo
# src/net/rtmp/client_demo/rtmp_play_demo.cpp
# src/net/rtmp/rtmp_client_session.cpp
# src/net/rtmp/rtmp_session_base.cpp
# src/net/rtmp/rtmp_control_handler.cpp
# src/net/rtmp/rtmp_handshake.cpp
# src/net/rtmp/chunk_stream.cpp
# src/format/flv/flv_mux.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp
# src/utils/byte_stream.cpp)
#add_dependencies(rtmp_play_demo openssl)
#
#IF (APPLE)
#target_link_libraries(rtmp_play_demo pthread dl z m ssl crypto pthread uv)
#ELSEIF (UNIX)
#target_link_libraries(rtmp_play_demo pthread rt dl z m ssl crypto pthread uv)
#ENDIF ()
#
#add_executable(rtmp_publish_demo
# src/net/rtmp/client_demo/rtmp_publish_demo.cpp
# src/net/rtmp/rtmp_client_session.cpp
# src/net/rtmp/rtmp_session_base.cpp
# src/net/rtmp/rtmp_control_handler.cpp
# src/net/rtmp/rtmp_handshake.cpp
# src/net/rtmp/chunk_stream.cpp
# src/format/flv/flv_demux.cpp
# src/format/flv/flv_mux.cpp
# src/utils/logger.cpp
# src/utils/data_buffer.cpp
# src/utils/byte_stream.cpp)
#add_dependencies(rtmp_publish_demo openssl)
#
#IF (APPLE)
#target_link_libraries(rtmp_publish_demo pthread dl z m ssl crypto pthread uv)
#ELSEIF (UNIX)
#target_link_libraries(rtmp_publish_demo pthread rt dl z m ssl crypto pthread uv)
#ENDIF ()
SET(SRC_LIST src/media_server.cpp
src/media_server.hpp
src/format/flv/flv_demux.cpp
src/format/flv/flv_demux.hpp
src/format/flv/flv_mux.cpp
src/format/flv/flv_mux.hpp
src/format/flv/flv_pub.hpp
src/format/mpegts/mpegts_mux.cpp
src/format/mpegts/mpegts_mux.hpp
src/format/mpegts/mpegts_demux.cpp
src/format/mpegts/mpegts_demux.hpp
src/format/mpegts/mpegts_pub.hpp
src/format/audio_pub.hpp
src/format/av_format_interface.hpp
src/format/h264_header.hpp
src/net/tcp/tcp_server.hpp
src/net/tcp/tcp_session.hpp
src/net/udp/udp_server.hpp
src/net/http/http_session.cpp
src/net/http/http_server.cpp
src/net/http/http_common.hpp
src/net/http/http_server.hpp
src/net/http/http_session.hpp
src/net/hls/hls_worker.cpp
src/net/hls/hls_worker.hpp
src/net/hls/hls_writer.cpp
src/net/hls/hls_writer.hpp
src/net/hls/mpegts_handle.cpp
src/net/hls/mpegts_handle.hpp
src/net/rtmp/amf/amf0.hpp
src/net/rtmp/rtmp_pub.hpp
src/net/rtmp/rtmp_request.hpp
src/net/rtmp/rtmp_server.cpp
src/net/rtmp/rtmp_server.hpp
src/net/rtmp/rtmp_server_session.cpp
src/net/rtmp/rtmp_server_session.hpp
src/net/rtmp/rtmp_client_session.cpp
src/net/rtmp/rtmp_client_session.hpp
src/net/rtmp/rtmp_session_base.cpp
src/net/rtmp/rtmp_session_base.hpp
src/net/rtmp/rtmp_control_handler.cpp
src/net/rtmp/rtmp_control_handler.hpp
src/net/rtmp/rtmp_handshake.cpp
src/net/rtmp/rtmp_handshake.hpp
src/net/rtmp/chunk_stream.cpp
src/net/rtmp/chunk_stream.hpp
src/net/rtmp/rtmp_writer.cpp
src/net/rtmp/rtmp_writer.hpp
src/net/rtmp/rtmp_relay.cpp
src/net/rtmp/rtmp_relay.hpp
src/net/rtmp/rtmp_relay_mgr.cpp
src/net/rtmp/rtmp_relay_mgr.hpp
src/net/rtprtcp/rtp_packet.cpp
src/net/rtprtcp/rtp_packet.hpp
src/net/rtprtcp/rtcp_fb_pub.hpp
src/net/rtprtcp/rtcp_pspli.hpp
src/net/rtprtcp/rtcp_rr.hpp
src/net/rtprtcp/rtcp_sr.hpp
src/net/rtprtcp/rtcp_xr_dlrr.hpp
src/net/rtprtcp/rtcp_xr_rrt.hpp
src/net/rtprtcp/rtcpfb_nack.hpp
src/net/rtprtcp/rtcpfb_remb.hpp
src/net/rtprtcp/rtprtcp_pub.hpp
src/net/websocket/ws_server.cpp
src/net/websocket/ws_server.hpp
src/net/websocket/ws_session.cpp
src/net/websocket/ws_session.hpp
src/net/websocket/ws28/Server.cpp
src/net/websocket/ws28/Server.h
src/net/websocket/ws28/base64.cpp
src/net/websocket/ws28/base64.h
src/net/websocket/ws28/Client.cpp
src/net/websocket/ws28/Client.h
src/net/websocket/ws28/Headers.h
src/net/websocket/wsimple/protoo_pub.hpp
src/net/websocket/wsimple/flv_websocket.cpp
src/net/websocket/wsimple/flv_websocket.hpp
src/net/websocket/wsimple/protoo_server.cpp
src/net/websocket/wsimple/protoo_server.hpp
src/net/stun/stun_packet.cpp
src/net/stun/stun_packet.hpp
src/net/webrtc/rtc_session_pub.hpp
src/net/webrtc/rtc_stream_pub.hpp
src/net/webrtc/webrtc_pub.hpp
src/net/webrtc/room_service.cpp
src/net/webrtc/room_service.hpp
src/net/webrtc/sdp_analyze.cpp
src/net/webrtc/sdp_analyze.hpp
src/net/webrtc/user_info.cpp
src/net/webrtc/user_info.hpp
src/net/webrtc/rtc_media_info.cpp
src/net/webrtc/rtc_media_info.hpp
src/net/webrtc/rtc_base_session.cpp
src/net/webrtc/rtc_base_session.hpp
src/net/webrtc/webrtc_session.cpp
src/net/webrtc/webrtc_session.hpp
src/net/webrtc/rtc_subscriber.cpp
src/net/webrtc/rtc_subscriber.hpp
src/net/webrtc/rtc_dtls.cpp
src/net/webrtc/rtc_dtls.hpp
src/net/webrtc/srtp_session.cpp
src/net/webrtc/srtp_session.hpp
src/net/webrtc/support_rtc_info.cpp
src/net/webrtc/support_rtc_info.hpp
src/net/webrtc/rtc_publisher.cpp
src/net/webrtc/rtc_publisher.hpp
src/net/webrtc/rtp_recv_stream.cpp
src/net/webrtc/rtp_recv_stream.hpp
src/net/webrtc/rtp_send_stream.cpp
src/net/webrtc/rtp_send_stream.hpp
src/net/webrtc/nack_generator.cpp
src/net/webrtc/nack_generator.hpp
src/net/webrtc/pack_handle_audio.hpp
src/net/webrtc/pack_handle_pub.hpp
src/net/webrtc/jitterbuffer.cpp
src/net/webrtc/jitterbuffer.hpp
src/net/webrtc/jitterbuffer_pub.hpp
src/net/webrtc/pack_handle_h264.cpp
src/net/webrtc/pack_handle_h264.hpp
src/net/webrtc/pack_handle_vp8.cpp
src/net/webrtc/pack_handle_vp8.hpp
src/net/webrtc/rtp_h264_pack.cpp
src/net/webrtc/rtp_h264_pack.hpp
src/net/webrtc/rtmp2rtc.cpp
src/net/webrtc/rtmp2rtc.hpp
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/bwe_defines.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/include/bwe_defines.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/inter_arrival.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/inter_arrival.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/overuse_detector.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/overuse_detector.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/rate_control.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/rate_control.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/overuse_estimator.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/overuse_estimator.h
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
src/net/webrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h
src/net/httpflv/httpflv_server.cpp
src/net/httpflv/httpflv_server.hpp
src/net/httpflv/httpflv_writer.cpp
src/net/httpflv/httpflv_writer.hpp
src/net/httpapi/httpapi_server.cpp
src/net/httpapi/httpapi_server.hpp
src/utils/ipaddress.hpp
src/utils/session_aliver.hpp
src/utils/stream_statics.hpp
src/utils/stringex.hpp
src/utils/timeex.hpp
src/utils/timer.hpp
src/utils/uuid.hpp
src/utils/logger.cpp
src/utils/logger.hpp
src/utils/config.cpp
src/utils/config.hpp
src/utils/data_buffer.cpp
src/utils/data_buffer.hpp
src/utils/byte_stream.cpp
src/utils/byte_stream.hpp
src/utils/byte_crypto.cpp
src/utils/byte_crypto.hpp
src/utils/av/media_stream_manager.cpp
src/utils/av/media_stream_manager.hpp
src/utils/av/gop_cache.cpp
src/utils/av/gop_cache.hpp)
IF(ENABLE_FFMPEG)
add_definitions(-DENABLE_FFMPEG)
list(APPEND LIBS avfilter avformat avcodec avutil swscale swresample)
aux_source_directory(src/transcode SRC_LIST)
ENDIF()
set_file_group(src ${SRC_LIST})
add_executable(cpp_media_server ${SRC_LIST})
add_dependencies(cpp_media_server sdptransform srtp2) #openssl libsrtp ffmpeg libx264 libopus)
list(APPEND LIBS srtp2 sdptransform uv)
IF (APPLE)
target_link_libraries(cpp_media_server ${LIBS} pthread dl z m)
ELSEIF (UNIX)
target_link_libraries(cpp_media_server
${LIBS} pthread rt dl z m bz2
x264 fdk-aac opus)
ELSEIF (WIN32)
target_link_libraries(cpp_media_server ${LIBS})
ENDIF ()