Skip to content

Commit

Permalink
fix(webapp): whip timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Jan 10, 2024
1 parent 2470135 commit 27920a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 11 additions & 5 deletions webapp/components/player/whep-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
}

Expand Down
16 changes: 11 additions & 5 deletions webapp/components/player/whip-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit 27920a0

Please sign in to comment.