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.
47 lines
1.2 KiB
47 lines
1.2 KiB
package live
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"laic-backend/common"
|
|
)
|
|
|
|
func NewAdapter(conf common.Live) (Adapter, error) {
|
|
cfg := Config{
|
|
Mode: strings.ToLower(conf.Mode),
|
|
Provider: strings.ToLower(conf.Provider),
|
|
PushDomain: conf.PushDomain,
|
|
PlayDomain: conf.PlayDomain,
|
|
AppName: conf.AppName,
|
|
AuthKey: conf.AuthKey,
|
|
PlayAuthKey: conf.PlayAuthKey,
|
|
AccessKeyID: conf.AccessKeyID,
|
|
AccessKeySecret: conf.AccessKeySecret,
|
|
RegionID: conf.RegionID,
|
|
APIEndpoint: conf.APIEndpoint,
|
|
AuthExpireSeconds: conf.AuthExpireSeconds,
|
|
PlayURLTTLSeconds: conf.PlayURLTTLSeconds,
|
|
Protocol: strings.ToLower(conf.Protocol),
|
|
SRTPort: conf.SRTPort,
|
|
AllowRealCloud: conf.AllowRealCloud,
|
|
}
|
|
switch cfg.Mode {
|
|
case "", "disabled":
|
|
return DisabledAdapter{}, nil
|
|
case "fake":
|
|
if cfg.PushDomain == "" {
|
|
cfg.PushDomain = "local-push"
|
|
}
|
|
if cfg.PlayDomain == "" {
|
|
cfg.PlayDomain = "local-play"
|
|
}
|
|
if cfg.AppName == "" {
|
|
cfg.AppName = "dock-live"
|
|
}
|
|
return FakeAdapter{PushDomain: cfg.PushDomain, PlayDomain: cfg.PlayDomain, AppName: cfg.AppName}, nil
|
|
case "aliyun":
|
|
return NewAliyunAdapter(cfg)
|
|
default:
|
|
return nil, ErrInvalidConfig
|
|
}
|
|
}
|
|
|