add a monitoring camera setting for cetana
This commit is contained in:
@@ -1,20 +1,39 @@
|
||||
from django.db import models
|
||||
|
||||
from apps.core.models import TimeStampedModel, UUIDModel
|
||||
from apps.live_monitoring.protocols import DEFAULT_PROTOCOL, PROTOCOL_CHOICES
|
||||
|
||||
|
||||
class Camera(UUIDModel, TimeStampedModel):
|
||||
name = models.CharField(max_length=200)
|
||||
facility = models.CharField(max_length=200, blank=True)
|
||||
processing_line = models.CharField(max_length=200, blank=True)
|
||||
stream_url = models.URLField()
|
||||
# Blank = inherit camera.default_protocol from Live Monitoring settings.
|
||||
protocol = models.CharField(
|
||||
max_length=32,
|
||||
choices=PROTOCOL_CHOICES,
|
||||
blank=True,
|
||||
default="",
|
||||
help_text="Streaming standard. Leave blank to use the system default protocol.",
|
||||
)
|
||||
# CharField (not URLField) so RTSP/RTMP/SRT URLs are accepted.
|
||||
stream_url = models.CharField(max_length=1000)
|
||||
# Never expose credentials to the frontend; keep auth config server-side.
|
||||
# Expected keys: username, password, token, auth_method, host, port, path, transport…
|
||||
auth_config = models.JSONField(default=dict, blank=True)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
def resolved_protocol(self) -> str:
|
||||
if self.protocol:
|
||||
return self.protocol
|
||||
from apps.core.settings_service import SettingsService
|
||||
|
||||
value = SettingsService().get("camera.default_protocol", DEFAULT_PROTOCOL)
|
||||
return value if value in dict(PROTOCOL_CHOICES) else DEFAULT_PROTOCOL
|
||||
|
||||
|
||||
class LiveStream(UUIDModel, TimeStampedModel):
|
||||
camera = models.ForeignKey(Camera, on_delete=models.CASCADE, related_name="streams")
|
||||
|
||||
Reference in New Issue
Block a user