Rename mpegts module to mpeg

This commit is contained in:
Alex X
2026-02-08 07:09:36 +03:00
parent 44f6f111c4
commit 2735bafd86
8 changed files with 36 additions and 47 deletions
+3 -3
View File
@@ -47,8 +47,8 @@ Some formats and protocols go2rtc supports exclusively. They have no equivalent
| [`mjpeg`] | `mpjpeg` | `http` | | yes | yes | |
| [`mjpeg`] | `yuv4mpegpipe` | `http` | | yes | | |
| [`mp4`] | `mp4` | `http`, `ws` | | yes | | |
| [`mpegts`] | `adts` | `http` | | yes | | |
| [`mpegts`] | `mpegts` | `http` | | yes | yes | |
| [`mpeg`] | `adts` | `http` | | yes | | |
| [`mpeg`] | `mpegts` | `http` | | yes | yes | |
| [`multitrans`] | `rtp` | `tcp` | | | | yes |
| [`nest`] | `srtp` | `rtsp`, `webrtc` | yes | | | no |
| [`onvif`] | `rtp` | * | yes | yes | | |
@@ -90,7 +90,7 @@ Some formats and protocols go2rtc supports exclusively. They have no equivalent
[`kasa`]: kasa/README.md
[`mjpeg`]: mjpeg/README.md
[`mp4`]: mp4/README.md
[`mpegts`]: mpegts/README.md
[`mpeg`]: mpeg/README.md
[`multitrans`]: multitrans/README.md
[`nest`]: nest/README.md
[`ngrok`]: ngrok/README.md
@@ -1,4 +1,4 @@
# MPEG-TS
# MPEG
This module provides an [HTTP API](../api/README.md) for:
@@ -6,9 +6,6 @@ This module provides an [HTTP API](../api/README.md) for:
- Streaming output in `adts` format.
- Streaming ingest in `mpegts` format.
> [!NOTE]
> This module is probably better called mpeg. Because AAC is part of MPEG-2 and MPEG-4 and MPEG-TS is part of MPEG-2.
## MPEG-TS Server
```shell
@@ -1,10 +1,11 @@
package mpegts
package mpeg
import (
"net/http"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/aac"
"github.com/AlexxIT/go2rtc/pkg/mpegts"
)
@@ -66,3 +67,26 @@ func inputMpegTS(w http.ResponseWriter, r *http.Request) {
return
}
}
func apiStreamAAC(w http.ResponseWriter, r *http.Request) {
src := r.URL.Query().Get("src")
stream := streams.Get(src)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}
cons := aac.NewConsumer()
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "audio/aac")
_, _ = cons.WriteTo(w)
stream.RemoveConsumer(cons)
}
-32
View File
@@ -1,32 +0,0 @@
package mpegts
import (
"net/http"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/aac"
)
func apiStreamAAC(w http.ResponseWriter, r *http.Request) {
src := r.URL.Query().Get("src")
stream := streams.Get(src)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}
cons := aac.NewConsumer()
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "audio/aac")
_, _ = cons.WriteTo(w)
stream.RemoveConsumer(cons)
}