mirror of
https://github.com/flavioribeiro/donut.git
synced 2025-10-04 06:36:26 +08:00
split components
This commit is contained in:
49
internal/controller/srt/controller.go
Normal file
49
internal/controller/srt/controller.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package srt
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
astisrt "github.com/asticode/go-astisrt/pkg"
|
||||
"github.com/flavioribeiro/donut/internal/entity"
|
||||
)
|
||||
|
||||
type SRTController struct {
|
||||
c *entity.Config
|
||||
}
|
||||
|
||||
func NewSRTController(c *entity.Config) *SRTController {
|
||||
return &SRTController{
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SRTController) Connect(offer *entity.ParamsOffer) error {
|
||||
if err := offer.Valid(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// conn, err := c.srtConnect(offer)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *SRTController) srtConnect(offer *entity.ParamsOffer) (*astisrt.Connection, error) {
|
||||
srtConnection, err := astisrt.Dial(astisrt.DialOptions{
|
||||
ConnectionOptions: []astisrt.ConnectionOption{
|
||||
astisrt.WithLatency(c.c.SRTConnectionLatencyMS),
|
||||
astisrt.WithStreamid(offer.SRTStreamID),
|
||||
},
|
||||
OnDisconnect: func(c *astisrt.Connection, err error) {
|
||||
log.Fatal("Disconnected from SRT")
|
||||
},
|
||||
Host: offer.SRTHost,
|
||||
Port: offer.SRTPort,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return srtConnection, nil
|
||||
}
|
Reference in New Issue
Block a user