golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
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
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 |
|
}
|
|
|