完善节目平台与直播监控体验
This commit is contained in:
1 parent
229a8d0791
commit
e50b8b480b
11 files changed
+642
-37
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Float, ForeignKey, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from database import Base
|
||||
|
||||
|
||||
class ViewerSession(Base):
|
||||
__tablename__ = "viewer_sessions"
|
||||
|
||||
session_id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
||||
stream_id: Mapped[int] = mapped_column(ForeignKey("streams.id"), index=True)
|
||||
node_id: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
node_name: Mapped[str | None] = mapped_column(String(200), nullable=True)
|
||||
quality: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
playback_state: Mapped[str] = mapped_column(String(32), default="idle")
|
||||
buffered_seconds: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
remote_adjusted: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
last_heartbeat: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
|
||||
class ControlSession(Base):
|
||||
__tablename__ = "control_sessions"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
token: Mapped[str] = mapped_column(String(128), unique=True, default=lambda: uuid.uuid4().hex)
|
||||
stream_id: Mapped[int] = mapped_column(ForeignKey("streams.id"), index=True)
|
||||
operator: Mapped[str] = mapped_column(String(128), default="administrator")
|
||||
expires_at: Mapped[datetime] = mapped_column(DateTime, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
|
||||
class ControlCommand(Base):
|
||||
__tablename__ = "control_commands"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
control_session_id: Mapped[int] = mapped_column(ForeignKey("control_sessions.id"), index=True)
|
||||
stream_id: Mapped[int] = mapped_column(ForeignKey("streams.id"), index=True)
|
||||
target_session_id: Mapped[str] = mapped_column(ForeignKey("viewer_sessions.session_id"), index=True)
|
||||
operator: Mapped[str] = mapped_column(String(128), default="administrator")
|
||||
action: Mapped[str] = mapped_column(String(32))
|
||||
value: Mapped[str | None] = mapped_column(String(256), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(32), default="pending")
|
||||
result: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, index=True)
|
||||
claimed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
Reference in new issue
Block a user