Live video on the AT Protocol
1package mistconfig
2
3import (
4 "crypto/md5"
5 "encoding/json"
6 "fmt"
7 "os"
8
9 "stream.place/streamplace/pkg/config"
10 "stream.place/streamplace/pkg/mist/misttriggers"
11)
12
13var StreamName = "stream"
14
15func Generate(cli *config.CLI) ([]byte, error) {
16 exec, err := os.Executable()
17 if err != nil {
18 return nil, fmt.Errorf("couldn't find my path for extwriter purposes: %w", err)
19 }
20 triggers := map[string][]map[string]any{}
21 for name, blocking := range misttriggers.BlockingTriggers {
22 triggers[name] = []map[string]any{{
23 "handler": fmt.Sprintf("%s/mist-trigger", cli.OwnInternalURL()),
24 "streams": []string{},
25 "sync": blocking,
26 }}
27 }
28 conf := map[string]any{
29 "account": map[string]any{
30 // doesn't need to be secure, will only ever be exposed on localhost
31 "streamplace": map[string]any{
32 "password": md5.Sum([]byte("streamplace")),
33 },
34 },
35 "bandwidth": map[string]any{
36 "exceptions": []string{
37 "::1",
38 "127.0.0.0/8",
39 "10.0.0.0/8",
40 "192.168.0.0/16",
41 "172.16.0.0/12",
42 },
43 },
44 "config": map[string]any{
45 "accesslog": "LOG",
46 "prometheus": "streamplace",
47 "protocols": []map[string]any{
48 {"connector": "AAC"},
49 {"connector": "CMAF"},
50 {"connector": "EBML"},
51 {"connector": "FLAC"},
52 {"connector": "FLV"},
53 {"connector": "H264"},
54 {"connector": "HDS"},
55 {"connector": "HLS"},
56 {"connector": "HTTPTS"},
57 {"connector": "JSON"},
58 {"connector": "MP3"},
59 {"connector": "MP4"},
60 {"connector": "OGG"},
61 {"connector": "WAV"},
62 {
63 "connector": "RTMP",
64 "interface": "127.0.0.1",
65 "port": cli.MistRTMPPort,
66 },
67 {
68 "connector": "HTTP",
69 "interface": "127.0.0.1",
70 "port": cli.MistHTTPPort,
71 },
72 {
73 "connector": "WebRTC",
74 "jitterlog": false,
75 "mergesessions": false,
76 "nackdisable": false,
77 "packetlog": false,
78 },
79 },
80 "sessionInputMode": 15,
81 "sessionOutputMode": 15,
82 "sessionStreamInfoMode": 1,
83 "sessionUnspecifiedMode": 0,
84 "sessionViewerMode": 14,
85 "tknMode": 15,
86 "triggers": triggers,
87 "trustedproxy": []string{},
88 },
89 "streams": map[string]map[string]any{
90 StreamName: {
91 "name": StreamName,
92 "segmentsize": 1,
93 "source": fmt.Sprintf("mkv-exec:%s stream %s/playback/$wildcard/stream.mkv", exec, cli.OwnInternalURL()),
94 "stop_sessions": false,
95 },
96 },
97 "ui_settings": map[string]any{
98 "HTTPUrl": "http://localhost:8082/",
99 },
100 }
101 return json.Marshal(conf)
102}