Skip to content

Commit

Permalink
Windows: Add srs for windows support(with cygwin64) (#2622)
Browse files Browse the repository at this point in the history
* + add srs for windows support(with cygwin64)

* * fix srt lib64 path issue

* * fix ffmpeg path error
  • Loading branch information
wenjiegit authored and winlinvip committed Dec 4, 2021
1 parent b479b42 commit d969441
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 129 deletions.
2 changes: 1 addition & 1 deletion trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int octet_get_weight(uint8_t octet)

/* the value MAX_PRINT_STRING_LEN is defined in datatypes.h */

char bit_string[MAX_PRINT_STRING_LEN];
static char bit_string[MAX_PRINT_STRING_LEN];

uint8_t srtp_nibble_to_hex_char(uint8_t nibble)
{
Expand Down
226 changes: 120 additions & 106 deletions trunk/auto/depends.sh

Large diffs are not rendered by default.

52 changes: 47 additions & 5 deletions trunk/auto/setup_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ OS_KERNEL_NAME=$(uname -s)
OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}')
OS_PREFIX="Platform"

if [[ $OSTYPE == cygwin ]]; then
OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}')
fi

# Build platform cache.
SRS_PLATFORM="${SRS_BUILD_TAG}${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}"
# Build platform cache with gcc version.
Expand All @@ -23,17 +27,55 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then
SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD-$(echo $SRS_TOOL_CC|awk -F - '{print $1}')"
fi

#TODO find the link lib in objs/Platform_some_platfomr/3rdpatry/some-lib
# 3rdparty lib path
# eg: objs/st, objs/ffmpeg etc.
SRS_3RD_ST_PATH=${SRS_OBJS}/st
SRS_3RD_FFMPEG_PATH=${SRS_OBJS}/ffmpeg
SRS_3RD_OPUS_PATH=${SRS_OBJS}/opus
SRS_3RD_SRTP2_PATH=${SRS_OBJS}/srtp2
SRS_3RD_OPENSSL_PATH=${SRS_OBJS}/openssl
SRS_3RD_SRT_PATH=${SRS_OBJS}/srt

# 3rdparty lib store path
# eg: objs/Platform-CYGWIN_NT-10.0-3.2.0-GCC11.2.0-SRS5-x86_64/3rdpatry/st
SRS_3RD_ST_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st
SRS_3RD_FFMPEG_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg
SRS_3RD_OPUS_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus
SRS_3RD_SRTP2_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2
SRS_3RD_OPENSSL_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl
SRS_3RD_SRT_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt

echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}"

# For src object files on each platform.
(
mkdir -p ${SRS_OBJS_DIR} && cd ${SRS_OBJS_DIR} &&
rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser &&
mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src &&
mkdir -p ${SRS_PLATFORM}/utest && ln -sf ${SRS_PLATFORM}/utest &&
mkdir -p ${SRS_PLATFORM}/research && ln -sf ${SRS_PLATFORM}/research &&
mkdir -p ${SRS_PLATFORM}/include && ln -sf ${SRS_PLATFORM}/include &&
mkdir -p ${SRS_PLATFORM}/lib && ln -sf ${SRS_PLATFORM}/lib
# on windows, clean *.exe
rm -rf srs.exe srs_utest.exe srs_hls_ingester.exe srs_mp4_parser.exe &&
mkdir -p ${SRS_PLATFORM}/src &&
mkdir -p ${SRS_PLATFORM}/research &&
mkdir -p ${SRS_PLATFORM}/include &&
mkdir -p ${SRS_PLATFORM}/lib &&
mkdir -p ${SRS_PLATFORM}/utest &&

rm -rf st ffmpeg opus srtp2 openssl srt &&
# objs/some-lib
mkdir -p ${SRS_3RD_ST_PATH} &&
mkdir -p ${SRS_3RD_FFMPEG_PATH} &&
mkdir -p ${SRS_3RD_OPUS_PATH} &&
mkdir -p ${SRS_3RD_SRTP2_PATH} &&
mkdir -p ${SRS_3RD_OPENSSL_PATH} &&
mkdir -p ${SRS_3RD_SRT_STORE_PATH} &&

# objs/Platform_some_platform/3rdpatry/some-lib
mkdir -p ${SRS_3RD_ST_STORE_PATH} &&
mkdir -p ${SRS_3RD_FFMPEG_STORE_PATH} &&
mkdir -p ${SRS_3RD_OPUS_STORE_PATH} &&
mkdir -p ${SRS_3RD_SRTP2_STORE_PATH} &&
mkdir -p ${SRS_3RD_OPENSSL_STORE_PATH} &&
mkdir -p ${SRS_3RD_SRT_STORE_PATH}
)
if [[ $SRS_CLEAN == NO ]]; then
echo "Fast cleanup, if need to do full cleanup, please use: make clean"
Expand Down
6 changes: 3 additions & 3 deletions trunk/auto/utest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
# $MODULE_DIR the src dir of utest code. ie. src/utest
# $LINK_OPTIONS the link options for utest. ie. -lpthread -ldl

FILE=${SRS_OBJS}/utest/${SRS_MAKEFILE}
FILE=${SRS_OBJS}/${SRS_PLATFORM}/utest/${SRS_MAKEFILE}
# create dir for Makefile
mkdir -p ${SRS_OBJS}/utest
mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/utest

# the prefix to generate the objs/utest/Makefile
# dirs relative to current dir(objs/utest), it's trunk/objs/utest
# trunk of srs, which contains the src dir, relative to objs/utest, it's trunk
SRS_TRUNK_PREFIX=../../..
# gest dir, relative to objs/utest, it's trunk/objs/gtest
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${SRS_PLATFORM}/gtest

cat << END > ${FILE}
# user must run make the ${SRS_OBJS_DIR}/utest dir
Expand Down
14 changes: 11 additions & 3 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# the main output dir, all configure and make output are in this dir.
#####################################################################################
# create the main objs
SRS_WORKDIR="."
SRS_WORKDIR=`pwd`
SRS_OBJS_DIR="objs"
SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}"
SRS_MAKEFILE="Makefile"
Expand Down Expand Up @@ -87,6 +87,9 @@ CppStd="-ansi"
if [[ $SRS_CXX11 == YES ]]; then
CppStd="-std=c++11"
fi
if [[ $SRS_WINDOWS == YES ]]; then
CppStd="-std=gnu++11"
fi
if [[ $SRS_CXX14 == YES ]]; then
CppStd="-std=c++14"
fi
Expand Down Expand Up @@ -164,7 +167,7 @@ fi

# srt code path
if [[ $SRS_SRT == YES ]]; then
SrsSRTRoot="${SRS_WORKDIR}/src/srt"
SrsSRTRoot="src/srt"
LibSRTRoot="${SRS_OBJS_DIR}/srt/include"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a"
if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-L${SRS_OBJS_DIR}/srt/lib -lsrt"; fi
fi
Expand All @@ -188,10 +191,15 @@ if [[ $SRS_GCOV == YES ]]; then
fi

# For FFMPEG/RTC on Linux.
if [[ $SRS_OSX != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then
if [[ $SRS_OSX != YES && $SRS_WINDOWS != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lrt";
fi

# For FFMPEG/RTC on windows.
if [[ $SRS_WINDOWS == YES && $SRS_FFMPEG_FIT == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lbcrypt";
fi

#####################################################################################
# Modules, compile each module, then link to binary
#
Expand Down
6 changes: 3 additions & 3 deletions trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <algorithm>
#ifndef SRS_OSX
#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
#include <sys/inotify.h>
#endif
using namespace std;
Expand Down Expand Up @@ -370,7 +370,7 @@ srs_error_t SrsInotifyWorker::start()
{
srs_error_t err = srs_success;

#ifndef SRS_OSX
#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
// Whether enable auto reload config.
bool auto_reload = _srs_config->inotify_auto_reload();
if (!auto_reload && _srs_in_docker && _srs_config->auto_reload_for_docker()) {
Expand Down Expand Up @@ -450,7 +450,7 @@ srs_error_t SrsInotifyWorker::cycle()
{
srs_error_t err = srs_success;

#ifndef SRS_OSX
#if !defined(SRS_OSX) && !defined(SRS_WINDOWS)
string config_path = _srs_config->config();
string config_file = srs_path_basename(config_path);
string k8s_file = "..data";
Expand Down
6 changes: 0 additions & 6 deletions trunk/src/app/srs_app_uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ static inline __attribute__((const)) int is_power_of_2(unsigned long num)
return (num != 0 && ((num & (num - 1)) == 0));
}

#ifndef HAVE_LOFF_T
typedef int64_t loff_t;
#endif

#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
#include <sys/types.h>
#include <dirent.h>
Expand Down Expand Up @@ -1075,8 +1071,6 @@ void uuid_generate(uuid_t out)
#include <string.h>
#include <sys/time.h>

#include <sys/syscall.h>

//#include "randutils.h"

#ifdef HAVE_TLS
Expand Down
1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
#define ERROR_SOCKET_SETREUSEADDR 1079
#define ERROR_SOCKET_SETCLOSEEXEC 1080
#define ERROR_SOCKET_ACCEPT 1081
#define ERROR_ST_SET_SELECT 1082

///////////////////////////////////////////////////////
// RTMP protocol error.
Expand Down
10 changes: 8 additions & 2 deletions trunk/src/protocol/srs_service_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ srs_error_t srs_st_init()

// Select the best event system available on the OS. In Linux this is
// epoll(). On BSD it will be kqueue.
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
#ifdef SRS_WINDOWS
if (st_set_eventsys(ST_EVENTSYS_SELECT) == -1) {
return srs_error_new(ERROR_ST_SET_SELECT, "st enable st failed, current is %s", st_get_eventsys_name());
}
#else
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
}
#endif

// Before ST init, we might have already initialized the background cid.
SrsContextId cid = _srs_context->get_id();
Expand Down

0 comments on commit d969441

Please sign in to comment.