mirror of
https://github.com/flavioribeiro/donut.git
synced 2025-10-24 07:23:10 +08:00
add draft for rtmp
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user