mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-27 02:38:45 +02:00
Add WebRTC playback support: implement WebRTCPlayer component, update schema, database, playback types, and API endpoints to handle webrtc_url field and streaming logic
This commit is contained in:
@@ -50,7 +50,10 @@ const getProfile = async ({ request }: { request: Request }) => {
|
||||
})
|
||||
|
||||
const playback = stream
|
||||
? resolveStreamPlayback({ hlsUrl: stream.hls_url })
|
||||
? resolveStreamPlayback({
|
||||
hlsUrl: stream.hls_url,
|
||||
webrtcUrl: stream.webrtc_url,
|
||||
})
|
||||
: null
|
||||
|
||||
return new Response(
|
||||
@@ -66,6 +69,7 @@ const getProfile = async ({ request }: { request: Request }) => {
|
||||
title: stream.title,
|
||||
is_live: stream.is_live,
|
||||
hls_url: stream.hls_url,
|
||||
webrtc_url: stream.webrtc_url,
|
||||
playback,
|
||||
stream_key: stream.stream_key,
|
||||
}
|
||||
|
||||
@@ -43,7 +43,10 @@ const getStream = async ({ request }: { request: Request }) => {
|
||||
})
|
||||
}
|
||||
|
||||
const playback = resolveStreamPlayback({ hlsUrl: stream.hls_url })
|
||||
const playback = resolveStreamPlayback({
|
||||
hlsUrl: stream.hls_url,
|
||||
webrtcUrl: stream.webrtc_url,
|
||||
})
|
||||
|
||||
return new Response(JSON.stringify({ ...stream, playback }), {
|
||||
status: 200,
|
||||
@@ -72,10 +75,11 @@ const updateStream = async ({ request }: { request: Request }) => {
|
||||
|
||||
try {
|
||||
const body = await request.json()
|
||||
const { title, description, hls_url, is_live } = body as {
|
||||
const { title, description, hls_url, webrtc_url, is_live } = body as {
|
||||
title?: string
|
||||
description?: string
|
||||
hls_url?: string
|
||||
webrtc_url?: string
|
||||
is_live?: boolean
|
||||
}
|
||||
|
||||
@@ -96,6 +100,7 @@ const updateStream = async ({ request }: { request: Request }) => {
|
||||
if (title !== undefined) updates.title = title
|
||||
if (description !== undefined) updates.description = description
|
||||
if (hls_url !== undefined) updates.hls_url = hls_url
|
||||
if (webrtc_url !== undefined) updates.webrtc_url = webrtc_url
|
||||
if (is_live !== undefined) {
|
||||
updates.is_live = is_live
|
||||
if (is_live && !stream.started_at) {
|
||||
|
||||
@@ -60,7 +60,10 @@ const serve = async ({
|
||||
})
|
||||
|
||||
const playback = stream
|
||||
? resolveStreamPlayback({ hlsUrl: stream.hls_url })
|
||||
? resolveStreamPlayback({
|
||||
hlsUrl: stream.hls_url,
|
||||
webrtcUrl: stream.webrtc_url,
|
||||
})
|
||||
: null
|
||||
|
||||
const data = {
|
||||
@@ -78,6 +81,7 @@ const serve = async ({
|
||||
is_live: stream.is_live,
|
||||
viewer_count: stream.viewer_count,
|
||||
hls_url: stream.hls_url,
|
||||
webrtc_url: stream.webrtc_url,
|
||||
playback,
|
||||
thumbnail_url: stream.thumbnail_url,
|
||||
started_at: stream.started_at?.toISOString() ?? null,
|
||||
|
||||
Reference in New Issue
Block a user