|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "slices" |
| 5 | + |
4 | 6 | "github.com/AlexxIT/go2rtc/internal/alsa" |
5 | 7 | "github.com/AlexxIT/go2rtc/internal/api" |
6 | 8 | "github.com/AlexxIT/go2rtc/internal/api/ws" |
@@ -46,66 +48,65 @@ import ( |
46 | 48 | func main() { |
47 | 49 | app.Version = "1.9.11" |
48 | 50 |
|
49 | | - // 1. Core modules: app, api/ws, streams |
50 | | - |
51 | | - app.Init() // init config and logs |
52 | | - |
53 | | - api.Init() // init API before all others |
54 | | - ws.Init() // init WS API endpoint |
55 | | - |
56 | | - streams.Init() // streams module |
57 | | - |
58 | | - // 2. Main sources and servers |
59 | | - |
60 | | - rtsp.Init() // rtsp source, RTSP server |
61 | | - webrtc.Init() // webrtc source, WebRTC server |
62 | | - |
63 | | - // 3. Main API |
64 | | - |
65 | | - mp4.Init() // MP4 API |
66 | | - hls.Init() // HLS API |
67 | | - mjpeg.Init() // MJPEG API |
68 | | - |
69 | | - // 4. Other sources and servers |
70 | | - |
71 | | - hass.Init() // hass source, Hass API server |
72 | | - onvif.Init() // onvif source, ONVIF API server |
73 | | - webtorrent.Init() // webtorrent source, WebTorrent module |
74 | | - wyoming.Init() |
75 | | - |
76 | | - // 5. Other sources |
77 | | - |
78 | | - rtmp.Init() // rtmp source |
79 | | - exec.Init() // exec source |
80 | | - ffmpeg.Init() // ffmpeg source |
81 | | - echo.Init() // echo source |
82 | | - ivideon.Init() // ivideon source |
83 | | - http.Init() // http/tcp source |
84 | | - dvrip.Init() // dvrip source |
85 | | - tapo.Init() // tapo source |
86 | | - isapi.Init() // isapi source |
87 | | - mpegts.Init() // mpegts passive source |
88 | | - roborock.Init() // roborock source |
89 | | - homekit.Init() // homekit source |
90 | | - ring.Init() // ring source |
91 | | - nest.Init() // nest source |
92 | | - bubble.Init() // bubble source |
93 | | - expr.Init() // expr source |
94 | | - gopro.Init() // gopro source |
95 | | - doorbird.Init() // doorbird source |
96 | | - v4l2.Init() // v4l2 source |
97 | | - alsa.Init() // alsa source |
98 | | - flussonic.Init() |
99 | | - eseecloud.Init() |
100 | | - yandex.Init() |
101 | | - |
102 | | - // 6. Helper modules |
103 | | - |
104 | | - ngrok.Init() // ngrok module |
105 | | - srtp.Init() // SRTP server |
106 | | - debug.Init() // debug API |
107 | | - |
108 | | - // 7. Go |
| 51 | + type module struct { |
| 52 | + name string |
| 53 | + init func() |
| 54 | + } |
| 55 | + |
| 56 | + modules := []module{ |
| 57 | + {"", app.Init}, // init config and logs |
| 58 | + {"api", api.Init}, // init API before all others |
| 59 | + {"ws", ws.Init}, // init WS API endpoint |
| 60 | + {"", streams.Init}, |
| 61 | + // Main sources and servers |
| 62 | + {"http", http.Init}, // rtsp source, HTTP server |
| 63 | + {"rtsp", rtsp.Init}, // rtsp source, RTSP server |
| 64 | + {"webrtc", webrtc.Init}, // webrtc source, WebRTC server |
| 65 | + // Main API |
| 66 | + {"mp4", mp4.Init}, // MP4 API |
| 67 | + {"hls", hls.Init}, // HLS API |
| 68 | + {"mjpeg", mjpeg.Init}, // MJPEG API |
| 69 | + // Other sources and servers |
| 70 | + {"hass", hass.Init}, // hass source, Hass API server |
| 71 | + {"homekit", homekit.Init}, // homekit source, HomeKit server |
| 72 | + {"onvif", onvif.Init}, // onvif source, ONVIF API server |
| 73 | + {"rtmp", rtmp.Init}, // rtmp source, RTMP server |
| 74 | + {"webtorrent", webtorrent.Init}, // webtorrent source, WebTorrent module |
| 75 | + {"wyoming", wyoming.Init}, |
| 76 | + // Exec and script sources |
| 77 | + {"echo", echo.Init}, |
| 78 | + {"exec", exec.Init}, |
| 79 | + {"expr", expr.Init}, |
| 80 | + {"ffmpeg", ffmpeg.Init}, |
| 81 | + // Hardware sources |
| 82 | + {"alsa", alsa.Init}, |
| 83 | + {"v4l2", v4l2.Init}, |
| 84 | + // Other sources |
| 85 | + {"bubble", bubble.Init}, |
| 86 | + {"doorbird", doorbird.Init}, |
| 87 | + {"dvrip", dvrip.Init}, |
| 88 | + {"eseecloud", eseecloud.Init}, |
| 89 | + {"flussonic", flussonic.Init}, |
| 90 | + {"gopro", gopro.Init}, |
| 91 | + {"isapi", isapi.Init}, |
| 92 | + {"ivideon", ivideon.Init}, |
| 93 | + {"mpegts", mpegts.Init}, |
| 94 | + {"nest", nest.Init}, |
| 95 | + {"ring", ring.Init}, |
| 96 | + {"roborock", roborock.Init}, |
| 97 | + {"tapo", tapo.Init}, |
| 98 | + {"yandex", yandex.Init}, |
| 99 | + // Helper modules |
| 100 | + {"debug", debug.Init}, |
| 101 | + {"ngrok", ngrok.Init}, |
| 102 | + {"srtp", srtp.Init}, |
| 103 | + } |
| 104 | + |
| 105 | + for _, m := range modules { |
| 106 | + if app.Modules == nil || m.name == "" || slices.Contains(app.Modules, m.name) { |
| 107 | + m.init() |
| 108 | + } |
| 109 | + } |
109 | 110 |
|
110 | 111 | shell.RunUntilSignal() |
111 | 112 | } |
0 commit comments