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.
65 lines
1.1 KiB
65 lines
1.1 KiB
package conf |
|
|
|
import ( |
|
"encoding/json" |
|
"fmt" |
|
|
|
"github.com/aler9/rtsp-simple-server/internal/logger" |
|
) |
|
|
|
// LogDestinations is the logDestionations parameter. |
|
type LogDestinations map[logger.Destination]struct{} |
|
|
|
// MarshalJSON marshals a LogDestinations into JSON. |
|
func (d LogDestinations) MarshalJSON() ([]byte, error) { |
|
out := make([]string, len(d)) |
|
i := 0 |
|
|
|
for p := range d { |
|
var v string |
|
|
|
switch p { |
|
case logger.DestinationStdout: |
|
v = "stdout" |
|
|
|
case logger.DestinationFile: |
|
v = "file" |
|
|
|
default: |
|
v = "syslog" |
|
} |
|
|
|
out[i] = v |
|
i++ |
|
} |
|
|
|
return json.Marshal(out) |
|
} |
|
|
|
// UnmarshalJSON unmarshals a LogDestinations from JSON. |
|
func (d *LogDestinations) UnmarshalJSON(b []byte) error { |
|
var in []string |
|
if err := json.Unmarshal(b, &in); err != nil { |
|
return err |
|
} |
|
|
|
*d = make(LogDestinations) |
|
|
|
for _, proto := range in { |
|
switch proto { |
|
case "stdout": |
|
(*d)[logger.DestinationStdout] = struct{}{} |
|
|
|
case "file": |
|
(*d)[logger.DestinationFile] = struct{}{} |
|
|
|
case "syslog": |
|
(*d)[logger.DestinationSyslog] = struct{}{} |
|
|
|
default: |
|
return fmt.Errorf("invalid log destination: %s", proto) |
|
} |
|
} |
|
|
|
return nil |
|
}
|
|
|