mirror of
https://github.com/flavioribeiro/donut.git
synced 2025-09-26 19:11:11 +08:00
add code context
This commit is contained in:
24
README.md
24
README.md
@@ -5,6 +5,30 @@
|
||||
|
||||
# HOW IT WORKS
|
||||
|
||||
|
||||
```go
|
||||
// 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)
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
actor User
|
||||
|
Reference in New Issue
Block a user