package main

import (
	"lc/common/util"

	"lc/common/configor"
	"lc/common/protocol"
)

func GetTopic(devtype, id, topic string) string {
	return appConfig.Tenant + "/" + devtype + "/" + id + "/" + topic
}

type OnvifDevConfig struct {
	Ffmpeg string              `json:"ffmpeg"`
	Rtu    []protocol.OnvifDev `json:"dev"`
}

var appConfig protocol.AppConfig
var onvifDevConfig OnvifDevConfig

func loadAppConfig() error {
	var o protocol.AppConfig
	err := configor.Load(&o, util.GetPath(0)+"app.json")
	if err == nil && o.GID != "" {
		appConfig = o
	}
	return err
}

func LoadOnvifDevConfig() error {
	var o OnvifDevConfig
	err := configor.Load(&o, util.GetPath(0)+"onvif.json")
	if err == nil {
		onvifDevConfig = o
	}
	return err
}
