diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 18:05:14 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-01-21 18:05:14 +0000 |
commit | c8beaf22577ee69de28898382d74673a9edcf395 (patch) | |
tree | ca4c00ae4bc56efd3e52a861c1e9396d3c15a173 | |
parent | 4613054faf335a84ab8f413506f4b75bbd72e5eb (diff) |
changed formatting of the code, to never go beyond column 80
(rule is purely for visual purposes, macro expansions are not taken into account).
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@262 f606c939-3180-4ac9-a4b8-4b8779d57d0a
31 files changed, 1781 insertions, 1286 deletions
diff --git a/recordmydesktop/README b/recordmydesktop/README index 4f330b5..2896af0 100644 --- a/recordmydesktop/README +++ b/recordmydesktop/README @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ Complete lisence can be found in the COPYING file. Installation and compilation instruction can be found in the INSTALL file. diff --git a/recordmydesktop/include/recordmydesktop.h b/recordmydesktop/include/recordmydesktop.h index ed522db..e97a8c0 100644 --- a/recordmydesktop/include/recordmydesktop.h +++ b/recordmydesktop/include/recordmydesktop.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #ifndef RECORDMYDESKTOP_H @@ -48,8 +48,8 @@ unsigned char Yr[256],Yg[256],Yb[256], Vr[256],Vg[256],Vb[256]; //the following values are of no effect //but they might be usefull later for profiling -unsigned int frames_total,//frames calculated by total time expirations - frames_lost;//the value of shame +unsigned int frames_total, //frames calculated by total time expirations + frames_lost; //the value of shame //used to determine frame drop which can //happen on failure to receive a signal over a condition variable int capture_busy, diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h index 447351a..a4908d5 100644 --- a/recordmydesktop/include/rmdfunc.h +++ b/recordmydesktop/include/rmdfunc.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #ifndef RMDFUNC_H #define RMDFUNC_H 1 @@ -107,7 +107,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom); * \retval -10 Grouping the two geoms is possible * */ -int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,int *ngeoms); +int CollideRects(WGeometry *wgeom1, + WGeometry *wgeom2, + WGeometry **wgeom_return, + int *ngeoms); /** * Broadcast time condition variable, increment frame count. @@ -132,7 +135,8 @@ void RegisterCallbacks(ProgArgs *args); * * \param yuv_mutex lock on the buffer * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * * \param root Root entry of the list with damaged areas * @@ -140,7 +144,8 @@ void RegisterCallbacks(ProgArgs *args); * * \param enc Encoding options * -* \param datatemp Buffer for pixel data to be retrieved before placed on the yuv buffer +* \param datatemp Buffer for pixel data to be +* retrieved before placed on the yuv buffer * * \param noshmem don't use MIT_Shm extension * @@ -181,7 +186,13 @@ void UpdateImage(Display * dpy, * * \returns 0 on Success 1 on Failure */ -int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int height); +int GetZPixmap(Display *dpy, + Window root, + char *data, + int x, + int y, + int width, + int height); /** * Fill ProgArgs struct with arguments entered at execution @@ -209,7 +220,10 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return); * * \note Can be an exit point if extensions are not found */ -void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_error); +void QueryExtensions(Display *dpy, + ProgArgs *args, + int *damage_event, + int *damage_error); /** * Check and align window size @@ -218,43 +232,53 @@ void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_e * * \param brwin BRWindow struct contaning the initial and final window * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * * \param args ProgArgs struct containing the user-set options * * \returns 0 on Success 1 on Failure */ -int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args); +int SetBRWindow(Display *dpy, + BRWindow *brwin, + DisplaySpecs *specs, + ProgArgs *args); /** * Create an array containing the data for the dummy pointer * -* \param specs DisplaySpecs struct with information about the display to be recorded +* \param specs DisplaySpecs struct with +* information about the display to be recorded * -* \param size Pointer size, always square, always 16.(exists only for the possibility to create -* more dummy cursors) +* \param size Pointer size, always square, always 16.(exists only +* for the possibility to create more dummy cursors) * \param color 0 white, 1 black * * \param type Always 0.(exists only for the possibility to create * more dummy cursors) * -* \param npxl Return of pixel value that denotes non-drawing, while applying the cursor -* on the target image +* \param npxl Return of pixel value that denotes non-drawing, while +* applying the cursor on the target image * * \returns Pointer to pixel data of the cursor */ -unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type,unsigned char *npxl); +unsigned char *MakeDummyPointer(DisplaySpecs *specs, + int size, + int color, + int type, + unsigned char *npxl); /** -* Sound capturing thread. Data are placed on a list to be picked up by other threads. +* Sound capturing thread. Data are placed on a +* list to be picked up by other threads. * * \param pdata ProgData struct containing all program data */ void *CaptureSound(ProgData *pdata); /** -* Sound encoding thread. Picks up data from the buffer queue , encodes and places them -* on the vorbis stream. +* Sound encoding thread. Picks up data from the buffer queue , +* encodes and places them on the vorbis stream. * * \param pdata ProgData struct containing all program data */ @@ -266,7 +290,8 @@ void *EncodeSoundBuffer(ProgData *pdata); * * \param pcm_dev name of the device * -* \param channels desired number of channels(gets modified with the acieved value) +* \param channels desired number of channels +* (gets modified with the acieved value) * * \param frequency desired frequency(gets modified with the acieved value) * @@ -339,7 +364,9 @@ void *CacheImageBuffer(ProgData *pdata); * \param cache_data_t Caching options * */ -void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t); +void InitCacheData(ProgData *pdata, + EncData *enc_data_t, + CacheData *cache_data_t); /** * Sound caching thread. Simply writes the pcm buffers on disk @@ -358,7 +385,8 @@ void *CacheSoundBuffer(ProgData *pdata); void *LoadCache(ProgData *pdata); /** -* As EncodeImageBuffer, only with the assumption that this is not a thread on it's own +* As EncodeImageBuffer, only with the assumption that +* this is not a thread on it's own * * \param pdata ProgData struct containing all program data * @@ -371,7 +399,8 @@ void SyncEncodeImageBuffer(ProgData *pdata); void CancelTimer(void); /** -* As EncodeSoundBuffer, only with the assumption that this is not a thread on it's own +* As EncodeSoundBuffer, only with the assumption that +* this is not a thread on it's own * * \param pdata ProgData struct containing all program data * diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h index 3576a3b..87ac39f 100644 --- a/recordmydesktop/include/rmdmacro.h +++ b/recordmydesktop/include/rmdmacro.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #ifndef RMDMACRO_H #define RMDMACRO_H 1 @@ -75,7 +75,8 @@ #define CLIP_EVENT_AREA(e,brwin,wgeom){\ if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\ - ((e)->area.width>=(brwin)->rgeom.width)&&((e)->area.height<(brwin)->rgeom.height)){\ + ((e)->area.width>=(brwin)->rgeom.width)&&\ + ((e)->area.height<(brwin)->rgeom.height)){\ (wgeom)->x=(brwin)->rgeom.x;\ (wgeom)->y=(brwin)->rgeom.y;\ (wgeom)->width=(brwin)->rgeom.width;\ @@ -99,33 +100,53 @@ (wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\ (e)->area.height-((brwin)->rgeom.y-(e)->area.y):\ ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\ - (((brwin)->rgeom.height-(e)->area.y+(brwin)->rgeom.y<(e)->area.height)?\ - (brwin)->rgeom.height-(e)->area.y+(brwin)->rgeom.y:(e)->area.height):-1;\ + (((brwin)->rgeom.height-(e)->area.y+\ + (brwin)->rgeom.y<(e)->area.height)?\ + (brwin)->rgeom.height-(e)->area.y+\ + (brwin)->rgeom.y:(e)->area.height):-1;\ \ - if((wgeom)->width>(brwin)->rgeom.width)(wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)(wgeom)->height=(brwin)->rgeom.height;\ + if((wgeom)->width>(brwin)->rgeom.width)\ + (wgeom)->width=(brwin)->rgeom.width;\ + if((wgeom)->height>(brwin)->rgeom.height)\ + (wgeom)->height=(brwin)->rgeom.height;\ }\ } #define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\ - (wgeom)->x=((((dummy_p_area).x+(dummy_p_area).width>=(brwin)->rgeom.x)&&\ - ((dummy_p_area).x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\ - (((dummy_p_area).x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(dummy_p_area).x):-1);\ - (wgeom)->y=((((dummy_p_area).y+(dummy_p_area).height>=(brwin)->rgeom.y)&&\ - ((dummy_p_area).y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\ - (((dummy_p_area).y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(dummy_p_area).y):-1);\ + (wgeom)->x=((((dummy_p_area).x+\ + (dummy_p_area).width>=(brwin)->rgeom.x)&&\ + ((dummy_p_area).x<=(brwin)->rgeom.x+\ + (brwin)->rgeom.width))?\ + (((dummy_p_area).x<=(brwin)->rgeom.x)?\ + (brwin)->rgeom.x:(dummy_p_area).x):-1);\ + (wgeom)->y=((((dummy_p_area).y+\ + (dummy_p_area).height>=(brwin)->rgeom.y)&&\ + ((dummy_p_area).y<=(brwin)->rgeom.y+\ + (brwin)->rgeom.height))?\ + (((dummy_p_area).y<=(brwin)->rgeom.y)?\ + (brwin)->rgeom.y:(dummy_p_area).y):-1);\ (wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\ - (dummy_p_area).width-((brwin)->rgeom.x-(dummy_p_area).x):\ - ((dummy_p_area).x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\ - ((brwin)->rgeom.width-(dummy_p_area).x+(brwin)->rgeom.x<(dummy_p_area).width)?\ - (brwin)->rgeom.width-(dummy_p_area).x+(brwin)->rgeom.x:(dummy_p_area).width:-1;\ + (dummy_p_area).width-\ + ((brwin)->rgeom.x-(dummy_p_area).x):\ + ((dummy_p_area).x<=(brwin)->rgeom.x+\ + (brwin)->rgeom.width)?\ + ((brwin)->rgeom.width-(dummy_p_area).x+\ + (brwin)->rgeom.x<(dummy_p_area).width)?\ + (brwin)->rgeom.width-(dummy_p_area).x+\ + (brwin)->rgeom.x:(dummy_p_area).width:-1;\ (wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\ - (dummy_p_area).height-((brwin)->rgeom.y-(dummy_p_area).y):\ - ((dummy_p_area).y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\ - ((brwin)->rgeom.height-(dummy_p_area).y+(brwin)->rgeom.y<(dummy_p_area).height)?\ - (brwin)->rgeom.height-(dummy_p_area).y+(brwin)->rgeom.y:(dummy_p_area).height:-1;\ - if((wgeom)->width>(brwin)->rgeom.width)(wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)(wgeom)->height=(brwin)->rgeom.height;\ + (dummy_p_area).height-\ + ((brwin)->rgeom.y-(dummy_p_area).y):\ + ((dummy_p_area).y<=(brwin)->rgeom.y+\ + (brwin)->rgeom.height)?\ + ((brwin)->rgeom.height-(dummy_p_area).y+\ + (brwin)->rgeom.y<(dummy_p_area).height)?\ + (brwin)->rgeom.height-(dummy_p_area).y+\ + (brwin)->rgeom.y:(dummy_p_area).height:-1;\ + if((wgeom)->width>(brwin)->rgeom.width)\ + (wgeom)->width=(brwin)->rgeom.width;\ + if((wgeom)->height>(brwin)->rgeom.height)\ + (wgeom)->height=(brwin)->rgeom.height;\ } @@ -221,13 +242,21 @@ (t3&__B16_MASK)+(t4&__B16_MASK))/4)&__B16_MASK);\ } -#define UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__bit_depth__){ \ +#define UPDATE_Y_PLANE(data,\ + x_tm,\ + y_tm,\ + height_tm,\ + width_tm,\ + yuv,\ + __copy_type,\ + __bit_depth__){ \ int k,i;\ register RMD_TYPE_##__bit_depth__ t_val;\ register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ *_yr=Yr,*_yg=Yg,*_yb=Yb;\ - register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data+\ - ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0);\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data\ + +((__copy_type==__X_SHARED)?\ + (x_tm+y_tm*yuv->y_width):0);\ for(k=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ t_val=*datapi;\ @@ -243,16 +272,25 @@ }\ } -#define UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,__bit_depth__){ \ +#define UPDATE_UV_PLANES(data,\ + x_tm,\ + y_tm,\ + height_tm,\ + width_tm,\ + yuv,\ + __copy_type,\ + __sampling_type,\ + __bit_depth__){ \ int k,i;\ register RMD_TYPE_##__bit_depth__ t_val;\ register unsigned char *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\ *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\ *_ur=Ur,*_ug=Ug,*_ub=Ub,\ *_vr=Vr,*_vg=Vg,*_vb=Vb;\ - register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data+\ - ((__copy_type==__X_SHARED)?(x_tm+y_tm*yuv->y_width):0),\ - *datapi_next=NULL;\ + register RMD_TYPE_##__bit_depth__ *datapi=(RMD_TYPE_##__bit_depth__ *)data\ + +((__copy_type==__X_SHARED)?\ + (x_tm+y_tm*yuv->y_width):0),\ + *datapi_next=NULL;\ if(__sampling_type==__PXL_AVERAGE){\ datapi_next=datapi+\ ((__copy_type==__X_SHARED)?(yuv->y_width):(width_tm));\ @@ -280,40 +318,69 @@ }\ yuv_u+=(yuv->y_width-width_tm)/2;\ yuv_v+=(yuv->y_width-width_tm)/2;\ - datapi+=((__copy_type==__X_SHARED)?(2*yuv->y_width-width_tm):width_tm);\ + datapi+=((__copy_type==__X_SHARED)?\ + (2*yuv->y_width-width_tm):width_tm);\ if(__sampling_type==__PXL_AVERAGE)\ - datapi_next+=((__copy_type==__X_SHARED)?(2*yuv->y_width-width_tm):width_tm);\ + datapi_next+=((__copy_type==__X_SHARED)?\ + (2*yuv->y_width-width_tm):width_tm);\ }\ } -#define UPDATE_YUV_BUFFER(yuv,data,x_tm,y_tm,width_tm,height_tm,__copy_type,__sampling_type,__color_depth){\ +#define UPDATE_YUV_BUFFER(yuv,\ + data,\ + x_tm,\ + y_tm,\ + width_tm,\ + height_tm,\ + __copy_type,\ + __sampling_type,\ + __color_depth){\ if((__color_depth==24)||(__color_depth==32)){\ UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,32)\ - UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,32)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ + yuv,__copy_type,__sampling_type,32)\ }\ else if(__color_depth==16){\ UPDATE_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,16)\ - UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,yuv,__copy_type,__sampling_type,16)\ + UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ + yuv,__copy_type,__sampling_type,16)\ }\ } -#define XFIXES_POINTER_TO_YUV(yuv,data,x_tm,y_tm,width_tm,height_tm,column_discard_stride){\ +#define XFIXES_POINTER_TO_YUV(yuv,\ + data,\ + x_tm,\ + y_tm,\ + width_tm,\ + height_tm,\ + column_discard_stride){\ int i,k,j=0;\ unsigned char avg0,avg1,avg2,avg3;\ int x_2=x_tm/2,y_2=y_tm/2;\ for(k=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]=\ - (yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]*(UCHAR_MAX-data[(j*RMD_ULONG_SIZE_T)+__ABYTE])+\ - (Yr[data[(j*RMD_ULONG_SIZE_T)+__RBYTE]] + Yg[data[(j*RMD_ULONG_SIZE_T)+__GBYTE]] +\ - Yb[data[(j*RMD_ULONG_SIZE_T)+__BBYTE]])*data[(j*RMD_ULONG_SIZE_T)+__ABYTE])/UCHAR_MAX ;\ + (yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]*\ + (UCHAR_MAX-data[(j*RMD_ULONG_SIZE_T)+__ABYTE])+\ + (Yr[data[(j*RMD_ULONG_SIZE_T)+__RBYTE]]+\ + Yg[data[(j*RMD_ULONG_SIZE_T)+__GBYTE]] +\ + Yb[data[(j*RMD_ULONG_SIZE_T)+__BBYTE]])*\ + data[(j*RMD_ULONG_SIZE_T)+__ABYTE])/UCHAR_MAX ;\ if((k%2)&&(i%2)){\ - avg3=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__ABYTE);\ - avg2=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__RBYTE);\ - avg1=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__GBYTE);\ - avg0=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__BBYTE);\ + avg3=AVG_4_PIXELS(data,\ + (width_tm+column_discard_stride),\ + k,i,__ABYTE);\ + avg2=AVG_4_PIXELS(data,\ + (width_tm+column_discard_stride),\ + k,i,__RBYTE);\ + avg1=AVG_4_PIXELS(data,\ + (width_tm+column_discard_stride),\ + k,i,__GBYTE);\ + avg0=AVG_4_PIXELS(data,\ + (width_tm+column_discard_stride),\ + k,i,__BBYTE);\ yuv->u[x_2+i/2+(k/2+y_2)*yuv->uv_width]=\ (yuv->u[x_2+i/2+(k/2+y_2)*yuv->uv_width]*(UCHAR_MAX-avg3)+\ (Ur[avg2] + Ug[avg1] +Ub[avg0])*avg3)/UCHAR_MAX;\ @@ -327,16 +394,31 @@ }\ } -#define DUMMY_POINTER_TO_YUV(yuv,data_tm,x_tm,y_tm,width_tm,height_tm,no_pixel){\ +#define DUMMY_POINTER_TO_YUV(yuv,\ + data_tm,\ + x_tm,\ + y_tm,\ + width_tm,\ + height_tm,\ + no_pixel){\ int i,k,j=0;\ int x_2=x_tm/2,y_2=y_tm/2,y_width_2=(yuv)->y_width/2;\ for(k=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ if(data_tm[(j*4)]!=(no_pixel)){\ - (yuv)->y[x_tm+i+(k+y_tm)*(yuv)->y_width]=Yr[data_tm[(j*4)+__RBYTE]] + Yg[data_tm[(j*4)+__GBYTE]] + Yb[data_tm[(j*4)+__BBYTE]];\ + (yuv)->y[x_tm+i+(k+y_tm)*(yuv)->y_width]=\ + Yr[data_tm[(j*4)+__RBYTE]] +\ + Yg[data_tm[(j*4)+__GBYTE]] +\ + Yb[data_tm[(j*4)+__BBYTE]];\ if((k%2)&&(i%2)){\ - yuv->u[x_2+i/2+(k/2+y_2)*y_width_2]=Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] + Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] + Ub[data_tm[(k*width_tm+i)*4+__BBYTE]];\ - yuv->v[x_2+i/2+(k/2+y_2)*y_width_2]=Vr[data_tm[(k*width_tm+i)*4+__RBYTE]] + Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] + Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\ + yuv->u[x_2+i/2+(k/2+y_2)*y_width_2]=\ + Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] +\ + Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] +\ + Ub[data_tm[(k*width_tm+i)*4+__BBYTE]];\ + yuv->v[x_2+i/2+(k/2+y_2)*y_width_2]=\ + Vr[data_tm[(k*width_tm+i)*4+__RBYTE]] +\ + Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] +\ + Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\ }\ }\ j++;\ diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h index 328532f..ea1e517 100644 --- a/recordmydesktop/include/rmdtypes.h +++ b/recordmydesktop/include/rmdtypes.h @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #ifndef RMDTYPES_H #define RMDTYPES_H 1 @@ -104,7 +104,7 @@ typedef struct _BRWindow{ //'basic recorded window' specs WGeometry geom; //window attributes WGeometry rgeom; //part of window that is recorded int nbytes; //size of zpixmap when screenshoting - Window windowid; //id + Window windowid; //id }BRWindow; //defaults in the following comment lines may be out of sync with reality @@ -118,14 +118,14 @@ typedef struct _ProgArgs{ int quietmode; //no messages to stderr,stdout char *filename; //output file(default out.[ogg|*]) int cursor_color; //black or white=>1 or 0 - int have_dummy_cursor;//disable/enable drawing of the dummy cursor - int xfixes_cursor; //disable/enable drawing of a cursor obtained - //through the xfixes extension - float fps; //desired framerate(default 15) - unsigned int frequency; //desired frequency (default 22050) - unsigned int channels; //no of channels(default 2) - char *device; //default sound device(default according to alsa or oss) - snd_pcm_uframes_t buffsize;//buffer size(in frames) for sound capturing + int have_dummy_cursor; //disable/enable drawing of the dummy cursor + int xfixes_cursor; //disable/enable drawing of a cursor obtained + //through the xfixes extension + float fps; //desired framerate(default 15) + unsigned int frequency; //desired frequency (default 22050) + unsigned int channels; //no of channels(default 2) + char *device; //default sound device + snd_pcm_uframes_t buffsize; //buffer size(in frames) for sound capturing int nosound; //do not record sound(default 0) int noshared; //do not use shared memory extension(default 1) int nocondshared; //do not use shared memory on large image aquititions @@ -133,25 +133,26 @@ typedef struct _ProgArgs{ //(which changes full-shots and with-shared to 1) int shared_thres; //threshold to use shared memory int full_shots; //do not poll damage, take full screenshots - int no_quick_subsample;//average pixels in chroma planes - int v_bitrate,v_quality,s_quality;//video bitrate,video-sound quality + int no_quick_subsample; //average pixels in chroma planes + int v_bitrate,v_quality,s_quality; //video bitrate,video-sound quality int dropframes; //option for theora encoder int encOnTheFly; //encode while recording, no caching(default 0) char *workdir; //directory to be used for cache files(default $HOME) int zerocompression;//image data are always flushed uncompressed - int overwrite;//overwite a previously existing file(do not add a .number postfix) + int overwrite; //overwite a previously existing file + //(do not add a .number postfix) }ProgArgs; //this struct holds anything related to encoding AND //writting out to file. typedef struct _EncData{ - ogg_stream_state m_ogg_ts;//theora - ogg_stream_state m_ogg_vs;//vorbis - ogg_page m_ogg_pg;//this could be avoided since - // it is used only while initializing - ogg_packet m_ogg_pckt1;//theora stream - ogg_packet m_ogg_pckt2;//vorbis stream + ogg_stream_state m_ogg_ts; //theora + ogg_stream_state m_ogg_vs; //vorbis + ogg_page m_ogg_pg; //this could be avoided since + // it is used only while initializing + ogg_packet m_ogg_pckt1; //theora stream + ogg_packet m_ogg_pckt2; //vorbis stream //theora data theora_state m_th_st; theora_info m_th_inf; @@ -173,13 +174,18 @@ typedef struct _EncData{ //this struct will hold a few basic //information, needed for caching the frames. typedef struct _CacheData{ - char *workdir, //The directory were the project will be stored, while recording. + char *workdir, //The directory were the project + //will be stored, while recording. //Since this will take a lot of space, the user must be //able to change the location. - *projname, //This is the name of the folder that will hold the project. - //It is rMD-session-%d where %d is the pid of the current proccess. - //This way, running two instances will not create problems - //and also, a frontend can identify leftovers from a possible crash + *projname, //This is the name of the folder that + //will hold the project. + //It is rMD-session-%d where %d is the pid + //of the current proccess. + //This way, running two instances + //will not create problems + //and also, a frontend can identify + //leftovers from a possible crash //and delete them *imgdata, //workdir+projname+img.out.gz *audiodata; //workdir+projname+audio.pcm @@ -204,54 +210,67 @@ typedef struct _SndBuffer{ //threads,so they will have access to the program data, avoiding //at the same time usage of any globals. typedef struct _ProgData{ - ProgArgs args;//the program arguments - DisplaySpecs specs;//Display specific information - BRWindow brwin;//recording window - Display *dpy;//curtrent display - char *window_manager;//name of the window manager at program launch - XImage *image;//the image that holds the current full screenshot - XImage *shimage;//the image that holds the current full screenshot(shared memory) + ProgArgs args; //the program arguments + DisplaySpecs specs; //Display specific information + BRWindow brwin; //recording window + Display *dpy; //curtrent display + char *window_manager; //name of the window manager at program launch + XImage *image; //the image that holds the current full screenshot + XImage *shimage; //the image that holds the current + //full screenshot(shared memory) XShmSegmentInfo shminfo;//info structure for the image above. - unsigned char *dummy_pointer;//a dummy pointer to be drawn in every frame - //data is casted to unsigned for later use in YUV buffer - int dummy_p_size;//initially 16x16,always square - unsigned char npxl;//this is the no pixel convention when drawing the dummy pointer - char *datamain,//the data of image - *datash,//the data of shimage - *datatemp;//buffer for the temporary image,which will be - //preallocated in case shared memory is not used. - RectArea *rect_root[2];//the interchanging list roots for storing the changed regions - int list_selector,//selector for the above - damage_event,//damage event base code - damage_error,//damage error base code + unsigned char *dummy_pointer; //a dummy pointer to be drawn + //in every frame + //data is casted to unsigned for + //later use in YUV buffer + int dummy_p_size; //initially 16x16,always square + unsigned char npxl; //this is the no pixel convention + //when drawing the dummy pointer + char *datamain, //the data of image + *datash, //the data of shimage + *datatemp; //buffer for the temporary image,which will be + //preallocated in case shared memory is not used. + RectArea *rect_root[2]; //the interchanging list roots for storing + //the changed regions + int list_selector, //selector for the above + damage_event, //damage event base code + damage_error, //damage error base code running; SndBuffer *sound_buffer; EncData *enc_data; CacheData *cache_data; - int hard_pause;//if sound device doesn't support pause - //we have to close and reopen - int avd;//syncronization among audio and video + int hard_pause; //if sound device doesn't support pause + //we have to close and reopen + int avd; //syncronization among audio and video unsigned int periodtime, frametime; - pthread_mutex_t list_mutex[2],//mutexes for concurrency protection of the lists + pthread_mutex_t list_mutex[2], //mutexes for concurrency + //protection of the lists sound_buffer_mutex, - libogg_mutex,//libogg is not thread safe, - yuv_mutex;//this might not be needed since we only have - //one read-only and one write-only thread - //also on previous versions, y component was looped separately - //and then u and v so this was needed to avoid wrong coloring to render - //Currently this mutex only prevents the cursor from flickering - pthread_cond_t time_cond,//this gets a broadcast by the handler whenever it's time to get a screenshot - pause_cond,//this is blocks execution, when program is paused - sound_buffer_ready,//sound encoding finished - sound_data_read,//a buffer is ready for proccessing - image_buffer_ready,//image encoding finished - theora_lib_clean,//the flush_ogg thread cannot procceed to creating last - vorbis_lib_clean;//packages until these two libs are no longer used, by other threads - int th_encoding_clean,//these indicate a wait condition on the above cond vars + libogg_mutex, //libogg is not thread safe, + yuv_mutex; //this might not be needed since we only have + //one read-only and one write-only thread + //also on previous versions, + //y component was looped separately + //and then u and v so this was needed + //to avoid wrong coloring to render + //Currently this mutex only prevents + //the cursor from flickering + pthread_cond_t time_cond, //this gets a broadcast by the handler + //whenever it's time to get a screenshot + pause_cond, //this is blocks execution, + //when program is paused + sound_buffer_ready, //sound encoding finished + sound_data_read, //a buffer is ready for proccessing + image_buffer_ready, //image encoding finished + theora_lib_clean, //the flush_ogg thread cannot + //procceed to creating last + vorbis_lib_clean; //packages until these two libs + //are no longer used, by other threads + int th_encoding_clean, v_encoding_clean; - int v_enc_thread_waiting, - th_enc_thread_waiting; + int v_enc_thread_waiting, //these indicate a wait + th_enc_thread_waiting; //condition on the above cond vars snd_pcm_t *sound_handle; snd_pcm_uframes_t periodsize; }ProgData; @@ -268,17 +287,16 @@ typedef struct _ProgData{ //number of time expirations at the time of //caching, will enable us to make up for lost frames. -//default 4+4+2+2+2=14!bad! -//me add pad, make god of 2 happy! + typedef struct _FrameHeader{ - char frame_prefix[4];//always FRAM - u_int32_t frameno,//number of frame(cached frames) - current_total;//number of frames that should have been - //taken at time of caching this one - u_int16_t Ynum,//number of changed blocks in the Y plane - Unum,//number of changed blocks in the U plane - Vnum;//number of changed blocks in the V plane - u_int16_t pad;//always zero + char frame_prefix[4]; //always FRAM + u_int32_t frameno, //number of frame(cached frames) + current_total; //number of frames that should have been + //taken at time of caching this one + u_int16_t Ynum, //number of changed blocks in the Y plane + Unum, //number of changed blocks in the U plane + Vnum; //number of changed blocks in the V plane + u_int16_t pad; //always zero }FrameHeader; @@ -289,12 +307,12 @@ typedef struct _FrameHeader{ typedef struct _CachedFrame{ FrameHeader *header; - unsigned char *YBlocks;//identifying number on the grid, starting at top left - unsigned char *UBlocks;// >> >> - unsigned char *VBlocks;// >> >> - unsigned char *YData;//pointer to data for the blocks that have changed, - unsigned char *UData;//which have to be remapped on the buffer when reading - unsigned char *VData; + unsigned char *YBlocks; //identifying number on the grid, + unsigned char *UBlocks; //starting at top left + unsigned char *VBlocks; // >> >> + unsigned char *YData; //pointer to data for the blocks that have changed, + unsigned char *UData; //which have to be remapped + unsigned char *VData; //on the buffer when reading }CachedFrame; #endif diff --git a/recordmydesktop/src/bgr_to_yuv.c b/recordmydesktop/src/bgr_to_yuv.c index 0f775e2..f0632e7 100644 --- a/recordmydesktop/src/bgr_to_yuv.c +++ b/recordmydesktop/src/bgr_to_yuv.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> diff --git a/recordmydesktop/src/cache_audio.c b/recordmydesktop/src/cache_audio.c index afd08cf..c8a71da 100644 --- a/recordmydesktop/src/cache_audio.c +++ b/recordmydesktop/src/cache_audio.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> void *CacheSoundBuffer(ProgData *pdata){ @@ -30,7 +30,8 @@ void *CacheSoundBuffer(ProgData *pdata){ //It's sound is tiny compared to that of image, so //compressing would reducethe overall size by only an //insignificant fraction. - int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*pdata->args.channels; + int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)* + pdata->args.channels; pthread_mutex_t smut; pthread_mutex_init(&smut,NULL); while((pdata->running)){ @@ -55,7 +56,8 @@ void *CacheSoundBuffer(ProgData *pdata){ pdata->sound_buffer=pdata->sound_buffer->next; pthread_mutex_unlock(&pdata->sound_buffer_mutex); - fwrite(buff->data,pdata->periodsize*framesize,1,pdata->cache_data->afp); + fwrite(buff->data,pdata->periodsize*framesize,1, + pdata->cache_data->afp); diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c index d77308a..07c7c70 100644 --- a/recordmydesktop/src/cache_frame.c +++ b/recordmydesktop/src/cache_frame.c @@ -1,38 +1,46 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -int CompareBlocks(unsigned char *incoming,unsigned char *old,int blockno,int width, int height,int divisor){ +int CompareBlocks(unsigned char *incoming, + unsigned char *old, + int blockno, + int width, + int height, + int divisor){ int j,i, block_i=blockno/divisor,//place on the grid block_k=blockno%divisor; - register unsigned char *incoming_reg=&(incoming[block_i*(width*height/divisor)+block_k*width/divisor]), - *old_reg=&(old[block_i*(width*height/divisor)+block_k*width/divisor]); + register unsigned char *incoming_reg=&(incoming[block_i* + (width*height/divisor)+ + block_k*width/divisor]), + *old_reg=&(old[block_i*(width*height/divisor)+ + block_k*width/divisor]); for(j=0;j<height/divisor;j++){ for(i=0;i<width/divisor;i++){ @@ -46,11 +54,18 @@ int CompareBlocks(unsigned char *incoming,unsigned char *old,int blockno,int wid return 0; } -int FlushBlock(unsigned char *buf,int blockno,int width, int height,int divisor,gzFile *fp,FILE *ucfp){ +int FlushBlock(unsigned char *buf, + int blockno, + int width, + int height, + int divisor, + gzFile *fp, + FILE *ucfp){ int j, block_i=blockno/divisor,//place on the grid block_k=blockno%divisor; - register unsigned char *buf_reg=(&buf[block_i*(width*height/divisor)+block_k*width/divisor]); + register unsigned char *buf_reg=(&buf[block_i*(width*height/divisor) + +block_k*width/divisor]); if(ucfp==NULL){ for(j=0;j<height/divisor;j++){//we flush in rows gzwrite(fp,(void *)buf_reg,width/divisor); @@ -123,9 +138,12 @@ void *CacheImageBuffer(ProgData *pdata){ prev=current; current=(current)?0:1; //copy incoming - memcpy(yuv[current].y,pdata->enc_data->yuv.y,yuv[current].y_width*yuv[current].y_height); - memcpy(yuv[current].u,pdata->enc_data->yuv.u,yuv[current].uv_width*yuv[current].uv_height); - memcpy(yuv[current].v,pdata->enc_data->yuv.v,yuv[current].uv_width*yuv[current].uv_height); + memcpy(yuv[current].y,pdata->enc_data->yuv.y, + yuv[current].y_width*yuv[current].y_height); + memcpy(yuv[current].u,pdata->enc_data->yuv.u, + yuv[current].uv_width*yuv[current].uv_height); + memcpy(yuv[current].v,pdata->enc_data->yuv.v, + yuv[current].uv_width*yuv[current].uv_height); //release main buffer pthread_mutex_unlock(&pdata->yuv_mutex); //get checksums for new @@ -149,19 +167,25 @@ void *CacheImageBuffer(ProgData *pdata){ } else{ for(j=0;j<pow(divisor,2);j++){ - if(CompareBlocks(yuv[current].y,yuv[prev].y,j,yuv[current].y_width,yuv[current].y_height,divisor)){ + if(CompareBlocks(yuv[current].y,yuv[prev].y,j, + yuv[current].y_width, + yuv[current].y_height,divisor)){ ynum++; yblocks[ynum-1]=j; } } for(j=0;j<pow(divisor/2,2);j++){ - if(CompareBlocks(yuv[current].u,yuv[prev].u,j,yuv[current].uv_width,yuv[current].uv_height,divisor/2)){ + if(CompareBlocks(yuv[current].u,yuv[prev].u,j, + yuv[current].uv_width, + yuv[current].uv_height,divisor/2)){ unum++; ublocks[unum-1]=j; } } for(j=0;j<pow(divisor/2,2);j++){ - if(CompareBlocks(yuv[current].v,yuv[prev].v,j,yuv[current].uv_width,yuv[current].uv_height,divisor/2)){ + if(CompareBlocks(yuv[current].v,yuv[prev].v,j, + yuv[current].uv_width, + yuv[current].uv_height,divisor/2)){ vnum++; vblocks[vnum-1]=j; } @@ -191,7 +215,8 @@ void *CacheImageBuffer(ProgData *pdata){ if(vnum)nbytes+=gzwrite(fp,vblocks,vnum); } else{ - nbytes+=sizeof(FrameHeader)*fwrite((void*)&fheader,sizeof(FrameHeader),1,ucfp); + nbytes+=sizeof(FrameHeader)* + fwrite((void*)&fheader,sizeof(FrameHeader),1,ucfp); //flush indexes if(ynum)nbytes+=ynum*fwrite(yblocks,ynum,1,ucfp); if(unum)nbytes+=unum*fwrite(ublocks,unum,1,ucfp); @@ -227,18 +252,23 @@ void *CacheImageBuffer(ProgData *pdata){ /**@________________@**/ pdata->avd+=pdata->frametime; if(nbytes>CACHE_FILE_SIZE_LIMIT){ - if(SwapCacheFilesWrite(pdata->cache_data->imgdata,nth_cache,&fp,&ucfp)){ - fprintf(stderr,"New cache file could not be created.\nEnding recording...\n"); + if(SwapCacheFilesWrite(pdata->cache_data->imgdata, + nth_cache,&fp,&ucfp)){ + fprintf(stderr,"New cache file could not be created.\n" + "Ending recording...\n"); fflush(stderr); raise(SIGINT); //if for some reason we cannot make a new file - //we have to stop. If we are out of space,which means + //we have to stop. If we are out of space, + //which means //that encoding cannot happen either, //InitEncoder will cause an abrupt end with an //error code and the cache will remain intact. - //If we've chosen separate two-stages, the program will make a + //If we've chosen separate two-stages, + //the program will make a //clean exit. //In either case data will be preserved so if - //space is freed the recording can be proccessed later. + //space is freed the recording + //can be proccessed later. } nth_cache++; nbytes=0; @@ -251,7 +281,8 @@ void *CacheImageBuffer(ProgData *pdata){ free(yuv[i].u); free(yuv[i].v); } - fprintf(stderr,"Saved %d frames in a total of %d requests\n",frameno,frames_total); + fprintf(stderr,"Saved %d frames in a total of %d requests\n", + frameno,frames_total); if(!pdata->args.zerocompression){ gzflush(fp,Z_FINISH); gzclose(fp); diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c index 945f322..32f2638 100644 --- a/recordmydesktop/src/capture_sound.c +++ b/recordmydesktop/src/capture_sound.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -30,7 +30,8 @@ void *CaptureSound(ProgData *pdata){ int frames=pdata->periodsize; - int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*pdata->args.channels; + int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)* + pdata->args.channels; pthread_mutex_t pmut; pthread_mutex_init(&pmut,NULL); @@ -57,7 +58,8 @@ void *CaptureSound(ProgData *pdata){ &pdata->args.buffsize, NULL, NULL, - NULL//let's hope that the device capabilities didn't magically change + NULL//let's hope that the device capabilities + //didn't magically change ); if(pdata->sound_handle==NULL){ fprintf(stderr,"Couldn't reopen sound device.Exiting\n"); @@ -79,11 +81,14 @@ void *CaptureSound(ProgData *pdata){ newbuf->data+framesize*sret, frames-sret); if(temp_sret==-EPIPE){ - fprintf(stderr,"%s: Underrun occurred.\n",snd_strerror(temp_sret)); + fprintf(stderr,"%s: Underrun occurred.\n", + snd_strerror(temp_sret)); snd_pcm_prepare(pdata->sound_handle); } else if (temp_sret<0){ - fprintf(stderr,"An error occured while reading sound data:\n %s\n",snd_strerror(temp_sret)); + fprintf(stderr,"An error occured while reading sound data:\n" + " %s\n", + snd_strerror(temp_sret)); snd_pcm_prepare(pdata->sound_handle); } else diff --git a/recordmydesktop/src/encode_cache.c b/recordmydesktop/src/encode_cache.c index 5063d74..0113b59 100644 --- a/recordmydesktop/src/encode_cache.c +++ b/recordmydesktop/src/encode_cache.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -33,7 +33,8 @@ void EncodeCache(ProgData *pdata){ load_cache_t; fprintf(stderr,"Encoding started!\nThis may take several minutes.\n" - "Pressing Ctrl-C will cancel the procedure (resuming will not be possible, but\n" + "Pressing Ctrl-C will cancel the procedure" + " (resuming will not be possible, but\n" "any portion of the video, which is already encoded won't be deleted).\n" "Please wait...\n"); pdata->running=1; diff --git a/recordmydesktop/src/encode_image_buffer.c b/recordmydesktop/src/encode_image_buffer.c index 3c50a6f..97a78ed 100644 --- a/recordmydesktop/src/encode_image_buffer.c +++ b/recordmydesktop/src/encode_image_buffer.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> void *EncodeImageBuffer(ProgData *pdata){ @@ -36,36 +36,37 @@ void *EncodeImageBuffer(ProgData *pdata){ pdata->th_enc_thread_waiting=0; encoder_busy=1; if(Paused) - pthread_cond_wait(&pdata->pause_cond,&pmut);//this may not be needed + pthread_cond_wait(&pdata->pause_cond,&pmut);//this may + //not be needed pthread_mutex_lock(&pdata->yuv_mutex); -// pthread_mutex_lock(&pdata->libtheora_mutex); - if(theora_encode_YUVin(&pdata->enc_data->m_th_st,&pdata->enc_data->yuv)){ + + if(theora_encode_YUVin(&pdata->enc_data->m_th_st, + &pdata->enc_data->yuv)){ fprintf(stderr,"Encoder not ready!\n"); pthread_mutex_unlock(&pdata->yuv_mutex); } else{ pthread_mutex_unlock(&pdata->yuv_mutex); - if(theora_encode_packetout(&pdata->enc_data->m_th_st,0,&pdata->enc_data->m_ogg_pckt1)==1){ + if(theora_encode_packetout(&pdata->enc_data->m_th_st,0, + &pdata->enc_data->m_ogg_pckt1)==1){ pthread_mutex_lock(&pdata->libogg_mutex); - ogg_stream_packetin(&pdata->enc_data->m_ogg_ts,&pdata->enc_data->m_ogg_pckt1); + ogg_stream_packetin(&pdata->enc_data->m_ogg_ts, + &pdata->enc_data->m_ogg_pckt1); pthread_mutex_unlock(&pdata->libogg_mutex); pdata->avd+=pdata->frametime; } } -// pthread_mutex_unlock(&pdata->libtheora_mutex); encoder_busy=0; } //last packet pdata->th_encoding_clean=1; pthread_cond_signal(&pdata->theora_lib_clean); -// SyncEncodeImageBuffer(pdata); pthread_exit(&errno); } //this function is meant to be called normally //not through a thread of it's own void SyncEncodeImageBuffer(ProgData *pdata){ -// pthread_mutex_lock(&pdata->libtheora_mutex); if(theora_encode_YUVin(&pdata->enc_data->m_th_st, &pdata->enc_data->yuv)){ fprintf(stderr,"Encoder not ready!\n"); @@ -81,6 +82,5 @@ void SyncEncodeImageBuffer(ProgData *pdata){ pdata->avd+=pdata->frametime; } } -// pthread_mutex_unlock(&pdata->libtheora_mutex); } diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c index d4c673b..828855c 100644 --- a/recordmydesktop/src/encode_sound_buffer.c +++ b/recordmydesktop/src/encode_sound_buffer.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -57,30 +57,32 @@ void *EncodeSoundBuffer(ProgData *pdata){ pdata->sound_buffer=pdata->sound_buffer->next; pthread_mutex_unlock(&pdata->sound_buffer_mutex); -// pthread_mutex_lock(&pdata->libvorbis_mutex); - vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,sampread); + vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp, + sampread); for(i=0;i<sampread;i++){ for(j=0;j<pdata->args.channels;j++){ vorbis_buffer[j][i]=((buff->data[count+1]<<8)| - (0x00ff&(int)buff->data[count]))/32768.f; + (0x00ff&(int)buff->data[count]))/32768.f; count+=2; } } vorbis_analysis_wrote(&pdata->enc_data->m_vo_dsp,sampread); pthread_mutex_lock(&pdata->libogg_mutex); - while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ + while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp, + &pdata->enc_data->m_vo_block)==1){ vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); - while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)){ - ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); + while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp, + &pdata->enc_data->m_ogg_pckt2)){ + ogg_stream_packetin(&pdata->enc_data->m_ogg_vs, + &pdata->enc_data->m_ogg_pckt2); } } pthread_mutex_unlock(&pdata->libogg_mutex); -// pthread_mutex_unlock(&pdata->libvorbis_mutex); pdata->avd-=pdata->periodtime; free(buff->data); @@ -89,7 +91,6 @@ void *EncodeSoundBuffer(ProgData *pdata){ pdata->v_encoding_clean=1; pthread_cond_signal(&pdata->vorbis_lib_clean); -// SyncEncodeSoundBuffer(pdata,NULL); pthread_exit(&errno); } @@ -97,7 +98,6 @@ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff){ float **vorbis_buffer; int count=0,i,j; int sampread=(buff!=NULL)?pdata->periodsize:0; -// pthread_mutex_lock(&pdata->libvorbis_mutex); vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,sampread); for(i=0;i<sampread;i++){ for(j=0;j<pdata->args.channels;j++){ @@ -110,19 +110,21 @@ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff){ vorbis_analysis_wrote(&pdata->enc_data->m_vo_dsp,sampread); pthread_mutex_lock(&pdata->libogg_mutex); - while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ + while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp, + &pdata->enc_data->m_vo_block)==1){ vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); - while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)){ - ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); + while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp, + &pdata->enc_data->m_ogg_pckt2)){ + ogg_stream_packetin(&pdata->enc_data->m_ogg_vs, + &pdata->enc_data->m_ogg_pckt2); } } pthread_mutex_unlock(&pdata->libogg_mutex); if(!pdata->running)pdata->enc_data->m_ogg_vs.e_o_s=1; -// pthread_mutex_unlock(&pdata->libvorbis_mutex); pdata->avd-=pdata->periodtime; } diff --git a/recordmydesktop/src/flush_to_ogg.c b/recordmydesktop/src/flush_to_ogg.c index 10d9553..cc00708 100644 --- a/recordmydesktop/src/flush_to_ogg.c +++ b/recordmydesktop/src/flush_to_ogg.c @@ -1,33 +1,34 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> //we copy the page because the next call to ogg_stream_pageout -//will invalidate it. But we must have pages from both streams at every time in +//will invalidate it. But we must have pages from +//both streams at every time in //order to do correct multiplexing void ogg_page_cp(ogg_page *new,ogg_page *old){ int i=0; @@ -76,14 +77,20 @@ void *FlushToOgg(ProgData *pdata){ if(pdata->running){ pthread_mutex_lock(&pdata->libogg_mutex); if(!videoflag){ - videoflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_ts,&videopage); - videotime=(videoflag)?theora_granule_time(&pdata->enc_data->m_th_st,ogg_page_granulepos(&videopage)):-1; + videoflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_ts, + &videopage); + videotime=(videoflag)? + theora_granule_time(&pdata->enc_data->m_th_st, + ogg_page_granulepos(&videopage)):-1; if(videoflag)ogg_page_cp(&videopage_copy,&videopage); } if(!pdata->args.nosound) if(!audioflag){ - audioflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_vs,&audiopage); - audiotime=(audioflag)?vorbis_granule_time(&pdata->enc_data->m_vo_dsp,ogg_page_granulepos(&audiopage)):-1; + audioflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_vs, + &audiopage); + audiotime=(audioflag)? + vorbis_granule_time(&pdata->enc_data->m_vo_dsp, + ogg_page_granulepos(&audiopage)):-1; if(audioflag)ogg_page_cp(&audiopage_copy,&audiopage); } pthread_mutex_unlock(&pdata->libogg_mutex); @@ -91,8 +98,11 @@ void *FlushToOgg(ProgData *pdata){ else{ if(!th_st_fin && !videoflag){ pthread_mutex_lock(&pdata->libogg_mutex); - videoflag=ogg_stream_flush(&pdata->enc_data->m_ogg_ts,&videopage); - videotime=(videoflag)?theora_granule_time(&pdata->enc_data->m_th_st,ogg_page_granulepos(&videopage)):-1; + videoflag=ogg_stream_flush(&pdata->enc_data->m_ogg_ts, + &videopage); + videotime=(videoflag)? + theora_granule_time(&pdata->enc_data->m_th_st, + ogg_page_granulepos(&videopage)):-1; if(videoflag)ogg_page_cp(&videopage_copy,&videopage); pthread_mutex_unlock(&pdata->libogg_mutex); //we need the last page to properly close the stream @@ -105,8 +115,11 @@ void *FlushToOgg(ProgData *pdata){ } if(!pdata->args.nosound && !v_st_fin &&!audioflag){ pthread_mutex_lock(&pdata->libogg_mutex); - audioflag=ogg_stream_flush(&pdata->enc_data->m_ogg_vs,&audiopage); - audiotime=(audioflag)?vorbis_granule_time(&pdata->enc_data->m_vo_dsp,ogg_page_granulepos(&audiopage)):-1; + audioflag=ogg_stream_flush(&pdata->enc_data->m_ogg_vs, + &audiopage); + audiotime=(audioflag)? + vorbis_granule_time(&pdata->enc_data->m_vo_dsp, + ogg_page_granulepos(&audiopage)):-1; if(audioflag)ogg_page_cp(&audiopage_copy,&audiopage); pthread_mutex_unlock(&pdata->libogg_mutex); //we need the last page to properly close the stream @@ -120,7 +133,8 @@ void *FlushToOgg(ProgData *pdata){ } if(th_st_fin)videoflag=0; if(v_st_fin)audioflag=0; - if((!audioflag && !v_st_fin && !pdata->args.nosound) || (!videoflag && !th_st_fin)){ + if((!audioflag && !v_st_fin && !pdata->args.nosound)|| + (!videoflag && !th_st_fin)){ usleep(10000); continue; } @@ -137,8 +151,12 @@ void *FlushToOgg(ProgData *pdata){ audio_or_video=1; } if(audio_or_video==1){ - video_bytesout+=fwrite(videopage_copy.header,1,videopage_copy.header_len,pdata->enc_data->fp); - video_bytesout+=fwrite(videopage_copy.body,1,videopage_copy.body_len,pdata->enc_data->fp); + video_bytesout+=fwrite(videopage_copy.header,1, + videopage_copy.header_len, + pdata->enc_data->fp); + video_bytesout+=fwrite(videopage_copy.body,1, + videopage_copy.body_len, + pdata->enc_data->fp); videoflag=0; if(!pdata->running){ pthread_mutex_lock(&pdata->libogg_mutex); @@ -149,8 +167,12 @@ void *FlushToOgg(ProgData *pdata){ ogg_page_cp_free(&videopage_copy); } else{ - audio_bytesout+=fwrite(audiopage_copy.header,1,audiopage_copy.header_len,pdata->enc_data->fp); - audio_bytesout+=fwrite(audiopage_copy.body,1,audiopage_copy.body_len,pdata->enc_data->fp); + audio_bytesout+=fwrite(audiopage_copy.header,1, + audiopage_copy.header_len, + pdata->enc_data->fp); + audio_bytesout+=fwrite(audiopage_copy.body,1, + audiopage_copy.body_len, + pdata->enc_data->fp); audioflag=0; if(!pdata->running){ pthread_mutex_lock(&pdata->libogg_mutex); @@ -172,6 +194,10 @@ void *FlushToOgg(ProgData *pdata){ // theora_clear(&pdata->enc_data->m_th_st); if(pdata->enc_data->fp)fclose(pdata->enc_data->fp); - fprintf(stderr,"\r \nDone.\nWritten %.0f bytes\n(%.0f of which were video data and %.0f audio data)\n\n",video_bytesout+audio_bytesout,video_bytesout,audio_bytesout); + fprintf(stderr,"\r \nDone.\nWritten %.0f bytes\n" + "(%.0f of which were video data " + "and %.0f audio data)\n\n", + video_bytesout+audio_bytesout, + video_bytesout,audio_bytesout); pthread_exit(&errno); } diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index 83e3058..425049b 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -85,8 +85,12 @@ void *GetFrame(ProgData *pdata){ //update previous_position //(if full_shots is enabled this is skipped since it's pointless) if(!pdata->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin, + &mouse_pos_temp); + if((mouse_pos_temp.x>=0)&& + (mouse_pos_temp.y>=0)&& + (mouse_pos_temp.width>0)&& + (mouse_pos_temp.height>0)) RectInsert(&pdata->rect_root[tlist_sel],&mouse_pos_temp); } xcim=XFixesGetCursorImage(pdata->dpy); @@ -100,8 +104,12 @@ void *GetFrame(ProgData *pdata){ //update previous_position //(if full_shots is enabled this is skipped since it's pointless) if(!pdata->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin, + &mouse_pos_temp); + if((mouse_pos_temp.x>=0)&& + (mouse_pos_temp.y>=0)&& + (mouse_pos_temp.width>0)&& + (mouse_pos_temp.height>0)) RectInsert(&pdata->rect_root[tlist_sel],&mouse_pos_temp); } //find new one @@ -112,7 +120,9 @@ void *GetFrame(ProgData *pdata){ &mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret); } if(!pdata->args.noshared) - XShmGetImage(pdata->dpy,pdata->specs.root,pdata->shimage,(pdata->brwin.rgeom.x),(pdata->brwin.rgeom.y),AllPlanes); + XShmGetImage(pdata->dpy,pdata->specs.root,pdata->shimage, + (pdata->brwin.rgeom.x), + (pdata->brwin.rgeom.y),AllPlanes); if(!pdata->args.full_shots) UpdateImage(pdata->dpy, &pdata->enc_data->yuv, @@ -121,7 +131,9 @@ void *GetFrame(ProgData *pdata){ &pdata->rect_root[tlist_sel], &pdata->brwin, pdata->enc_data, - ((pdata->args.noshared)?(pdata->datatemp):pdata->shimage->data), + ((pdata->args.noshared)? + (pdata->datatemp): + (pdata->shimage->data)), pdata->args.noshared, pdata->args.no_quick_subsample); else{ @@ -151,15 +163,24 @@ void *GetFrame(ProgData *pdata){ } if(pdata->args.xfixes_cursor){ //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin, + &mouse_pos_temp); //draw the cursor - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ - XFIXES_POINTER_TO_YUV((&pdata->enc_data->yuv),((unsigned char*)xcim->pixels), - (mouse_pos_temp.x-pdata->brwin.rgeom.x+pdata->enc_data->x_offset), - (mouse_pos_temp.y-pdata->brwin.rgeom.y+pdata->enc_data->y_offset), - mouse_pos_temp.width, - mouse_pos_temp.height, - (xcim->width-mouse_pos_temp.width)); + if((mouse_pos_temp.x>=0)&& + (mouse_pos_temp.y>=0)&& + (mouse_pos_temp.width>0)&& + (mouse_pos_temp.height>0)){ + XFIXES_POINTER_TO_YUV((&pdata->enc_data->yuv), + ((unsigned char*)xcim->pixels), + (mouse_pos_temp.x- + pdata->brwin.rgeom.x+ + pdata->enc_data->x_offset), + (mouse_pos_temp.y- + pdata->brwin.rgeom.y+ + pdata->enc_data->y_offset), + mouse_pos_temp.width, + mouse_pos_temp.height, + (xcim->width-mouse_pos_temp.width)); } XFree(xcim); xcim=NULL; @@ -167,16 +188,24 @@ void *GetFrame(ProgData *pdata){ if(pdata->args.have_dummy_cursor){ //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin, + &mouse_pos_temp); //draw the cursor - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ + if((mouse_pos_temp.x>=0)&& + (mouse_pos_temp.y>=0)&& + (mouse_pos_temp.width>0)&& + (mouse_pos_temp.height>0)){ DUMMY_POINTER_TO_YUV((&pdata->enc_data->yuv), - pdata->dummy_pointer, - (mouse_pos_temp.x-pdata->brwin.rgeom.x+pdata->enc_data->x_offset), - (mouse_pos_temp.y-pdata->brwin.rgeom.y+pdata->enc_data->y_offset), - mouse_pos_temp.width, - mouse_pos_temp.height, - pdata->npxl); + pdata->dummy_pointer, + (mouse_pos_temp.x- + pdata->brwin.rgeom.x+ + pdata->enc_data->x_offset), + (mouse_pos_temp.y- + pdata->brwin.rgeom.y+ + pdata->enc_data->y_offset), + mouse_pos_temp.width, + mouse_pos_temp.height, + pdata->npxl); } } if(!pdata->args.full_shots){ diff --git a/recordmydesktop/src/getzpixmap.c b/recordmydesktop/src/getzpixmap.c index 4a7a7de..6deaf15 100644 --- a/recordmydesktop/src/getzpixmap.c +++ b/recordmydesktop/src/getzpixmap.c @@ -1,37 +1,43 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int height) { +int GetZPixmap(Display *dpy, + Window root, + char *data, + int x, + int y, + int width, + int height){ xGetImageReply reply; xGetImageReq *request; long nbytes; - + LockDisplay(dpy); GetReq(GetImage,request); request->drawable=root; @@ -52,4 +58,4 @@ int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int hei SyncHandle(); return 0; } - + diff --git a/recordmydesktop/src/init_encoder.c b/recordmydesktop/src/init_encoder.c index 618c790..34775fd 100644 --- a/recordmydesktop/src/init_encoder.c +++ b/recordmydesktop/src/init_encoder.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -34,7 +34,8 @@ int IncrementalNaming(char **name){ base_name__=malloc(strlen(*name)+1); strcpy(base_name__,*name); - //this will go on an endless loop if you have 65536? files with the same name + //this will go on an endless loop if you have 65536? + //files with the same name //or it will crash and die.anyone interested in trying ? while (stat(*name,&buff)==0){ //create new name @@ -66,75 +67,87 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ y2=rand(); y2+=(y1==y2); - ogg_stream_init(&(enc_data_t)->m_ogg_ts,y1); + ogg_stream_init(&enc_data_t->m_ogg_ts,y1); if(!pdata->args.nosound) - ogg_stream_init(&(enc_data_t)->m_ogg_vs,y2); + ogg_stream_init(&enc_data_t->m_ogg_vs,y2); if(!pdata->args.overwrite) IncrementalNaming(&(pdata)->args.filename); - (enc_data_t)->fp=fopen((pdata)->args.filename,"w"); - if((enc_data_t)->fp==NULL){ - fprintf(stderr,"Cannot open file %s for writting!\n",(pdata)->args.filename); + enc_data_t->fp=fopen((pdata)->args.filename,"w"); + if(enc_data_t->fp==NULL){ + fprintf(stderr,"Cannot open file %s for writting!\n", + (pdata)->args.filename); exit(13); } - theora_info_init(&(enc_data_t)->m_th_inf); - (enc_data_t)->m_th_inf.frame_width=(pdata)->brwin.rgeom.width; - (enc_data_t)->m_th_inf.frame_height=(pdata)->brwin.rgeom.height; - (enc_data_t)->m_th_inf.width=(((enc_data_t)->m_th_inf.frame_width + 15) >>4)<<4; - (enc_data_t)->m_th_inf.height=(((enc_data_t)->m_th_inf.frame_height + 15) >>4)<<4; - (enc_data_t)->m_th_inf.offset_x=(((enc_data_t)->m_th_inf.width-(enc_data_t)->m_th_inf.frame_width)/2)&~1; - (enc_data_t)->m_th_inf.offset_y=(((enc_data_t)->m_th_inf.height-(enc_data_t)->m_th_inf.frame_height)/2)&~1; - (enc_data_t)->m_th_inf.fps_numerator=((pdata)->args.fps*100.0); - (enc_data_t)->m_th_inf.fps_denominator=100; - (enc_data_t)->m_th_inf.aspect_numerator=1;//(pdata)->brwin.rgeom.width; - (enc_data_t)->m_th_inf.aspect_denominator=1;//(pdata)->brwin.rgeom.height; - (enc_data_t)->m_th_inf.colorspace=OC_CS_UNSPECIFIED; - (enc_data_t)->m_th_inf.pixelformat=OC_PF_420; - (enc_data_t)->m_th_inf.target_bitrate=(pdata)->args.v_bitrate; - (enc_data_t)->m_th_inf.quality=(pdata)->args.v_quality; - (enc_data_t)->m_th_inf.dropframes_p=(pdata)->args.dropframes; - (enc_data_t)->m_th_inf.quick_p=1; - (enc_data_t)->m_th_inf.keyframe_auto_p=1; - (enc_data_t)->m_th_inf.keyframe_frequency=64; - (enc_data_t)->m_th_inf.keyframe_frequency_force=64; - (enc_data_t)->m_th_inf.keyframe_data_target_bitrate=(enc_data_t)->m_th_inf.quality*1.5; - (enc_data_t)->m_th_inf.keyframe_auto_threshold=80; - (enc_data_t)->m_th_inf.keyframe_mindistance=8; - (enc_data_t)->m_th_inf.noise_sensitivity=1; - (enc_data_t)->m_th_inf.sharpness=2; - - theora_encode_init(&(enc_data_t)->m_th_st,&(enc_data_t)->m_th_inf); + theora_info_init(&enc_data_t->m_th_inf); + enc_data_t->m_th_inf.frame_width=(pdata)->brwin.rgeom.width; + enc_data_t->m_th_inf.frame_height=(pdata)->brwin.rgeom.height; + enc_data_t->m_th_inf.width=((enc_data_t->m_th_inf.frame_width+15)>>4)<<4; + enc_data_t->m_th_inf.height=((enc_data_t->m_th_inf.frame_height+15)>>4)<<4; + enc_data_t->m_th_inf.offset_x=((enc_data_t->m_th_inf.width- + enc_data_t->m_th_inf.frame_width)/2)&~1; + enc_data_t->m_th_inf.offset_y=((enc_data_t->m_th_inf.height- + enc_data_t->m_th_inf.frame_height)/2)&~1; + enc_data_t->m_th_inf.fps_numerator=((pdata)->args.fps*100.0); + enc_data_t->m_th_inf.fps_denominator=100; + enc_data_t->m_th_inf.aspect_numerator=1;//(pdata)->brwin.rgeom.width; + enc_data_t->m_th_inf.aspect_denominator=1;//(pdata)->brwin.rgeom.height; + enc_data_t->m_th_inf.colorspace=OC_CS_UNSPECIFIED; + enc_data_t->m_th_inf.pixelformat=OC_PF_420; + enc_data_t->m_th_inf.target_bitrate=(pdata)->args.v_bitrate; + enc_data_t->m_th_inf.quality=(pdata)->args.v_quality; + enc_data_t->m_th_inf.dropframes_p=(pdata)->args.dropframes; + enc_data_t->m_th_inf.quick_p=1; + enc_data_t->m_th_inf.keyframe_auto_p=1; + enc_data_t->m_th_inf.keyframe_frequency=64; + enc_data_t->m_th_inf.keyframe_frequency_force=64; + enc_data_t->m_th_inf.keyframe_data_target_bitrate= + enc_data_t->m_th_inf.quality*1.5; + + enc_data_t->m_th_inf.keyframe_auto_threshold=80; + enc_data_t->m_th_inf.keyframe_mindistance=8; + enc_data_t->m_th_inf.noise_sensitivity=1; + enc_data_t->m_th_inf.sharpness=2; + + theora_encode_init(&enc_data_t->m_th_st,&enc_data_t->m_th_inf); if(!pdata->args.nosound){ int ret; - vorbis_info_init(&(enc_data_t)->m_vo_inf); - ret = vorbis_encode_init_vbr(&(enc_data_t)->m_vo_inf,pdata->args.channels,pdata->args.frequency,(float)pdata->args.s_quality*0.1); + vorbis_info_init(&enc_data_t->m_vo_inf); + ret = vorbis_encode_init_vbr(&enc_data_t->m_vo_inf, + pdata->args.channels, + pdata->args.frequency, + (float)pdata->args.s_quality*0.1); if(ret){ fprintf(stderr,"Error while setting up vorbis stream quality!\n"); exit(2); } - vorbis_comment_init(&(enc_data_t)->m_vo_cmmnt); - vorbis_analysis_init(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_inf); - vorbis_block_init(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_block); + vorbis_comment_init(&enc_data_t->m_vo_cmmnt); + vorbis_analysis_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_inf); + vorbis_block_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_block); } - theora_encode_header(&(enc_data_t)->m_th_st,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); - if(ogg_stream_pageout(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pg)!=1){ + theora_encode_header(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1); + ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); + if(ogg_stream_pageout(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pg)!=1){ fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); + fwrite(enc_data_t->m_ogg_pg.header,1, + enc_data_t->m_ogg_pg.header_len, + enc_data_t->fp); + fwrite(enc_data_t->m_ogg_pg.body,1, + enc_data_t->m_ogg_pg.body_len, + enc_data_t->fp); - theora_comment_init(&(enc_data_t)->m_th_cmmnt); - theora_comment_add_tag(&(enc_data_t)->m_th_cmmnt,"recordMyDesktop",VERSION); - theora_encode_comment(&(enc_data_t)->m_th_cmmnt,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); - theora_encode_tables(&(enc_data_t)->m_th_st,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); + theora_comment_init(&enc_data_t->m_th_cmmnt); + theora_comment_add_tag(&enc_data_t->m_th_cmmnt,"recordMyDesktop",VERSION); + theora_encode_comment(&enc_data_t->m_th_cmmnt,&enc_data_t->m_ogg_pckt1); + ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); + theora_encode_tables(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1); + ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); if(!pdata->args.nosound){ @@ -142,61 +155,81 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ ogg_packet header_comm; ogg_packet header_code; - vorbis_analysis_headerout(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_cmmnt,&header,&header_comm,&header_code); - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header); - if(ogg_stream_pageout(&(enc_data_t)->m_ogg_vs,&(enc_data_t)->m_ogg_pg)!=1){ + vorbis_analysis_headerout(&enc_data_t->m_vo_dsp, + &enc_data_t->m_vo_cmmnt, + &header,&header_comm, + &header_code); + ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header); + if(ogg_stream_pageout(&enc_data_t->m_ogg_vs,&enc_data_t->m_ogg_pg)!=1){ fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); - - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header_comm); - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header_code); + fwrite(enc_data_t->m_ogg_pg.header,1, + enc_data_t->m_ogg_pg.header_len, + enc_data_t->fp); + fwrite(enc_data_t->m_ogg_pg.body,1, + enc_data_t->m_ogg_pg.body_len, + enc_data_t->fp); + + ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header_comm); + ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header_code); } while(1){ - int result = ogg_stream_flush(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pg); + int result = ogg_stream_flush(&enc_data_t->m_ogg_ts, + &enc_data_t->m_ogg_pg); if(result<0){ fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } if(result==0)break; - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); + fwrite(enc_data_t->m_ogg_pg.header,1, + enc_data_t->m_ogg_pg.header_len, + enc_data_t->fp); + fwrite(enc_data_t->m_ogg_pg.body,1, + enc_data_t->m_ogg_pg.body_len, + enc_data_t->fp); } if(!pdata->args.nosound){ while(1){ - int result=ogg_stream_flush(&(enc_data_t)->m_ogg_vs,&(enc_data_t)->m_ogg_pg); + int result=ogg_stream_flush(&enc_data_t->m_ogg_vs, + &enc_data_t->m_ogg_pg); if(result<0){ fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } if(result==0)break; - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); + fwrite(enc_data_t->m_ogg_pg.header,1, + enc_data_t->m_ogg_pg.header_len, + enc_data_t->fp); + fwrite(enc_data_t->m_ogg_pg.body,1, + enc_data_t->m_ogg_pg.body_len, + enc_data_t->fp); } } if(!buffer_ready){ - (enc_data_t)->yuv.y=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width); - (enc_data_t)->yuv.u=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width/4); - (enc_data_t)->yuv.v=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width/4); - (enc_data_t)->yuv.y_width=(enc_data_t)->m_th_inf.width; - (enc_data_t)->yuv.y_height=(enc_data_t)->m_th_inf.height; - (enc_data_t)->yuv.y_stride=(enc_data_t)->m_th_inf.width; - - (enc_data_t)->yuv.uv_width=(enc_data_t)->m_th_inf.width/2; - (enc_data_t)->yuv.uv_height=(enc_data_t)->m_th_inf.height/2; - (enc_data_t)->yuv.uv_stride=(enc_data_t)->m_th_inf.width/2; - (enc_data_t)->x_offset=(enc_data_t)->m_th_inf.offset_x; - (enc_data_t)->y_offset=(enc_data_t)->m_th_inf.offset_y; + enc_data_t->yuv.y=(unsigned char *)malloc(enc_data_t->m_th_inf.height* + enc_data_t->m_th_inf.width); + enc_data_t->yuv.u=(unsigned char *)malloc(enc_data_t->m_th_inf.height* + enc_data_t->m_th_inf.width/4); + enc_data_t->yuv.v=(unsigned char *)malloc(enc_data_t->m_th_inf.height* + enc_data_t->m_th_inf.width/4); + enc_data_t->yuv.y_width=enc_data_t->m_th_inf.width; + enc_data_t->yuv.y_height=enc_data_t->m_th_inf.height; + enc_data_t->yuv.y_stride=enc_data_t->m_th_inf.width; + + enc_data_t->yuv.uv_width=enc_data_t->m_th_inf.width/2; + enc_data_t->yuv.uv_height=enc_data_t->m_th_inf.height/2; + enc_data_t->yuv.uv_stride=enc_data_t->m_th_inf.width/2; + enc_data_t->x_offset=enc_data_t->m_th_inf.offset_x; + enc_data_t->y_offset=enc_data_t->m_th_inf.offset_y; } - theora_info_clear(&(enc_data_t)->m_th_inf); + theora_info_clear(&enc_data_t->m_th_inf); } diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 93f7858..4830c83 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -40,7 +40,9 @@ int InitializeData(ProgData *pdata, fprintf(stderr,"Initializing...\n"); MakeMatrices(); if(pdata->args.have_dummy_cursor){ - pdata->dummy_pointer=MakeDummyPointer(&pdata->specs,16,pdata->args.cursor_color,0,&pdata->npxl); + pdata->dummy_pointer=MakeDummyPointer(&pdata->specs,16, + pdata->args.cursor_color,0, + &pdata->npxl); pdata->dummy_p_size=16; } @@ -72,25 +74,49 @@ int InitializeData(ProgData *pdata, Running=&pdata->running; if((pdata->args.noshared)){ - pdata->image=XCreateImage(pdata->dpy, pdata->specs.visual, pdata->specs.depth, ZPixmap, 0,pdata->datamain,pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height, 8, 0); + pdata->image=XCreateImage(pdata->dpy, + pdata->specs.visual, + pdata->specs.depth, + ZPixmap, + 0, + pdata->datamain, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height, + 8, + 0); XInitImage(pdata->image); - GetZPixmap(pdata->dpy,pdata->specs.root,pdata->image->data,pdata->brwin.rgeom.x,pdata->brwin.rgeom.y, - pdata->brwin.rgeom.width,pdata->brwin.rgeom.height); + GetZPixmap(pdata->dpy,pdata->specs.root, + pdata->image->data, + pdata->brwin.rgeom.x, + pdata->brwin.rgeom.y, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height); } if((!pdata->args.noshared)||(!pdata->args.nocondshared)){ - pdata->shimage=XShmCreateImage (pdata->dpy,pdata->specs.visual,pdata->specs.depth,ZPixmap,pdata->datash, - &pdata->shminfo, pdata->brwin.rgeom.width,pdata->brwin.rgeom.height); - pdata->shminfo.shmid = shmget (IPC_PRIVATE, - pdata->shimage->bytes_per_line * pdata->shimage->height, - IPC_CREAT|0777); - pdata->shminfo.shmaddr = pdata->shimage->data = shmat (pdata->shminfo.shmid, 0, 0); + pdata->shimage=XShmCreateImage(pdata->dpy, + pdata->specs.visual, + pdata->specs.depth, + ZPixmap,pdata->datash, + &pdata->shminfo, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height); + pdata->shminfo.shmid=shmget (IPC_PRIVATE, + pdata->shimage->bytes_per_line* + pdata->shimage->height, + IPC_CREAT|0777); + pdata->shminfo.shmaddr=pdata->shimage->data=shmat(pdata->shminfo.shmid, + 0,0); pdata->shminfo.readOnly = False; if(!XShmAttach(pdata->dpy,&pdata->shminfo)){ fprintf(stderr,"Failed to attach shared memory to proccess.\n"); return 12; } - XShmGetImage(pdata->dpy,pdata->specs.root,pdata->shimage,pdata->brwin.rgeom.x,pdata->brwin.rgeom.y,AllPlanes); + XShmGetImage(pdata->dpy, + pdata->specs.root, + pdata->shimage, + pdata->brwin.rgeom.x, + pdata->brwin.rgeom.y, + AllPlanes); } if(!pdata->args.nosound){ pdata->sound_handle=OpenDev( pdata->args.device, @@ -101,7 +127,10 @@ int InitializeData(ProgData *pdata, &pdata->periodtime, &pdata->hard_pause); if(pdata->sound_handle==NULL){ - fprintf(stderr,"Error while opening/configuring soundcard %s\nTry running with the --no-sound or specify a correct device.\n",pdata->args.device); + fprintf(stderr,"Error while opening/configuring soundcard %s\n" + "Try running with the --no-sound or specify a " + "correct device.\n", + pdata->args.device); return 3; } } @@ -113,7 +142,9 @@ int InitializeData(ProgData *pdata, for(i=0;i<(pdata->enc_data->yuv.y_width*pdata->enc_data->yuv.y_height);i++) pdata->enc_data->yuv.y[i]=0; - for(i=0;i<(pdata->enc_data->yuv.uv_width*pdata->enc_data->yuv.uv_height);i++){ + for(i=0; + i<(pdata->enc_data->yuv.uv_width*pdata->enc_data->yuv.uv_height); + i++){ pdata->enc_data->yuv.v[i]=pdata->enc_data->yuv.u[i]=127; } diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c index 7693774..c9fc96b 100644 --- a/recordmydesktop/src/load_cache.c +++ b/recordmydesktop/src/load_cache.c @@ -1,39 +1,45 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -void LoadBlock(unsigned char *dest,unsigned char *source,int blockno,int width, int height,int divisor){ +void LoadBlock(unsigned char *dest, + unsigned char *source, + int blockno, + int width, + int height, + int divisor){ int j, block_i=blockno/divisor,//place on the grid block_k=blockno%divisor; for(j=0;j<height/divisor;j++)//we copy rows - memcpy( &dest[block_i*(width*height/divisor)+j*width+block_k*width/divisor], + memcpy( &dest[block_i*(width*height/divisor)+ + j*width+block_k*width/divisor], &source[j*width/divisor], width/divisor); } @@ -58,7 +64,8 @@ void *LoadCache(ProgData *pdata){ divisor=16, blockszy=0,//size of y plane block in bytes blockszuv=0,//size of u,v plane blocks in bytes - framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*pdata->args.channels;//audio frame size + framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)* + pdata->args.channels;//audio frame size signed char *sound_data=(signed char *)malloc(pdata->periodsize*framesize); //we allocate the frame that we will use @@ -106,11 +113,13 @@ void *LoadCache(ProgData *pdata){ SyncEncodeImageBuffer(pdata); } else if(((!pdata->args.zerocompression)&& - (gzread(ifp,frame.header,sizeof(FrameHeader))==sizeof(FrameHeader) ))|| + (gzread(ifp,frame.header,sizeof(FrameHeader))== + sizeof(FrameHeader) ))|| ((pdata->args.zerocompression)&& (fread(frame.header,sizeof(FrameHeader),1,ucfp)==1))){ //sync - missing_frames+=frame.header->current_total-(extra_frames+frame.header->frameno); + missing_frames+=frame.header->current_total- + (extra_frames+frame.header->frameno); fprintf(stdout,"\r[%d%%] ", ((frame.header->frameno+extra_frames)*100)/frames_total); @@ -121,21 +130,35 @@ void *LoadCache(ProgData *pdata){ ( ((!pdata->args.zerocompression)&& - ((gzread(ifp,frame.YBlocks,frame.header->Ynum)==frame.header->Ynum) && - (gzread(ifp,frame.UBlocks,frame.header->Unum)==frame.header->Unum) && - (gzread(ifp,frame.VBlocks,frame.header->Vnum)==frame.header->Vnum) && - (gzread(ifp,frame.YData,blockszy*frame.header->Ynum)==blockszy*frame.header->Ynum) && - (gzread(ifp,frame.UData,(blockszuv*frame.header->Unum))==(blockszuv*frame.header->Unum)) && - (gzread(ifp,frame.VData,(blockszuv*frame.header->Vnum))==(blockszuv*frame.header->Vnum)))) || + ((gzread(ifp,frame.YBlocks,frame.header->Ynum)== + frame.header->Ynum) && + (gzread(ifp,frame.UBlocks,frame.header->Unum)== + frame.header->Unum) && + (gzread(ifp,frame.VBlocks,frame.header->Vnum)== + frame.header->Vnum) && + (gzread(ifp,frame.YData,blockszy*frame.header->Ynum)== + blockszy*frame.header->Ynum) && + (gzread(ifp,frame.UData,(blockszuv*frame.header->Unum))== + (blockszuv*frame.header->Unum)) && + (gzread(ifp,frame.VData,(blockszuv*frame.header->Vnum))== + (blockszuv*frame.header->Vnum)))) || ((pdata->args.zerocompression)&& - ((fread(frame.YBlocks,1,frame.header->Ynum,ucfp)==frame.header->Ynum) && - (fread(frame.UBlocks,1,frame.header->Unum,ucfp)==frame.header->Unum) && - (fread(frame.VBlocks,1,frame.header->Vnum,ucfp)==frame.header->Vnum) && - (frame.header->Ynum==0 ||fread(frame.YData,blockszy,frame.header->Ynum,ucfp)==frame.header->Ynum) && - (frame.header->Unum==0 ||fread(frame.UData,blockszuv,frame.header->Unum,ucfp)==frame.header->Unum) && - (frame.header->Vnum==0 ||fread(frame.VData,blockszuv,frame.header->Vnum,ucfp)==frame.header->Vnum))) - + ((fread(frame.YBlocks,1,frame.header->Ynum,ucfp)== + frame.header->Ynum) && + (fread(frame.UBlocks,1,frame.header->Unum,ucfp)== + frame.header->Unum) && + (fread(frame.VBlocks,1,frame.header->Vnum,ucfp)== + frame.header->Vnum) && + (frame.header->Ynum==0 || + fread(frame.YData,blockszy,frame.header->Ynum,ucfp)== + frame.header->Ynum) && + (frame.header->Unum==0 || + fread(frame.UData,blockszuv,frame.header->Unum,ucfp)== + frame.header->Unum) && + (frame.header->Vnum==0 || + fread(frame.VData,blockszuv,frame.header->Vnum,ucfp)== + frame.header->Vnum))) ) ){ //load the blocks for each buffer @@ -163,8 +186,10 @@ void *LoadCache(ProgData *pdata){ yuv->uv_width, yuv->uv_height, divisor/2); - //encode. This is not made in a thread since now blocking is not a problem - //and this way sync problems can be avoided more easily. + //encode. This is not made in a thread since + //now blocking is not a problem + //and this way sync problems + //can be avoided more easily. SyncEncodeImageBuffer(pdata); } else{ @@ -173,7 +198,10 @@ void *LoadCache(ProgData *pdata){ } } else{ - if(SwapCacheFilesRead(pdata->cache_data->imgdata,nth_cache,&ifp,&ucfp)){ + if(SwapCacheFilesRead(pdata->cache_data->imgdata, + nth_cache, + &ifp, + &ucfp)){ raise(SIGINT); } else{ diff --git a/recordmydesktop/src/make_dummy_pointer.c b/recordmydesktop/src/make_dummy_pointer.c index 00a346e..9e0ad3a 100644 --- a/recordmydesktop/src/make_dummy_pointer.c +++ b/recordmydesktop/src/make_dummy_pointer.c @@ -1,33 +1,36 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type,unsigned char *npxl){ +unsigned char *MakeDummyPointer(DisplaySpecs *specs, + int size, + int color, + int type, + unsigned char *npxl){ int i,k,o='.'; unsigned long b=(color)?'w':'b', w=(color)?'b':'w'; @@ -65,12 +68,20 @@ unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type, *npxl=((wp[0]-1)!=bp[0])?wp[0]-100:wp[0]-102; for(i=0;i<size;i++){ for(k=0;k<size;k++){ - ret[(i*size+k)*4+__ABYTE]=(pmask[type][i][k]=='w')?wp[0]:(pmask[type][i][k]=='b')?bp[0]:*npxl; - ret[(i*size+k)*4+__RBYTE]=(pmask[type][i][k]=='w')?wp[1]:(pmask[type][i][k]=='b')?bp[1]:*npxl; - ret[(i*size+k)*4+__GBYTE]=(pmask[type][i][k]=='w')?wp[2]:(pmask[type][i][k]=='b')?bp[2]:*npxl; - ret[(i*size+k)*4+__BBYTE]=(pmask[type][i][k]=='w')?wp[3]:(pmask[type][i][k]=='b')?bp[3]:*npxl; + ret[(i*size+k)*4+__ABYTE]=(pmask[type][i][k]=='w')? + wp[0]:(pmask[type][i][k]=='b')? + bp[0]:*npxl; + ret[(i*size+k)*4+__RBYTE]=(pmask[type][i][k]=='w')? + wp[1]:(pmask[type][i][k]=='b')? + bp[1]:*npxl; + ret[(i*size+k)*4+__GBYTE]=(pmask[type][i][k]=='w')? + wp[2]:(pmask[type][i][k]=='b')? + bp[2]:*npxl; + ret[(i*size+k)*4+__BBYTE]=(pmask[type][i][k]=='w')? + wp[3]:(pmask[type][i][k]=='b')? + bp[3]:*npxl; } } - + return ret; } diff --git a/recordmydesktop/src/opendev.c b/recordmydesktop/src/opendev.c index 6e13933..5fc24f7 100644 --- a/recordmydesktop/src/opendev.c +++ b/recordmydesktop/src/opendev.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ @@ -45,7 +45,7 @@ snd_pcm_t *OpenDev( const char *pcm_dev, snd_pcm_hw_params_alloca(&hwparams); - if (snd_pcm_open(&mhandle, pcm_dev, SND_PCM_STREAM_CAPTURE, SND_PCM_ASYNC)<0){ + if (snd_pcm_open(&mhandle,pcm_dev,SND_PCM_STREAM_CAPTURE,SND_PCM_ASYNC)<0){ fprintf(stderr, "Couldn't open PCM device %s\n", pcm_dev); return NULL; } @@ -55,11 +55,15 @@ snd_pcm_t *OpenDev( const char *pcm_dev, fprintf(stderr, "Couldn't configure PCM device.\n"); return NULL; } - if (snd_pcm_hw_params_set_access(mhandle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)<0) { + if (snd_pcm_hw_params_set_access(mhandle, + hwparams, + SND_PCM_ACCESS_RW_INTERLEAVED)<0){ fprintf(stderr, "Couldn't set access.\n"); return NULL; } - if (snd_pcm_hw_params_set_format(mhandle, hwparams, SND_PCM_FORMAT_S16_LE)<0){ + if (snd_pcm_hw_params_set_format(mhandle, + hwparams, + SND_PCM_FORMAT_S16_LE)<0){ fprintf(stderr, "Couldn't set format.\n"); return NULL; } @@ -68,7 +72,8 @@ snd_pcm_t *OpenDev( const char *pcm_dev, return NULL; } if (*frequency != exactrate){ - fprintf(stderr, "Playback frequency %dHz is not available...\nUsing %dHz instead.\n",*frequency,exactrate); + fprintf(stderr, "Playback frequency %dHz is not available...\n" + "Using %dHz instead.\n",*frequency,exactrate); *frequency=exactrate; } if (snd_pcm_hw_params_set_channels_near(mhandle, hwparams, channels)<0){ @@ -79,16 +84,16 @@ snd_pcm_t *OpenDev( const char *pcm_dev, fprintf(stderr,"Channels number should be 1(mono) or 2(stereo).\n"); return NULL; } - if (snd_pcm_hw_params_set_periods_near(mhandle, hwparams, &periods,0)<0) { + if (snd_pcm_hw_params_set_periods_near(mhandle,hwparams,&periods,0)<0){ fprintf(stderr, "Couldn't set periods.\n"); return NULL; } - if (snd_pcm_hw_params_set_buffer_size_near(mhandle, hwparams,buffsize)<0){ + if (snd_pcm_hw_params_set_buffer_size_near(mhandle,hwparams,buffsize)<0){ fprintf(stderr, "Couldn't set buffer size.\n"); return NULL; } - if (snd_pcm_hw_params(mhandle, hwparams)<0){ + if (snd_pcm_hw_params(mhandle,hwparams)<0){ fprintf(stderr, "Couldn't set hardware parameters.\n"); return NULL; } @@ -101,7 +106,8 @@ snd_pcm_t *OpenDev( const char *pcm_dev, if(periodtime!=NULL) snd_pcm_hw_params_get_period_time(hwparams,periodtime,0); - fprintf(stderr,"Recording on device %s is set to:\n%d channels at %dHz\n",pcm_dev,*channels,*frequency); + fprintf(stderr,"Recording on device %s is set to:\n%d channels at %dHz\n", + pcm_dev,*channels,*frequency); fprintf(stderr,"Buffer size set to %d frames.\n",(int)(*buffsize)); snd_pcm_prepare(mhandle); diff --git a/recordmydesktop/src/parseargs.c b/recordmydesktop/src/parseargs.c index 7340110..36dbbea 100644 --- a/recordmydesktop/src/parseargs.c +++ b/recordmydesktop/src/parseargs.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -31,12 +31,18 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ int i; char *usage="\nUsage:\n" - "\trecordmydesktop [-h| --help| --version| -delay n[H|h|M|m]| -windowid id_of_window|\n" - "\t-display DISPLAY| -x X| -y Y|-width N| -height N| -fps N(number>0)| --on-the-fly-encoding|\n" - "\t -v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color|\n" - "\t --no-cursor| -freq N(number>0)| -channels N(number>0)|-buffer-size N(number>0)| -device SOUND_DEVICE|\n" - "\t --no-sound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|\n" - "\t --quick-subsampling| -workdir DIR| --zero-compression| --no-wm-check| --overwite| -o filename]^filename\n\n\n" + "\trecordmydesktop [-h| --help| --version|" + " -delay n[H|h|M|m]| -windowid id_of_window|\n" + "\t-display DISPLAY| -x X| -y Y|-width N| -height N|" + " -fps N(number>0)| --on-the-fly-encoding|\n" + "\t -v_quality n| -s_quality n| -v_bitrate n| --no-framedrop|" + " -dummy-cursor color|\n" + "\t --no-cursor| -freq N(number>0)| -channels N(number>0)|" + " -buffer-size N(number>0)| -device SOUND_DEVICE|\n" + "\t --no-sound| --with-shared| --no-cond-shared| -shared-threshold n|" + " --full-shots|\n" + "\t --quick-subsampling| -workdir DIR| --zero-compression| --no-wm-check|" + " --overwite| -o filename]^filename\n\n\n" "General Options:\n" "\t-h or --help\t\tPrint this help and exit.\n" @@ -52,36 +58,61 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ "\t-dummy-cursor color\tColor of the dummy cursor [black|white]\n" "\t--no-cursor\t\tDisable drawing of the cursor.\n" - "\t--with-shared\t\tEnable usage of MIT-shared memory extension at all times.\n" - "\t--no-cond-shared\tDo not use the MIT-shared memory extension when aquiring large areas.\n" - "\t-shared-threshold n\tThreshold over which shared memory is used(default 75).\n" + "\t--with-shared\t\tEnable usage of" + " MIT-shared memory extension at all times.\n" + + "\t--no-cond-shared\tDo not use" + " the MIT-shared memory extension when aquiring large areas.\n" + + "\t-shared-threshold n\tThreshold over" + " which shared memory is used(default 75).\n" + "\t--full-shots\t\tTake full screenshot at every frame(Not recomended!).\n" - "\t--quick-subsampling\tDo subsampling of the chroma planes by discarding,not averaging.\n" + "\t--quick-subsampling\tDo subsampling" + " of the chroma planes by discarding,not averaging.\n" + "\t-fps N(number>0.0)\tA positive number denoting desired framerate.\n\n" "Sound Options:\n" - "\t-channels N\t\tA positive number denoting desired sound channels in recording.\n" + "\t-channels N\t\tA positive number denoting" + " desired sound channels in recording.\n" + "\t-freq N\t\t\tA positive number denoting desired sound frequency.\n" - "\t-buffer-size N\t\tA positive number denoting the desired sound buffer size(in frames)\n" + "\t-buffer-size N\t\tA positive number denoting the desired" + " sound buffer size(in frames)\n" + "\t-device SOUND_DEVICE\tSound device(default hw0:0).\n" "\t--no-sound\t\tDo not record sound.\n\n" "Encoding Options\n" "\t--on-the-fly-encoding\tEncode the audio-video data, while recording.\n" - "\t-v_quality n\t\tA number from 0 to 63 for desired encoded video quality(default 63).\n" - "\t-v_bitrate n\t\tA number from 45000 to 2000000 for desired encoded video bitrate(default 45000).\n" + "\t-v_quality n\t\tA number from 0 to 63 for" + " desired encoded video quality(default 63).\n" + + "\t-v_bitrate n\t\tA number from 45000 to 2000000" + " for desired encoded video bitrate(default 45000).\n" + "\t--drop-frames\t\tAllow theora encoder to drop frames.\n" "\t-s_quality n\t\tDesired audio quality(-1 to 10).\n\n" "Misc Options:\n" - "\t--no-wm-check\t\tDo not try to detect the window manager(and set options according to it)\n" + "\t--no-wm-check\t\tDo not try to detect" + " the window manager(and set options according to it)\n" + "\t--zero-compression\tImage data are always cached uncompressed.\n" - "\t-workdir DIR\t\tLocation where a temporary directory will be created to hold project files(default $HOME).\n" - "\t-delay n[H|h|M|m]\tNumber of secs(default),minutes or hours before capture starts(number can be float)\n" - "\t--overwrite\t\tIf there is already a file with the same name, delete it\n" + "\t-workdir DIR\t\tLocation where a temporary directory" + " will be created to hold project files(default $HOME).\n" + + "\t-delay n[H|h|M|m]\tNumber of secs(default),minutes or hours" + " before capture starts(number can be float)\n" + + "\t--overwrite\t\tIf there is already a file with the same name," + " delete it\n" + "\t\t\t\t(default is to add a number postfix to the new one).\n" "\t-o filename\t\tName of recorded video(default out.ogg).\n" - "\n\tIf no other options are specified, filename can be given without the -o switch.\n\n\n"; + "\n\tIf no other options are specified, filename can be given " + "without the -o switch.\n\n\n"; if(argc==2){ if(argv[1][0]!='-'){ @@ -110,12 +141,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ arg_return->delay=(int)num; } else{ - fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\nwhere n is a float number\n"); + fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\n" + "where n is a float number\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\nwhere n is a float number\n"); + fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\n" + "where n is a float number\n"); return 1; } i++; @@ -126,12 +159,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if(num>0) arg_return->windowid=num; else{ - fprintf(stderr,"Argument Usage: -windowid id_of_window(number)\n"); + fprintf(stderr,"Argument Usage:" + " -windowid id_of_window(number)\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -windowid id_of_window(number)\n"); + fprintf(stderr,"Argument Usage:" + " -windowid id_of_window(number)\n"); return 1; } i++; @@ -247,12 +282,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if((num>=0)&&(num<64)) arg_return->v_quality=num; else{ - fprintf(stderr,"Argument Usage: -v_quality n(number 0-63)\n"); + fprintf(stderr,"Argument Usage:" + " -v_quality n(number 0-63)\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -v_quality n(number 0-63)\n"); + fprintf(stderr,"Argument Usage:" + " -v_quality n(number 0-63)\n"); return 1; } i++; @@ -263,12 +300,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if((num>=45000)&&(num<=2000000)) arg_return->v_bitrate=num; else{ - fprintf(stderr,"Argument Usage: -v_bitrate n(number 45000-2000000)\n"); + fprintf(stderr,"Argument Usage:" + " -v_bitrate n(number 45000-2000000)\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -v_bitrate n(number 45000-2000000)\n"); + fprintf(stderr,"Argument Usage:" + " -v_bitrate n(number 45000-2000000)\n"); return 1; } i++; @@ -280,14 +319,16 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ else if(!strcmp(argv[i+1],"black")) arg_return->cursor_color=1; else{ - fprintf(stderr,"Argument Usage: -dummy-cursor [black|white]\n"); + fprintf(stderr,"Argument Usage:" + " -dummy-cursor [black|white]\n"); return 1; } arg_return->have_dummy_cursor=1; arg_return->xfixes_cursor=0; } else{ - fprintf(stderr,"Argument Usage: -dummy-cursor [black|white]\n"); + fprintf(stderr,"Argument Usage:" + " -dummy-cursor [black|white]\n"); return 1; } i++; @@ -332,12 +373,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if((num>=-1)&&(num<=10)) arg_return->s_quality=num; else{ - fprintf(stderr,"Argument Usage: -s_quality n(number -1 to 10)\n"); + fprintf(stderr,"Argument Usage:" + " -s_quality n(number -1 to 10)\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -s_quality n(number -1 to 10)\n"); + fprintf(stderr,"Argument Usage:" + " -s_quality n(number -1 to 10)\n"); return 1; } i++; @@ -348,12 +391,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if((num>0)&&(num<100)) arg_return->shared_thres=num; else{ - fprintf(stderr,"Argument Usage: -shared-threshold N(0<number<100)\n"); + fprintf(stderr,"Argument Usage:" + " -shared-threshold N(0<number<100)\n"); return 1; } } else{ - fprintf(stderr,"Argument Usage: -shared-threshold N(0<number<100)\n"); + fprintf(stderr,"Argument Usage:" + " -shared-threshold N(0<number<100)\n"); return 1; } i++; @@ -388,7 +433,8 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ if(num>0) arg_return->buffsize=num; else{ - fprintf(stderr,"Argument Usage: -buffer-size N(number>0)\n"); + fprintf(stderr,"Argument Usage:" + " -buffer-size N(number>0)\n"); return 1; } } @@ -434,7 +480,8 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ return 1; } else{ - fprintf(stderr,"\n\tError parsing arguments.\n\tType --help or -h for usage.\n\n"); + fprintf(stderr,"\n\tError parsing arguments.\n\t" + "Type --help or -h for usage.\n\n"); return 1; } } diff --git a/recordmydesktop/src/poll_damage.c b/recordmydesktop/src/poll_damage.c index a5b384d..4763fa0 100644 --- a/recordmydesktop/src/poll_damage.c +++ b/recordmydesktop/src/poll_damage.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -65,25 +65,29 @@ void *PollDamage(ProgData *pdata){ for (i = 0; i < nchildren; i++){ XWindowAttributes attribs; if (XGetWindowAttributes (pdata->dpy,children[i],&attribs)){ - if (!attribs.override_redirect && attribs.depth==pdata->specs.depth) - XDamageCreate (pdata->dpy, children[i],XDamageReportRawRectangles); + if(!attribs.override_redirect && attribs.depth==pdata->specs.depth) + XDamageCreate(pdata->dpy, + children[i], + XDamageReportRawRectangles); } } XFree(children); - XDamageCreate( pdata->dpy, pdata->brwin.windowid, XDamageReportRawRectangles); + XDamageCreate(pdata->dpy,pdata->brwin.windowid,XDamageReportRawRectangles); while(pdata->running){ - //damage polling doesn't stop,eventually full image may be needed - //30/10/2006 : when and why did I write the above line? what did I mean? XNextEvent(pdata->dpy,&event); if (event.type == MapNotify ){ XWindowAttributes attribs; - if (!((XMapEvent *)(&event))->override_redirect && XGetWindowAttributes (pdata->dpy, - event.xcreatewindow.window, - &attribs)){ - if (!attribs.override_redirect && attribs.depth==pdata->specs.depth) - XDamageCreate (pdata->dpy,event.xcreatewindow.window,XDamageReportRawRectangles); + if (!((XMapEvent *)(&event))->override_redirect&& + XGetWindowAttributes(pdata->dpy, + event.xcreatewindow.window, + &attribs)){ + if(!attribs.override_redirect&& + attribs.depth==pdata->specs.depth) + XDamageCreate(pdata->dpy, + event.xcreatewindow.window, + XDamageReportRawRectangles); } } else if(event.type == pdata->damage_event + XDamageNotify ){ diff --git a/recordmydesktop/src/queryextensions.c b/recordmydesktop/src/queryextensions.c index 0b311b9..3c28a2a 100644 --- a/recordmydesktop/src/queryextensions.c +++ b/recordmydesktop/src/queryextensions.c @@ -1,33 +1,36 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_error){ +void QueryExtensions(Display *dpy, + ProgArgs *args, + int *damage_event, + int *damage_error){ int xf_event_basep, xf_error_basep; @@ -37,12 +40,18 @@ void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_e } if((!args->noshared)&&(XShmQueryExtension(dpy)==False)){ args->noshared=1; - fprintf(stderr,"Shared Memory extension not present!\nTry again removing the --with-shared option(if you used it)\nand add the --no-cond-shared option.\n"); + fprintf(stderr,"Shared Memory extension not present!\n" + "Try again removing the --with-shared option" + "(if you used it)\nand add the" + " --no-cond-shared option.\n"); exit(5); } - if((args->xfixes_cursor)&&(XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)){ + if((args->xfixes_cursor)&& + (XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)){ args->xfixes_cursor=0; - fprintf(stderr,"Xfixes extension not present!\nPlease run with the -dummy-cursor or --no-cursor option.\n"); + fprintf(stderr,"Xfixes extension not present!\n" + "Please run with the -dummy-cursor or" + " --no-cursor option.\n"); exit(6); } } diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index 7f41e6e..c832a3e 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -54,33 +54,45 @@ int main(int argc,char **argv){ CacheData cache_data; QUERY_DISPLAY_SPECS(pdata.dpy,&pdata.specs); - if((pdata.specs.depth!=32)&&(pdata.specs.depth!=24)&&(pdata.specs.depth!=16)){ - fprintf(stderr,"Only 32bpp,24bpp and 16bpp color depth modes are currently supported.\n"); + if((pdata.specs.depth!=32)&& + (pdata.specs.depth!=24)&& + (pdata.specs.depth!=16)){ + fprintf(stderr,"Only 32bpp,24bpp and 16bpp" + " color depth modes are currently supported.\n"); exit(10); } if(SetBRWindow(pdata.dpy,&pdata.brwin,&pdata.specs,&pdata.args)) exit(11); - //check if we are under compiz or beryl,in which case we must enable full-shots + //check if we are under compiz or beryl, + //in which case we must enable full-shots //and with it use of shared memory.User can override this - pdata.window_manager=((pdata.args.nowmcheck)?NULL:rmdWMCheck(pdata.dpy,pdata.specs.root)); + pdata.window_manager=((pdata.args.nowmcheck)? + NULL:rmdWMCheck(pdata.dpy,pdata.specs.root)); if(pdata.window_manager==NULL){ fprintf(stderr,"Not taking window manager into account.\n"); } - //Right now only wm's that I know of performing 3d compositing are beryl and compiz. + //Right now only wm's that I know of performing + //3d compositing are beryl and compiz. //No, the blue screen in metacity doesn't count :) - //names can be compiz for compiz and beryl/beryl-co/beryl-core for beryl(so it's strncmp ) - else if(!strcmp(pdata.window_manager,"compiz") || !strncmp(pdata.window_manager,"beryl",5)){ + //names can be compiz for compiz and beryl/beryl-co/beryl-core + //for beryl(so it's strncmp ) + else if(!strcmp(pdata.window_manager,"compiz") || + !strncmp(pdata.window_manager,"beryl",5)){ fprintf(stderr,"\nDetected 3d compositing window manager.\n" "Reverting to full screen capture at every frame.\n" "To disable this check run with --no-wm-check\n" - "(though that is not advised, since it will probably produce faulty results).\n\n"); + "(though that is not advised, since it will " + "probably produce faulty results).\n\n"); pdata.args.full_shots=1; pdata.args.noshared=0; pdata.args.nocondshared=1; } - QueryExtensions(pdata.dpy,&pdata.args,&pdata.damage_event, &pdata.damage_error); + QueryExtensions(pdata.dpy, + &pdata.args, + &pdata.damage_event, + &pdata.damage_error); if((exit_status=InitializeData(&pdata,&enc_data,&cache_data))!=0) @@ -104,7 +116,8 @@ int main(int argc,char **argv){ } fprintf(stderr,"Cleanning up cache...\n"); if(PurgeCache(pdata.cache_data,!pdata.args.nosound)) - fprintf(stderr,"Some error occured while cleaning up cache!\n"); + fprintf(stderr,"Some error occured " + "while cleaning up cache!\n"); fprintf(stderr,"Done!!!\n"); } @@ -118,7 +131,8 @@ int main(int argc,char **argv){ return 1; } else{ - fprintf(stderr,"SIGABRT received,file %s removed\n",pdata.args.filename); + fprintf(stderr,"SIGABRT received,file %s removed\n", + pdata.args.filename); return 0; } } diff --git a/recordmydesktop/src/rectinsert.c b/recordmydesktop/src/rectinsert.c index aefeb1e..fea6a1d 100644 --- a/recordmydesktop/src/rectinsert.c +++ b/recordmydesktop/src/rectinsert.c @@ -1,35 +1,40 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> -//return 1 and null if geom1 in geom2 ,2 and null if geom2 in geom1,0 if they don't collide -//-1 and two geoms if they collide and geom1 is broken.//-2 and one or two geoms if they collide and geom2 is broken. +//return 1 and null if geom1 in geom2 ,2 and null if geom2 in geom1, +//0 if they don't collide +//-1 and two geoms if they collide and geom1 is broken. +//-2 and one or two geoms if they collide and geom2 is broken. //-10 if group and replace is possible -int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,int *ngeoms){ +int CollideRects(WGeometry *wgeom1, + WGeometry *wgeom2, + WGeometry **wgeom_return, + int *ngeoms){ //1 fits in 2 if((wgeom1->x>=wgeom2->x)&& (wgeom1->x+wgeom1->width<=wgeom2->x+wgeom2->width)&& @@ -59,9 +64,9 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in //this happens because libxdamage may generate many events for one change //and some of them may be in the the exact same region //so identical rects would be considered not colliding -//in order though to avoid endless recursion on the RectInsert +//in order though to avoid endless recursion on the RectInsert //function should always start at the next element(which is logical since -//if any rect makes it to a points none of it's part collides with previous +//if any rect makes it to a points none of it's part collides with previous //nodes on the list, too) int x1[2]={wgeom1->x,wgeom1->x+wgeom1->width}; int y1[2]={wgeom1->y,wgeom1->y+wgeom1->height}; @@ -88,7 +93,8 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in tot2=enclosed[1][0]+enclosed[1][1]+enclosed[1][2]+enclosed[1][3]; if((tot1==2)&&(tot2==2)){//same width or height, which is the best case //group - if((enclosed[1][0]&&enclosed[1][1])&&(wgeom1->width==wgeom2->width)){ + if((enclosed[1][0]&&enclosed[1][1])&& + (wgeom1->width==wgeom2->width)){ wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); *ngeoms=1; wgeom_return[0]->x=wgeom1->x; @@ -97,17 +103,17 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in wgeom_return[0]->height=wgeom2->height+wgeom2->y-wgeom1->y; return -10; } - else if((enclosed[1][0]&&enclosed[1][2])&&(wgeom1->height==wgeom2->height)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); + else if((enclosed[1][0]&&enclosed[1][2])&& + (wgeom1->height==wgeom2->height)){ *ngeoms=1; wgeom_return[0]->x=wgeom1->x; wgeom_return[0]->y=wgeom1->y; wgeom_return[0]->width=wgeom2->width+wgeom2->x-wgeom1->x; - wgeom_return[0]->height=wgeom1->height; + wgeom_return[0]->height=wgeom1->height; return -10; } - else if((enclosed[1][3]&&enclosed[1][1])&&(wgeom1->height==wgeom2->height)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); + else if((enclosed[1][3]&&enclosed[1][1])&& + (wgeom1->height==wgeom2->height)){ *ngeoms=1; wgeom_return[0]->x=wgeom2->x; wgeom_return[0]->y=wgeom2->y; @@ -115,8 +121,8 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in wgeom_return[0]->height=wgeom2->height; return -10; } - else if((enclosed[1][3]&&enclosed[1][2])&&(wgeom1->width==wgeom2->width)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); + else if((enclosed[1][3]&&enclosed[1][2])&& + (wgeom1->width==wgeom2->width)){ *ngeoms=1; wgeom_return[0]->x=wgeom2->x; wgeom_return[0]->y=wgeom2->y; @@ -128,7 +134,6 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in } if(tot2==2){ //break geom2 -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); wgeom_return[0]->x=wgeom2->x; wgeom_return[0]->y=wgeom2->y; wgeom_return[0]->width=wgeom2->width; @@ -150,14 +155,12 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in } else if(tot1==2){ //if the first one breaks(which is already inserted) - //then we reenter the part that was left and the one + //then we reenter the part that was left and the one //that was to be inserted -// wgeom_return[1]=wgeom2; wgeom_return[1]->x=wgeom2->x; wgeom_return[1]->y=wgeom2->y; wgeom_return[1]->width=wgeom2->width; wgeom_return[1]->height=wgeom2->height; -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); wgeom_return[0]->x=wgeom1->x; wgeom_return[0]->y=wgeom1->y; wgeom_return[0]->width=wgeom1->width; @@ -178,10 +181,9 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in return -1; } - else if(tot2==1){//in which case there is also tot1==1 but we rather not break that - //break geom2 in two -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); -// wgeom_return[1]=(WGeometry *)malloc(sizeof(WGeometry)); + else if(tot2==1){ //in which case there is also tot1==1 + //but we rather not break that + //break geom2 in two *ngeoms=2; if(enclosed[1][0]){ //first @@ -205,7 +207,7 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in wgeom_return[1]->x=x1[0]; wgeom_return[1]->y=y1[1]; wgeom_return[1]->width=x2[1]-x1[0]; - wgeom_return[1]->height=wgeom2->height-y1[1]+y2[0]; + wgeom_return[1]->height=wgeom2->height-y1[1]+y2[0]; } else if(enclosed[1][2]){ //first(same as [1][0]) @@ -241,8 +243,6 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in //geom2 crossing vertically geom1 //and geom2 crossing horizontally geom1 //The proper one can be found by simply checking x,y positions -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); -// wgeom_return[1]=(WGeometry *)malloc(sizeof(WGeometry)); *ngeoms=2; if(wgeom2->y<wgeom1->y){ //common @@ -299,14 +299,17 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ int ngeoms=0,insert_ok=1,i=0; temp=*root; - while(insert_ok){//if something is broken list does not procceed(except on -1 collres case) - int collres/*=0;//*/=CollideRects(&(temp->geom),wgeom,wgeom_return,&ngeoms); + while(insert_ok){ //if something is broken list does not procceed + //(except on -1 collres case) + int collres=CollideRects(&(temp->geom),wgeom,wgeom_return,&ngeoms); if((!collres)) insert_ok=1; else{ for(i=0;i<ngeoms;i++){ - wgeom_return[i]->width+=(wgeom_return[i]->width%2)|(wgeom_return[i]->x%2); - wgeom_return[i]->height+=(wgeom_return[i]->height%2)|(wgeom_return[i]->y%2); + wgeom_return[i]->width+=(wgeom_return[i]->width%2)| + (wgeom_return[i]->x%2); + wgeom_return[i]->height+=(wgeom_return[i]->height%2)| + (wgeom_return[i]->y%2); wgeom_return[i]->width+=(wgeom_return[i]->width%2); wgeom_return[i]->height+=(wgeom_return[i]->height%2); wgeom_return[i]->x-=wgeom_return[i]->x%2; @@ -353,9 +356,11 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ case 2://done,area is already covered free(newnode); break; - case -1://current node is broken and reinserted(in same pos) + case -1://current node is broken and reinserted + //(in same pos) //newnode is also reinserted - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)){ + if((wgeom_return[0]->width>0)&& + (wgeom_return[0]->height>0)){ temp->geom.x=wgeom_return[0]->x; temp->geom.y=wgeom_return[0]->y; temp->geom.width=wgeom_return[0]->width; @@ -369,11 +374,9 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ insert_ok=1; } } - else{//it might happen that the old and now broken node - //is of zero width or height(so it isn't reinserted) - /*TODO this may cause lines to be left not updated - so maybe it is needed to increase the size by one - pixel(zero width or height cause BadValue*/ + else{//it might happen that the old and now broken node + //is of zero width or height + //(so it isn't reinserted) if((temp->prev==NULL)&&(temp->next!=NULL)){ *root=(*root)->next; (*root)->prev=NULL; @@ -388,7 +391,8 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ total_insertions--; temp->next->prev=temp->prev; temp->prev->next=temp->next; - total_insertions+=RectInsert(&temp->next,wgeom); + total_insertions+=RectInsert(&temp->next, + wgeom); } free(temp); } @@ -403,7 +407,9 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ temp->next=newnode; newnode->prev=temp; if(ngeoms>1){ - RectArea *newnode1=(RectArea *)malloc(sizeof(RectArea)); + RectArea *newnode1= + (RectArea *)malloc(sizeof(RectArea)); + newnode1->geom.x=wgeom_return[1]->x; newnode1->geom.y=wgeom_return[1]->y; newnode1->geom.width=wgeom_return[1]->width; @@ -415,8 +421,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ } else{ for(i=0;i<ngeoms;i++){ - if((wgeom_return[i]->width>0)&&(wgeom_return[i]->height>0)) - total_insertions+=RectInsert(&temp->next,wgeom_return[i]); + if((wgeom_return[i]->width>0)&& + (wgeom_return[i]->height>0)) + total_insertions+= + RectInsert(&temp->next,wgeom_return[i]); } } break; @@ -426,7 +434,9 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ newnode->geom.x=wgeom_return[0]->x; newnode->geom.y=wgeom_return[0]->y; newnode->geom.width=wgeom_return[0]->width; - newnode->geom.height=wgeom_return[0]->height; + newnode->geom.height= + wgeom_return[0]->height; + *root=newnode; free(temp); } @@ -435,8 +445,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ *root=temp->next; (*root)->prev=NULL; free(temp); - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)) - total_insertions+=RectInsert(root,wgeom_return[0]); + if((wgeom_return[0]->width>0)&& + (wgeom_return[0]->height>0)) + total_insertions+= + RectInsert(root,wgeom_return[0]); } } else if(temp->next==NULL){//last, enter anyway @@ -454,8 +466,10 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ temp->prev->next=temp->next; temp->next->prev=temp->prev; free(temp); - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)) - total_insertions+=RectInsert(&temp1,wgeom_return[0]); + if((wgeom_return[0]->width>0)&& + (wgeom_return[0]->height>0)) + total_insertions+= + RectInsert(&temp1,wgeom_return[0]); } break; } @@ -480,8 +494,8 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ free(wgeom_return[1]); } return total_insertions; -} - +} + void ClearList(RectArea **root){ RectArea *temp; @@ -490,7 +504,7 @@ void ClearList(RectArea **root){ while(temp->next!=NULL){ temp=temp->next; free(temp->prev); - + } free(temp); *root=NULL; diff --git a/recordmydesktop/src/register_callbacks.c b/recordmydesktop/src/register_callbacks.c index 730c47a..27244fe 100644 --- a/recordmydesktop/src/register_callbacks.c +++ b/recordmydesktop/src/register_callbacks.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -32,9 +32,13 @@ void SetExpired(int signum){ if(capture_busy){ frames_lost++; } - pthread_cond_broadcast(time_cond);//sig handlers should not call this func - //could be a set_expired and main thread - //doing a while(running) if set_expired broadcast else usleep(n) + pthread_cond_broadcast(time_cond); //sig handlers should + //not call this func + //could be a set_expired + // and main thread + //doing a while(running) + //if set_expired broadcast + //else usleep(n) } } @@ -42,11 +46,18 @@ void SetPaused(int signum){ if(!Paused) Paused=1; else{ -// pthread_cond_broadcast(pause_cond);//thsi should work, but it doesn't - int i;//this is a bug - Paused=0;//normally with the broadcast all the threads should restart, but sound capture thread - for(i=0;i<15;i++)//remains dead. If a bunch of signals, restarts all threads, why can't a broadcast do the same? - pthread_cond_signal(pause_cond);//if you have any idea please contact me. +// pthread_cond_broadcast(pause_cond);//this should work, +// but it doesn't + int i; //this is a bug + Paused=0; //normally with the broadcast + //all the threads should restart, + //but sound capture thread + for(i=0;i<15;i++) //remains dead. If a bunch of signals, + pthread_cond_signal(pause_cond);//restarts all threads, + //why can't a broadcast + //do the same? + //if you have any idea + //please contact me. //(misses the signal?) } } diff --git a/recordmydesktop/src/rmd_cache.c b/recordmydesktop/src/rmd_cache.c index 2a49895..8a0894e 100644 --- a/recordmydesktop/src/rmd_cache.c +++ b/recordmydesktop/src/rmd_cache.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -78,7 +78,8 @@ int PurgeCache(CacheData *cache_data_t,int sound){ while (stat(fname,&buff)==0){ if(remove(fname)){ - fprintf(stderr,"Couldn't remove temporary file %s",cache_data_t->imgdata); + fprintf(stderr,"Couldn't remove temporary file %s", + cache_data_t->imgdata); exit_value=1; } CacheFileN(cache_data_t->imgdata,&fname,nth_cache); @@ -87,18 +88,22 @@ int PurgeCache(CacheData *cache_data_t,int sound){ free(fname); if(sound){ if(remove(cache_data_t->audiodata)){ - fprintf(stderr,"Couldn't remove temporary file %s",cache_data_t->audiodata); + fprintf(stderr,"Couldn't remove temporary file %s", + cache_data_t->audiodata); exit_value=1; } } if(remove(cache_data_t->projname)){ - fprintf(stderr,"Couldn't remove temporary directory %s",cache_data_t->projname); + fprintf(stderr,"Couldn't remove temporary directory %s", + cache_data_t->projname); exit_value=1; } return exit_value; } -void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){ +void InitCacheData(ProgData *pdata, + EncData *enc_data_t, + CacheData *cache_data_t){ int width,height,offset_x,offset_y,pid; char pidbuf[8]; @@ -133,7 +138,8 @@ void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){ I16TOA(pid,pidbuf) //names are stored relatively to current dir(i.e. no chdir) - cache_data_t->projname=malloc(strlen(cache_data_t->workdir)+12+strlen(pidbuf)+3); + cache_data_t->projname=malloc(strlen(cache_data_t->workdir)+ + 12+strlen(pidbuf)+3); //projname strcpy(cache_data_t->projname,cache_data_t->workdir); strcat(cache_data_t->projname,"/"); @@ -153,27 +159,31 @@ void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){ //creating the needed files if(mkdir(cache_data_t->projname,0777)){ - fprintf(stderr,"Could not create temporary directory %s !!!\n",cache_data_t->projname); + fprintf(stderr,"Could not create temporary directory %s !!!\n", + cache_data_t->projname); exit(13); } if(!pdata->args.zerocompression){ cache_data_t->ifp=gzopen(cache_data_t->imgdata,"wb0f"); if(cache_data_t->ifp==NULL){ - fprintf(stderr,"Could not create temporary file %s !!!\n",cache_data_t->imgdata); + fprintf(stderr,"Could not create temporary file %s !!!\n", + cache_data_t->imgdata); exit(13); } } else{ cache_data_t->uncifp=fopen(cache_data_t->imgdata,"wb0f"); if(cache_data_t->uncifp==NULL){ - fprintf(stderr,"Could not create temporary file %s !!!\n",cache_data_t->imgdata); + fprintf(stderr,"Could not create temporary file %s !!!\n", + cache_data_t->imgdata); exit(13); } } if(!pdata->args.nosound){ cache_data_t->afp=fopen(cache_data_t->audiodata,"wb"); if(cache_data_t->afp==NULL){ - fprintf(stderr,"Could not create temporary file %s !!!\n",cache_data_t->audiodata); + fprintf(stderr,"Could not create temporary file %s !!!\n", + cache_data_t->audiodata); exit(13); } } diff --git a/recordmydesktop/src/rmdthreads.c b/recordmydesktop/src/rmdthreads.c index 9a93416..442c67e 100644 --- a/recordmydesktop/src/rmdthreads.c +++ b/recordmydesktop/src/rmdthreads.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -45,22 +45,46 @@ void rmdThreads(ProgData *pdata){ /*start threads*/ if(!pdata->args.full_shots) - pthread_create(&poll_damage_t,NULL,(void *)PollDamage,(void *)pdata); - pthread_create(&image_capture_t,NULL,(void *)GetFrame,(void *)pdata); + pthread_create(&poll_damage_t, + NULL, + (void *)PollDamage, + (void *)pdata); + pthread_create(&image_capture_t, + NULL, + (void *)GetFrame, + (void *)pdata); if(pdata->args.encOnTheFly) - pthread_create(&image_encode_t,NULL,(void *)EncodeImageBuffer,(void *)pdata); + pthread_create(&image_encode_t, + NULL, + (void *)EncodeImageBuffer, + (void *)pdata); else - pthread_create(&image_cache_t,NULL,(void *)CacheImageBuffer,(void *)pdata); + pthread_create(&image_cache_t, + NULL, + (void *)CacheImageBuffer, + (void *)pdata); if(!pdata->args.nosound){ - pthread_create(&sound_capture_t,NULL,(void *)CaptureSound,(void *)pdata); + pthread_create(&sound_capture_t, + NULL, + (void *)CaptureSound, + (void *)pdata); if(pdata->args.encOnTheFly) - pthread_create(&sound_encode_t,NULL,(void *)EncodeSoundBuffer,(void *)pdata); + pthread_create(&sound_encode_t, + NULL, + (void *)EncodeSoundBuffer, + (void *)pdata); else - pthread_create(&sound_cache_t,NULL,(void *)CacheSoundBuffer,(void *)pdata); + pthread_create(&sound_cache_t, + NULL, + (void *)CacheSoundBuffer, + (void *)pdata); } if(pdata->args.encOnTheFly) - pthread_create(&flush_to_ogg_t,NULL,(void *)FlushToOgg,(void *)pdata); + pthread_create(&flush_to_ogg_t, + NULL, + (void *)FlushToOgg, + (void *)pdata); RegisterCallbacks(&pdata->args); fprintf(stderr,"Capturing!\n"); diff --git a/recordmydesktop/src/setbrwindow.c b/recordmydesktop/src/setbrwindow.c index 2b7b694..936e3fc 100644 --- a/recordmydesktop/src/setbrwindow.c +++ b/recordmydesktop/src/setbrwindow.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -80,7 +80,8 @@ void SizePack2_8_16(int *start,int *size,int limit){ } } - //16 divisble width(needed for shared memory only,but applied anyway since theora wants it, too) + //16 divisble width(needed for shared memory only, + //but applied anyway since theora wants it, too) //we already have divisibility by 8 so module //by 16 is euther 8 or 0 hexoffset=((*size)%16); @@ -106,7 +107,10 @@ void SizePack2_8_16(int *start,int *size,int limit){ -int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args){ +int SetBRWindow(Display *dpy, + BRWindow *brwin, + DisplaySpecs *specs, + ProgArgs *args){ //before we start recording we have to make sure the ranges are valid if(args->windowid==0){//root window //first set it up @@ -116,12 +120,16 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args) brwin->geom.height=specs->height; brwin->rgeom.x=args->x; brwin->rgeom.y=args->y; - brwin->rgeom.width=((args->width)?args->width:specs->width-brwin->rgeom.x); - brwin->rgeom.height=((args->height)?args->height:specs->height-brwin->rgeom.y); + brwin->rgeom.width=((args->width)? + args->width:specs->width-brwin->rgeom.x); + brwin->rgeom.height=((args->height)? + args->height:specs->height-brwin->rgeom.y); //and then check validity if((brwin->rgeom.x+brwin->rgeom.width>specs->width)|| (brwin->rgeom.y+brwin->rgeom.height>specs->height)){ - fprintf(stderr,"Window size specification out of bounds!(current resolution:%dx%d)\n",specs->width,specs->height); + fprintf(stderr,"Window size specification out of bounds!" + "(current resolution:%dx%d)\n", + specs->width,specs->height); return 1; } } @@ -135,7 +143,14 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args) fprintf(stderr,"Window must be mapped and visible!\n"); return 1; } - XTranslateCoordinates(dpy,specs->root,args->windowid,attribs.x,attribs.y,&transl_x,&transl_y,&wchid); + XTranslateCoordinates(dpy, + specs->root, + args->windowid, + attribs.x, + attribs.y, + &transl_x, + &transl_y, + &wchid); brwin->windowid=specs->root; brwin->geom.x=attribs.x-transl_x; brwin->geom.y=attribs.y-transl_y; @@ -149,8 +164,10 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args) brwin->rgeom.x=brwin->geom.x+args->x; brwin->rgeom.y=brwin->geom.y+args->y; - brwin->rgeom.width=((args->width)?args->width:brwin->geom.width-args->x); - brwin->rgeom.height=((args->height)?args->height:brwin->geom.height-args->y); + brwin->rgeom.width=((args->width)? + args->width:brwin->geom.width-args->x); + brwin->rgeom.height=((args->height)? + args->height:brwin->geom.height-args->y); if((args->x+brwin->rgeom.width>brwin->geom.width)|| (args->y+brwin->rgeom.height>brwin->geom.height)){ fprintf(stderr,"Specified Area is larger than window!\n"); @@ -158,20 +175,22 @@ int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args) } } fprintf(stderr, "Initial recording window is set to:\n" - "X:%d Y:%d Width:%d Height:%d\n" - ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height); + "X:%d Y:%d Width:%d Height:%d\n", + brwin->rgeom.x,brwin->rgeom.y, + brwin->rgeom.width,brwin->rgeom.height); SizePack2_8_16(&brwin->rgeom.x,&brwin->rgeom.width,specs->width); SizePack2_8_16(&brwin->rgeom.y,&brwin->rgeom.height,specs->height); fprintf(stderr, "Adjusted recording window is set to:\n" - "X:%d Y:%d Width:%d Height:%d\n" - ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height); + "X:%d Y:%d Width:%d Height:%d\n", + brwin->rgeom.x,brwin->rgeom.y, + brwin->rgeom.width,brwin->rgeom.height); - brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)* + brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)* + (((brwin->rgeom.height+15)>>4)<<4)* ((specs->depth==16)?2:4); - return 0; } diff --git a/recordmydesktop/src/update_image.c b/recordmydesktop/src/update_image.c index 7ae39ff..9681ce7 100644 --- a/recordmydesktop/src/update_image.c +++ b/recordmydesktop/src/update_image.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> diff --git a/recordmydesktop/src/wm_check.c b/recordmydesktop/src/wm_check.c index ac25efb..4429cd3 100644 --- a/recordmydesktop/src/wm_check.c +++ b/recordmydesktop/src/wm_check.c @@ -1,28 +1,28 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ +/****************************************************************************** +* recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2006,2007 John Varouhakis * +* * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +* * +* * +* For further information contact me at johnvarouhakis@gmail.com * +******************************************************************************/ #include <recordmydesktop.h> @@ -51,14 +51,17 @@ char *rmdWMCheck(Display *dpy,Window root){ &rt,&fmt,&nitems, &nbytes, (unsigned char **)((void*)&wm_child)) != Success ){ - fprintf(stderr,"Error while trying to get a window to identify the window manager.\n"); + fprintf(stderr,"Error while trying to get a" + " window to identify the window manager.\n"); } - if((wm_child == NULL) || (XGetWindowProperty( dpy,*wm_child,wm_name_atom,0,100, - False,utf8_string,&rt, - &fmt,&nitems, &nbytes, - (unsigned char **)((void*)&wm_name_str)) - != Success )){ - fprintf(stderr,"Warning!!!\nYour window manager appears to be non-compliant!\n"); + if((wm_child == NULL)|| + (XGetWindowProperty(dpy,*wm_child,wm_name_atom,0,100, + False,utf8_string,&rt, + &fmt,&nitems, &nbytes, + (unsigned char **)((void*)&wm_name_str)) + !=Success)){ + fprintf(stderr,"Warning!!!\nYour window manager appears" + " to be non-compliant!\n"); } } fprintf(stderr,"Your window manager appears to be %s\n\n", |