-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathmain.go
43 lines (35 loc) · 897 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
log "github.com/sirupsen/logrus"
"github.com/yutopp/go-rtmp"
rtmpmsg "github.com/yutopp/go-rtmp/message"
)
const (
chunkSize = 128
)
func main() {
client, err := rtmp.Dial("rtmp", "localhost:1935", &rtmp.ConnConfig{
Logger: log.StandardLogger(),
})
if err != nil {
log.Fatalf("Failed to dial: %+v", err)
}
defer client.Close()
log.Infof("Client created")
if err := client.Connect(nil); err != nil {
log.Fatalf("Failed to connect: Err=%+v", err)
}
log.Infof("connected")
stream, err := client.CreateStream(nil, chunkSize)
if err != nil {
log.Fatalf("Failed to create stream: Err=%+v", err)
}
defer stream.Close()
if err := stream.Publish(&rtmpmsg.NetStreamPublish{
PublishingName: "testtesttesttest",
PublishingType: "live",
}); err != nil {
log.Fatalf("Failed to send publish message: Err=%+v", err)
}
log.Infof("stream created")
}