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.
 
 
 
 
 
 

65 lines
1.2 KiB

package conf
import (
"encoding/json"
"fmt"
"github.com/bluenviron/gohlslib"
)
// HLSVariant is the hlsVariant parameter.
type HLSVariant hls.MuxerVariant
// supported HLS variants.
const (
HLSVariantMPEGTS HLSVariant = HLSVariant(hls.MuxerVariantMPEGTS)
HLSVariantFMP4 HLSVariant = HLSVariant(hls.MuxerVariantFMP4)
HLSVariantLowLatency HLSVariant = HLSVariant(hls.MuxerVariantLowLatency)
)
// MarshalJSON implements json.Marshaler.
func (d HLSVariant) MarshalJSON() ([]byte, error) {
var out string
switch d {
case HLSVariantMPEGTS:
out = "mpegts"
case HLSVariantFMP4:
out = "fmp4"
default:
out = "lowLatency"
}
return json.Marshal(out)
}
// UnmarshalJSON implements json.Unmarshaler.
func (d *HLSVariant) UnmarshalJSON(b []byte) error {
var in string
if err := json.Unmarshal(b, &in); err != nil {
return err
}
switch in {
case "mpegts":
*d = HLSVariantMPEGTS
case "fmp4":
*d = HLSVariantFMP4
case "lowLatency":
*d = HLSVariantLowLatency
default:
return fmt.Errorf("invalid hlsVariant value: '%s'", in)
}
return nil
}
// unmarshalEnv implements envUnmarshaler.
func (d *HLSVariant) unmarshalEnv(s string) error {
return d.UnmarshalJSON([]byte(`"` + s + `"`))
}