hedgewars/uVideoRec.pas
changeset 13495 b5f8864a38d3
parent 13493 3bb07c847886
child 13513 d8462cc9d42d
equal deleted inserted replaced
13494:424944a835a7 13495:b5f8864a38d3
    46 
    46 
    47 procedure initModule;
    47 procedure initModule;
    48 procedure freeModule;
    48 procedure freeModule;
    49 
    49 
    50 implementation
    50 implementation
    51 uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uTypes, uDebug;
    51 uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uConsts, uTypes, uDebug;
    52 
    52 
    53 type TAddFileLogRaw = procedure (s: pchar); cdecl;
    53 type TAddFileLogRaw = procedure (s: pchar); cdecl;
    54 const AvwrapperLibName = 'libavwrapper';
    54 const AvwrapperLibName = 'libavwrapper';
    55 
    55 
    56 function AVWrapper_Init(
    56 function AVWrapper_Init(
   151 begin
   151 begin
   152     AddFileLog('StopVideoRecording');
   152     AddFileLog('StopVideoRecording');
   153     FreeMem(RGB_Buffer, 4*numPixels);
   153     FreeMem(RGB_Buffer, 4*numPixels);
   154     Close(cameraFile);
   154     Close(cameraFile);
   155     if AVWrapper_Close() < 0 then
   155     if AVWrapper_Close() < 0 then
   156         halt(-1);
   156         begin
       
   157         AddFileLog('AVWrapper_Close() has failed.');
       
   158         halt(HaltVideoRec);
       
   159         end;
   157     Erase(cameraFile);
   160     Erase(cameraFile);
   158     if recordAudio then
   161     if recordAudio then
   159         DeleteFile(soundFilePath);
   162         DeleteFile(soundFilePath);
   160     SendIPC(_S'v'); // inform frontend that we finished
   163     SendIPC(_S'v'); // inform frontend that we finished
   161 end;
   164 end;
   165 begin
   168 begin
   166     // read pixels from OpenGL
   169     // read pixels from OpenGL
   167     glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, RGB_Buffer);
   170     glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, RGB_Buffer);
   168 
   171 
   169     if AVWrapper_WriteFrame(RGB_Buffer) < 0 then
   172     if AVWrapper_WriteFrame(RGB_Buffer) < 0 then
   170         halt(-1);
   173         begin
       
   174         AddFileLog('AVWrapper_WriteFrame(RGB_Buffer) has failed.');
       
   175         halt(HaltVideoRec);
       
   176         end;
   171 
   177 
   172     // inform frontend that we have encoded new frame
   178     // inform frontend that we have encoded new frame
   173     s[0]:= #3;
   179     s[0]:= #3;
   174     s[1]:= 'p'; // p for progress
   180     s[1]:= 'p'; // p for progress
   175     SDLNet_Write16(progress*10000 div maxProgress, @s[2]);
   181     SDLNet_Write16(progress*10000 div maxProgress, @s[2]);