add more annotations

This commit is contained in:
Leandro Moreira
2024-02-15 14:42:29 -03:00
parent c839c5d3a5
commit 48deaf7ee6
6 changed files with 51 additions and 23 deletions

View File

@@ -29,5 +29,5 @@ ENV CGO_LDFLAGS="-L${SRT_FOLDER}/lib/"
COPY . ./donut
WORKDIR ${WD}/donut
RUN go build .
RUN go build -race .
CMD ["/usr/src/app/donut/donut", "--enable-ice-mux=true"]

View File

@@ -3,6 +3,7 @@
* add ffmpeg test utility
* add run test locally
* add run linter on docker
* tag integration tests // +build integration || go test -tags integration -v ./...
# Adding audio (WIP)
@@ -16,6 +17,11 @@
* TODO: test push directly vp8 and ogg through rtc (is it possible through SRT?)
* TODO: test push directly h264 and aac through
* TODO: test transcode server side stream (h264 and aac) to client side stream support (vp8/vp9/ogg) through libav/ffmpeg.
// selects proper media that client and server has adverted.
// donutEngine preferable vp8, ogg???
// From: [] To: [] or Transcode:[], Bypass: []
// libav_streamer.go, libav_streamer_format.go, libav_streamer_codec.go...
// reads from Server (input) and generates h264 raw, and ogg and send it with timing attributes
refs:
* binding go https://github.com/asticode/go-astiav
@@ -23,6 +29,7 @@ refs:
* using buffer streaming https://github.com/bubbajoe/go-astiav-contr/blob/misc-update/examples/gocv/main.go#L167
* (working) go webrtc same stream https://github.com/pion/webrtc/blob/v3.2.24/examples/play-from-disk/main.go#L88C39-L88C64
* (working) https://jsfiddle.net/8kup9mvn/
* (two tracks - js side) https://www.youtube.com/watch?v=8I2axE6j204
* webrtc discussion https://github.com/pion/webrtc/discussions/1955
* go webrtc example https://github.com/pion/webrtc/blob/master/examples/play-from-disk-renegotiation/main.go

View File

@@ -12,7 +12,7 @@ import (
type DonutEngine interface {
Prober() probers.DonutProber
Streamer() streamers.DonutStreamer
CompatibleStreamsFor(server, client *entities.StreamInfo) []entities.Stream
CompatibleStreamsFor(server, client *entities.StreamInfo) ([]entities.Stream, bool)
}
type DonutEngineParams struct {
@@ -79,7 +79,7 @@ func (d *donutEngine) Streamer() streamers.DonutStreamer {
return d.streamer
}
func (d *donutEngine) CompatibleStreamsFor(server, client *entities.StreamInfo) []entities.Stream {
func (d *donutEngine) CompatibleStreamsFor(server, client *entities.StreamInfo) ([]entities.Stream, bool) {
// TODO: implement proper matching
return server.Streams
return server.Streams, true
}

View File

@@ -12,17 +12,26 @@ import (
"go.uber.org/fx/fxtest"
)
var controller *probers.SrtMpegTs
var p []probers.DonutProber
func setupController(t *testing.T) *probers.SrtMpegTs {
if controller != nil {
return controller
}
func setupController(t *testing.T, req *entities.RequestParams) probers.DonutProber {
if p == nil {
fxtest.New(t,
web.Dependencies(false),
fx.Populate(&controller),
fx.Populate(
fx.Annotate(
&p,
fx.ParamTags(`group:"probers"`),
),
),
)
return controller
}
for _, c := range p {
if c.Match(req) {
return c
}
}
return nil
}
func TestSrtMpegTs_StreamInfo(t *testing.T) {
@@ -32,13 +41,15 @@ func TestSrtMpegTs_StreamInfo(t *testing.T) {
defer ffmpeg.Stop()
ffmpeg.Start()
controller = setupController(t)
streamInfo, err := controller.StreamInfo(&entities.RequestParams{
req := &entities.RequestParams{
SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id",
})
}
controller := setupController(t, req)
streamInfo, err := controller.StreamInfo(req)
assert.Nil(t, err)
assert.NotNil(t, streamInfo)
@@ -52,13 +63,15 @@ func TestSrtMpegTs_StreamInfo_265(t *testing.T) {
defer ffmpeg.Stop()
ffmpeg.Start()
controller = setupController(t)
streamInfo, err := controller.StreamInfo(&entities.RequestParams{
req := &entities.RequestParams{
SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id",
})
}
controller := setupController(t, req)
streamInfo, err := controller.StreamInfo(req)
assert.Nil(t, err)
assert.NotNil(t, streamInfo)

View File

@@ -71,7 +71,15 @@ func (h *SignalingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) err
// TODO: introduce a mode to deal with transcoding recipes
// selects proper media that client and server has adverted.
compatibleStreams := donutEngine.CompatibleStreamsFor(serverStreamInfo, clientStreamInfo)
// donutEngine preferable vp8, ogg???
// From: [] To: [] or Transcode:[], Bypass: []
// libav_streamer.go, libav_streamer_format.go, libav_streamer_codec.go...
// reads from Server (input) and generates h264 raw, and ogg and send it with timing attributes
compatibleStreams, ok := donutEngine.CompatibleStreamsFor(serverStreamInfo, clientStreamInfo)
if !ok {
h.l.Info("we must transcode")
}
if compatibleStreams == nil || len(compatibleStreams) == 0 {
return entities.ErrMissingCompatibleStreams
}

View File

@@ -4,4 +4,4 @@ source ./scripts/mac_check_deps.sh
export CGO_LDFLAGS="-L$(brew --prefix srt)/lib -lsrt"
export CGO_CFLAGS="-I$(brew --prefix srt)/include/"
go run main.go
go run -race main.go