mirror of
https://github.com/flavioribeiro/donut.git
synced 2025-10-05 15:06:51 +08:00
renaming stream variables
This commit is contained in:
19
README.md
19
README.md
@@ -13,22 +13,9 @@ $ go install github.com/flavioribeiro/donut@latest
|
|||||||
```
|
```
|
||||||
Once installed, execute `donut`. This will be in your `$GOPATH/bin`. The default will be `~/go/bin/donut`
|
Once installed, execute `donut`. This will be in your `$GOPATH/bin`. The default will be `~/go/bin/donut`
|
||||||
|
|
||||||
|
|
||||||
### Install & Run using Docker
|
|
||||||
|
|
||||||
Alternatively, you can build a docker image. Docker will take care of downloading the dependencies (including the libsrt) and compiling donut for you.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ docker build -t donut .
|
|
||||||
$ docker run -it -p 8080:8080 donut
|
|
||||||
```
|
|
||||||
|
|
||||||
### Open the Web UI
|
|
||||||
Open [http://localhost:8080](http://localhost:8080). You will see three text boxes. Fill in your details for your SRT listener configuration and hit connect.
|
|
||||||
|
|
||||||
### Run using docker-compose
|
### Run using docker-compose
|
||||||
|
|
||||||
Docker-compose can simulate an SRT live transmission and run the donut in separate containers.
|
Alternatively, you can use `docker-compose` to simulate an SRT live transmission and run the donut effortless.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ make run
|
$ make run
|
||||||
@@ -39,6 +26,10 @@ Open [http://localhost:8080](http://localhost:8080). You will see three text box
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### How it works
|
||||||
|
|
||||||
|
Please check the [How it works](/HOW_IT_WORKS.md) section.
|
||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
Please check the [FAQ](/FAQ.md) if you're facing any trouble.
|
Please check the [FAQ](/FAQ.md) if you're facing any trouble.
|
@@ -42,7 +42,7 @@ func (c *StreamingController) Stream(sp entities.StreamParameters) {
|
|||||||
go c.readFromSRTIntoWriterPipe(sp.SRTConnection, w)
|
go c.readFromSRTIntoWriterPipe(sp.SRTConnection, w)
|
||||||
|
|
||||||
// reading from reader pipe into mpeg-ts demuxer
|
// reading from reader pipe into mpeg-ts demuxer
|
||||||
dmx := astits.NewDemuxer(sp.Ctx, r)
|
mpegTSDemuxer := astits.NewDemuxer(sp.Ctx, r)
|
||||||
eia608Reader := eia608.NewEIA608Reader()
|
eia608Reader := eia608.NewEIA608Reader()
|
||||||
h264PID := uint16(0)
|
h264PID := uint16(0)
|
||||||
|
|
||||||
@@ -52,42 +52,45 @@ func (c *StreamingController) Stream(sp entities.StreamParameters) {
|
|||||||
c.l.Sugar().Errorw("stream was cancelled")
|
c.l.Sugar().Errorw("stream was cancelled")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
d, err := dmx.NextData()
|
// ref https://tsduck.io/download/docs/mpegts-introduction.pdf
|
||||||
|
mpegTSDemuxData, err := mpegTSDemuxer.NextData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.l.Sugar().Errorw("failed to demux mpeg ts",
|
c.l.Sugar().Errorw("failed to demux mpeg-ts",
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.PMT != nil {
|
if mpegTSDemuxData.PMT != nil {
|
||||||
h264PID = c.captureMediaInfoAndSendToWebRTC(d, sp.MetadataTrack, h264PID)
|
// writing mpeg-ts meida metadata to the metadata webrtc channel
|
||||||
c.captureBitrateAndSendToWebRTC(d, sp.MetadataTrack)
|
h264PID = c.captureMediaInfoAndSendToWebRTC(mpegTSDemuxData, sp.MetadataTrack, h264PID)
|
||||||
|
c.captureBitrateAndSendToWebRTC(mpegTSDemuxData, sp.MetadataTrack)
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.PID == h264PID && d.PES != nil {
|
if mpegTSDemuxData.PID == h264PID && mpegTSDemuxData.PES != nil {
|
||||||
// writing video from mpeg-ts into webrtc
|
// writing video from mpeg-ts into webrtc
|
||||||
if err = sp.VideoTrack.WriteSample(media.Sample{Data: d.PES.Data, Duration: time.Second / 30}); err != nil {
|
if err = sp.VideoTrack.WriteSample(media.Sample{Data: mpegTSDemuxData.PES.Data, Duration: time.Second / 30}); err != nil {
|
||||||
c.l.Sugar().Errorw("failed to write a sample mpeg ts to web rtc",
|
c.l.Sugar().Errorw("failed to write a sample mpeg-ts to web rtc",
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
captions, err := eia608Reader.Parse(d.PES)
|
captions, err := eia608Reader.Parse(mpegTSDemuxData.PES)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.l.Sugar().Errorw("failed to parse eia 608",
|
c.l.Sugar().Errorw("failed to parse eia 608",
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
if captions != "" {
|
if captions != "" {
|
||||||
captionsMsg, err := eia608.BuildCaptionsMessage(d.PES.Header.OptionalHeader.PTS, captions)
|
captionsMsg, err := eia608.BuildCaptionsMessage(mpegTSDemuxData.PES.Header.OptionalHeader.PTS, captions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.l.Sugar().Errorw("failed to build captions message",
|
c.l.Sugar().Errorw("failed to build captions message",
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
// writing metadata to the metadata webrtc channel
|
||||||
sp.MetadataTrack.SendText(captionsMsg)
|
sp.MetadataTrack.SendText(captionsMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user