You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
605 B
Go
30 lines
605 B
Go
4 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
"github.com/Danile71/joy4/format"
|
||
|
"github.com/Danile71/joy4/av/avutil"
|
||
|
"github.com/Danile71/joy4/format/rtmp"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
format.RegisterAll()
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
server := &rtmp.Server{}
|
||
|
|
||
|
server.HandlePlay = func(conn *rtmp.Conn) {
|
||
|
segs := strings.Split(conn.URL.Path, "/")
|
||
|
url := fmt.Sprintf("%s://%s", segs[1], strings.Join(segs[2:], "/"))
|
||
|
src, _ := avutil.Open(url)
|
||
|
avutil.CopyFile(conn, src)
|
||
|
}
|
||
|
|
||
|
server.ListenAndServe()
|
||
|
|
||
|
// ffplay rtmp://localhost/rtsp/192.168.1.1/camera1
|
||
|
// ffplay rtmp://localhost/rtmp/live.hkstv.hk.lxdns.com/live/hks
|
||
|
}
|