Files
mediamtx/internal/conf/encryption.go
T
Alessandro RosandGitHub a56408db19 add always available streams (#5335)
When the publisher or source of a stream is offline, the server can be
configured to fill gaps in the stream with a video that is played on
repeat until a publisher comes back online. This allows readers to stay
connected regardless of the state of the stream. The offline video and
any future online stream are concatenated without decoding or
re-encoding packets, using the original codec.
2026-01-31 14:44:58 +01:00

47 lines
935 B
Go

package conf
import (
"fmt"
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
)
// Encryption is the rtspEncryption / rtmpEncryption parameter.
type Encryption string
// values.
const (
EncryptionNo Encryption = "no"
EncryptionOptional Encryption = "optional"
EncryptionStrict Encryption = "strict"
)
// UnmarshalJSON implements json.Unmarshaler.
func (d *Encryption) UnmarshalJSON(b []byte) error {
type alias Encryption
if err := jsonwrapper.Unmarshal(b, (*alias)(d)); err != nil {
return err
}
switch *d {
case "false":
*d = EncryptionNo
case "true", "yes":
*d = EncryptionStrict
}
switch *d {
case EncryptionNo, EncryptionOptional, EncryptionStrict:
default:
return fmt.Errorf("invalid encryption: '%s'", *d)
}
return nil
}
// UnmarshalEnv implements env.Unmarshaler.
func (d *Encryption) UnmarshalEnv(_ string, v string) error {
return d.UnmarshalJSON([]byte(`"` + v + `"`))
}