diff --git a/README.md b/README.md index 0bb2ea52..e66175a8 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ A summary table of all modules and features can be found [here](internal/README. ### Streaming output -- [`adts`](internal/mpegts/README.md) - Output stream in ADTS format with [AAC](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) audio. +- [`adts`](internal/mpeg/README.md) - Output stream in ADTS format with [AAC](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) audio. - [`ascii`](internal/mjpeg/README.md#ascii) - Just for fun stream as [ASCII to Terminal](https://www.youtube.com/watch?v=sHj_3h_sX7M). - [`flv`](internal/rtmp/README.md) - Output stream in [Flash Video](https://en.wikipedia.org/wiki/Flash_Video) format. - [`hls`](internal/hls/README.md) - Output stream in [HTTP Live Streaming](https://en.wikipedia.org/wiki/HTTP_Live_Streaming) format. @@ -245,7 +245,7 @@ A summary table of all modules and features can be found [here](internal/README. - [`jpeg`](internal/mjpeg/README.md#jpeg) - Output snapshots in [JPEG](https://en.wikipedia.org/wiki/JPEG) format. - [`mpjpeg`](internal/mjpeg/README.md#mpjpeg) - Output a stream in [MJPEG](https://en.wikipedia.org/wiki/Motion_JPEG) format. - [`mp4`](internal/mp4/README.md) - Output as [MP4 stream](https://en.wikipedia.org/wiki/Progressive_download) or [Media Source Extensions](https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API) (MSE) compatible format. -- [`mpegts`](internal/homekit/README.md) - Output stream in [MPEG transport stream](https://en.wikipedia.org/wiki/MPEG_transport_stream) format. +- [`mpegts`](internal/mpeg/README.md) - Output stream in [MPEG transport stream](https://en.wikipedia.org/wiki/MPEG_transport_stream) format. - [`onvif`](internal/onvif/README.md#onvif-server) - Output stream using [ONVIF](https://en.wikipedia.org/wiki/ONVIF) protocol. - [`rtmp`](internal/rtmp/README.md#rtmp-server) - Output stream using [Real-Time Messaging](https://en.wikipedia.org/wiki/Real-Time_Messaging_Protocol) protocol. - [`rtsp`](internal/rtsp/README.md#rtsp-server) - Output stream using [Real-Time Streaming](https://en.wikipedia.org/wiki/Real-Time_Streaming_Protocol) protocol. @@ -258,7 +258,7 @@ A summary table of all modules and features can be found [here](internal/README. Supported for: [`flv`](internal/rtmp/README.md#flv-server), [`mjpeg`](internal/mjpeg/README.md#streaming-ingest), -[`mpegts`](internal/mpegts/README.md#streaming-ingest), +[`mpegts`](internal/mpeg/README.md#streaming-ingest), [`rtmp`](internal/rtmp/README.md#rtmp-server), [`rtsp`](internal/rtsp/README.md#streaming-ingest), [`webrtc`](internal/webrtc/README.md#streaming-ingest). diff --git a/internal/README.md b/internal/README.md index 4a5e8354..f3e9f3b3 100644 --- a/internal/README.md +++ b/internal/README.md @@ -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 diff --git a/internal/mpegts/README.md b/internal/mpeg/README.md similarity index 77% rename from internal/mpegts/README.md rename to internal/mpeg/README.md index 9ad83ac2..e1c444b6 100644 --- a/internal/mpegts/README.md +++ b/internal/mpeg/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 diff --git a/internal/mpegts/mpegts.go b/internal/mpeg/mpeg.go similarity index 72% rename from internal/mpegts/mpegts.go rename to internal/mpeg/mpeg.go index d5f7752b..0a55299d 100644 --- a/internal/mpegts/mpegts.go +++ b/internal/mpeg/mpeg.go @@ -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) +} diff --git a/internal/mpegts/aac.go b/internal/mpegts/aac.go deleted file mode 100644 index 3b1522fe..00000000 --- a/internal/mpegts/aac.go +++ /dev/null @@ -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) -} diff --git a/main.go b/main.go index c05791da..00c059e3 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ import ( "github.com/AlexxIT/go2rtc/internal/kasa" "github.com/AlexxIT/go2rtc/internal/mjpeg" "github.com/AlexxIT/go2rtc/internal/mp4" - "github.com/AlexxIT/go2rtc/internal/mpegts" + "github.com/AlexxIT/go2rtc/internal/mpeg" "github.com/AlexxIT/go2rtc/internal/multitrans" "github.com/AlexxIT/go2rtc/internal/nest" "github.com/AlexxIT/go2rtc/internal/ngrok" @@ -98,7 +98,7 @@ func main() { {"isapi", isapi.Init}, {"ivideon", ivideon.Init}, {"kasa", kasa.Init}, - {"mpegts", mpegts.Init}, + {"mpegts", mpeg.Init}, {"multitrans", multitrans.Init}, {"nest", nest.Init}, {"ring", ring.Init}, diff --git a/website/.vitepress/config.js b/website/.vitepress/config.js index c5ef0776..8134c947 100644 --- a/website/.vitepress/config.js +++ b/website/.vitepress/config.js @@ -134,7 +134,7 @@ export default defineConfig({ {text: 'isapi', link: '/internal/isapi/'}, {text: 'ivideon', link: '/internal/ivideon/'}, {text: 'kasa', link: '/internal/kasa/'}, - {text: 'mpegts', link: '/internal/mpegts/'}, + {text: 'mpeg', link: '/internal/mpeg/'}, {text: 'multitrans', link: '/internal/multitrans/'}, {text: 'nest', link: '/internal/nest/'}, {text: 'ring', link: '/internal/ring/'}, diff --git a/www/schema.json b/www/schema.json index 29c2ca1e..27fee57d 100644 --- a/www/schema.json +++ b/www/schema.json @@ -172,7 +172,7 @@ "isapi", "ivideon", "kasa", - "mpegts", + "mpeg", "nest", "ring", "roborock",