mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Fix rtc to rtmp sync timestamp using sender report. (#2470)
* fix annotation spell failed * RTC to RTMP using SenderReport to sync av timestamp * update pion/webrtc versio from v3.0.4 -> v3.0.13, auto config sender/receiver report * Add rtc push flv play regression test * Add unit test of ntp and av sync time * Take flag CXX to makefile of utest * Add annotation about rtc unit test * Fix compiler error in C++98 * Add FFmpeg log callback funciton.
This commit is contained in:
parent
5e876277b6
commit
ea8cff6163
301 changed files with 13882 additions and 8323 deletions
172
trunk/3rdparty/srs-bench/vendor/github.com/pion/transport/connctx/connctx.go
generated
vendored
Normal file
172
trunk/3rdparty/srs-bench/vendor/github.com/pion/transport/connctx/connctx.go
generated
vendored
Normal file
|
@ -0,0 +1,172 @@
|
|||
// Package connctx wraps net.Conn using context.Context.
|
||||
package connctx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrClosing is returned on Write to closed connection.
|
||||
var ErrClosing = errors.New("use of closed network connection")
|
||||
|
||||
// Reader is an interface for context controlled reader.
|
||||
type Reader interface {
|
||||
ReadContext(context.Context, []byte) (int, error)
|
||||
}
|
||||
|
||||
// Writer is an interface for context controlled writer.
|
||||
type Writer interface {
|
||||
WriteContext(context.Context, []byte) (int, error)
|
||||
}
|
||||
|
||||
// ReadWriter is a composite of ReadWriter.
|
||||
type ReadWriter interface {
|
||||
Reader
|
||||
Writer
|
||||
}
|
||||
|
||||
// ConnCtx is a wrapper of net.Conn using context.Context.
|
||||
type ConnCtx interface {
|
||||
Reader
|
||||
Writer
|
||||
io.Closer
|
||||
LocalAddr() net.Addr
|
||||
RemoteAddr() net.Addr
|
||||
Conn() net.Conn
|
||||
}
|
||||
|
||||
type connCtx struct {
|
||||
nextConn net.Conn
|
||||
closed chan struct{}
|
||||
closeOnce sync.Once
|
||||
readMu sync.Mutex
|
||||
writeMu sync.Mutex
|
||||
}
|
||||
|
||||
var veryOld = time.Unix(0, 1) //nolint:gochecknoglobals
|
||||
|
||||
// New creates a new ConnCtx wrapping given net.Conn.
|
||||
func New(conn net.Conn) ConnCtx {
|
||||
c := &connCtx{
|
||||
nextConn: conn,
|
||||
closed: make(chan struct{}),
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *connCtx) ReadContext(ctx context.Context, b []byte) (int, error) {
|
||||
c.readMu.Lock()
|
||||
defer c.readMu.Unlock()
|
||||
|
||||
select {
|
||||
case <-c.closed:
|
||||
return 0, io.EOF
|
||||
default:
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
var wg sync.WaitGroup
|
||||
var errSetDeadline atomic.Value
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// context canceled
|
||||
if err := c.nextConn.SetReadDeadline(veryOld); err != nil {
|
||||
errSetDeadline.Store(err)
|
||||
return
|
||||
}
|
||||
<-done
|
||||
if err := c.nextConn.SetReadDeadline(time.Time{}); err != nil {
|
||||
errSetDeadline.Store(err)
|
||||
}
|
||||
case <-done:
|
||||
}
|
||||
}()
|
||||
|
||||
n, err := c.nextConn.Read(b)
|
||||
|
||||
close(done)
|
||||
wg.Wait()
|
||||
if e := ctx.Err(); e != nil && n == 0 {
|
||||
err = e
|
||||
}
|
||||
if err2 := errSetDeadline.Load(); err == nil && err2 != nil {
|
||||
err = err2.(error)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (c *connCtx) WriteContext(ctx context.Context, b []byte) (int, error) {
|
||||
c.writeMu.Lock()
|
||||
defer c.writeMu.Unlock()
|
||||
|
||||
select {
|
||||
case <-c.closed:
|
||||
return 0, ErrClosing
|
||||
default:
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
var wg sync.WaitGroup
|
||||
var errSetDeadline atomic.Value
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// context canceled
|
||||
if err := c.nextConn.SetWriteDeadline(veryOld); err != nil {
|
||||
errSetDeadline.Store(err)
|
||||
return
|
||||
}
|
||||
<-done
|
||||
if err := c.nextConn.SetWriteDeadline(time.Time{}); err != nil {
|
||||
errSetDeadline.Store(err)
|
||||
}
|
||||
case <-done:
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
n, err := c.nextConn.Write(b)
|
||||
|
||||
close(done)
|
||||
wg.Wait()
|
||||
if e := ctx.Err(); e != nil && n == 0 {
|
||||
err = e
|
||||
}
|
||||
if err2 := errSetDeadline.Load(); err == nil && err2 != nil {
|
||||
err = err2.(error)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (c *connCtx) Close() error {
|
||||
err := c.nextConn.Close()
|
||||
c.closeOnce.Do(func() {
|
||||
c.writeMu.Lock()
|
||||
c.readMu.Lock()
|
||||
close(c.closed)
|
||||
c.readMu.Unlock()
|
||||
c.writeMu.Unlock()
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *connCtx) LocalAddr() net.Addr {
|
||||
return c.nextConn.LocalAddr()
|
||||
}
|
||||
|
||||
func (c *connCtx) RemoteAddr() net.Addr {
|
||||
return c.nextConn.RemoteAddr()
|
||||
}
|
||||
|
||||
func (c *connCtx) Conn() net.Conn {
|
||||
return c.nextConn
|
||||
}
|
11
trunk/3rdparty/srs-bench/vendor/github.com/pion/transport/connctx/pipe.go
generated
vendored
Normal file
11
trunk/3rdparty/srs-bench/vendor/github.com/pion/transport/connctx/pipe.go
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
package connctx
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// Pipe creates piped pair of ConnCtx.
|
||||
func Pipe() (ConnCtx, ConnCtx) {
|
||||
ca, cb := net.Pipe()
|
||||
return New(ca), New(cb)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue