add draft for rtmp

This commit is contained in:
Leandro Moreira
2024-05-12 15:05:35 -03:00
parent 4cb98061df
commit 199c23e9fd
23 changed files with 420 additions and 98 deletions

View File

@@ -3,6 +3,7 @@ package entities
import (
"context"
"fmt"
"strings"
"time"
"github.com/asticode/go-astiav"
@@ -27,6 +28,9 @@ type RequestParams struct {
SRTPort uint16 `json:",string"`
SRTStreamID string
Offer webrtc.SessionDescription
StreamURL string
StreamID string
}
func (p *RequestParams) Valid() error {
@@ -34,16 +38,18 @@ func (p *RequestParams) Valid() error {
return ErrMissingParamsOffer
}
if p.SRTHost == "" {
return ErrMissingSRTHost
if p.StreamID == "" {
return ErrMissingStreamID
}
if p.SRTPort == 0 {
return ErrMissingSRTPort
if p.StreamURL == "" {
return ErrMissingStreamURL
}
isRTMP := strings.Contains(strings.ToLower(p.StreamURL), "rtmp")
isSRT := strings.Contains(strings.ToLower(p.StreamURL), "srt")
if p.SRTStreamID == "" {
return ErrMissingSRTStreamID
if !(isRTMP || isSRT) {
return ErrUnsupportedStreamURL
}
return nil
@@ -53,7 +59,7 @@ func (p *RequestParams) String() string {
if p == nil {
return ""
}
return fmt.Sprintf("ParamsOffer %v:%v/%v", p.SRTHost, p.SRTPort, p.SRTStreamID)
return fmt.Sprintf("RequestParams {StreamURL: %s, StreamID: %s}", p.StreamURL, p.StreamID)
}
type MessageType string
@@ -175,6 +181,8 @@ var DonutSRTStreamID DonutInputOptionKey = "srt_streamid"
var DonutSRTsmoother DonutInputOptionKey = "smoother"
var DonutSRTTranstype DonutInputOptionKey = "transtype"
var DonutRTMPLive DonutInputOptionKey = "rtmp_live"
type DonutInputFormat string
func (d DonutInputFormat) String() string {