测试合并写

This commit is contained in:
yangjiechina
2023-12-03 23:35:55 +08:00
parent 0149865a26
commit baebd7d25d
5 changed files with 122 additions and 15 deletions

28
main.go
View File

@@ -1,13 +1,20 @@
package main
import (
"net"
"net/http"
_ "net/http/pprof"
"github.com/yangjiechina/avformat/librtmp"
"github.com/yangjiechina/avformat/utils"
"github.com/yangjiechina/live-server/rtmp"
"github.com/yangjiechina/live-server/stream"
)
func CreateTransStream(protocol stream.Protocol, streams []utils.AVStream) stream.ITransStream {
if stream.ProtocolRtmp == protocol {
return rtmp.NewTransStream(librtmp.ChunkSize)
}
return nil
@@ -18,5 +25,24 @@ func init() {
}
func main() {
stream.AppConfig.GOPCache = 2
impl := rtmp.NewServer()
addr := "0.0.0.0:1935"
tcpAddr, err := net.ResolveTCPAddr("tcp", addr)
if err != nil {
panic(err)
}
err = impl.Start(tcpAddr)
if err != nil {
panic(err)
}
println("启动rtmp服务成功:" + addr)
loadConfigError := http.ListenAndServe(":19999", nil)
if loadConfigError != nil {
panic(loadConfigError)
}
select {}
}