From 27920a0ff48a37f99b8f972735dcf7856501777b Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Thu, 11 Jan 2024 03:02:38 +0800 Subject: [PATCH] fix(webapp): whip timeout --- webapp/components/player/whep-player.tsx | 16 +++++++++++----- webapp/components/player/whip-player.tsx | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/webapp/components/player/whep-player.tsx b/webapp/components/player/whep-player.tsx index 9d783d2..c0c9fb3 100644 --- a/webapp/components/player/whep-player.tsx +++ b/webapp/components/player/whep-player.tsx @@ -40,15 +40,21 @@ export default function WhepPlayer(props: { streamId: string, status: UserStatus refPC.current = pc } - const run = () => refUserStatus.current.state !== "connected" || refConnState.current !== "connected" ? restart(props.streamId) : null + const run = () => refUserStatus.current.state !== "connected" && refUserStatus.current.state !== "signaled" || refConnState.current !== "connected" ? restart(props.streamId) : null const start = async (resource: string) => { setLoading(false) if (refPC.current) { - const whep = new WHEPClient() - const url = location.origin + "/whep/" + resource - await whep.view(refPC.current, url) - //await whep.stop() + refUserStatus.current.state = 'signaled' + try { + const whep = new WHEPClient() + const url = location.origin + "/whep/" + resource + await whep.view(refPC.current, url) + //await whep.stop() + } catch (e) { + console.log(e) + refUserStatus.current.state = 'failed' + } } } diff --git a/webapp/components/player/whip-player.tsx b/webapp/components/player/whip-player.tsx index b02ae07..ea5b23d 100644 --- a/webapp/components/player/whip-player.tsx +++ b/webapp/components/player/whip-player.tsx @@ -70,10 +70,16 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { const stream = localStream.stream if (stream) { if (refPC.current) { - const whip = new WHIPClient(); - const url = location.origin + `/whip/${resource}` - await whip.publish(refPC.current, url) - refClient.current = whip + refUserStatus.current.state = 'signaled' + try { + const whip = new WHIPClient(); + const url = location.origin + `/whip/${resource}` + await whip.publish(refPC.current, url) + refClient.current = whip + } catch (e) { + console.log(e) + refUserStatus.current.state = 'failed' + } } } setLoading(false) @@ -88,7 +94,7 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { start(resource) } - const run = () => refUserStatus.current.state !== "connected" ? restart(props.streamId) : null + const run = () => refUserStatus.current.state !== "connected" && refUserStatus.current.state !== "signaled" ? restart(props.streamId) : null const init = () => { if (!!localStream.stream.getTracks().length) {