File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,19 @@ export function broadcastToClients(message: string) {
3939 } )
4040}
4141
42+ function serveVideo ( sessionId : string , reply : any ) {
43+ const videoPath = videoRegistry . get ( sessionId )
44+ if ( ! videoPath ) {
45+ return reply . code ( 404 ) . send ( { error : 'Video not found' } )
46+ }
47+ if ( ! fs . existsSync ( videoPath ) ) {
48+ return reply . code ( 404 ) . send ( { error : 'Video file missing from disk' } )
49+ }
50+ return reply
51+ . header ( 'Content-Type' , 'video/webm' )
52+ . send ( fs . createReadStream ( videoPath ) )
53+ }
54+
4255export async function start (
4356 opts : DevtoolsBackendOptions = { }
4457) : Promise < { server : FastifyInstance ; port : number } > {
@@ -188,16 +201,7 @@ export async function start(
188201 reply
189202 ) => {
190203 const { sessionId } = request . params
191- const videoPath = videoRegistry . get ( sessionId )
192- if ( ! videoPath ) {
193- return reply . code ( 404 ) . send ( { error : 'Video not found' } )
194- }
195- if ( ! fs . existsSync ( videoPath ) ) {
196- return reply . code ( 404 ) . send ( { error : 'Video file missing from disk' } )
197- }
198- return reply
199- . header ( 'Content-Type' , 'video/webm' )
200- . send ( fs . createReadStream ( videoPath ) )
204+ return serveVideo ( sessionId , reply )
201205 }
202206 )
203207
You can’t perform that action at this time.
0 commit comments