Leandro Moreira c613a891fa add code context
2024-06-04 21:43:31 -03:00
2024-02-26 08:43:45 -03:00
2024-05-12 15:05:35 -03:00
2024-05-19 00:36:36 -03:00
2024-05-19 00:36:36 -03:00
2024-02-24 22:17:33 -03:00
2024-02-18 11:27:04 -03:00
2024-02-18 11:27:04 -03:00
2024-05-14 15:15:35 -03:00
2024-05-19 00:36:36 -03:00
2024-01-31 16:51:08 -03:00
2024-05-13 09:48:26 -03:00
2024-05-14 15:15:35 -03:00
2024-05-14 15:15:35 -03:00
2024-06-02 14:44:17 -03:00
2023-01-12 09:35:44 -05:00
2024-02-09 09:49:17 -03:00
2024-05-19 00:36:36 -03:00
2024-06-04 21:43:31 -03:00

donut is a zero setup required SRT (MPEG-TS) and RTMP to WebRTC bridge powered by Pion.

HOW IT WORKS

// It builds an engine based on user inputs
// {url: url, id: id, sdp: webRTCOffer}
donutEngine := donut.EngineFor(reqParams)
// It fetches the server-side (streaming server) stream info (codec, ...)
serverStreamInfo := donutEngine.ServerIngredients(reqParams)
// It gets the client side (browser) media support (codec, ...)
clientStreamInfo := donutEngine.ClientIngredients(reqParams)
// Given the client's restrictions and the server's availability, it builds the right recipe.
donutRecipe := donutEngine.RecipeFor(reqParams, serverStreamInfo, clientStreamInfo)

// It streams the media from the backend server to the client while there's data.
go donutEngine.Serve(DonutParameters{
	Recipe: donutRecipe,
	OnVideoFrame: func(data []byte, c MediaFrameContext) error {
		return SendMediaSample(VIDEO_TYPE, data, c)
	},
	OnAudioFrame: func(data []byte, c MediaFrameContext) error {
		return SendMediaSample(AUDIO_TYPE, data, c)
	},
})
sequenceDiagram
    actor User

    box Navy
        participant browser
    end

    User->>+browser: input protocol, host, port, id, and opts
    User->>+browser: click on [Connect]
    
    Note over donut,browser: WebRTC connection setup
    
    browser->>+browser: create WebRTC browserOffer
    browser->>+donut: POST /doSignaling {browserOffer}

    donut->>+browser: reply WebRTC {serverOffer}

    Note over donut,browser: WebRTC connection setup

    loop Async streaming
        donut--)streaming server: fetchMedia
        donut--)donut: ffmpeg::libav demux/transcode
        donut--)browser: sendWebRTCMedia
        browser--)browser: render audio/video frames
        User--)browser: watch media
    end

donut docker-compose setup

ref: how donut works

QUICK START

Make sure you have the ffmpeg 5.x.x. You must configure the CGO library path pointing it to ffmpeg 5.

export CGO_LDFLAGS="-L/opt/homebrew/Cellar/ffmpeg@5/5.1.4_6/lib/"
export CGO_CFLAGS="-I/opt/homebrew/Cellar/ffmpeg@5/5.1.4_6/include/"
export PKG_CONFIG_PATH="/opt/homebrew/Cellar/ffmpeg@5/5.1.4_6/lib/pkgconfig"

Now you can install and run it:

go install github.com/flavioribeiro/donut@latest
donut

Here are specific instructions to run on MacOS.

RUN USING DOCKER-COMPOSE

Alternatively, you can use docker-compose to simulate an SRT live transmission and run the donut effortless.

make run

OPEN THE WEB UI

Open http://localhost:8080/demo. You will see two text fields. Fill them with the your streaming info and hit connect.

donut docker-compose setup

How it works

Please check the How it works section.

FAQ

Please check the FAQ if you're facing any trouble.

Description
donut is a zero setup required SRT+MPEG-TS -> WebRTC Bridge powered by Pion.
Readme Apache-2.0 4.9 MiB
Languages
Go 86%
JavaScript 5.2%
HTML 3.9%
CSS 1.7%
Shell 1.6%
Other 1.6%