-
Notifications
You must be signed in to change notification settings - Fork 28
Fix audio/video sync: publish audio from camera when enabled and and … #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,18 +236,19 @@ export function ConnectedActions() { | |
| </TooltipProvider> | ||
| )} | ||
| <Button | ||
| className="w-full border-red-500 text-red-600 flex flex-row gap-2" | ||
| className="w-full border-red-500 text-red-600 flex flex-row gap-1.5 text-sm" | ||
| variant="gradient-white" | ||
| onClick={handleEndCall} | ||
| > | ||
| <HiOutlinePhoneXMark className="size-4" /> | ||
| <HiOutlinePhoneXMark className="size-3.5" /> | ||
| End call | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <ListenToRemoteAudio /> | ||
| {/* Render remote audio only if camera is NOT enabled */} | ||
| {!callTokens?.hasCameraEnabled && <ListenToRemoteAudio />} diable to solve the issue related to sync audio playback | ||
| </> | ||
| ); | ||
| } | ||
|
|
@@ -343,7 +344,7 @@ function MicrophoneIcon({ setMicEnabled }: { setMicEnabled: (enabled: boolean) = | |
| [Colors.mic.text]: hasAudioEnabled, | ||
| [Colors.deactivatedIcon]: !hasAudioEnabled, | ||
| })} | ||
| className="hover:outline-solid hover:outline-1 hover:outline-slate-300 focus:ring-0 focus-visible:ring-0 hover:bg-slate-200 size-4 rounded-xs p-0 border-0 shadow-none hover:shadow-xs" | ||
| className=" p-0.5 text-xs rounded-sm hover:outline-solid hover:outline-1 hover:outline-slate-300 focus:ring-0 focus-visible:ring-0 hover:bg-slate-200 size-4 border-0 shadow-none hover:shadow-xs" | ||
| /> | ||
| <SelectPortal container={document.getElementsByClassName("container")[0]}> | ||
| <SelectContent align="center"> | ||
|
|
@@ -509,7 +510,7 @@ function ScreensharingEventListener({ | |
| return <div />; | ||
| } | ||
|
|
||
| function CameraIcon() { | ||
| function CameraIcon({ micEnabled }: { micEnabled: boolean }) { | ||
|
||
| const { updateCallTokens, callTokens } = useStore(); | ||
| const [retry, setRetry] = useState(0); | ||
| const tracks = useTracks([Track.Source.Camera], {}); | ||
|
|
@@ -541,23 +542,27 @@ function CameraIcon() { | |
|
|
||
| const isDisabled = cameraDevices.length === 0; | ||
|
|
||
|
|
||
|
|
||
| const handleCameraToggle = () => { | ||
| clickedCameraRef.current = true; | ||
| let newCameraEnabled = !cameraEnabled; | ||
| updateCallTokens({ | ||
| ...callTokens, | ||
| hasCameraEnabled: newCameraEnabled, | ||
| }); | ||
| if (!newCameraEnabled) { | ||
| const cameraTrack = localParticipant | ||
| .getTrackPublications() | ||
| .filter((track) => track.source === Track.Source.Camera)[0]; | ||
| if (cameraTrack && cameraTrack.track && cameraTrack.track instanceof LocalTrack) { | ||
| localParticipant.unpublishTrack(cameraTrack.track); | ||
| } | ||
| clickedCameraRef.current = true; | ||
| const newCameraEnabled = !cameraEnabled; | ||
| updateCallTokens({ ...callTokens, hasCameraEnabled: newCameraEnabled }); | ||
|
|
||
| if (newCameraEnabled && micEnabled) { | ||
| // Publish a camera track with audio | ||
| localParticipant.setMicrophoneEnabled(true, { noiseSuppression: true, echoCancellation: true }); | ||
| } else if (!newCameraEnabled) { | ||
| // Unpublish camera track and audio | ||
| const cameraTrack = localParticipant | ||
| .getTrackPublications() | ||
| .find((track) => track.source === Track.Source.Camera); | ||
| if (cameraTrack && cameraTrack.track instanceof LocalTrack) { | ||
| localParticipant.unpublishTrack(cameraTrack.track); | ||
| } | ||
| }; | ||
|
|
||
| localParticipant.setMicrophoneEnabled(false); | ||
| } | ||
| }; | ||
| const handleCameraChange = (value: string) => { | ||
| console.debug("Selected camera: ", value); | ||
| setActiveCameraDevice(value); | ||
|
|
@@ -604,7 +609,7 @@ function CameraIcon() { | |
| } | ||
| size="unsized" | ||
| disabled={isDisabled} | ||
| className={clsx("flex-1 min-w-0", { | ||
| className={clsx("flex-1 min-w-0 text-xs", { | ||
| [Colors.deactivatedText]: !cameraEnabled, | ||
| [`${Colors.camera.text} ${Colors.camera.ring}`]: cameraEnabled, | ||
| })} | ||
|
|
@@ -623,7 +628,7 @@ function CameraIcon() { | |
| return ( | ||
| device.deviceId !== "" && ( | ||
| <SelectItem key={device.deviceId} value={device.deviceId}> | ||
| <span className="text-xs truncate"> | ||
| <span className="text-xs truncate "> | ||
| {device.label || `Camera ${device.label.slice(0, 8)}...`} | ||
| </span> | ||
| </SelectItem> | ||
|
|
@@ -716,7 +721,7 @@ function MediaDevicesSettings() { | |
| return ( | ||
| <div className="flex flex-row gap-1 w-full"> | ||
| <MicrophoneIcon setMicEnabled={setMicEnabled} /> | ||
| <CameraIcon /> | ||
| <CameraIcon micEnabled={micEnabled}/> | ||
| <ScreenShareIcon | ||
| callTokens={callTokens} | ||
| setCallTokens={setCallTokens} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not 100% correct, hasCameraEnabled is set when the current user is publishing their local camera. We want to disable this when the camera window is open, which could also happen if another participant is publishing their camera. We could update
CallStateto keep track of the camera window is opened or not.