Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
734 B

package serverudpl
import (
"strconv"
"github.com/aler9/gortsplib"
"github.com/aler9/rtsp-simple-server/internal/logger"
)
// Parent is implemented by program.
type Parent interface {
Log(logger.Level, string, ...interface{})
}
// New allocates a gortsplib.ServerUDPListener.
func New(port int,
streamType gortsplib.StreamType,
parent Parent) (*gortsplib.ServerUDPListener, error) {
listener, err := gortsplib.NewServerUDPListener(":" + strconv.FormatInt(int64(port), 10))
if err != nil {
return nil, err
}
label := func() string {
if streamType == gortsplib.StreamTypeRTP {
return "RTP"
}
return "RTCP"
}()
parent.Log(logger.Info, "[UDP/"+label+" listener] opened on :%d", port)
return listener, nil
}