mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge remote-tracking branch 'srs/feature/codec' into feature/rtc_audio
This commit is contained in:
commit
923209b070
16 changed files with 136 additions and 79 deletions
|
@ -2,5 +2,5 @@
|
|||
#ifndef AVUTIL_AVCONFIG_H
|
||||
#define AVUTIL_AVCONFIG_H
|
||||
#define AV_HAVE_BIGENDIAN 0
|
||||
#define AV_HAVE_FAST_UNALIGNED 1
|
||||
#define AV_HAVE_FAST_UNALIGNED 0
|
||||
#endif /* AVUTIL_AVCONFIG_H */
|
||||
|
|
|
@ -84,11 +84,13 @@ function Ubuntu_prepare()
|
|||
echo "The unzip is installed."
|
||||
fi
|
||||
|
||||
nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
|
||||
echo "Installing nasm."
|
||||
require_sudoer "sudo apt-get install -y --force-yes nasm"
|
||||
sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
|
||||
echo "The nasm is installed."
|
||||
if [[ $SRS_NASM == YES ]]; then
|
||||
nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
|
||||
echo "Installing nasm."
|
||||
require_sudoer "sudo apt-get install -y --force-yes nasm"
|
||||
sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
|
||||
echo "The nasm is installed."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $SRS_VALGRIND == YES ]]; then
|
||||
|
@ -420,6 +422,10 @@ fi
|
|||
# ffmpeg-fix, for WebRTC to transcode AAC with Opus.
|
||||
#####################################################################################
|
||||
if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then
|
||||
FFMPEG_OPTIONS=""
|
||||
if [[ $SRS_NASM == NO ]]; then
|
||||
FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm"
|
||||
fi
|
||||
if [[ -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]]; then
|
||||
echo "The ffmpeg-4.2-fit is ok.";
|
||||
else
|
||||
|
@ -429,7 +435,7 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then
|
|||
ln -sf ../3rdparty/ffmpeg-4.2-fit && cd ffmpeg-4.2-fit &&
|
||||
PKG_CONFIG_PATH=$ABS_OBJS/opus/lib/pkgconfig ./configure \
|
||||
--prefix=`pwd`/_release \
|
||||
--pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm \
|
||||
--pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm ${FFMPEG_OPTIONS} \
|
||||
--disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \
|
||||
--disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network \
|
||||
--disable-dct --disable-dwt --disable-error-resilience --disable-lsp --disable-lzo --disable-faan --disable-pixelutils \
|
||||
|
@ -437,7 +443,7 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then
|
|||
--disable-avfoundation --disable-securetransport --disable-iconv --disable-lzma --disable-sdl2 --disable-everything \
|
||||
--enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm --enable-decoder=libopus --enable-encoder=aac \
|
||||
--enable-encoder=opus --enable-encoder=libopus --enable-libopus &&
|
||||
make ${SRS_JOBS} && make install
|
||||
make ${SRS_JOBS} && make install &&
|
||||
cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4.2-fit/_release ffmpeg
|
||||
)
|
||||
fi
|
||||
|
|
|
@ -18,6 +18,7 @@ help=no
|
|||
SRS_HDS=NO
|
||||
SRS_SRT=NO
|
||||
SRS_RTC=YES
|
||||
SRS_NASM=YES
|
||||
SRS_NGINX=NO
|
||||
SRS_FFMPEG_TOOL=NO
|
||||
SRS_LIBRTMP=NO
|
||||
|
@ -179,6 +180,8 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec
|
|||
--ld=<LD> Use linker tool LD, default is ld.
|
||||
--randlib=<RANDLIB> Use randlib tool RANDLIB, default is randlib.
|
||||
--extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS.
|
||||
--with-nasm Build FFMPEG for RTC with nasm support.
|
||||
--without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old.
|
||||
|
||||
Conflicts:
|
||||
1. --with-gmc vs --with-gmp:
|
||||
|
@ -229,6 +232,7 @@ function parse_user_option() {
|
|||
--with-utest) SRS_UTEST=YES ;;
|
||||
--with-srt) SRS_SRT=YES ;;
|
||||
--with-rtc) SRS_RTC=YES ;;
|
||||
--with-nasm) SRS_NASM=YES ;;
|
||||
--with-gperf) SRS_GPERF=YES ;;
|
||||
--with-gmc) SRS_GPERF_MC=YES ;;
|
||||
--with-gmd) SRS_GPERF_MD=YES ;;
|
||||
|
@ -246,6 +250,7 @@ function parse_user_option() {
|
|||
--without-utest) SRS_UTEST=NO ;;
|
||||
--without-srt) SRS_SRT=NO ;;
|
||||
--without-rtc) SRS_RTC=NO ;;
|
||||
--without-nasm) SRS_NASM=NO ;;
|
||||
--without-gperf) SRS_GPERF=NO ;;
|
||||
--without-gmc) SRS_GPERF_MC=NO ;;
|
||||
--without-gmd) SRS_GPERF_MD=NO ;;
|
||||
|
@ -545,6 +550,7 @@ function regenerate_options() {
|
|||
if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi
|
||||
if [ $SRS_SRT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-srt"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-srt"; fi
|
||||
if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-rtc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-rtc"; fi
|
||||
if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nasm"; fi
|
||||
if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi
|
||||
if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi
|
||||
if [ $SRS_GPERF_MD = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmd"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmd"; fi
|
||||
|
|
4
trunk/configure
vendored
4
trunk/configure
vendored
|
@ -192,6 +192,10 @@ fi
|
|||
if [[ $SRS_GCOV == YES ]]; then
|
||||
SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
|
||||
fi
|
||||
# For FFMPEG/RTC.
|
||||
if [[ $SRS_RTC == YES && $SRS_NASM == NO ]]; then
|
||||
SrsLinkOptions="${SrsLinkOptions} -lrt";
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
# Modules, compile each module, then link to binary
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
cmake_minimum_required(VERSION 2.6.4)
|
||||
project(srs CXX)
|
||||
|
||||
INCLUDE_DIRECTORIES(../../objs
|
||||
../../objs/st ../../objs/hp ../../objs/openssl/include
|
||||
../../src/core ../../src/kernel ../../src/protocol ../../src/app)
|
||||
INCLUDE_DIRECTORIES(../../objs
|
||||
../../objs/st ../../objs/hp ../../objs/openssl/include
|
||||
../../src/core ../../src/kernel ../../src/protocol ../../src/app
|
||||
../../src/service)
|
||||
|
||||
set(SOURCE_FILES ../../src/main/srs_main_server.cpp)
|
||||
AUX_SOURCE_DIRECTORY(../../src/core SOURCE_FILES)
|
||||
AUX_SOURCE_DIRECTORY(../../src/kernel SOURCE_FILES)
|
||||
AUX_SOURCE_DIRECTORY(../../src/protocol SOURCE_FILES)
|
||||
AUX_SOURCE_DIRECTORY(../../src/app SOURCE_FILES)
|
||||
AUX_SOURCE_DIRECTORY(../../src/service SOURCE_FILES)
|
||||
|
||||
ADD_DEFINITIONS("-g -O0")
|
||||
|
||||
|
@ -18,7 +20,6 @@ TARGET_LINK_LIBRARIES(srs dl)
|
|||
TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/st/libst.a)
|
||||
TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/openssl/lib/libssl.a)
|
||||
TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/openssl/lib/libcrypto.a)
|
||||
TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/hp/libhttp_parser.a)
|
||||
TARGET_LINK_LIBRARIES(srs -ldl)
|
||||
|
||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/../../objs/st/libst.a)
|
||||
|
|
|
@ -237,23 +237,21 @@ SrsUdpMuxSocket::~SrsUdpMuxSocket()
|
|||
srs_freepa(buf);
|
||||
}
|
||||
|
||||
SrsUdpMuxSocket::SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs)
|
||||
SrsUdpMuxSocket* SrsUdpMuxSocket::copy_sendonly()
|
||||
{
|
||||
operator=(rhs);
|
||||
}
|
||||
SrsUdpMuxSocket* sendonly = new SrsUdpMuxSocket(lfd);
|
||||
|
||||
SrsUdpMuxSocket& SrsUdpMuxSocket::operator=(const SrsUdpMuxSocket& rhs)
|
||||
{
|
||||
buf = NULL;
|
||||
nb_buf = 0;
|
||||
nread = 0;
|
||||
lfd = rhs.lfd;
|
||||
from = rhs.from;
|
||||
fromlen = rhs.fromlen;
|
||||
peer_ip = rhs.peer_ip;
|
||||
peer_port = rhs.peer_port;
|
||||
// Don't copy buffer
|
||||
srs_freepa(sendonly->buf);
|
||||
sendonly->nb_buf = 0;
|
||||
sendonly->nread = 0;
|
||||
sendonly->lfd = lfd;
|
||||
sendonly->from = from;
|
||||
sendonly->fromlen = fromlen;
|
||||
sendonly->peer_ip = peer_ip;
|
||||
sendonly->peer_port = peer_port;
|
||||
|
||||
return *this;
|
||||
return sendonly;
|
||||
}
|
||||
|
||||
int SrsUdpMuxSocket::recvfrom(srs_utime_t timeout)
|
||||
|
|
|
@ -143,9 +143,6 @@ public:
|
|||
SrsUdpMuxSocket(srs_netfd_t fd);
|
||||
virtual ~SrsUdpMuxSocket();
|
||||
|
||||
SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs);
|
||||
SrsUdpMuxSocket& operator=(const SrsUdpMuxSocket& rhs);
|
||||
|
||||
int recvfrom(srs_utime_t timeout);
|
||||
srs_error_t sendto(void* data, int size, srs_utime_t timeout);
|
||||
|
||||
|
@ -154,6 +151,12 @@ public:
|
|||
std::string get_peer_ip() const { return peer_ip; }
|
||||
int get_peer_port() const { return peer_port; }
|
||||
std::string get_peer_id();
|
||||
public:
|
||||
SrsUdpMuxSocket* copy_sendonly();
|
||||
private:
|
||||
// Don't allow copy, user copy_sendonly instead
|
||||
SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs);
|
||||
SrsUdpMuxSocket& operator=(const SrsUdpMuxSocket& rhs);
|
||||
};
|
||||
|
||||
class SrsUdpMuxListener : public ISrsCoroutineHandler
|
||||
|
|
|
@ -605,18 +605,19 @@ srs_error_t SrsDtlsSession::unprotect_rtcp(char* out_buf, const char* in_buf, in
|
|||
}
|
||||
|
||||
SrsRtcSenderThread::SrsRtcSenderThread(SrsRtcSession* s, SrsUdpMuxSocket* u, int parent_cid)
|
||||
: ukt(NULL)
|
||||
: sendonly_ukt(NULL)
|
||||
{
|
||||
_parent_cid = parent_cid;
|
||||
trd = new SrsDummyCoroutine();
|
||||
|
||||
rtc_session = s;
|
||||
ukt = *u;
|
||||
sendonly_ukt = u->copy_sendonly();
|
||||
}
|
||||
|
||||
SrsRtcSenderThread::~SrsRtcSenderThread()
|
||||
{
|
||||
srs_freep(trd);
|
||||
srs_freep(sendonly_ukt);
|
||||
}
|
||||
|
||||
int SrsRtcSenderThread::cid()
|
||||
|
@ -695,10 +696,19 @@ srs_error_t SrsRtcSenderThread::cycle()
|
|||
continue;
|
||||
}
|
||||
|
||||
send_and_free_messages(msgs.msgs, msg_count, &ukt);
|
||||
send_and_free_messages(msgs.msgs, msg_count, sendonly_ukt);
|
||||
}
|
||||
}
|
||||
|
||||
void SrsRtcSenderThread::update_sendonly_socket(SrsUdpMuxSocket* ukt)
|
||||
{
|
||||
srs_trace("session %s address changed, update %s -> %s",
|
||||
rtc_session->id().c_str(), sendonly_ukt->get_peer_id().c_str(), ukt->get_peer_id().c_str());
|
||||
|
||||
srs_freep(sendonly_ukt);
|
||||
sendonly_ukt = ukt->copy_sendonly();
|
||||
}
|
||||
|
||||
void SrsRtcSenderThread::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, SrsUdpMuxSocket* udp_mux_skt)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -776,6 +786,12 @@ srs_error_t SrsRtcSession::on_stun(SrsUdpMuxSocket* udp_mux_skt, SrsStunPacket*
|
|||
|
||||
last_stun_time = srs_get_system_time();
|
||||
|
||||
if (strd && strd->sendonly_ukt) {
|
||||
if (strd->sendonly_ukt->get_peer_id() != udp_mux_skt->get_peer_id()) {
|
||||
strd->update_sendonly_socket(udp_mux_skt);
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,8 @@ protected:
|
|||
int _parent_cid;
|
||||
private:
|
||||
SrsRtcSession* rtc_session;
|
||||
SrsUdpMuxSocket ukt;
|
||||
public:
|
||||
SrsUdpMuxSocket* sendonly_ukt;
|
||||
public:
|
||||
SrsRtcSenderThread(SrsRtcSession* s, SrsUdpMuxSocket* u, int parent_cid);
|
||||
virtual ~SrsRtcSenderThread();
|
||||
|
@ -177,6 +178,8 @@ public:
|
|||
virtual void stop_loop();
|
||||
public:
|
||||
virtual srs_error_t cycle();
|
||||
public:
|
||||
void update_sendonly_socket(SrsUdpMuxSocket* ukt);
|
||||
private:
|
||||
void send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, SrsUdpMuxSocket* udp_mux_skt);
|
||||
};
|
||||
|
|
|
@ -62,6 +62,11 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
|
||||
// For RTC/FFMPEG build.
|
||||
#if defined(SRS_AUTO_RTC) && !defined(__STDC_CONSTANT_MACROS)
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#endif
|
||||
|
||||
// For srs-librtmp, @see https://github.com/ossrs/srs/issues/213
|
||||
#ifndef _WIN32
|
||||
#include <inttypes.h>
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef SRS_CORE_VERSION4_HPP
|
||||
#define SRS_CORE_VERSION4_HPP
|
||||
|
||||
#define SRS_VERSION4_REVISION 13
|
||||
#define SRS_VERSION4_REVISION 14
|
||||
|
||||
#endif
|
||||
|
|
|
@ -652,15 +652,20 @@ bool srs_path_exists(std::string path)
|
|||
string srs_path_dirname(string path)
|
||||
{
|
||||
std::string dirname = path;
|
||||
|
||||
// No slash, it must be current dir.
|
||||
size_t pos = string::npos;
|
||||
|
||||
if ((pos = dirname.rfind("/")) != string::npos) {
|
||||
if (pos == 0) {
|
||||
return "/";
|
||||
}
|
||||
dirname = dirname.substr(0, pos);
|
||||
if ((pos = dirname.rfind("/")) == string::npos) {
|
||||
return "./";
|
||||
}
|
||||
|
||||
|
||||
// Path under root.
|
||||
if (pos == 0) {
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Fetch the directory.
|
||||
dirname = dirname.substr(0, pos);
|
||||
return dirname;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,8 +337,8 @@ void show_macro_features()
|
|||
#endif
|
||||
|
||||
#if VERSION_MAJOR > VERSION_STABLE
|
||||
#warning "Current branch is unstable."
|
||||
srs_warn("Develop is unstable, please use branch: git checkout -b %s origin/%s", VERSION_STABLE_BRANCH, VERSION_STABLE_BRANCH);
|
||||
#warning "Current branch is beta."
|
||||
srs_warn("%s/%s is beta", RTMP_SIG_SRS_KEY, RTMP_SIG_SRS_VERSION);
|
||||
#endif
|
||||
|
||||
#if defined(SRS_PERF_SO_SNDBUF_SIZE) && !defined(SRS_PERF_MW_SO_SNDBUF)
|
||||
|
|
|
@ -2565,7 +2565,7 @@ VOID TEST(KernelUtility, BytesUtils)
|
|||
VOID TEST(KernelUtility, PathUtils)
|
||||
{
|
||||
if (true) {
|
||||
EXPECT_TRUE("" == srs_path_dirname(""));
|
||||
EXPECT_TRUE("./" == srs_path_dirname(""));
|
||||
EXPECT_TRUE("/" == srs_path_dirname("/"));
|
||||
EXPECT_TRUE("/" == srs_path_dirname("//"));
|
||||
EXPECT_TRUE("/" == srs_path_dirname("/stream"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue