Skip to content

Commit

Permalink
Merge pull request #701 from gagan-suie/dev
Browse files Browse the repository at this point in the history
Fix: obs streaming live-inputs not deleting
  • Loading branch information
gagansuie authored Sep 13, 2023
2 parents 31de195 + 9c208db commit bfc006b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
34 changes: 8 additions & 26 deletions src/lib/components/Channel/Stream/StreamControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@
(video: any) => video._id === $page.data.user?.userId
)
let obsUid: string = '',
screenUid: string = '',
webcamUid: string = '',
audioUid: string = '',
subcriptions: any[] = []
let subcriptions: any[] = []
const handleChatDrawer = () => {
if ($is_chat_drawer_open) {
Expand Down Expand Up @@ -65,17 +61,15 @@
const deleteLiveInput = async ({
channelId,
userId,
trackType,
inputId
trackType
}: {
channelId: string
userId: string
trackType: string
inputId: string
}) => {
if (inputId) {
if (channelId && userId && trackType) {
return await del(
`cloudflare/live-input?channelId=${channelId}&userId=${userId}&trackType=${trackType}&inputId=${inputId}`,
`cloudflare/live-input?channelId=${channelId}&userId=${userId}&trackType=${trackType}`,
{
userId: $page.data.user?.userId,
token: $page.data.user?.token
Expand All @@ -97,7 +91,6 @@
recording: { mode: 'automatic' }
}
})
obsUid = liveInput.uid
channel.videoItems = updateVideoItems(channel.videoItems, [liveInput])
emitAction({
channelSocket: channel?.socket,
Expand All @@ -113,8 +106,7 @@
await deleteLiveInput({
channelId: $page.params.channelId,
userId: $page.data.user.userId,
trackType: 'obs',
inputId: obsUid
trackType: 'obs'
})
channel.videoItems = updateVideoItems(channel.videoItems, [
{ _id: $page.data.user.userId, trackType: 'obs', isTrackActive: false }
Expand All @@ -131,7 +123,6 @@
}
}
})
obsUid = ''
}
const startScreenStream = async () => {
Expand All @@ -147,7 +138,6 @@
recording: { mode: 'off' }
}
})
screenUid = liveInput.uid
channel.videoItems = updateVideoItems(channel.videoItems, [liveInput])
emitAction({
channelSocket: channel?.socket,
Expand All @@ -163,8 +153,7 @@
await deleteLiveInput({
channelId: $page.params.channelId,
userId: $page.data.user.userId,
trackType: 'screen',
inputId: screenUid
trackType: 'screen'
})
channel.videoItems = updateVideoItems(channel.videoItems, [
{ _id: $page.data.user.userId, trackType: 'screen', isTrackActive: false }
Expand All @@ -181,7 +170,6 @@
}
}
})
screenUid = ''
}
const startWebcamStream = async () => {
Expand All @@ -197,7 +185,6 @@
recording: { mode: 'off' }
}
})
webcamUid = liveInput.uid
channel.videoItems = updateVideoItems(channel.videoItems, [liveInput])
emitAction({
channelSocket: channel?.socket,
Expand All @@ -213,8 +200,7 @@
await deleteLiveInput({
channelId: $page.params.channelId,
userId: $page.data.user.userId,
trackType: 'webcam',
inputId: webcamUid
trackType: 'webcam'
})
channel.videoItems = updateVideoItems(channel.videoItems, [
{ _id: $page.data.user.userId, trackType: 'webcam', isTrackActive: false }
Expand All @@ -231,7 +217,6 @@
}
}
})
webcamUid = ''
}
const startAudioStream = async () => {
Expand All @@ -247,7 +232,6 @@
recording: { mode: 'off' }
}
})
audioUid = liveInput.uid
channel.videoItems = updateVideoItems(channel.videoItems, [liveInput])
emitAction({
channelSocket: channel?.socket,
Expand All @@ -263,8 +247,7 @@
await deleteLiveInput({
channelId: $page.params.channelId,
userId: $page.data.user.userId,
trackType: 'audio',
inputId: audioUid
trackType: 'audio'
})
channel.videoItems = updateVideoItems(channel.videoItems, [
{ _id: $page.data.user.userId, trackType: 'audio', isTrackActive: false }
Expand All @@ -281,7 +264,6 @@
}
}
})
audioUid = ''
}
onMount(() => {
Expand Down
18 changes: 14 additions & 4 deletions src/lib/components/Channel/Stream/VideoItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@
if ($page.data.user?.userId === video._id) {
switch (trackType) {
case 'obs':
iframeUrl = video.obs?.playback?.iframe
// console.log('got here---- video.obs.playback?.iframeUrl', iframeUrl)
if ($is_sharing_obs) {
iframeUrl = video.obs?.playback?.iframe
// console.log('got here---- video.obs.playback?.iframeUrl', iframeUrl)
} else {
$is_sharing_obs = false
iframeUrl = ''
}
break
case 'screen':
if (video.screen && $is_sharing_screen) {
Expand Down Expand Up @@ -187,6 +192,11 @@
audioWhip.addEventListener(`localAudioSpeakingValue`, (ev: any) => {
speakingValue = ev.detail
})
} else if (!video.audio) {
if (audio_element) {
audio_element.srcObject = null
}
$is_sharing_audio = false
}
break
}
Expand Down Expand Up @@ -468,7 +478,7 @@
? 'mask-hexagon'
: 'mask-squircle'} object-cover m-auto" />
<div class="absolute inset-0">
{#if $is_feature_stats_enabled && (isScreenLive || isWebcamLive || iframeUrl)}
{#if $is_feature_stats_enabled && (isScreenLive || iframeUrl)}
<span
class="z-10 btn btn-sm btn-neutral font-medium text-white border-none items-center w-fit absolute top-2 left-2 {isHoverVideo
? 'opacity-100'
Expand Down Expand Up @@ -508,7 +518,7 @@
</div>
<video bind:this={audio_element} autoplay class="rounded-md w-0 h-0" />
{/if}
<div class="absolute left-2 bottom-2 rounded-md dropdown">
<div class="absolute left-2 bottom-2 rounded-md dropdown {iframeUrl ? 'mb-16' : ''}">
<label
tabindex="0"
class="{coloredRole.textColor} bg-base-100 btn btn-sm normal-case flex gap-1 {speakingValue >
Expand Down

0 comments on commit bfc006b

Please sign in to comment.