mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-27 04:20:13 +08:00
修改服务器版本信息声明相关代码
This commit is contained in:
parent
dfbfd65ab3
commit
3165a2f81c
113
CMakeLists.txt
113
CMakeLists.txt
@ -7,13 +7,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
#set(CMAKE_BUILD_TYPE "Release")
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
message(STATUS "Release版本")
|
||||
set(BuildType "Release")
|
||||
else()
|
||||
else ()
|
||||
set(BuildType "Debug")
|
||||
message(STATUS "Debug版本")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#设置bin和lib库目录
|
||||
set(RELEASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
|
||||
@ -57,6 +57,41 @@ option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
|
||||
option(ENABLE_ASAN "Enable Address Sanitize" false)
|
||||
option(ENABLE_WEBRTC "Enable WebRTC" false)
|
||||
|
||||
# 添加git版本信息
|
||||
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
||||
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
|
||||
set(BUILD_TIME "")
|
||||
|
||||
string(TIMESTAMP BUILD_TIME "%Y/%m/%d-%H:%M:%S")
|
||||
|
||||
find_package(Git QUIET)
|
||||
if (GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
||||
OUTPUT_VARIABLE BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif ()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
|
||||
${CMAKE_BINARY_DIR}/Version.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
add_definitions(-DENABLE_VERSION)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")
|
||||
|
||||
if (ENABLE_MEM_DEBUG)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,realloc -Wl,-wrap,calloc")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-wrap,free -Wl,-wrap,malloc -Wl,-wrap,realloc -Wl,-wrap,calloc")
|
||||
@ -74,11 +109,11 @@ set(LINK_LIB_LIST zlmediakit zltoolkit)
|
||||
|
||||
#默认链接jemalloc库避免内存碎片
|
||||
find_package(JEMALLOC QUIET)
|
||||
if(JEMALLOC_FOUND)
|
||||
if (JEMALLOC_FOUND)
|
||||
message(STATUS "found library:\"${JEMALLOC_LIBRARIES}\"")
|
||||
include_directories(${JEMALLOC_INCLUDE_DIR})
|
||||
list(APPEND LINK_LIB_LIST ${JEMALLOC_LIBRARIES})
|
||||
endif()
|
||||
list(APPEND LINK_LIB_LIST ${JEMALLOC_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
#查找openssl是否安装
|
||||
find_package(OpenSSL QUIET)
|
||||
@ -89,9 +124,9 @@ if (OPENSSL_FOUND AND ENABLE_OPENSSL)
|
||||
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES})
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND OPENSSL_USE_STATIC_LIBS)
|
||||
list(APPEND LINK_LIB_LIST dl)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
else()
|
||||
else ()
|
||||
message(WARNING "openssl未找到,rtmp将不支持flash播放器,https/wss/rtsps/rtmps也将失效")
|
||||
endif ()
|
||||
|
||||
@ -124,10 +159,10 @@ if (FAAC_FOUND AND ENABLE_FAAC)
|
||||
endif ()
|
||||
|
||||
#set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573 /wd4996" )
|
||||
set(VS_FALGS "/wd4819" )
|
||||
set(VS_FALGS "/wd4819")
|
||||
|
||||
#添加mpeg用于支持ts生成
|
||||
if(ENABLE_HLS)
|
||||
if (ENABLE_HLS)
|
||||
message(STATUS "ENABLE_HLS defined")
|
||||
add_definitions(-DENABLE_HLS)
|
||||
|
||||
@ -139,13 +174,13 @@ if(ENABLE_HLS)
|
||||
list(APPEND LINK_LIB_LIST mpeg)
|
||||
list(APPEND CXX_API_TARGETS mpeg)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||
endif(WIN32)
|
||||
endif()
|
||||
if (WIN32)
|
||||
set_target_properties(mpeg PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||
endif (WIN32)
|
||||
endif ()
|
||||
|
||||
#添加mov、flv库用于MP4录制
|
||||
if(ENABLE_MP4)
|
||||
if (ENABLE_MP4)
|
||||
message(STATUS "ENABLE_MP4 defined")
|
||||
add_definitions(-DENABLE_MP4)
|
||||
|
||||
@ -153,39 +188,39 @@ if(ENABLE_MP4)
|
||||
include_directories(${MediaServer_Root}/libflv/include)
|
||||
|
||||
aux_source_directory(${MediaServer_Root}/libmov/include src_mov)
|
||||
aux_source_directory(${MediaServer_Root}/libmov/source src_mov)
|
||||
aux_source_directory(${MediaServer_Root}/libmov/source src_mov)
|
||||
|
||||
aux_source_directory(${MediaServer_Root}/libflv/include src_flv)
|
||||
aux_source_directory(${MediaServer_Root}/libflv/source src_flv)
|
||||
aux_source_directory(${MediaServer_Root}/libflv/source src_flv)
|
||||
|
||||
add_library(mov STATIC ${src_mov})
|
||||
add_library(flv STATIC ${src_flv})
|
||||
add_library(flv STATIC ${src_flv})
|
||||
list(APPEND LINK_LIB_LIST mov flv)
|
||||
list(APPEND CXX_API_TARGETS mov flv)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||
endif(WIN32)
|
||||
endif()
|
||||
if (WIN32)
|
||||
set_target_properties(mov flv PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||
endif (WIN32)
|
||||
endif ()
|
||||
|
||||
#添加rtp库用于rtp转ps/ts
|
||||
if(ENABLE_RTPPROXY AND ENABLE_HLS)
|
||||
if (ENABLE_RTPPROXY AND ENABLE_HLS)
|
||||
message(STATUS "ENABLE_RTPPROXY defined")
|
||||
add_definitions(-DENABLE_RTPPROXY)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
#收集源代码
|
||||
file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c)
|
||||
if(IOS)
|
||||
if (IOS)
|
||||
list(APPEND ToolKit_src_list ${ToolKit_Root}/Network/Socket_ios.mm)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c)
|
||||
|
||||
#去除win32的适配代码
|
||||
if (NOT WIN32)
|
||||
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
|
||||
else()
|
||||
else ()
|
||||
#防止Windows.h包含Winsock.h
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
endif ()
|
||||
@ -205,18 +240,18 @@ else ()
|
||||
set(INSTALL_PATH_EXECUTABLE bin)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_CXX_API)
|
||||
if (ENABLE_CXX_API)
|
||||
# 保留目录结构
|
||||
install(DIRECTORY ${ToolKit_Root}/ DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE)
|
||||
install(DIRECTORY ${ToolKit_Root}/ DESTINATION ${INSTALL_PATH_INCLUDE}/ZLToolKit REGEX "(.*[.](md|cpp)|win32)$" EXCLUDE)
|
||||
install(DIRECTORY ${MediaKit_Root}/ DESTINATION ${INSTALL_PATH_INCLUDE}/ZLMediaKit REGEX ".*[.](md|cpp)$" EXCLUDE)
|
||||
install(TARGETS ${CXX_API_TARGETS} DESTINATION ${INSTALL_PATH_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
||||
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||
elseif(NOT ANDROID OR IOS)
|
||||
set_target_properties(zltoolkit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||
set_target_properties(zlmediakit PROPERTIES COMPILE_FLAGS ${VS_FALGS})
|
||||
elseif (NOT ANDROID OR IOS)
|
||||
list(APPEND LINK_LIB_LIST pthread)
|
||||
endif ()
|
||||
|
||||
@ -225,9 +260,9 @@ execute_process(COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/www ${EXECUTABLE_OUTPU
|
||||
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/conf/config.ini ${EXECUTABLE_OUTPUT_PATH}/)
|
||||
|
||||
#添加c库
|
||||
if(ENABLE_API)
|
||||
if (ENABLE_API)
|
||||
add_subdirectory(api)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (ENABLE_WEBRTC)
|
||||
#查找srtp是否安装
|
||||
@ -249,11 +284,11 @@ endif ()
|
||||
|
||||
if (NOT IOS)
|
||||
#测试程序
|
||||
if(ENABLE_TESTS)
|
||||
if (ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif ()
|
||||
#主服务器
|
||||
if(ENABLE_SERVER)
|
||||
if (ENABLE_SERVER)
|
||||
add_subdirectory(server)
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
@ -142,7 +142,7 @@ keepAliveSecond=30
|
||||
#http请求体最大字节数,如果post的body太大,则不适合缓存body在内存
|
||||
maxReqSize=40960
|
||||
#404网页内容,用户可以自定义404网页
|
||||
notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit-4.0</center></body></html>
|
||||
#notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit-4.0</center></body></html>
|
||||
#http服务器监听端口
|
||||
port=80
|
||||
#http文件服务器根目录
|
||||
|
@ -1,44 +1,7 @@
|
||||
include_directories(../3rdpart)
|
||||
file(GLOB jsoncpp_src_list ../3rdpart/jsoncpp/*.cpp ../3rdpart/jsoncpp/*.h )
|
||||
add_library(jsoncpp STATIC ${jsoncpp_src_list})
|
||||
|
||||
file(GLOB MediaServer_src_list ./*.cpp ./*.h)
|
||||
#message(STATUS ${MediaServer_src_list})
|
||||
|
||||
# 添加git版本信息
|
||||
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
|
||||
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
|
||||
set(BUILD_TIME "")
|
||||
|
||||
string(TIMESTAMP BUILD_TIME "%Y/%m/%d-%H:%M:%S")
|
||||
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
|
||||
OUTPUT_VARIABLE BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
|
||||
${CMAKE_BINARY_DIR}/Version.h
|
||||
@ONLY
|
||||
)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
add_definitions(-DENABLE_VERSION)
|
||||
|
||||
add_executable(MediaServer ${MediaServer_src_list})
|
||||
|
||||
|
@ -154,9 +154,9 @@ public:
|
||||
(*_parser) << Option('v', "version", Option::ArgNone, nullptr, false, "显示版本号",
|
||||
[](const std::shared_ptr<ostream> &stream, const string &arg) -> bool {
|
||||
//版本信息
|
||||
*stream << "编译日期: " << build_time << std::endl;
|
||||
*stream << "当前git分支: " << branch_name << std::endl;
|
||||
*stream << "当前git hash值: " << commit_hash << std::endl;
|
||||
*stream << "编译日期: " << BUILD_TIME << std::endl;
|
||||
*stream << "当前git分支: " << BRANCH_TIME << std::endl;
|
||||
*stream << "当前git hash值: " << COMMIT_HASH << std::endl;
|
||||
throw ExitException();
|
||||
});
|
||||
#endif
|
||||
|
@ -1,11 +0,0 @@
|
||||
#ifndef __GIT_VERSION_H__
|
||||
#define __GIT_VERSION_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
const std::string commit_hash = "@COMMIT_HASH@";
|
||||
const std::string branch_name = "@BRANCH_NAME@";
|
||||
const std::string build_time = "@BUILD_TIME@";
|
||||
|
||||
#endif //__GIT_VERSION_H__
|
||||
|
@ -11,6 +11,10 @@
|
||||
#ifndef ZLMEDIAKIT_MACROS_H
|
||||
#define ZLMEDIAKIT_MACROS_H
|
||||
|
||||
#if defined(ENABLE_VERSION)
|
||||
#include "Version.h"
|
||||
#endif
|
||||
|
||||
#if defined(__MACH__)
|
||||
#include <arpa/inet.h>
|
||||
#include <machine/endian.h>
|
||||
@ -53,7 +57,13 @@
|
||||
#define CLEAR_ARR(arr) for(auto &item : arr){ item = 0;}
|
||||
#endif //CLEAR_ARR
|
||||
|
||||
#define SERVER_NAME "ZLMediaKit-5.0(build in " __DATE__ " " __TIME__ ")"
|
||||
//请遵循MIT协议,勿修改服务器声明
|
||||
#if !defined(ENABLE_VERSION)
|
||||
#define SERVER_NAME "ZLMediaKit-6.0(build in " __DATE__ " " __TIME__ ")"
|
||||
#else
|
||||
#define SERVER_NAME "ZLMediaKit(git hash:" COMMIT_HASH ",branch:" BRANCH_TIME ",build time:" BUILD_TIME ")"
|
||||
#endif
|
||||
|
||||
#define VHOST_KEY "vhost"
|
||||
#define HTTP_SCHEMA "http"
|
||||
#define RTSP_SCHEMA "rtsp"
|
||||
|
@ -266,7 +266,7 @@ public:
|
||||
size_t fileSize = 0,
|
||||
const map<string,string> &header = map<string,string>()){
|
||||
_metadata.set("duration", dur_sec);
|
||||
_metadata.set("fileSize", 0);
|
||||
_metadata.set("fileSize", (int)fileSize);
|
||||
_metadata.set("server",SERVER_NAME);
|
||||
for (auto &pr : header){
|
||||
_metadata.set(pr.first, pr.second);
|
||||
|
@ -101,6 +101,7 @@ public:
|
||||
*/
|
||||
virtual void setMetaData(const AMFValue &metadata) {
|
||||
_metadata = metadata;
|
||||
_metadata.set("server", SERVER_NAME);
|
||||
if (_ring) {
|
||||
regist();
|
||||
}
|
||||
|
@ -141,11 +141,11 @@ public:
|
||||
* 设置sdp
|
||||
*/
|
||||
virtual void setSdp(const string &sdp) {
|
||||
_sdp = sdp;
|
||||
SdpParser sdp_parser(sdp);
|
||||
_tracks[TrackVideo] = sdp_parser.getTrack(TrackVideo);
|
||||
_tracks[TrackAudio] = sdp_parser.getTrack(TrackAudio);
|
||||
_have_video = (bool) _tracks[TrackVideo];
|
||||
_sdp = sdp_parser.toString();
|
||||
if (_ring) {
|
||||
regist();
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
_push_src = std::make_shared<RtspMediaSourceImp>(_media_info._vhost, _media_info._app, _media_info._streamid);
|
||||
_push_src->setListener(dynamic_pointer_cast<MediaSourceEvent>(shared_from_this()));
|
||||
_push_src->setProtocolTranslation(enableHls, enableMP4);
|
||||
_push_src->setSdp(sdpParser.toString());
|
||||
_push_src->setSdp(parser.Content());
|
||||
sendRtspResponse("200 OK");
|
||||
};
|
||||
|
||||
|
9
version.h.ini
Normal file
9
version.h.ini
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __GIT_VERSION_H__
|
||||
#define __GIT_VERSION_H__
|
||||
|
||||
#define COMMIT_HASH "@COMMIT_HASH@"
|
||||
#define BRANCH_TIME "@BRANCH_NAME@"
|
||||
#define BUILD_TIME "@BUILD_TIME@"
|
||||
|
||||
#endif //__GIT_VERSION_H__
|
||||
|
@ -1043,7 +1043,6 @@ string RtcSession::toRtspSdp() const{
|
||||
}
|
||||
}
|
||||
|
||||
copy.session_name = "zlmediakit rtsp stream from webrtc";
|
||||
auto sdp = copy.toRtcSessionSdp();
|
||||
toRtsp(sdp->items);
|
||||
int i = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user