feat: expand livestream management platform
This commit is contained in:
1 parent
383c066d86
commit
ed62d42a63
12 files changed
+223
-24
No files matched your search
@@ -14,6 +14,17 @@ class StreamService:
|
||||
def __init__(self, db: AsyncSession):
|
||||
self.db = db
|
||||
|
||||
@staticmethod
|
||||
def effective_renditions(stream: Stream) -> list:
|
||||
if stream.renditions_json:
|
||||
try:
|
||||
renditions = json.loads(stream.renditions_json)
|
||||
if isinstance(renditions, list) and renditions:
|
||||
return renditions
|
||||
except (TypeError, ValueError, json.JSONDecodeError):
|
||||
pass
|
||||
return settings.transcode_profiles.get(stream.transcode_profile, settings.qualities)
|
||||
|
||||
async def create_stream(self, title: str, description: str | None = None,
|
||||
cover_url: str | None = None,
|
||||
scheduled_at: str | None = None,
|
||||
@@ -95,7 +106,7 @@ class StreamService:
|
||||
started_at=datetime.utcnow(),
|
||||
)
|
||||
rtmp_url = media_service.get_rtmp_url(stream_key)
|
||||
transcode_mgr.start_transcode(stream_key, rtmp_url, stream.transcode_profile)
|
||||
transcode_mgr.start_transcode(stream_key, rtmp_url, self.effective_renditions(stream))
|
||||
|
||||
async def set_stream_ended(self, stream_key: str):
|
||||
stream = await self.get_stream_by_key(stream_key)
|
||||
@@ -112,7 +123,7 @@ class StreamService:
|
||||
stream = await self.get_stream_by_key(stream_key)
|
||||
if not stream:
|
||||
return {"lines": [], "qualities": [], "multicast_available": False, "selected_node": None}
|
||||
qualities = settings.transcode_profiles.get(stream.transcode_profile, settings.qualities)
|
||||
qualities = self.effective_renditions(stream)
|
||||
best_node = lb.select_best_node(client_ip)
|
||||
if not best_node:
|
||||
best_node = lb.get_enabled_nodes()[0] if lb.get_enabled_nodes() else None
|
||||
|
||||
Reference in new issue
Block a user