From 7487ea601384016ed6185e9083ea3e0d1b71fa46 Mon Sep 17 00:00:00 2001 From: enselic Date: Thu, 11 Sep 2008 19:26:27 +0000 Subject: Started working towards a more clean include hierarchy and distinguishable program modules. First step: move stuff from global headers that is only used in one source file to those source files. include/rmdfunc.h include/rmdmacro.h include/rmdtypes.h: Move stuff from here src/rmd_jack.c src/get_frame.c src/rmd_cache.c src/load_cache.c src/rectinsert.c src/cache_frame.c src/poll_events.c src/setbrwindow.c src/recordmydesktop.c: To here. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@508 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/include/rmdfunc.h | 131 +---------------------- recordmydesktop/include/rmdmacro.h | 209 ------------------------------------- recordmydesktop/include/rmdtypes.h | 15 --- 3 files changed, 1 insertion(+), 354 deletions(-) (limited to 'recordmydesktop/include') diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h index 77446e8..f7390b8 100644 --- a/recordmydesktop/include/rmdfunc.h +++ b/recordmydesktop/include/rmdfunc.h @@ -102,36 +102,6 @@ void ClearList(RectArea **root); */ int RectInsert(RectArea **root,WGeometry *wgeom); -/** -* Collide two rectangles and dictate most sane action for insertion, -* as well as provide the updated rectangle(s) -* \param wgeom1 resident rectangle -* -* \param wgeom2 New rectangle -* -* \param wgeom_return Pointer to rectangles to be inserted -* -* \param ngeoms number of entries in wgeom_return -* -* \retval 0 No collision -* -* \retval 1 wgeom1 is covered by wgeom2 -* -* \retval 2 wgeom2 is covered by wgeom1 -* -* \retval -1 wgeom1 was broken (new is picked up in wgeom_return) -* -* \retval -2 wgeom2 was broken (new is picked up in wgeom_return) -* -* \retval -10 Grouping the two geoms is possible -* -*/ -int CollideRects(WGeometry *wgeom1, - WGeometry *wgeom2, - WGeometry **wgeom_return, - int *ngeoms); - - /** * Set up all callbacks and signal handlers * \param pdata ProgData struct containing all program data @@ -394,19 +364,6 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready); * Fill Yr,Yg,Yb,Ur,Ug.Ub,Vr,Vg,Vb arrays(globals) with values. */ void MakeMatrices(); -/** -*Align the recording window to a divisible by 2 pixel start and -*and a size divisible by 16. -* -* \param start x or y of the recording window -* -* \param size width or height of the recording window -* -* \param limit width or height of the Display -* -* \note This is called separately for width and height. -*/ -void SizePack2_8_16(int *start,int *size,int limit); /** * Image caching thread. Copies the yuv buffer, compares with the last one and @@ -477,18 +434,6 @@ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff); */ char *rmdWMCheck(Display *dpy,Window root); -/** -*Construct an number postfixed name -* -* \param name base name -* -* \param newname modified name -* -* \n number to be used as a postfix -* -*/ -void CacheFileN(char *name,char **newname,int n); - /** * Change file pointer to a new file while writting * (file name is incremented with CacheFileN) @@ -563,84 +508,10 @@ int InitializeData(ProgData *pdata, CacheData *cache_data); #ifdef HAVE_JACK_H -/** -* -* Global Fuction Pointers To Jack API Calls -* -*/ -jack_client_t *(*jack_client_new_p)(const char *client_name); -jack_nframes_t (*jack_get_sample_rate_p)(jack_client_t * client); -int (*jack_set_buffer_size_p)(jack_client_t *client, jack_nframes_t nframes); -jack_nframes_t (*jack_get_buffer_size_p)(jack_client_t *client); -int (*jack_set_process_callback_p)(jack_client_t *client, - JackProcessCallback process_callback, - void *arg); -void (*jack_on_shutdown_p)(jack_client_t *client, - void(*function)(void *arg), - void *arg); -int (*jack_activate_p)(jack_client_t *client); -int (*jack_client_close_p)(jack_client_t *client); -void *(*jack_port_get_buffer_p)(jack_port_t *port,jack_nframes_t); -jack_port_t *(*jack_port_register_p)(jack_client_t *client, - const char *port_name, - const char *port_type, - unsigned long flags, - unsigned long buffer_size); -int (*jack_connect_p)(jack_client_t *client, - const char *source_port, - const char *destination_port); -const char *(*jack_port_name_p)(const jack_port_t *port); -int (*jack_port_name_size_p)(void); -jack_ringbuffer_t *(*jack_ringbuffer_create_p)(size_t sz); -void (*jack_ringbuffer_free_p)(jack_ringbuffer_t *rb); + size_t (*jack_ringbuffer_read_p)(jack_ringbuffer_t *rb, char *dest, size_t cnt); size_t (*jack_ringbuffer_read_space_p)(const jack_ringbuffer_t *rb); -size_t (*jack_ringbuffer_write_p)(jack_ringbuffer_t *rb, - const char *src, - size_t cnt); -/** -* End Of Function Pointers -*/ - -/** -* Callback for capture through jack -* -* \param nframes Number of frames captured -* -* \param jdata_t Pointer to JackData struct containing port -* and client information -* -* \returns Zero always -*/ -int JackCapture(jack_nframes_t nframes,void *jdata_t); - -/** -* Callback for jack server shutdown -* -* \param jdata_t Pointer to JackData struct containing port -* and client information -*/ -void JackShutdown(void *jdata_t); - -/** -* Register and Activate specified ports -* -* \param jdata_t Pointer to JackData struct containing port -* and client information -* -* \returns 0 on Success, 1 on failure -*/ -int SetupPorts(JackData *jdata); - -/** -* dlopen libjack and dlsym all needed functions -* -* \param jack_lib_handle Pointer to handle for jack library -* -* \returns 0 on Success, 1 on failure -*/ -int LoadJackLib(void *jack_lib_handle); /** * Load libjack, create and activate client,register ports diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h index f3dfcd6..13455ed 100644 --- a/recordmydesktop/include/rmdmacro.h +++ b/recordmydesktop/include/rmdmacro.h @@ -77,10 +77,6 @@ #define COMPARE_STRIDE 4 #endif -//500 mb file size -#define CACHE_FILE_SIZE_LIMIT (500*1<<20) -//minimize hard disk access -#define CACHE_OUT_BUFFER_SIZE 4096 //The width, in bytes, of the blocks @@ -89,16 +85,6 @@ #define Y_UNIT_WIDTH 0x0010 #define UV_UNIT_WIDTH 0x0008 -//The number of bytes for every -//sub-block of the y,u and v planes. -//Since the blocks are square -//these are obviously the squares -//of the widths(specified above), -//but the definitions bellow are only -//for convenience anyway. -#define Y_UNIT_BYTES 0x0100 -#define UV_UNIT_BYTES 0x0040 - #ifdef HAVE_LIBASOUND #define DEFAULT_AUDIO_DEVICE "hw:0,0" #else @@ -107,84 +93,6 @@ -#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)){\ - (wgeom)->x=(brwin)->rgeom.x;\ - (wgeom)->y=(brwin)->rgeom.y;\ - (wgeom)->width=(brwin)->rgeom.width;\ - (wgeom)->height=(brwin)->rgeom.height;\ - }\ - else{\ - (wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\ - (((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\ - \ - (wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\ - ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\ - (((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\ - \ - (wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\ - (e)->area.width-((brwin)->rgeom.x-(e)->area.x):\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\ - (((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\ - (brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\ - \ - (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;\ - \ - 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)->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;\ - (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;\ -} - - - #define DEFAULT_ARGS(args){\ (args)->delay=0;\ if(getenv("DISPLAY")!=NULL){\ @@ -235,18 +143,6 @@ strcpy((args)->stop_shortcut,"Control+Mod1+s");\ } -#define QUERY_DISPLAY_SPECS(display,specstruct){\ - (specstruct)->screen=DefaultScreen(display);\ - (specstruct)->width=DisplayWidth(display,(specstruct)->screen);\ - (specstruct)->height=DisplayHeight(display,(specstruct)->screen);\ - (specstruct)->root=RootWindow(display,(specstruct)->screen);\ - (specstruct)->visual=DefaultVisual(display,(specstruct)->screen);\ - (specstruct)->gc=DefaultGC(display,(specstruct)->screen);\ - (specstruct)->depth=DefaultDepth(display,(specstruct)->screen);\ - (specstruct)->bpixel=XBlackPixel(display,(specstruct)->screen);\ - (specstruct)->wpixel=XWhitePixel(display,(specstruct)->screen);\ -} - #define AVG_4_PIXELS(data_array,width_img,k_tm,i_tm,offset)\ ((data_array[(k_tm*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\ data_array[((k_tm-1)*width_img+i_tm)*RMD_ULONG_SIZE_T+offset]+\ @@ -550,58 +446,6 @@ -#define XFIXES_POINTER_TO_YUV(yuv,\ - data,\ - x_tm,\ - y_tm,\ - width_tm,\ - height_tm,\ - x_offset,\ - y_offset,\ - 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=y_offset;ky[x_tm+(i-x_offset)+(k+y_tm-y_offset)*yuv->y_width]=\ - (yuv->y[x_tm+(i-x_offset)+(k-y_offset+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);\ - yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\ - yuv->uv_width]=\ - (yuv->u[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\ - yuv->uv_width]*\ - (UCHAR_MAX-avg3)+\ - (Ur[avg2] + Ug[avg1] +UbVr[avg0])*avg3)/UCHAR_MAX;\ - yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\ - yuv->uv_width]=\ - (yuv->v[x_2+(i-x_offset)/2+((k-y_offset)/2+y_2)*\ - yuv->uv_width]*\ - (UCHAR_MAX-avg3)+\ - (UbVr[avg2] + Vg[avg1] +Vb[avg0])*avg3)/UCHAR_MAX;\ - }\ - }\ - }\ -} - #define DUMMY_POINTER_TO_YUV(yuv,\ data_tm,\ x_tm,\ @@ -636,34 +480,6 @@ }\ } -#define MARK_BACK_BUFFER( data,\ - x_tm,\ - y_tm,\ - width_tm,\ - height_tm,\ - buffer_width,\ - __bit_depth__){\ - if((__bit_depth__==24)||(__bit_depth__==32)){\ - MARK_BACK_BUFFER_C( data,\ - x_tm,\ - y_tm,\ - width_tm,\ - height_tm,\ - buffer_width,\ - 32)\ - }\ - else{\ - MARK_BACK_BUFFER_C( data,\ - x_tm,\ - y_tm,\ - width_tm,\ - height_tm,\ - buffer_width,\ - 16)\ - }\ -}\ - - #define MARK_BACK_BUFFER_C( data,\ x_tm,\ y_tm,\ @@ -701,36 +517,11 @@ free(t_buf);\ };\ -#define INIT_FRAME(frame_t,fheader_t,yuv_t,\ - YBlocks_t,UBlocks_t,VBlocks_t){\ - (frame_t)->header=(fheader_t);\ - (frame_t)->YBlocks=YBlocks_t;\ - (frame_t)->UBlocks=UBlocks_t;\ - (frame_t)->VBlocks=VBlocks_t;\ - (frame_t)->YData=malloc((yuv_t)->y_width*(yuv_t)->y_height);\ - (frame_t)->UData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\ - (frame_t)->VData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\ -}; - #define CLEAR_FRAME(frame_t){\ free((frame_t)->YData);\ free((frame_t)->UData);\ free((frame_t)->VData);\ }; -#ifdef HAVE_JACK_H - -#define CHECK_DLERRORS_FATAL(__error_p)\ - if((__error_p=dlerror())!=NULL){\ - fprintf(stderr,"%s\n",__error_p);\ - return 1;\ - } - -#define DLSYM_AND_CHECK(lib_handle,__call_name__,__error_p)\ - __call_name__##_p=dlsym(lib_handle,#__call_name__);\ - CHECK_DLERRORS_FATAL(__error_p) - -#endif - #endif diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h index db1e430..08e72dd 100644 --- a/recordmydesktop/include/rmdtypes.h +++ b/recordmydesktop/include/rmdtypes.h @@ -371,20 +371,5 @@ typedef struct _FrameHeader{ Vnum; //number of changed blocks in the V plane }FrameHeader; -//The frame after retrieval. -//Based on the Header information -//we can read the correct amount of bytes. - - -typedef struct _CachedFrame{ - FrameHeader *header; - u_int32_t *YBlocks, //identifying number on the grid, - *UBlocks, //starting at top left - *VBlocks; // >> >> - unsigned char *YData, //pointer to data for the blocks that have changed, - *UData, //which have to be remapped - *VData; //on the buffer when reading -}CachedFrame; - #endif -- cgit v1.2.3