mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine RTC, disable NASM, SENDMMSG, SRTP-NASM
This commit is contained in:
parent
32c4febafe
commit
2a0562da5e
12 changed files with 44 additions and 82 deletions
10
trunk/3rdparty/st-srs/io.c
vendored
10
trunk/3rdparty/st-srs/io.c
vendored
|
@ -743,16 +743,18 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(MD_HAVE_SENDMMSG) && defined(__linux__) && defined(_GNU_SOURCE)
|
int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
|
||||||
int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
|
|
||||||
{
|
{
|
||||||
|
#if !defined(MD_HAVE_SENDMMSG) || !defined(_GNU_SOURCE)
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
int n;
|
int n;
|
||||||
int left;
|
int left;
|
||||||
struct mmsghdr *p;
|
struct mmsghdr *p;
|
||||||
|
|
||||||
left = (int)vlen;
|
left = (int)vlen;
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
p = msgvec + (vlen - left);
|
p = (struct mmsghdr*)msgvec + (vlen - left);
|
||||||
|
|
||||||
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
|
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
|
@ -772,8 +774,8 @@ int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int fl
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return (int)vlen - left;
|
return (int)vlen - left;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
4
trunk/3rdparty/st-srs/public.h
vendored
4
trunk/3rdparty/st-srs/public.h
vendored
|
@ -151,9 +151,7 @@ extern int st_recvfrom(st_netfd_t fd, void *buf, int len, struct sockaddr *from,
|
||||||
extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout);
|
extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout);
|
||||||
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
|
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
|
||||||
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
|
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
|
||||||
#if defined(__linux__) && defined(_GNU_SOURCE)
|
extern int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
|
||||||
extern int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
|
|
||||||
#endif
|
|
||||||
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
|
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -165,11 +165,6 @@ if [ $SRS_SENDMMSG = YES ]; then
|
||||||
else
|
else
|
||||||
srs_undefine_macro "SRS_SENDMMSG" $SRS_AUTO_HEADERS_H
|
srs_undefine_macro "SRS_SENDMMSG" $SRS_AUTO_HEADERS_H
|
||||||
fi
|
fi
|
||||||
if [ $SRS_HAS_SENDMMSG = YES ]; then
|
|
||||||
srs_define_macro "SRS_HAS_SENDMMSG" $SRS_AUTO_HEADERS_H
|
|
||||||
else
|
|
||||||
srs_undefine_macro "SRS_HAS_SENDMMSG" $SRS_AUTO_HEADERS_H
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $SRS_DEBUG = YES ]; then
|
if [ $SRS_DEBUG = YES ]; then
|
||||||
srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
|
srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
|
||||||
|
|
|
@ -347,7 +347,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||||
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_`uname -r`_DBG"
|
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_`uname -r`_DBG"
|
||||||
fi
|
fi
|
||||||
# For UDP sendmmsg, disable it if not suppported.
|
# For UDP sendmmsg, disable it if not suppported.
|
||||||
if [[ $SRS_HAS_SENDMMSG == YES ]]; then
|
if [[ $SRS_SENDMMSG == YES ]]; then
|
||||||
echo "Build ST with UDP sendmmsg support."
|
echo "Build ST with UDP sendmmsg support."
|
||||||
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
|
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
|
||||||
else
|
else
|
||||||
|
|
|
@ -118,11 +118,9 @@ SRS_EXTRA_FLAGS=
|
||||||
#
|
#
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# Performance optimize.
|
# Performance optimize.
|
||||||
SRS_NASM=YES
|
SRS_NASM=NO
|
||||||
SRS_SRTP_ASM=YES
|
SRS_SRTP_ASM=NO
|
||||||
SRS_SENDMMSG=YES
|
SRS_SENDMMSG=NO
|
||||||
SRS_HAS_SENDMMSG=YES
|
|
||||||
SRS_DETECT_SENDMMSG=YES
|
|
||||||
SRS_DEBUG=NO
|
SRS_DEBUG=NO
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
@ -257,8 +255,6 @@ function parse_user_option() {
|
||||||
--export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;;
|
--export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;;
|
||||||
--export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;;
|
--export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;;
|
||||||
|
|
||||||
--detect-sendmmsg) if [[ $value == off ]]; then SRS_DETECT_SENDMMSG=NO; else SRS_DETECT_SENDMMSG=YES; fi ;;
|
|
||||||
--has-sendmmsg) if [[ $value == off ]]; then SRS_HAS_SENDMMSG=NO; else SRS_HAS_SENDMMSG=YES; fi ;;
|
|
||||||
--sendmmsg) if [[ $value == off ]]; then SRS_SENDMMSG=NO; else SRS_SENDMMSG=YES; fi ;;
|
--sendmmsg) if [[ $value == off ]]; then SRS_SENDMMSG=NO; else SRS_SENDMMSG=YES; fi ;;
|
||||||
|
|
||||||
--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
|
--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
|
||||||
|
@ -612,31 +608,6 @@ function apply_user_detail_options() {
|
||||||
echo "Disable SRTP ASM, because NASM is disabled."
|
echo "Disable SRTP ASM, because NASM is disabled."
|
||||||
SRS_SRTP_ASM=NO
|
SRS_SRTP_ASM=NO
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect whether has sendmmsg.
|
|
||||||
# @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
|
||||||
if [[ $SRS_DETECT_SENDMMSG == YES ]]; then
|
|
||||||
mkdir -p ${SRS_OBJS} &&
|
|
||||||
echo " #include <sys/socket.h> " > ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
echo " int main(int argc, char** argv) { " >> ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
echo " struct mmsghdr hdr; " >> ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
echo " hdr.msg_len = 0; " >> ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
echo " return 0; " >> ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
echo " } " >> ${SRS_OBJS}/_tmp_sendmmsg_detect.c
|
|
||||||
${SRS_TOOL_CC} -c ${SRS_OBJS}/_tmp_sendmmsg_detect.c -D_GNU_SOURCE -o /dev/null >/dev/null 2>&1
|
|
||||||
ret=$?; rm -f ${SRS_OBJS}/_tmp_sendmmsg_detect.c;
|
|
||||||
if [[ $ret -ne 0 ]]; then
|
|
||||||
SRS_HAS_SENDMMSG=NO
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If system has no sendmmsg, disable sendmmsg.
|
|
||||||
if [[ $SRS_HAS_SENDMMSG == NO ]]; then
|
|
||||||
if [[ $SRS_SENDMMSG == YES ]]; then
|
|
||||||
echo "Disable UDP sendmmsg automatically"
|
|
||||||
SRS_SENDMMSG=NO
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
apply_user_detail_options
|
apply_user_detail_options
|
||||||
|
|
||||||
|
@ -666,8 +637,6 @@ function regenerate_options() {
|
||||||
if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=off"; fi
|
if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=off"; fi
|
||||||
if [ $SRS_SRTP_ASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=off"; fi
|
if [ $SRS_SRTP_ASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=off"; fi
|
||||||
if [ $SRS_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=off"; fi
|
if [ $SRS_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=off"; fi
|
||||||
if [ $SRS_DETECT_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --detect-sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --detect-sendmmsg=off"; fi
|
|
||||||
if [ $SRS_HAS_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --has-sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --has-sendmmsg=off"; fi
|
|
||||||
if [ $SRS_CLEAN = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=off"; fi
|
if [ $SRS_CLEAN = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --clean=off"; fi
|
||||||
if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=off"; fi
|
if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gperf=off"; fi
|
||||||
if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=off"; fi
|
if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gmc=off"; fi
|
||||||
|
|
|
@ -4781,7 +4781,7 @@ bool SrsConfig::get_rtc_server_encrypt()
|
||||||
|
|
||||||
int SrsConfig::get_rtc_server_sendmmsg()
|
int SrsConfig::get_rtc_server_sendmmsg()
|
||||||
{
|
{
|
||||||
#if !defined(SRS_HAS_SENDMMSG) || !defined(SRS_SENDMMSG)
|
#if !defined(SRS_SENDMMSG)
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
static int DEFAULT = 256;
|
static int DEFAULT = 256;
|
||||||
|
|
|
@ -138,9 +138,9 @@ public:
|
||||||
virtual ~ISrsUdpSender();
|
virtual ~ISrsUdpSender();
|
||||||
public:
|
public:
|
||||||
// Fetch a mmsghdr from sender's cache.
|
// Fetch a mmsghdr from sender's cache.
|
||||||
virtual srs_error_t fetch(mmsghdr** pphdr) = 0;
|
virtual srs_error_t fetch(srs_mmsghdr** pphdr) = 0;
|
||||||
// Notify the sender to send out the msg.
|
// Notify the sender to send out the msg.
|
||||||
virtual srs_error_t sendmmsg(mmsghdr* hdr) = 0;
|
virtual srs_error_t sendmmsg(srs_mmsghdr* hdr) = 0;
|
||||||
// Whether sender exceed the max queue, that is, overflow.
|
// Whether sender exceed the max queue, that is, overflow.
|
||||||
virtual bool overflow() = 0;
|
virtual bool overflow() = 0;
|
||||||
// Set the queue extra ratio, for example, when mw_msgs > 0, we need larger queue.
|
// Set the queue extra ratio, for example, when mw_msgs > 0, we need larger queue.
|
||||||
|
|
|
@ -965,7 +965,7 @@ srs_error_t SrsRtcSenderThread::send_packets(SrsRtcPackets& packets)
|
||||||
|
|
||||||
// Fetch a cached message from queue.
|
// Fetch a cached message from queue.
|
||||||
// TODO: FIXME: Maybe encrypt in async, so the state of mhdr maybe not ready.
|
// TODO: FIXME: Maybe encrypt in async, so the state of mhdr maybe not ready.
|
||||||
mmsghdr* mhdr = NULL;
|
srs_mmsghdr* mhdr = NULL;
|
||||||
if ((err = sender->fetch(&mhdr)) != srs_success) {
|
if ((err = sender->fetch(&mhdr)) != srs_success) {
|
||||||
return srs_error_wrap(err, "fetch msghdr");
|
return srs_error_wrap(err, "fetch msghdr");
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1028,7 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsRtcPackets& packets)
|
||||||
ISrsUdpSender* sender = rtc_session->sendonly_skt->sender();
|
ISrsUdpSender* sender = rtc_session->sendonly_skt->sender();
|
||||||
|
|
||||||
// Previous handler, if has the same size, we can use GSO.
|
// Previous handler, if has the same size, we can use GSO.
|
||||||
mmsghdr* gso_mhdr = NULL; int gso_size = 0; int gso_encrypt = 0; int gso_cursor = 0;
|
srs_mmsghdr* gso_mhdr = NULL; int gso_size = 0; int gso_encrypt = 0; int gso_cursor = 0;
|
||||||
// GSO, N packets has same length, the final one may not.
|
// GSO, N packets has same length, the final one may not.
|
||||||
bool using_gso = false; bool gso_final = false;
|
bool using_gso = false; bool gso_final = false;
|
||||||
// The message will marshal in iovec.
|
// The message will marshal in iovec.
|
||||||
|
@ -1099,7 +1099,7 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsRtcPackets& packets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For GSO, reuse mhdr if possible.
|
// For GSO, reuse mhdr if possible.
|
||||||
mmsghdr* mhdr = gso_mhdr;
|
srs_mmsghdr* mhdr = gso_mhdr;
|
||||||
if (!mhdr) {
|
if (!mhdr) {
|
||||||
// Fetch a cached message from queue.
|
// Fetch a cached message from queue.
|
||||||
// TODO: FIXME: Maybe encrypt in async, so the state of mhdr maybe not ready.
|
// TODO: FIXME: Maybe encrypt in async, so the state of mhdr maybe not ready.
|
||||||
|
@ -2970,13 +2970,13 @@ srs_error_t SrsUdpMuxSender::initialize(srs_netfd_t fd, int senders)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsUdpMuxSender::free_mhdrs(std::vector<mmsghdr>& mhdrs)
|
void SrsUdpMuxSender::free_mhdrs(std::vector<srs_mmsghdr>& mhdrs)
|
||||||
{
|
{
|
||||||
int nn_mhdrs = (int)mhdrs.size();
|
int nn_mhdrs = (int)mhdrs.size();
|
||||||
for (int i = 0; i < nn_mhdrs; i++) {
|
for (int i = 0; i < nn_mhdrs; i++) {
|
||||||
// @see https://linux.die.net/man/2/sendmmsg
|
// @see https://linux.die.net/man/2/sendmmsg
|
||||||
// @see https://linux.die.net/man/2/sendmsg
|
// @see https://linux.die.net/man/2/sendmsg
|
||||||
mmsghdr* hdr = &mhdrs[i];
|
srs_mmsghdr* hdr = &mhdrs[i];
|
||||||
|
|
||||||
// Free control for GSO.
|
// Free control for GSO.
|
||||||
char* msg_control = (char*)hdr->msg_hdr.msg_control;
|
char* msg_control = (char*)hdr->msg_hdr.msg_control;
|
||||||
|
@ -2993,13 +2993,13 @@ void SrsUdpMuxSender::free_mhdrs(std::vector<mmsghdr>& mhdrs)
|
||||||
mhdrs.clear();
|
mhdrs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsUdpMuxSender::fetch(mmsghdr** pphdr)
|
srs_error_t SrsUdpMuxSender::fetch(srs_mmsghdr** pphdr)
|
||||||
{
|
{
|
||||||
// TODO: FIXME: Maybe need to shrink?
|
// TODO: FIXME: Maybe need to shrink?
|
||||||
if (cache_pos >= (int)cache.size()) {
|
if (cache_pos >= (int)cache.size()) {
|
||||||
// @see https://linux.die.net/man/2/sendmmsg
|
// @see https://linux.die.net/man/2/sendmmsg
|
||||||
// @see https://linux.die.net/man/2/sendmsg
|
// @see https://linux.die.net/man/2/sendmsg
|
||||||
mmsghdr mhdr;
|
srs_mmsghdr mhdr;
|
||||||
|
|
||||||
mhdr.msg_len = 0;
|
mhdr.msg_len = 0;
|
||||||
mhdr.msg_hdr.msg_flags = 0;
|
mhdr.msg_hdr.msg_flags = 0;
|
||||||
|
@ -3040,7 +3040,7 @@ void SrsUdpMuxSender::set_extra_ratio(int r)
|
||||||
max_sendmmsg, gso, queue_length, nn_senders, extra_ratio, extra_queue, cache_pos, (int)cache.size(), (int)hotspot.size());
|
max_sendmmsg, gso, queue_length, nn_senders, extra_ratio, extra_queue, cache_pos, (int)cache.size(), (int)hotspot.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsUdpMuxSender::sendmmsg(mmsghdr* hdr)
|
srs_error_t SrsUdpMuxSender::sendmmsg(srs_mmsghdr* hdr)
|
||||||
{
|
{
|
||||||
if (waiting_msgs) {
|
if (waiting_msgs) {
|
||||||
waiting_msgs = false;
|
waiting_msgs = false;
|
||||||
|
@ -3092,7 +3092,7 @@ srs_error_t SrsUdpMuxSender::cycle()
|
||||||
// Send out all messages.
|
// Send out all messages.
|
||||||
// @see https://linux.die.net/man/2/sendmmsg
|
// @see https://linux.die.net/man/2/sendmmsg
|
||||||
// @see https://linux.die.net/man/2/sendmsg
|
// @see https://linux.die.net/man/2/sendmsg
|
||||||
mmsghdr* p = &hotspot[0]; mmsghdr* end = p + pos;
|
srs_mmsghdr* p = &hotspot[0]; srs_mmsghdr* end = p + pos;
|
||||||
for (p = &hotspot[0]; p < end; p += max_sendmmsg) {
|
for (p = &hotspot[0]; p < end; p += max_sendmmsg) {
|
||||||
int vlen = (int)(end - p);
|
int vlen = (int)(end - p);
|
||||||
vlen = srs_min(max_sendmmsg, vlen);
|
vlen = srs_min(max_sendmmsg, vlen);
|
||||||
|
@ -3113,7 +3113,7 @@ srs_error_t SrsUdpMuxSender::cycle()
|
||||||
// @see https://linux.die.net/man/2/sendmmsg
|
// @see https://linux.die.net/man/2/sendmmsg
|
||||||
// @see https://linux.die.net/man/2/sendmsg
|
// @see https://linux.die.net/man/2/sendmsg
|
||||||
for (int i = 0; i < pos; i++) {
|
for (int i = 0; i < pos; i++) {
|
||||||
mmsghdr* mhdr = &hotspot[i];
|
srs_mmsghdr* mhdr = &hotspot[i];
|
||||||
|
|
||||||
nn_writen += (int)mhdr->msg_len;
|
nn_writen += (int)mhdr->msg_len;
|
||||||
|
|
||||||
|
@ -3159,7 +3159,7 @@ srs_error_t SrsUdpMuxSender::cycle()
|
||||||
int nn_cache = 0;
|
int nn_cache = 0;
|
||||||
int nn_hotspot_size = (int)hotspot.size();
|
int nn_hotspot_size = (int)hotspot.size();
|
||||||
for (int i = 0; i < nn_hotspot_size; i++) {
|
for (int i = 0; i < nn_hotspot_size; i++) {
|
||||||
mmsghdr* hdr = &hotspot[i];
|
srs_mmsghdr* hdr = &hotspot[i];
|
||||||
nn_cache += hdr->msg_hdr.msg_iovlen;
|
nn_cache += hdr->msg_hdr.msg_iovlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -388,9 +388,9 @@ private:
|
||||||
private:
|
private:
|
||||||
// Hotspot msgs, we are working on it.
|
// Hotspot msgs, we are working on it.
|
||||||
// @remark We will wait util all messages are ready.
|
// @remark We will wait util all messages are ready.
|
||||||
std::vector<mmsghdr> hotspot;
|
std::vector<srs_mmsghdr> hotspot;
|
||||||
// Cache msgs, for other coroutines to fill it.
|
// Cache msgs, for other coroutines to fill it.
|
||||||
std::vector<mmsghdr> cache;
|
std::vector<srs_mmsghdr> cache;
|
||||||
int cache_pos;
|
int cache_pos;
|
||||||
// The max number of messages for sendmmsg. If 1, we use sendmsg to send.
|
// The max number of messages for sendmmsg. If 1, we use sendmsg to send.
|
||||||
int max_sendmmsg;
|
int max_sendmmsg;
|
||||||
|
@ -405,10 +405,10 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize(srs_netfd_t fd, int senders);
|
virtual srs_error_t initialize(srs_netfd_t fd, int senders);
|
||||||
private:
|
private:
|
||||||
void free_mhdrs(std::vector<mmsghdr>& mhdrs);
|
void free_mhdrs(std::vector<srs_mmsghdr>& mhdrs);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t fetch(mmsghdr** pphdr);
|
virtual srs_error_t fetch(srs_mmsghdr** pphdr);
|
||||||
virtual srs_error_t sendmmsg(mmsghdr* hdr);
|
virtual srs_error_t sendmmsg(srs_mmsghdr* hdr);
|
||||||
virtual bool overflow();
|
virtual bool overflow();
|
||||||
virtual void set_extra_ratio(int r);
|
virtual void set_extra_ratio(int r);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -635,9 +635,9 @@ srs_error_t SrsSipStack::do_parse_request(SrsSipRequest* req, const char* recv_m
|
||||||
std::vector<std::string> vec_device_status = srs_string_split(body_map["Response@DeviceList@Item@Status"], ",");
|
std::vector<std::string> vec_device_status = srs_string_split(body_map["Response@DeviceList@Item@Status"], ",");
|
||||||
|
|
||||||
//map key:devicd_id value:status
|
//map key:devicd_id value:status
|
||||||
for(int i=0 ; i<vec_device_id.size(); i++){
|
for(int i=0 ; i< (int)vec_device_id.size(); i++){
|
||||||
std::string status = "";
|
std::string status = "";
|
||||||
if (vec_device_id.size() > i) {
|
if ((int)vec_device_id.size() > i) {
|
||||||
status = vec_device_status.at(i);
|
status = vec_device_status.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +653,7 @@ srs_error_t SrsSipStack::do_parse_request(SrsSipRequest* req, const char* recv_m
|
||||||
if (cmdtype == "Keepalive"){
|
if (cmdtype == "Keepalive"){
|
||||||
//TODO: ????
|
//TODO: ????
|
||||||
std::vector<std::string> vec_device_id = srs_string_split(body_map["Notify@Info@DeviceID"], ",");
|
std::vector<std::string> vec_device_id = srs_string_split(body_map["Notify@Info@DeviceID"], ",");
|
||||||
for(int i=0; i<vec_device_id.size(); i++){
|
for(int i=0; i< (int)vec_device_id.size(); i++){
|
||||||
//req->device_list_map[vec_device_id.at(i)] = "OFF";
|
//req->device_list_map[vec_device_id.at(i)] = "OFF";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -412,12 +412,12 @@ int srs_sendmsg(srs_netfd_t stfd, const struct msghdr *msg, int flags, srs_utime
|
||||||
return st_sendmsg((st_netfd_t)stfd, msg, flags, (st_utime_t)timeout);
|
return st_sendmsg((st_netfd_t)stfd, msg, flags, (st_utime_t)timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
int srs_sendmmsg(srs_netfd_t stfd, struct mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout)
|
int srs_sendmmsg(srs_netfd_t stfd, struct srs_mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout)
|
||||||
{
|
{
|
||||||
#if !defined(SRS_HAS_SENDMMSG) || !defined(SRS_SENDMMSG)
|
#if !defined(SRS_SENDMMSG)
|
||||||
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
||||||
for (int i = 0; i < (int)vlen; ++i) {
|
for (int i = 0; i < (int)vlen; ++i) {
|
||||||
struct mmsghdr* p = msgvec + i;
|
struct srs_mmsghdr* p = msgvec + i;
|
||||||
int n = srs_sendmsg(stfd, &p->msg_hdr, flags, timeout);
|
int n = srs_sendmsg(stfd, &p->msg_hdr, flags, timeout);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
// An error is returned only if no datagrams could be sent.
|
// An error is returned only if no datagrams could be sent.
|
||||||
|
@ -457,7 +457,7 @@ int srs_sendmmsg(srs_netfd_t stfd, struct mmsghdr *msgvec, unsigned int vlen, in
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return st_sendmmsg((st_netfd_t)stfd, msgvec, vlen, flags, (st_utime_t)timeout);
|
return st_sendmmsg((st_netfd_t)stfd, (void*)msgvec, vlen, flags, (st_utime_t)timeout);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,15 +92,13 @@ extern int srs_sendto(srs_netfd_t stfd, void *buf, int len, const struct sockadd
|
||||||
extern int srs_recvmsg(srs_netfd_t stfd, struct msghdr *msg, int flags, srs_utime_t timeout);
|
extern int srs_recvmsg(srs_netfd_t stfd, struct msghdr *msg, int flags, srs_utime_t timeout);
|
||||||
extern int srs_sendmsg(srs_netfd_t stfd, const struct msghdr *msg, int flags, srs_utime_t timeout);
|
extern int srs_sendmsg(srs_netfd_t stfd, const struct msghdr *msg, int flags, srs_utime_t timeout);
|
||||||
|
|
||||||
#if !defined(SRS_HAS_SENDMMSG)
|
|
||||||
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
// @see http://man7.org/linux/man-pages/man2/sendmmsg.2.html
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
struct mmsghdr {
|
struct srs_mmsghdr {
|
||||||
struct msghdr msg_hdr; /* Message header */
|
struct msghdr msg_hdr; /* Message header */
|
||||||
unsigned int msg_len; /* Number of bytes transmitted */
|
unsigned int msg_len; /* Number of bytes transmitted */
|
||||||
};
|
};
|
||||||
#endif
|
extern int srs_sendmmsg(srs_netfd_t stfd, struct srs_mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout);
|
||||||
extern int srs_sendmmsg(srs_netfd_t stfd, struct mmsghdr *msgvec, unsigned int vlen, int flags, srs_utime_t timeout);
|
|
||||||
|
|
||||||
extern srs_netfd_t srs_accept(srs_netfd_t stfd, struct sockaddr *addr, int *addrlen, srs_utime_t timeout);
|
extern srs_netfd_t srs_accept(srs_netfd_t stfd, struct sockaddr *addr, int *addrlen, srs_utime_t timeout);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue