feat: 自动建立实时监看媒体路径 (#51)

This commit is contained in:
ila
2026-08-13 12:42:07 +08:00
parent 20020c0c2f
commit 82672baf02
@@ -11,6 +11,11 @@ type Credential struct {
Password string
}
type DisplayInfo struct {
Name string
Location string
}
var activeService atomic.Pointer[Service]
// ReadCredential is an internal adapter port. Credentials must never be
@@ -50,6 +55,18 @@ func ReadRTSPCredential(ctx context.Context, id string) (Credential, error) {
return Credential{Username: username, Password: password}, err
}
func Describe(ctx context.Context, id string) (DisplayInfo, error) {
service := activeService.Load()
if service == nil {
return DisplayInfo{}, fmt.Errorf("device service is not ready")
}
item, err := service.store.Get(ctx, id)
if err != nil {
return DisplayInfo{}, err
}
return DisplayInfo{Name: item.Name, Location: item.Location}, nil
}
func MarkActive(ctx context.Context, id string) error {
service := activeService.Load()
if service == nil {