mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097)
1. Add live benchmark support in srs-bench, which only connects and disconnects without any media transport, to test source creation and disposal and verify source memory leaks. 2. SmartPtr: Support cleanup of HTTP-FLV stream. Unregister the HTTP-FLV handler for the pattern and clean up the objects and resources. 3. Support benchmarking RTMP/SRT with srs-bench by integrating the gosrt and oryx RTMP libraries. 4. Refine SRT and RTC sources by using a timer to clean up the sources, following the same strategy as the Live source. --------- Co-authored-by: Haibo Chen <495810242@qq.com> Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
parent
e3d74fb045
commit
1f9309ae25
508 changed files with 6805 additions and 3299 deletions
55
trunk/3rdparty/srs-bench/vendor/github.com/haivision/srtgo/write.go
generated
vendored
Normal file
55
trunk/3rdparty/srs-bench/vendor/github.com/haivision/srtgo/write.go
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
package srtgo
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -lsrt
|
||||
#include <srt/srt.h>
|
||||
|
||||
int srt_sendmsg2_wrapped(SRTSOCKET u, const char* buf, int len, SRT_MSGCTRL *mctrl, int *srterror, int *syserror)
|
||||
{
|
||||
int ret = srt_sendmsg2(u, buf, len, mctrl);
|
||||
if (ret < 0) {
|
||||
*srterror = srt_getlasterror(syserror);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func srtSendMsg2Impl(u C.SRTSOCKET, buf []byte, msgctrl *C.SRT_MSGCTRL) (n int, err error) {
|
||||
srterr := C.int(0)
|
||||
syserr := C.int(0)
|
||||
n = int(C.srt_sendmsg2_wrapped(u, (*C.char)(unsafe.Pointer(&buf[0])), C.int(len(buf)), msgctrl, &srterr, &syserr))
|
||||
if n < 0 {
|
||||
srterror := SRTErrno(srterr)
|
||||
if syserr < 0 {
|
||||
srterror.wrapSysErr(syscall.Errno(syserr))
|
||||
}
|
||||
err = srterror
|
||||
n = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Write data to the SRT socket
|
||||
func (s SrtSocket) Write(b []byte) (n int, err error) {
|
||||
|
||||
//Fastpath:
|
||||
if !s.blocking {
|
||||
s.pd.reset(ModeWrite)
|
||||
}
|
||||
n, err = srtSendMsg2Impl(s.socket, b, nil)
|
||||
|
||||
for {
|
||||
if !errors.Is(err, error(EAsyncSND)) || s.blocking {
|
||||
return
|
||||
}
|
||||
s.pd.wait(ModeWrite)
|
||||
n, err = srtSendMsg2Impl(s.socket, b, nil)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue