Browse Source

simplify configuration parser

pull/3081/head
aler9 2 years ago
parent
commit
95405dcc22
  1. 5
      internal/conf/encryption.go
  2. 5
      internal/conf/hls_variant.go
  3. 5
      internal/conf/log_destination.go
  4. 5
      internal/conf/log_level.go
  5. 5
      internal/conf/protocol.go
  6. 5
      internal/conf/rtsp_auth_methods.go
  7. 5
      internal/conf/rtsp_range_type.go
  8. 5
      internal/conf/rtsp_transport.go

5
internal/conf/encryption.go

@ -26,11 +26,8 @@ func (d Encryption) MarshalJSON() ([]byte, error) { @@ -26,11 +26,8 @@ func (d Encryption) MarshalJSON() ([]byte, error) {
case EncryptionOptional:
out = "optional"
case EncryptionStrict:
out = "strict"
default:
return nil, fmt.Errorf("invalid encryption: %v", d)
out = "strict"
}
return json.Marshal(out)

5
internal/conf/hls_variant.go

@ -21,11 +21,8 @@ func (d HLSVariant) MarshalJSON() ([]byte, error) { @@ -21,11 +21,8 @@ func (d HLSVariant) MarshalJSON() ([]byte, error) {
case HLSVariant(gohlslib.MuxerVariantFMP4):
out = "fmp4"
case HLSVariant(gohlslib.MuxerVariantLowLatency):
out = "lowLatency"
default:
return nil, fmt.Errorf("invalid HLS variant: %v", d)
out = "lowLatency"
}
return json.Marshal(out)

5
internal/conf/log_destination.go

@ -26,11 +26,8 @@ func (d LogDestinations) MarshalJSON() ([]byte, error) { @@ -26,11 +26,8 @@ func (d LogDestinations) MarshalJSON() ([]byte, error) {
case logger.DestinationFile:
v = "file"
case logger.DestinationSyslog:
v = "syslog"
default:
return nil, fmt.Errorf("invalid log destination: %v", p)
v = "syslog"
}
out[i] = v

5
internal/conf/log_level.go

@ -24,11 +24,8 @@ func (d LogLevel) MarshalJSON() ([]byte, error) { @@ -24,11 +24,8 @@ func (d LogLevel) MarshalJSON() ([]byte, error) {
case LogLevel(logger.Info):
out = "info"
case LogLevel(logger.Debug):
out = "debug"
default:
return nil, fmt.Errorf("invalid log level: %v", d)
out = "debug"
}
return json.Marshal(out)

5
internal/conf/protocol.go

@ -30,11 +30,8 @@ func (d Protocols) MarshalJSON() ([]byte, error) { @@ -30,11 +30,8 @@ func (d Protocols) MarshalJSON() ([]byte, error) {
case Protocol(gortsplib.TransportUDPMulticast):
v = "multicast"
case Protocol(gortsplib.TransportTCP):
v = "tcp"
default:
return nil, fmt.Errorf("invalid protocol: %v", p)
v = "tcp"
}
out[i] = v

5
internal/conf/rtsp_auth_methods.go

@ -21,11 +21,8 @@ func (d RTSPAuthMethods) MarshalJSON() ([]byte, error) { @@ -21,11 +21,8 @@ func (d RTSPAuthMethods) MarshalJSON() ([]byte, error) {
case headers.AuthBasic:
out[i] = "basic"
case headers.AuthDigestMD5:
out[i] = "digest"
default:
return nil, fmt.Errorf("invalid authentication method: %v", v)
out[i] = "digest"
}
}

5
internal/conf/rtsp_range_type.go

@ -30,11 +30,8 @@ func (d RTSPRangeType) MarshalJSON() ([]byte, error) { @@ -30,11 +30,8 @@ func (d RTSPRangeType) MarshalJSON() ([]byte, error) {
case RTSPRangeTypeSMPTE:
out = "smpte"
case RTSPRangeTypeUndefined:
out = ""
default:
return nil, fmt.Errorf("invalid rtsp range type: %v", d)
out = ""
}
return json.Marshal(out)

5
internal/conf/rtsp_transport.go

@ -26,11 +26,8 @@ func (d RTSPTransport) MarshalJSON() ([]byte, error) { @@ -26,11 +26,8 @@ func (d RTSPTransport) MarshalJSON() ([]byte, error) {
case gortsplib.TransportUDPMulticast:
out = "multicast"
case gortsplib.TransportTCP:
out = "tcp"
default:
return nil, fmt.Errorf("invalid protocol: %v", d.Transport)
out = "tcp"
}
}

Loading…
Cancel
Save