-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
67 lines (55 loc) · 1.44 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"context"
"github.com/shigde/sfu/internal/config"
"github.com/shigde/sfu/internal/rtp"
"github.com/shigde/sfu/internal/runner"
"github.com/shigde/sfu/internal/static"
"github.com/shigde/sfu/pkg/client"
)
const (
spaceId = "123"
streamId = "value"
bearer = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyLCJ1dWlkIjoiYTY0MzY1ZGItMTc0ZC00ZDExLThjYjEtZWIyYTM2MzlmZmU2In0._xbasA_1ljeszeWdqYqp96EWvJIbCnYOTOFxKgcd7vM"
)
func main() {
// 1. load movie file
// 2. transcode
// 3. create endpoint with tracks and offer
// 2. send offer to sfu over whip
// 4. Get answer and set answer to endpoint
cli := runner.NewCli()
cli.Parse()
media, err := static.NewMediaFile(cli.AudioFileName, cli.VideoFileName)
if err != nil {
panic(err)
}
conf, err := config.ParseConfig(cli.Config, config.ParseEnv())
if err != nil {
panic(err)
}
engine, err := rtp.NewEngine(conf.RtpConfig)
if err != nil {
panic(err)
}
endpoint, err := engine.NewStaticMediaSenderEndpoint(media)
if err != nil {
panic(err)
}
offer, err := endpoint.GetLocalDescription(context.Background())
if err != nil {
panic(err)
}
whipClient := client.NewWhip()
whipClient.Session.SetBearer(bearer)
answer, err := whipClient.GetAnswer(spaceId, streamId, offer)
if err != nil {
panic(err)
}
println("Answer", answer.SDP)
err = endpoint.SetAnswer(answer)
if err != nil {
panic(err)
}
select {}
}