Skip to content

Commit 16384ec

Browse files
committed
Refactor input manager to support only RTMP protocol, removing SRT-related code and validation logic. Simplify input management by eliminating unused fields and methods. Update related components to ensure compatibility with the new input structure.
Replace pooled buffer reading with standard io.ReadAll for RTMP input handling, improving memory management and simplifying code. Remove SRT ingest and validator implementations, as well as associated tests and references throughout the codebase, streamlining the ingest process. Update dashboard data structure to remove SRT port reference, reflecting the removal of SRT support. Refactor pipeline and relay components to remove unused methods and improve clarity, ensuring they align with the new input management approach. Eliminate redundant audio and IDR gate implementations, simplifying the relay logic and focusing on essential functionality. Revise fanout logic to improve tag handling and remove unnecessary header broadcasting, optimizing performance. Clean up runtime configuration by removing unused fallback delay and stability settings, focusing on IDR timeout configuration. Remove unused source implementations and related matching logic, streamlining the source management process.
1 parent ef1f7a7 commit 16384ec

35 files changed

Lines changed: 93 additions & 1321 deletions

cmd/neverdrop/main.go

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
}
4343

4444
log.Printf("[WARN] NeverDrop v0.1 iniciando")
45-
log.Printf("[WARN] Puertos — RTMP:%d API:%d SRT:%d", cfg.RTMPPort, cfg.APIPort, cfg.SRTPort)
45+
log.Printf("[WARN] Puertos — RTMP:%d API:%d", cfg.RTMPPort, cfg.APIPort)
4646
log.Printf("[INFO] Base datos: %s", cfg.DBPath)
4747
log.Printf("[INFO] Videos: %s", cfg.VideosDir)
4848

@@ -56,8 +56,7 @@ func main() {
5656
log.Printf("[INFO] Base de datos lista")
5757

5858
runtimeCfg := store.NewRuntimeConfig(sqlite)
59-
log.Printf("[INFO] Config: fallback_delay=%dms stability=%ds idr_timeout=%dms",
60-
runtimeCfg.FallbackDelayMs, runtimeCfg.StabilitySecs, runtimeCfg.IDRTimeoutMs)
59+
log.Printf("[INFO] Config: idr_timeout=%dms", runtimeCfg.IDRTimeoutMs)
6160

6261
log.Printf("[WARN] Iniciando inputs...")
6362

@@ -72,32 +71,13 @@ func main() {
7271
log.Printf("[INFO] RTMP → :%d — OBS: rtmp://IP:%d/live/<path>", cfg.RTMPPort, cfg.RTMPPort)
7372
}
7473

75-
inputCfg2 := ingest.InputConfig{
76-
ID: "srt-ingest",
77-
Name: "SRT Ingest",
78-
Protocol: "srt",
79-
Port: cfg.SRTPort,
80-
Enabled: true,
81-
}
82-
if err := inputManager.AddInput(inputCfg2); err != nil {
83-
log.Printf("[WARN] SRT ingest: %v", err)
84-
} else {
85-
log.Printf("[INFO] SRT → :%d", cfg.SRTPort)
86-
}
87-
8874
fallbackGen := ingest.NewFallbackGenerator()
8975
inputManager.AddProtectedID(ingest.FallbackGenID)
9076
fallbackGen.Start(ctx, cfg.RTMPPort)
9177
log.Printf("[INFO] Fallback generator started: rtmp://localhost:%d/live/%s", cfg.RTMPPort, ingest.FallbackGenID)
9278

9379
pip := pipeline.New(inputManager)
94-
selector := relay.NewInputSelector(
95-
inputManager,
96-
pip,
97-
nil,
98-
time.Duration(runtimeCfg.FallbackDelayMs)*time.Millisecond,
99-
time.Duration(runtimeCfg.StabilitySecs)*time.Second,
100-
)
80+
selector := relay.NewInputSelector(inputManager, pip, nil)
10181
selector.SetFallbackChain([]string{ingest.FallbackGenID})
10282

10383
rtmpServer.OnInputChange = func() {
@@ -208,7 +188,6 @@ func main() {
208188
},
209189
PublicIP: publicIP,
210190
RTMPPort: cfg.RTMPPort,
211-
SRTPort: cfg.SRTPort,
212191
SuggestedKey: suggestedKey,
213192
}
214193
}
@@ -244,28 +223,6 @@ func main() {
244223

245224
log.Printf("[WARN] NeverDrop listo. Conectá OBS y abrí http://localhost:%d", cfg.APIPort)
246225

247-
go func() {
248-
ticker := time.NewTicker(10 * time.Second)
249-
defer ticker.Stop()
250-
for {
251-
select {
252-
case <-ctx.Done():
253-
return
254-
case <-ticker.C:
255-
}
256-
stats := inputManager.Statuses()
257-
activeID := selector.ActiveInputID()
258-
for _, s := range stats {
259-
src := ""
260-
if s.ID == activeID {
261-
src = " [ACTIVE]"
262-
}
263-
log.Printf("[status] input %s: %dx%d %dfps %dkbps %dbytes connected=%v%s",
264-
s.ID, s.Width, s.Height, s.FPS, s.BitrateKbps, s.BytesIn, s.Connected, src)
265-
}
266-
}
267-
}()
268-
269226
sigCh := make(chan os.Signal, 1)
270227
signal.Notify(sigCh, os.Interrupt)
271228

go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module github.com/pablodz/neverdrop
33
go 1.26.2
44

55
require (
6-
github.com/asticode/go-astits v1.15.0
7-
github.com/datarhei/gosrt v0.10.0
86
github.com/gofiber/contrib/websocket v1.3.4
97
github.com/gofiber/fiber/v2 v2.52.13
108
github.com/pion/webrtc/v4 v4.2.12
@@ -14,8 +12,6 @@ require (
1412

1513
require (
1614
github.com/andybalholm/brotli v1.2.1 // indirect
17-
github.com/asticode/go-astikit v0.59.0 // indirect
18-
github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c // indirect
1915
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
2016
github.com/dustin/go-humanize v1.0.1 // indirect
2117
github.com/fasthttp/websocket v1.5.12 // indirect

go.sum

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro=
22
github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
3-
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
4-
github.com/asticode/go-astikit v0.59.0 h1:tjbwDym+MTSxqkAhJoHRZmHMXK6Jv4vGx+97FptKH6k=
5-
github.com/asticode/go-astikit v0.59.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
6-
github.com/asticode/go-astits v1.15.0 h1:yRyCiUc8Jj4F7clt2GDxHghMpWuFL5rkaLuGUd2/0J4=
7-
github.com/asticode/go-astits v1.15.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
8-
github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c h1:8XZeJrs4+ZYhJeJ2aZxADI2tGADS15AzIF8MQ8XAhT4=
9-
github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c/go.mod h1:x1vxHcL/9AVzuk5HOloOEPrtJY0MaalYr78afXZ+pWI=
103
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
114
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
12-
github.com/datarhei/gosrt v0.10.0 h1:dPn+gOo93JTvW2Rfd8Jfz+J/sUbdr+miE9eHUNMoPZY=
13-
github.com/datarhei/gosrt v0.10.0/go.mod h1:M+KtvdduBtW64WqCByr6Mb27eNYBMNs0/RtTgY7d6TQ=
145
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
156
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
167
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -87,7 +78,6 @@ github.com/pion/webrtc/v4 v4.2.12 h1:ux8i+aJxu0OdhcAcVO39JEeodWugD0wdVJoRDtXk1CY
8778
github.com/pion/webrtc/v4 v4.2.12/go.mod h1:M/DeGZkhdWZVmVgGr34HOD9yUDekVJtz9c9PGO18urQ=
8879
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8980
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
90-
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
9181
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
9282
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9383
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
@@ -101,7 +91,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
10191
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
10292
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
10393
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
104-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
10594
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
10695
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
10796
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
@@ -138,7 +127,6 @@ golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
138127
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
139128
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
140129
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
141-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
142130
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
143131
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
144132
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/api/handler_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ func (h *ConfigHandler) Put(c *fiber.Ctx) error {
2626
return c.Status(400).JSON(APIResponse{Ok: false, Error: "body inválido"})
2727
}
2828
switch req.Key {
29-
case "fallback_delay_ms", "stability_secs", "idr_timeout_ms":
29+
case "idr_timeout_ms":
3030
h.runtime.Set(req.Key, req.Value)
3131
return c.JSON(APIResponse{Ok: true})
3232
default:
33-
return c.Status(400).JSON(APIResponse{Ok: false, Error: "clave inválida. Usá: fallback_delay_ms, stability_secs, idr_timeout_ms"})
33+
return c.Status(400).JSON(APIResponse{Ok: false, Error: "clave inválida. Usá: idr_timeout_ms"})
3434
}
3535
}

internal/api/handler_inputs.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ func (h *InputsHandler) SetPriority(c *fiber.Ctx) error {
7171
return c.JSON(APIResponse{Ok: true})
7272
}
7373

74-
func (h *InputsHandler) Preview(c *fiber.Ctx) error {
75-
id := c.Params("id")
76-
h.manager.SelectPreview(id)
77-
log.Printf("[api] Preview set to %s", id)
78-
return c.JSON(APIResponse{Ok: true})
79-
}
80-
8174
func (h *InputsHandler) Status(c *fiber.Ctx) error {
8275
statuses := h.manager.Statuses()
8376
return c.JSON(APIResponse{Ok: true, Data: statuses})

internal/api/handler_preview.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

internal/api/handler_stream.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package api
22

33
import (
4-
"log"
5-
64
"github.com/gofiber/fiber/v2"
75
"github.com/pablodz/neverdrop/internal/relay"
86
)
@@ -39,18 +37,4 @@ func (h *StreamHandler) Start(c *fiber.Ctx) error {
3937
return c.JSON(APIResponse{Ok: true})
4038
}
4139

42-
func (h *StreamHandler) Stop(c *fiber.Ctx) error {
43-
h.controller.SetLive(false)
44-
return c.JSON(APIResponse{Ok: true})
45-
}
46-
47-
func (h *StreamHandler) ToggleLive(c *fiber.Ctx) error {
48-
live := !h.controller.IsLive()
49-
h.controller.SetLive(live)
50-
log.Printf("[api] Live toggled: %v", live)
51-
return c.JSON(APIResponse{Ok: true, Data: map[string]bool{"live": live}})
52-
}
5340

54-
func (h *StreamHandler) LiveStatus(c *fiber.Ctx) error {
55-
return c.JSON(APIResponse{Ok: true, Data: map[string]bool{"live": h.controller.IsLive()}})
56-
}

internal/api/middleware.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/api/router.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"log"
7-
"strings"
87
"time"
98

109
"github.com/gofiber/contrib/websocket"
@@ -200,17 +199,4 @@ func PanelWSJSON(ws *websocket.Conn, getDashboardData func() panel.DashboardData
200199
}
201200
}
202201

203-
func mimeType(path string) string {
204-
if strings.HasSuffix(path, ".js") {
205-
return "application/javascript"
206-
}
207-
if strings.HasSuffix(path, ".css") {
208-
return "text/css"
209-
}
210-
if strings.HasSuffix(path, ".html") {
211-
return "text/html"
212-
}
213-
return "application/octet-stream"
214-
}
215202

216-
func init() {}

internal/config/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package config
33
import (
44
"crypto/rand"
55
"encoding/hex"
6-
"fmt"
76
"log"
87
"os"
98
"strconv"
@@ -12,7 +11,6 @@ import (
1211
type Config struct {
1312
APIPort int
1413
RTMPPort int
15-
SRTPort int
1614
APIKey string
1715
DBPath string
1816
VideosDir string
@@ -22,7 +20,6 @@ func Load() *Config {
2220
c := &Config{
2321
APIPort: envInt("API_PORT", 3000),
2422
RTMPPort: envInt("RTMP_PORT", 1935),
25-
SRTPort: envInt("SRT_PORT", 10080),
2623
APIKey: os.Getenv("API_KEY"),
2724
DBPath: env("DB_PATH", "neverdrop.db"),
2825
VideosDir: env("VIDEOS_DIR", "videos"),
@@ -40,10 +37,6 @@ func Load() *Config {
4037
return c
4138
}
4239

43-
func (c *Config) APIPortStr() string {
44-
return fmt.Sprintf(":%d", c.APIPort)
45-
}
46-
4740
func env(key, def string) string {
4841
if v := os.Getenv(key); v != "" {
4942
return v

0 commit comments

Comments
 (0)