mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-21 09:50:13 -07:00
fix peer connection desktop capturer sources call
This commit is contained in:
parent
2cbd71b9fa
commit
78318ce10b
@ -250,7 +250,7 @@ describe('DesktopCapturerSourcesService tests', () => {
|
|||||||
testWindowSource2
|
testWindowSource2
|
||||||
);
|
);
|
||||||
|
|
||||||
const res = desktopCapturerService.getSourceDisplayIDBySourceID(
|
const res = desktopCapturerService.getSourceDisplayIDByDisplayCapturerSourceID(
|
||||||
testScreenSource1.source.id
|
testScreenSource1.source.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export function getSourceTypeFromSourceID(
|
|||||||
type SourcesDisappearListener = (ids: string[]) => void;
|
type SourcesDisappearListener = (ids: string[]) => void;
|
||||||
type SharingSessionID = string;
|
type SharingSessionID = string;
|
||||||
|
|
||||||
class DesktopCapturerSources {
|
class DesktopCapturerSourcesService {
|
||||||
sources: Map<string, DesktopCapturerSourceWithType>;
|
sources: Map<string, DesktopCapturerSourceWithType>;
|
||||||
|
|
||||||
lastAvailableScreenIDs: string[];
|
lastAvailableScreenIDs: string[];
|
||||||
@ -84,7 +84,7 @@ class DesktopCapturerSources {
|
|||||||
return appWindowSources;
|
return appWindowSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSourceDisplayIDBySourceID(sourceID: string) {
|
getSourceDisplayIDByDisplayCapturerSourceID(sourceID: string) {
|
||||||
let displayID = '';
|
let displayID = '';
|
||||||
[...this.sources.keys()].forEach((key) => {
|
[...this.sources.keys()].forEach((key) => {
|
||||||
const source = this.sources.get(key);
|
const source = this.sources.get(key);
|
||||||
@ -206,4 +206,4 @@ class DesktopCapturerSources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DesktopCapturerSources;
|
export default DesktopCapturerSourcesService;
|
||||||
|
@ -4,11 +4,7 @@
|
|||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
import { prepare as prepareMessage } from '../../utils/message';
|
import { prepare as prepareMessage } from '../../utils/message';
|
||||||
import DeskreenCrypto from '../../utils/crypto';
|
import DeskreenCrypto from '../../utils/crypto';
|
||||||
import ConnectedDevicesService from '../ConnectedDevicesService';
|
|
||||||
import RoomIDService from '../../server/RoomIDService';
|
|
||||||
import SharingSessionService from '../SharingSessionService';
|
|
||||||
import connectSocket from '../../server/connectSocket';
|
import connectSocket from '../../server/connectSocket';
|
||||||
import DesktopCapturerSourcesService from '../DesktopCapturerSourcesService';
|
|
||||||
import handleCreatePeer from './handleCreatePeer';
|
import handleCreatePeer from './handleCreatePeer';
|
||||||
import handleSocket from './handleSocket';
|
import handleSocket from './handleSocket';
|
||||||
import handleRecieveEncryptedMessage from './handleRecieveEncryptedMessage';
|
import handleRecieveEncryptedMessage from './handleRecieveEncryptedMessage';
|
||||||
@ -19,6 +15,7 @@ import setDisplaySizeFromLocalStream from './handleSetDisplaySizeFromLocalStream
|
|||||||
import DesktopCapturerSourceType from '../DesktopCapturerSourcesService/DesktopCapturerSourceType';
|
import DesktopCapturerSourceType from '../DesktopCapturerSourcesService/DesktopCapturerSourceType';
|
||||||
import getAppLanguage from '../../utils/getAppLanguage';
|
import getAppLanguage from '../../utils/getAppLanguage';
|
||||||
import getAppTheme from '../../utils/getAppTheme';
|
import getAppTheme from '../../utils/getAppTheme';
|
||||||
|
import { IpcEvents } from '../../main/IpcEvents.enum';
|
||||||
|
|
||||||
type DisplaySize = { width: number; height: number };
|
type DisplaySize = { width: number; height: number };
|
||||||
|
|
||||||
@ -36,27 +33,11 @@ export default class PeerConnection {
|
|||||||
partnerDeviceDetails = {} as Device;
|
partnerDeviceDetails = {} as Device;
|
||||||
signalsDataToCallUser: string[];
|
signalsDataToCallUser: string[];
|
||||||
isCallStarted: boolean;
|
isCallStarted: boolean;
|
||||||
roomIDService: RoomIDService;
|
|
||||||
connectedDevicesService: ConnectedDevicesService;
|
|
||||||
sharingSessionService: SharingSessionService;
|
|
||||||
desktopCapturerSourcesService: DesktopCapturerSourcesService;
|
|
||||||
onDeviceConnectedCallback: (device: Device) => void;
|
onDeviceConnectedCallback: (device: Device) => void;
|
||||||
displayID: string;
|
displayID: string;
|
||||||
sourceDisplaySize: DisplaySize | undefined;
|
sourceDisplaySize: DisplaySize | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(roomID: string, sharingSessionID: string, user: LocalPeerUser) {
|
||||||
roomID: string,
|
|
||||||
sharingSessionID: string,
|
|
||||||
user: LocalPeerUser,
|
|
||||||
roomIDService: RoomIDService,
|
|
||||||
connectedDevicesService: ConnectedDevicesService,
|
|
||||||
sharingSessionsService: SharingSessionService,
|
|
||||||
desktopCapturerSourcesService: DesktopCapturerSourcesService
|
|
||||||
) {
|
|
||||||
this.roomIDService = roomIDService;
|
|
||||||
this.connectedDevicesService = connectedDevicesService;
|
|
||||||
this.sharingSessionService = sharingSessionsService;
|
|
||||||
this.desktopCapturerSourcesService = desktopCapturerSourcesService;
|
|
||||||
this.sharingSessionID = sharingSessionID;
|
this.sharingSessionID = sharingSessionID;
|
||||||
this.isSocketRoomLocked = false;
|
this.isSocketRoomLocked = false;
|
||||||
this.roomID = encodeURI(roomID);
|
this.roomID = encodeURI(roomID);
|
||||||
@ -104,13 +85,14 @@ export default class PeerConnection {
|
|||||||
this.handleCreatePeerAfterDesktopCapturerSourceIDWasSet();
|
this.handleCreatePeerAfterDesktopCapturerSourceIDWasSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
setDisplayIDByDesktopCapturerSourceID() {
|
async setDisplayIDByDesktopCapturerSourceID() {
|
||||||
if (
|
if (
|
||||||
!this.desktopCapturerSourceID.includes(DesktopCapturerSourceType.SCREEN)
|
!this.desktopCapturerSourceID.includes(DesktopCapturerSourceType.SCREEN)
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.displayID = this.desktopCapturerSourcesService.getSourceDisplayIDBySourceID(
|
this.displayID = await ipcRenderer.invoke(
|
||||||
|
IpcEvents.GetSourceDisplayIDByDesktopCapturerSourceID,
|
||||||
this.desktopCapturerSourceID
|
this.desktopCapturerSourceID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,4 +6,5 @@ export enum IpcEvents {
|
|||||||
GetAppPath = 'get-app-path',
|
GetAppPath = 'get-app-path',
|
||||||
ResetWaitingForConnectionSharingSession = 'reset-waiting-for-connection-sharing-session',
|
ResetWaitingForConnectionSharingSession = 'reset-waiting-for-connection-sharing-session',
|
||||||
SetDeviceConnectedStatus = 'set-device-connected-status',
|
SetDeviceConnectedStatus = 'set-device-connected-status',
|
||||||
|
GetSourceDisplayIDByDesktopCapturerSourceID = 'get-source-display-id-by-desktop-capturer-source-id',
|
||||||
}
|
}
|
||||||
|
@ -135,4 +135,13 @@ export default function initIpcMainHandlers(
|
|||||||
sharingSession?.setStatus(SharingSessionStatusEnum.CONNECTED);
|
sharingSession?.setStatus(SharingSessionStatusEnum.CONNECTED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(
|
||||||
|
IpcEvents.GetSourceDisplayIDByDesktopCapturerSourceID,
|
||||||
|
(_, sourceId) => {
|
||||||
|
return getDeskreenGlobal().desktopCapturerSourcesService.getSourceDisplayIDByDisplayCapturerSourceID(
|
||||||
|
sourceId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,16 @@
|
|||||||
import { ipcRenderer, remote } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
import ConnectedDevicesService from './features/ConnectedDevicesService';
|
|
||||||
import DesktopCapturerSourcesService from './features/DesktopCapturerSourcesService';
|
|
||||||
import PeerConnection from './features/PeerConnection';
|
import PeerConnection from './features/PeerConnection';
|
||||||
import SharingSessionService from './features/SharingSessionService';
|
|
||||||
import RoomIDService from './server/RoomIDService';
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export function handleIpcRenderer() {
|
export function handleIpcRenderer() {
|
||||||
ipcRenderer.on('start-peer-connection', () => {
|
ipcRenderer.on('start-peer-connection', () => {
|
||||||
const desktopCapturerSourcesService = remote.getGlobal(
|
|
||||||
'desktopCapturerSourcesService'
|
|
||||||
) as DesktopCapturerSourcesService;
|
|
||||||
const roomIDService = remote.getGlobal('roomIDService') as RoomIDService;
|
|
||||||
const connectedDevicesService = remote.getGlobal(
|
|
||||||
'connectedDevicesService'
|
|
||||||
) as ConnectedDevicesService;
|
|
||||||
const sharingSessionService = remote.getGlobal(
|
|
||||||
'sharingSessionService'
|
|
||||||
) as SharingSessionService;
|
|
||||||
|
|
||||||
let peerConnection: PeerConnection;
|
let peerConnection: PeerConnection;
|
||||||
|
|
||||||
ipcRenderer.on('create-peer-connection-with-data', (_, data) => {
|
ipcRenderer.on('create-peer-connection-with-data', (_, data) => {
|
||||||
peerConnection = new PeerConnection(
|
peerConnection = new PeerConnection(
|
||||||
data.roomID,
|
data.roomID,
|
||||||
data.sharingSessionID,
|
data.sharingSessionID,
|
||||||
data.user,
|
data.user
|
||||||
roomIDService,
|
|
||||||
connectedDevicesService,
|
|
||||||
sharingSessionService,
|
|
||||||
desktopCapturerSourcesService
|
|
||||||
);
|
);
|
||||||
|
|
||||||
peerConnection.setOnDeviceConnectedCallback((deviceData) => {
|
peerConnection.setOnDeviceConnectedCallback((deviceData) => {
|
||||||
|
@ -2,8 +2,7 @@ import ConnectedDevicesService from '../../features/ConnectedDevicesService';
|
|||||||
import SharingSessionService from '../../features/SharingSessionService';
|
import SharingSessionService from '../../features/SharingSessionService';
|
||||||
import RendererWebrtcHelpersService from '../../features/PeerConnectionHelperRendererService';
|
import RendererWebrtcHelpersService from '../../features/PeerConnectionHelperRendererService';
|
||||||
import RoomIDService from '../../server/RoomIDService';
|
import RoomIDService from '../../server/RoomIDService';
|
||||||
import DesktopCapturerSources from '../../features/DesktopCapturerSourcesService';
|
import DesktopCapturerSourcesService from '../../features/DesktopCapturerSourcesService';
|
||||||
import DeskreenGlobalService from './DeskreenGlobalService.enum';
|
|
||||||
|
|
||||||
interface DeskreenGlobal {
|
interface DeskreenGlobal {
|
||||||
appPath: string;
|
appPath: string;
|
||||||
@ -11,5 +10,5 @@ interface DeskreenGlobal {
|
|||||||
roomIDService: RoomIDService;
|
roomIDService: RoomIDService;
|
||||||
connectedDevicesService: ConnectedDevicesService;
|
connectedDevicesService: ConnectedDevicesService;
|
||||||
sharingSessionService: SharingSessionService;
|
sharingSessionService: SharingSessionService;
|
||||||
desktopCapturerSourcesService: DesktopCapturerSources;
|
desktopCapturerSourcesService: DesktopCapturerSourcesService;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user