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 COPY . ./donut
WORKDIR ${WD}/donut WORKDIR ${WD}/donut
RUN go build . RUN go build -race .
CMD ["/usr/src/app/donut/donut", "--enable-ice-mux=true"] CMD ["/usr/src/app/donut/donut", "--enable-ice-mux=true"]

View File

@@ -3,6 +3,7 @@
* add ffmpeg test utility * add ffmpeg test utility
* add run test locally * add run test locally
* add run linter on docker * add run linter on docker
* tag integration tests // +build integration || go test -tags integration -v ./...
# Adding audio (WIP) # 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 vp8 and ogg through rtc (is it possible through SRT?)
* TODO: test push directly h264 and aac through * 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. * 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: refs:
* binding go https://github.com/asticode/go-astiav * 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 * 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) 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/ * (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 * 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 * 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 { type DonutEngine interface {
Prober() probers.DonutProber Prober() probers.DonutProber
Streamer() streamers.DonutStreamer Streamer() streamers.DonutStreamer
CompatibleStreamsFor(server, client *entities.StreamInfo) []entities.Stream CompatibleStreamsFor(server, client *entities.StreamInfo) ([]entities.Stream, bool)
} }
type DonutEngineParams struct { type DonutEngineParams struct {
@@ -79,7 +79,7 @@ func (d *donutEngine) Streamer() streamers.DonutStreamer {
return d.streamer 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 // TODO: implement proper matching
return server.Streams return server.Streams, true
} }

View File

@@ -12,17 +12,26 @@ import (
"go.uber.org/fx/fxtest" "go.uber.org/fx/fxtest"
) )
var controller *probers.SrtMpegTs var p []probers.DonutProber
func setupController(t *testing.T) *probers.SrtMpegTs { func setupController(t *testing.T, req *entities.RequestParams) probers.DonutProber {
if controller != nil { if p == nil {
return controller fxtest.New(t,
web.Dependencies(false),
fx.Populate(
fx.Annotate(
&p,
fx.ParamTags(`group:"probers"`),
),
),
)
} }
fxtest.New(t, for _, c := range p {
web.Dependencies(false), if c.Match(req) {
fx.Populate(&controller), return c
) }
return controller }
return nil
} }
func TestSrtMpegTs_StreamInfo(t *testing.T) { func TestSrtMpegTs_StreamInfo(t *testing.T) {
@@ -32,13 +41,15 @@ func TestSrtMpegTs_StreamInfo(t *testing.T) {
defer ffmpeg.Stop() defer ffmpeg.Stop()
ffmpeg.Start() ffmpeg.Start()
controller = setupController(t) req := &entities.RequestParams{
streamInfo, err := controller.StreamInfo(&entities.RequestParams{
SRTHost: ffmpeg.Output().Host, SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port), SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id", SRTStreamID: "test_id",
}) }
controller := setupController(t, req)
streamInfo, err := controller.StreamInfo(req)
assert.Nil(t, err) assert.Nil(t, err)
assert.NotNil(t, streamInfo) assert.NotNil(t, streamInfo)
@@ -52,13 +63,15 @@ func TestSrtMpegTs_StreamInfo_265(t *testing.T) {
defer ffmpeg.Stop() defer ffmpeg.Stop()
ffmpeg.Start() ffmpeg.Start()
controller = setupController(t) req := &entities.RequestParams{
streamInfo, err := controller.StreamInfo(&entities.RequestParams{
SRTHost: ffmpeg.Output().Host, SRTHost: ffmpeg.Output().Host,
SRTPort: uint16(ffmpeg.Output().Port), SRTPort: uint16(ffmpeg.Output().Port),
SRTStreamID: "test_id", SRTStreamID: "test_id",
}) }
controller := setupController(t, req)
streamInfo, err := controller.StreamInfo(req)
assert.Nil(t, err) assert.Nil(t, err)
assert.NotNil(t, streamInfo) 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 // TODO: introduce a mode to deal with transcoding recipes
// selects proper media that client and server has adverted. // 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 { if compatibleStreams == nil || len(compatibleStreams) == 0 {
return entities.ErrMissingCompatibleStreams 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_LDFLAGS="-L$(brew --prefix srt)/lib -lsrt"
export CGO_CFLAGS="-I$(brew --prefix srt)/include/" export CGO_CFLAGS="-I$(brew --prefix srt)/include/"
go run main.go go run -race main.go