71 cameraFile: File of TFrame; |
71 cameraFile: File of TFrame; |
72 audioFile: File; |
72 audioFile: File; |
73 numPixels: LongWord; |
73 numPixels: LongWord; |
74 startTime, numFrames, curTime, progress, maxProgress: LongWord; |
74 startTime, numFrames, curTime, progress, maxProgress: LongWord; |
75 soundFilePath: shortstring; |
75 soundFilePath: shortstring; |
76 thumbnailSaved : Boolean; |
76 thumbnailSaved: boolean; |
|
77 recordAudio: boolean; |
77 |
78 |
78 function BeginVideoRecording: Boolean; |
79 function BeginVideoRecording: Boolean; |
79 var filename, desc: shortstring; |
80 var filename, desc: shortstring; |
80 begin |
81 begin |
81 AddFileLog('BeginVideoRecording'); |
82 AddFileLog('BeginVideoRecording'); |
111 if Theme <> '' then |
112 if Theme <> '' then |
112 desc:= desc + 'Theme: ' + Theme + #10; |
113 desc:= desc + 'Theme: ' + Theme + #10; |
113 desc:= desc + 'prefix[' + RecPrefix + ']prefix'; |
114 desc:= desc + 'prefix[' + RecPrefix + ']prefix'; |
114 |
115 |
115 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix; |
116 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix; |
116 soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; |
117 |
|
118 recordAudio:= (cAudioCodec <> 'no'); |
|
119 if recordAudio then |
|
120 soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw' |
|
121 else |
|
122 soundFilePath:= ''; |
117 |
123 |
118 if checkFails(AVWrapper_Init(@AddFileLogRaw |
124 if checkFails(AVWrapper_Init(@AddFileLogRaw |
119 , PChar(ansistring(filename)) |
125 , PChar(ansistring(filename)) |
120 , PChar(ansistring(desc)) |
126 , PChar(ansistring(desc)) |
121 , PChar(ansistring(soundFilePath)) |
127 , PChar(ansistring(soundFilePath)) |
266 if GameType <> gmtDemo then // this is save and game demo is not recording, abort |
273 if GameType <> gmtDemo then // this is save and game demo is not recording, abort |
267 exit; |
274 exit; |
268 CopyFile(recordFileName, UserPathPrefix + '/VideoTemp/' + RecPrefix + '.hwd'); |
275 CopyFile(recordFileName, UserPathPrefix + '/VideoTemp/' + RecPrefix + '.hwd'); |
269 end; |
276 end; |
270 |
277 |
271 Mix_QuerySpec(@frequency, @format, @channels); |
278 if cIsSoundEnabled then |
272 AddFileLog('sound: frequency = ' + IntToStr(frequency) + ', format = ' + IntToStr(format) + ', channels = ' + IntToStr(channels)); |
279 begin |
273 if format <> $8010 then |
280 Mix_QuerySpec(@frequency, @format, @channels); |
274 begin |
281 AddFileLog('sound: frequency = ' + IntToStr(frequency) + ', format = ' + IntToStr(format) + ', channels = ' + IntToStr(channels)); |
275 // TODO: support any audio format |
282 if format <> $8010 then |
276 AddFileLog('Error: Unexpected audio format ' + IntToStr(format)); |
283 begin |
277 exit; |
284 // TODO: support any audio format |
278 end; |
285 AddFileLog('Error: Unexpected audio format ' + IntToStr(format)); |
|
286 exit; |
|
287 end; |
279 |
288 |
280 {$IOCHECKS OFF} |
289 {$IOCHECKS OFF} |
281 // create sound file |
290 // create sound file |
282 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; |
291 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; |
283 Assign(audioFile, filename); |
292 Assign(audioFile, filename); |
284 Rewrite(audioFile, 1); |
293 Rewrite(audioFile, 1); |
285 if IOResult <> 0 then |
294 if IOResult <> 0 then |
286 begin |
295 begin |
287 AddFileLog('Error: Could not write to ' + filename); |
296 AddFileLog('Error: Could not write to ' + filename); |
288 exit; |
297 exit; |
289 end; |
298 end; |
|
299 end; |
290 |
300 |
291 // create file with camera positions |
301 // create file with camera positions |
292 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtout'; |
302 filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtout'; |
293 Assign(cameraFile, filename); |
303 Assign(cameraFile, filename); |
294 Rewrite(cameraFile); |
304 Rewrite(cameraFile); |
295 if IOResult <> 0 then |
305 if IOResult <> 0 then |
296 begin |
306 begin |
297 AddFileLog('Error: Could not write to ' + filename); |
307 AddFileLog('Error: Could not write to ' + filename); |
298 exit; |
308 exit; |
299 end; |
309 end; |
300 |
310 |
301 // save audio parameters in sound file |
311 if cIsSoundEnabled then |
302 BlockWrite(audioFile, frequency, 4); |
312 begin |
303 BlockWrite(audioFile, channels, 4); |
313 // save audio parameters in sound file |
|
314 BlockWrite(audioFile, frequency, 4); |
|
315 BlockWrite(audioFile, channels, 4); |
304 {$IOCHECKS ON} |
316 {$IOCHECKS ON} |
305 |
317 |
306 // register callback for actual audio recording |
318 // register callback for actual audio recording |
307 Mix_SetPostMix(@RecordPostMix, nil); |
319 Mix_SetPostMix(@RecordPostMix, nil); |
|
320 end; |
308 |
321 |
309 startTime:= SDL_GetTicks(); |
322 startTime:= SDL_GetTicks(); |
310 flagPrerecording:= true; |
323 flagPrerecording:= true; |
311 end; |
324 end; |
312 |
325 |
313 procedure StopPreRecording; |
326 procedure StopPreRecording; |
314 begin |
327 begin |
315 AddFileLog('StopPreRecording'); |
328 AddFileLog('StopPreRecording'); |
316 flagPrerecording:= false; |
329 flagPrerecording:= false; |
317 |
330 |
318 // call SDL_LockAudio because RecordPostMix may be executing right now |
331 if cIsSoundEnabled then |
319 SDL_LockAudio(); |
332 begin |
320 Close(audioFile); |
333 // call SDL_LockAudio because RecordPostMix may be executing right now |
|
334 SDL_LockAudio(); |
|
335 Close(audioFile); |
|
336 end |
321 Close(cameraFile); |
337 Close(cameraFile); |
322 Mix_SetPostMix(nil, nil); |
338 if cIsSoundEnabled then |
323 SDL_UnlockAudio(); |
339 begin |
|
340 Mix_SetPostMix(nil, nil); |
|
341 SDL_UnlockAudio(); |
|
342 end; |
324 |
343 |
325 if not thumbnailSaved then |
344 if not thumbnailSaved then |
326 SaveThumbnail(); |
345 SaveThumbnail(); |
327 end; |
346 end; |
328 |
347 |