clean up code
This commit is contained in:
		
							parent
							
								
									6c523503b6
								
							
						
					
					
						commit
						520b5d0a1e
					
				
					 2 changed files with 40 additions and 29 deletions
				
			
		|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
| import "./screenSharePicker.css"; | ||||
| 
 | ||||
| import { closeModal, Margins, Modals, ModalSize, openModal, useAwaiter } from "@vencord/types/utils"; | ||||
| import { closeModal, Logger, Margins, Modals, ModalSize, openModal, useAwaiter } from "@vencord/types/utils"; | ||||
| import { findStoreLazy, onceReady } from "@vencord/types/webpack"; | ||||
| import { | ||||
|     Button, | ||||
|  | @ -53,7 +53,7 @@ interface Source { | |||
| 
 | ||||
| export let currentSettings: StreamSettings | null = null; | ||||
| 
 | ||||
| const logger = new Vencord.Util.Logger("VesktopScreenShare"); | ||||
| const logger = new Logger("VesktopScreenShare"); | ||||
| 
 | ||||
| addPatch({ | ||||
|     patches: [ | ||||
|  | @ -455,41 +455,48 @@ function ModalComponent({ | |||
|                             const frameRate = Number(settings.fps); | ||||
|                             const height = Number(settings.resolution); | ||||
|                             const width = Math.round(height * (16 / 9)); | ||||
|                             var conn = [...MediaEngineStore.getMediaEngine().connections].find( | ||||
| 
 | ||||
|                             const conn = [...MediaEngineStore.getMediaEngine().connections].find( | ||||
|                                 connection => connection.streamUserId === UserStore.getCurrentUser().id | ||||
|                             ); | ||||
| 
 | ||||
|                             if (conn) { | ||||
|                                 conn.videoStreamParameters[0].maxFrameRate = frameRate; | ||||
|                                 conn.videoStreamParameters[0].maxResolution.height = height; | ||||
|                                 conn.videoStreamParameters[0].maxResolution.width = width; | ||||
|                             } | ||||
| 
 | ||||
|                             submit({ | ||||
|                                 id: selected!, | ||||
|                                 ...settings | ||||
|                             }); | ||||
| 
 | ||||
|                             setTimeout(() => { | ||||
|                                 conn = [...MediaEngineStore.getMediaEngine().connections].find( | ||||
|                             setTimeout(async () => { | ||||
|                                 const conn = [...MediaEngineStore.getMediaEngine().connections].find( | ||||
|                                     connection => connection.streamUserId === UserStore.getCurrentUser().id | ||||
|                                 ); | ||||
|                                 if (conn) { | ||||
|                                 if (!conn) return; | ||||
| 
 | ||||
|                                 const track = conn.input.stream.getVideoTracks()[0]; | ||||
| 
 | ||||
|                                     var constraints = track.getConstraints(); | ||||
|                                     const newConstraints = { | ||||
|                                         ...constraints, | ||||
|                                 const constraints = { | ||||
|                                     ...track.getConstraints(), | ||||
|                                     frameRate, | ||||
|                                     width: { min: 640, ideal: width, max: width }, | ||||
|                                     height: { min: 480, ideal: height, max: height }, | ||||
|                                     advanced: [{ width: width, height: height }], | ||||
|                                     resizeMode: "none" | ||||
|                                 }; | ||||
|                                     track.applyConstraints(newConstraints).then(() => { | ||||
|                                         logger.log( | ||||
| 
 | ||||
|                                 try { | ||||
|                                     await track.applyConstraints(constraints); | ||||
| 
 | ||||
|                                     logger.info( | ||||
|                                         "Applied constraints successfully. New constraints:", | ||||
|                                         track.getConstraints() | ||||
|                                     ); | ||||
|                                     }); | ||||
|                                 } catch (e) { | ||||
|                                     logger.error("Failed to apply constraints.", e); | ||||
|                                 } | ||||
|                             }, 100); | ||||
|                         } catch (error) { | ||||
|  |  | |||
|  | @ -4,10 +4,11 @@ | |||
|  * Copyright (c) 2023 Vendicated and Vencord contributors | ||||
|  */ | ||||
| 
 | ||||
| import { Logger } from "@vencord/types/utils"; | ||||
| import { currentSettings } from "renderer/components/ScreenSharePicker"; | ||||
| import { isLinux } from "renderer/utils"; | ||||
| 
 | ||||
| const logger = new Vencord.Util.Logger("VesktopScreenFixes"); | ||||
| const logger = new Logger("VesktopStreamFixes"); | ||||
| 
 | ||||
| if (isLinux) { | ||||
|     const original = navigator.mediaDevices.getDisplayMedia; | ||||
|  | @ -32,9 +33,9 @@ if (isLinux) { | |||
|         var track = stream.getVideoTracks()[0]; | ||||
| 
 | ||||
|         track.contentHint = String(currentSettings?.contentHint); | ||||
|         var constraints = track.getConstraints(); | ||||
|         const newConstraints = { | ||||
|             ...constraints, | ||||
| 
 | ||||
|         const constraints = { | ||||
|             ...track.getConstraints(), | ||||
|             frameRate, | ||||
|             width: { min: 640, ideal: width, max: width }, | ||||
|             height: { min: 480, ideal: height, max: height }, | ||||
|  | @ -42,9 +43,12 @@ if (isLinux) { | |||
|             resizeMode: "none" | ||||
|         }; | ||||
| 
 | ||||
|         track.applyConstraints(newConstraints).then(() => { | ||||
|             logger.log("Applied constraints successfully. New constraints: ", track.getConstraints()); | ||||
|         }); | ||||
|         track | ||||
|             .applyConstraints(constraints) | ||||
|             .then(() => { | ||||
|                 logger.info("Applied constraints successfully. New constraints: ", track.getConstraints()); | ||||
|             }) | ||||
|             .catch(e => logger.error("Failed to apply constraints.", e)); | ||||
| 
 | ||||
|         if (id) { | ||||
|             const audio = await navigator.mediaDevices.getUserMedia({ | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Vendicated
						Vendicated