Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
1.2 KiB

package conf
import (
"encoding/json"
"fmt"
)
// RtspRangeType is the type used in the Range header.
type RtspRangeType int
// supported rtsp range types.
const (
RtspRangeTypeUndefined RtspRangeType = iota
RtspRangeTypeClock
RtspRangeTypeNPT
RtspRangeTypeSMPTE
)
// MarshalJSON implements json.Marshaler.
func (d RtspRangeType) MarshalJSON() ([]byte, error) {
var out string
switch d {
case RtspRangeTypeClock:
out = "clock"
case RtspRangeTypeNPT:
out = "npt"
case RtspRangeTypeSMPTE:
out = "smpte"
case RtspRangeTypeUndefined:
out = ""
default:
return nil, fmt.Errorf("invalid rtsp range type: %v", d)
}
return json.Marshal(out)
}
// UnmarshalJSON implements json.Unmarshaler.
func (d *RtspRangeType) UnmarshalJSON(b []byte) error {
var in string
if err := json.Unmarshal(b, &in); err != nil {
return err
}
switch in {
case "clock":
*d = RtspRangeTypeClock
case "npt":
*d = RtspRangeTypeNPT
case "smpte":
*d = RtspRangeTypeSMPTE
case "":
*d = RtspRangeTypeUndefined
default:
return fmt.Errorf("invalid rtsp range type: '%s'", in)
}
return nil
}
// UnmarshalEnv implements envUnmarshaler.
func (d *RtspRangeType) UnmarshalEnv(s string) error {
return d.UnmarshalJSON([]byte(`"` + s + `"`))
}