golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
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.
56 lines
953 B
56 lines
953 B
package conf |
|
|
|
import ( |
|
"encoding/json" |
|
"fmt" |
|
) |
|
|
|
// RecordFormat is the recordFormat parameter. |
|
type RecordFormat int |
|
|
|
// supported values. |
|
const ( |
|
RecordFormatFMP4 RecordFormat = iota |
|
RecordFormatMPEGTS |
|
) |
|
|
|
// MarshalJSON implements json.Marshaler. |
|
func (d RecordFormat) MarshalJSON() ([]byte, error) { |
|
var out string |
|
|
|
switch d { |
|
case RecordFormatMPEGTS: |
|
out = "mpegts" |
|
|
|
default: |
|
out = "fmp4" |
|
} |
|
|
|
return json.Marshal(out) |
|
} |
|
|
|
// UnmarshalJSON implements json.Unmarshaler. |
|
func (d *RecordFormat) UnmarshalJSON(b []byte) error { |
|
var in string |
|
if err := json.Unmarshal(b, &in); err != nil { |
|
return err |
|
} |
|
|
|
switch in { |
|
case "mpegts": |
|
*d = RecordFormatMPEGTS |
|
|
|
case "fmp4": |
|
*d = RecordFormatFMP4 |
|
|
|
default: |
|
return fmt.Errorf("invalid record format '%s'", in) |
|
} |
|
|
|
return nil |
|
} |
|
|
|
// UnmarshalEnv implements env.Unmarshaler. |
|
func (d *RecordFormat) UnmarshalEnv(_ string, v string) error { |
|
return d.UnmarshalJSON([]byte(`"` + v + `"`)) |
|
}
|
|
|