-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import RTSPServer from 'node-rtsp-stream'; | ||
|
||
new RTSPServer.Stream({ | ||
name: 'name', | ||
streamUrl: 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4', | ||
wsPort: 9999, | ||
ffmpegOptions: { | ||
// options ffmpeg flags | ||
'-stats': '', // an option with no neccessary value uses a blank string | ||
'-r': 30, // options with required values specify the value after the key | ||
}, | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { log } from '@/main/logger'; | ||
import { ipcMain } from 'electron'; | ||
import { execaNode, ExecaChildProcess } from 'execa'; | ||
|
||
interface RtspProcess { | ||
process: ExecaChildProcess; | ||
wsPort: number; | ||
} | ||
|
||
const rtspServers: Map<string, RtspProcess> = new Map(); | ||
let nextPort = 9000; | ||
|
||
ipcMain.handle('rtsp_start', (event, url: string) => { | ||
const process = execaNode('script.ts'); | ||
|
||
log.info('starting rtsp process'); | ||
rtspServers.set(url, { | ||
process, | ||
wsPort: nextPort, | ||
}); | ||
|
||
return nextPort++; | ||
}); | ||
|
||
ipcMain.on('rtsp_stop', (event, url: string) => { | ||
const rtspProcess = rtspServers.get(url); | ||
|
||
if (!rtspProcess) { | ||
return; | ||
} | ||
|
||
rtspProcess.process.kill(); | ||
rtspServers.delete(url); | ||
}); |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import JSMpeg from '@cycjimmy/jsmpeg-player'; | ||
import { log } from '@/renderer/logger'; | ||
|
||
export const RTSPFeed = () => { | ||
// Execute rtspServer node script with stream url as argument | ||
const videoRef = useRef<HTMLDivElement>(null); | ||
useEffect(() => { | ||
const startServer = async () => { | ||
const port = (await window.preloadApi.rtsp.start('rtsp://')) as number; | ||
log.info(`RTSP server started on port ${port}`); | ||
}; | ||
startServer().catch((e) => log.error(e)); | ||
}, []); | ||
|
||
// Create video element | ||
useEffect(() => { | ||
const videoWrapper = videoRef.current; | ||
if (videoWrapper) { | ||
new JSMpeg.VideoElement(videoWrapper, 'ws://localhost:9999', { | ||
autoplay: true, | ||
audio: false, | ||
}); | ||
} | ||
}, [videoRef]); | ||
|
||
return ( | ||
<> | ||
<div ref={videoRef} /> | ||
</> | ||
); | ||
}; |
Empty file.
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare module '@cycjimmy/jsmpeg-player' { | ||
class VideoElement { | ||
constructor( | ||
videoWrapper: HTMLDivElement, | ||
url: string, | ||
options: { | ||
canvas?: HTMLCanvasElement; | ||
autoplay?: boolean; | ||
audio?: boolean; | ||
} | ||
); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare module 'node-rtsp-stream' { | ||
class Stream { | ||
constructor(params: { | ||
name: string; | ||
streamUrl: string; | ||
wsPort: number; | ||
ffmpegOptions: { | ||
'-stats': string; | ||
'-r': number; | ||
}; | ||
}); | ||
} | ||
} |