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.
 
 
 
 
 
 

35 lines
710 B

package conf
import (
"encoding/json"
"code.cloudfoundry.org/bytefmt"
)
// StringSize is a size that is unmarshaled from a string.
type StringSize uint64
// MarshalJSON marshals a StringSize into JSON.
func (s StringSize) MarshalJSON() ([]byte, error) {
return []byte(`"` + bytefmt.ByteSize(uint64(s)) + `"`), nil
}
// UnmarshalJSON unmarshals a StringSize from JSON.
func (s *StringSize) UnmarshalJSON(b []byte) error {
var in string
if err := json.Unmarshal(b, &in); err != nil {
return err
}
v, err := bytefmt.ToBytes(in)
if err != nil {
return err
}
*s = StringSize(v)
return nil
}
func (s *StringSize) unmarshalEnv(v string) error {
return s.UnmarshalJSON([]byte(`"` + v + `"`))
}