diff options
-rw-r--r-- | recordmydesktop/configure.ac | 2 | ||||
-rw-r--r-- | recordmydesktop/doc/recordmydesktop.1 | 30 | ||||
-rw-r--r-- | recordmydesktop/include/rmdfunc.h | 42 | ||||
-rw-r--r-- | recordmydesktop/include/rmdmacro.h | 40 | ||||
-rw-r--r-- | recordmydesktop/include/rmdtypes.h | 85 | ||||
-rw-r--r-- | recordmydesktop/src/get_frame.c | 52 | ||||
-rw-r--r-- | recordmydesktop/src/getzpixmap.c | 42 | ||||
-rw-r--r-- | recordmydesktop/src/init_encoder.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/initialize_data.c | 46 | ||||
-rw-r--r-- | recordmydesktop/src/load_cache.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/make_dummy_pointer.c | 30 | ||||
-rw-r--r-- | recordmydesktop/src/parseargs.c | 39 | ||||
-rw-r--r-- | recordmydesktop/src/queryextensions.c | 18 | ||||
-rw-r--r-- | recordmydesktop/src/recordmydesktop.c | 6 | ||||
-rw-r--r-- | recordmydesktop/src/update_image.c | 14 |
15 files changed, 222 insertions, 228 deletions
diff --git a/recordmydesktop/configure.ac b/recordmydesktop/configure.ac index 47acf8d..d369d25 100644 --- a/recordmydesktop/configure.ac +++ b/recordmydesktop/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.59) AC_INIT(src/recordmydesktop.c) -AM_INIT_AUTOMAKE(recordmydesktop,0.3.3.2-cvs,) +AM_INIT_AUTOMAKE(recordmydesktop,0.3.4-cvs,) AC_CONFIG_SRCDIR([src/recordmydesktop.c]) AM_CONFIG_HEADER(config.h) diff --git a/recordmydesktop/doc/recordmydesktop.1 b/recordmydesktop/doc/recordmydesktop.1 index b3fc345..f0e34ed 100644 --- a/recordmydesktop/doc/recordmydesktop.1 +++ b/recordmydesktop/doc/recordmydesktop.1 @@ -29,13 +29,7 @@ and update the frame. This behavior can be changed (option .br or capture windows that do not generate events on change(windows with accelerated 3d context) .br -but this will notably increase the workload. In this case, enabling the -.B -\-\-with\-shared -option is recommended -.br -(by default this option is switched on or off at every frame, according to the size of the area to be aquired). -.br +but this will notably increase the workload. .br recordMyDesktop doesn't have a commandline interface. .br @@ -229,18 +223,11 @@ Image Options: .br .TP .B - \-\-with\-shared - Enable usage of MIT\-shared memory extension at all times. -.br -.TP -.B - \-\-no\-cond\-shared - Do not use the MIT\-shared memory extension when aquiring large areas. -.br -.TP + \-\-no\-shared + Disable usage of MIT\-shared memory extension .B - \-shared\-threshold n - Threshold over which shared memory is used(default 75). +(Not Recommended). + .br .TP .B @@ -326,11 +313,6 @@ Encoding Options: .br .TP .B - \-\-drop\-frames - Allow theora encoder to drop frames(this can significantly lower proccessing times). -.br -.TP -.B \-s_quality n Desired audio quality(\-1 to 10). .br @@ -343,7 +325,7 @@ Misc Options: .B \-\-no\-wm\-check When a 3d compositing window manager is detected the program will function as if the - \-\-full\-shots and \-\-with\-shared options have been specified. This option disables that + \-\-full\-shots option has been specified. This option disables that behavior alltogether. .br .TP diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h index b4d3ef6..4c8e964 100644 --- a/recordmydesktop/include/rmdfunc.h +++ b/recordmydesktop/include/rmdfunc.h @@ -161,6 +161,8 @@ void UpdateImage(Display * dpy, EncData *enc, char *datatemp, int noshmem, + XShmSegmentInfo *shminfo, + int shm_opcode, int no_quick_subsample); /** @@ -182,8 +184,6 @@ void UpdateImage(Display * dpy, * * \param height height position of the screenshot * -* \param x x position of the screenshot -* * \returns 0 on Success 1 on Failure */ int GetZPixmap(Display *dpy, @@ -195,6 +195,41 @@ int GetZPixmap(Display *dpy, int height); /** +* Rerieve pixmap data from xserver through the MIT-Shm extension +* +* \param dpy Connection to the server +* +* \param root root window of the display +* +* \param shminfo Info for the shared memory segment +* +* \param shm_opcode Opcode of Shm extension +* +* \param data (preallocated)buffer to place the data +* +* \param x x position of the screenshot +* +* \param y y position of the screenshot +* +* \param x x position of the screenshot +* +* \param width width of the screenshot +* +* \param height height position of the screenshot +* +* \returns 0 on Success 1 on Failure +*/ +int GetZPixmapSHM(Display *dpy, + Window root, + XShmSegmentInfo *shminfo, + int shm_opcode, + char *data, + int x, + int y, + int width, + int height); + +/** * Fill ProgArgs struct with arguments entered at execution * * \param argc argc as entered from main @@ -223,7 +258,8 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return); void QueryExtensions(Display *dpy, ProgArgs *args, int *damage_event, - int *damage_error); + int *damage_error, + int *shm_opcode); /** * Check and align window size diff --git a/recordmydesktop/include/rmdmacro.h b/recordmydesktop/include/rmdmacro.h index ebeb8bf..f620f73 100644 --- a/recordmydesktop/include/rmdmacro.h +++ b/recordmydesktop/include/rmdmacro.h @@ -198,25 +198,21 @@ (args)->y=\ (args)->width=\ (args)->height=\ - (args)->quietmode=\ (args)->nosound=\ (args)->full_shots=\ (args)->encOnTheFly=\ (args)->zerocompression=\ (args)->nowmcheck=\ - (args)->dropframes=\ (args)->overwrite=\ (args)->use_jack=\ - (args)->jack_nports=\ - (args)->nocondshared=0;\ + (args)->noshared=\ + (args)->jack_nports=0;\ (args)->jack_ringbuffer_secs=3.0;\ (args)->jack_port_names=NULL;\ - (args)->no_quick_subsample=\ - (args)->noshared=1;\ + (args)->no_quick_subsample=1;\ (args)->filename=(char *)malloc(8);\ strcpy((args)->filename,"out.ogg");\ (args)->cursor_color=1;\ - (args)->shared_thres=75;\ (args)->have_dummy_cursor=0;\ (args)->xfixes_cursor=1;\ (args)->device=(char *)malloc(strlen(DEFAULT_AUDIO_DEVICE)+1);\ @@ -286,15 +282,12 @@ height_tm,\ width_tm,\ yuv,\ - __copy_type,\ __bit_depth__){ \ int k,i;\ register u_int##__bit_depth__##_t t_val;\ register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ *_yr=Yr,*_yg=Yg,*_yb=Yb;\ - register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data\ - +((__copy_type==__X_SHARED)?\ - (x_tm+y_tm*yuv->y_width):0);\ + register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data;\ for(k=0;k<height_tm;k++){\ for(i=0;i<width_tm;i++){\ t_val=*datapi;\ @@ -305,8 +298,6 @@ yuv_y++;\ }\ yuv_y+=yuv->y_width-width_tm;\ - if(__copy_type==__X_SHARED)\ - datapi+=yuv->y_width-width_tm;\ }\ } @@ -316,7 +307,6 @@ height_tm,\ width_tm,\ yuv,\ - __copy_type,\ __sampling_type,\ __bit_depth__){ \ int k,i;\ @@ -325,13 +315,10 @@ *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 u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data\ - +((__copy_type==__X_SHARED)?\ - (x_tm+y_tm*yuv->y_width):0),\ + register u_int##__bit_depth__##_t *datapi=(u_int##__bit_depth__##_t *)data,\ *datapi_next=NULL;\ if(__sampling_type==__PXL_AVERAGE){\ - datapi_next=datapi+\ - ((__copy_type==__X_SHARED)?(yuv->y_width):(width_tm));\ + datapi_next=datapi+width_tm;\ }\ for(k=0;k<height_tm;k+=2){\ for(i=0;i<width_tm;i+=2){\ @@ -356,11 +343,9 @@ }\ 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+=width_tm;\ if(__sampling_type==__PXL_AVERAGE)\ - datapi_next+=((__copy_type==__X_SHARED)?\ - (2*yuv->y_width-width_tm):width_tm);\ + datapi_next+=width_tm;\ }\ } @@ -370,18 +355,17 @@ 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_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,32)\ UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ - yuv,__copy_type,__sampling_type,32)\ + yuv,__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_Y_PLANE(data,x_tm,y_tm,height_tm,width_tm,yuv,16)\ UPDATE_UV_PLANES(data,x_tm,y_tm,height_tm,width_tm,\ - yuv,__copy_type,__sampling_type,16)\ + yuv,__sampling_type,16)\ }\ } diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h index f8d9f4a..31a0d6d 100644 --- a/recordmydesktop/include/rmdtypes.h +++ b/recordmydesktop/include/rmdtypes.h @@ -60,6 +60,7 @@ #include <X11/extensions/Xfixes.h> #include <X11/extensions/Xdamage.h> #include <X11/extensions/XShm.h> +#include <X11/extensions/shmstr.h> #include <theora/theora.h> #include <vorbis/codec.h> #include <vorbis/vorbisenc.h> @@ -93,11 +94,6 @@ typedef u_int64_t cmp_int_t; typedef u_int32_t cmp_int_t; #endif -//how we obtained the image we are converting to yuv -enum{ - __X_SHARED, //through MIT/Shm - __X_IPC //through the regular X IPC mechanism -}; //type of pixel proccessing for the Cb,Cr planes //when converting from full rgb to 4:2:2 Ycbcr enum{ @@ -144,7 +140,6 @@ typedef struct _ProgArgs{ char *display; //display to connect(default :0) int x,y; //x,y offset(default 0,0) int width,height; //defaults to window width and height - 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 @@ -160,15 +155,12 @@ typedef struct _ProgArgs{ u_int32_t buffsize; #endif 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 + int noshared; //do not use shared memory extension(default 0) int nowmcheck; //do not check if there's a 3d comp window manager //(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 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 @@ -264,43 +256,23 @@ typedef struct _JackData{ //threads,so they will have access to the program data, avoiding //at the same time usage of any globals. typedef struct _ProgData{ +/**recordMyDesktop specific structs*/ 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 - running; SndBuffer *sound_buffer; EncData *enc_data; CacheData *cache_data; #ifdef HAVE_JACK_H JackData *jdata; #endif - 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; +/**X related info*/ + Display *dpy; //curtrent display + XImage *image; //the image that holds the current full screenshot + XShmSegmentInfo shminfo;//info structure for the image above. +/** Mutexes*/ pthread_mutex_t list_mutex[2], //mutexes for concurrency //protection of the lists sound_buffer_mutex, @@ -317,6 +289,7 @@ typedef struct _ProgData{ //to avoid wrong coloring to render //Currently this mutex only prevents //the cursor from flickering +/**Condition Variables*/ 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, @@ -328,10 +301,30 @@ typedef struct _ProgData{ //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, //these indicate a wait - th_enc_thread_waiting; //condition on the above cond vars +/**Buffers,Flags and other vars*/ + unsigned char *dummy_pointer, //a dummy pointer to be drawn + //in every frame + //data is casted to unsigned for + //later use in YUV buffer + npxl; //this is the no pixel convention + //when drawing the dummy pointer + unsigned int periodtime,//time that a sound buffer lasts (microsecs) + frametime; //time that a frame lasts (microsecs) + char *pxl_data, //the data of image + *window_manager; //name of the window manager at program launch + int list_selector, //selector for the rect_roots + damage_event, //damage event base code + damage_error, //damage error base code + shm_opcode, //MIT-Shm opcode + running, //1 while the program is capturing/paused/encoding + dummy_p_size, //dummy pointer size,initially 16x16,always square + th_encoding_clean, //thread exit inidcator + v_encoding_clean, // >> >> + v_enc_thread_waiting, //these indicate a wait + th_enc_thread_waiting, //condition on the cond vars. + hard_pause, //if sound device doesn't support pause + //we have to close and reopen + avd; //syncronization among audio and video #ifdef HAVE_LIBASOUND snd_pcm_t *sound_handle; snd_pcm_uframes_t periodsize; @@ -371,12 +364,12 @@ typedef struct _FrameHeader{ typedef struct _CachedFrame{ FrameHeader *header; - u_int32_t *YBlocks; //identifying number on the grid, - u_int32_t *UBlocks; //starting at top left - u_int32_t *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 + 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 diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index 87e71aa..635a868 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -29,12 +29,9 @@ void *GetFrame(ProgData *pdata){ int tlist_sel=0; - unsigned char *dtap=NULL; //pointer switching among shared memory and - //normal buffer uint msk_ret; WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; Window root_ret,child_ret; - int pixel_total=pdata->brwin.rgeom.width*pdata->brwin.rgeom.height; XFixesCursorImage *xcim=NULL; mouse_pos_abs.x=mouse_pos_temp.x=0; @@ -64,21 +61,6 @@ void *GetFrame(ProgData *pdata){ pdata->list_selector=((pdata->list_selector+1)%2); pthread_mutex_lock(&pdata->list_mutex[tlist_sel]); } - //here we measure the list and decide which way we will go - if(!pdata->args.nocondshared){ - int level=0; - RectArea *temp=pdata->rect_root[tlist_sel]; - - if(temp!=NULL){ - do{ - level+=temp->geom.width*temp->geom.height; - temp=temp->next; - }while(temp!=NULL); - level*=100; - level/=pixel_total; - pdata->args.noshared=(level<pdata->args.shared_thres); - } - } if(pdata->args.xfixes_cursor){ //xfixes pointer sequence //update previous_position @@ -118,10 +100,6 @@ void *GetFrame(ProgData *pdata){ &mouse_pos_abs.x,&mouse_pos_abs.y, &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); if(!pdata->args.full_shots) UpdateImage(pdata->dpy, &pdata->enc_data->yuv, @@ -130,16 +108,16 @@ void *GetFrame(ProgData *pdata){ &pdata->rect_root[tlist_sel], &pdata->brwin, pdata->enc_data, - ((pdata->args.noshared)? - (pdata->datatemp): - (pdata->shimage->data)), + pdata->image->data, pdata->args.noshared, + &pdata->shminfo, + pdata->shm_opcode, pdata->args.no_quick_subsample); else{ - - dtap=(((pdata->args.nocondshared)&&(!pdata->args.noshared))? - ((unsigned char*)pdata->shimage->data): - ((unsigned char*)pdata->image->data)); + if(!pdata->args.noshared) + XShmGetImage(pdata->dpy,pdata->specs.root,pdata->image, + (pdata->brwin.rgeom.x), + (pdata->brwin.rgeom.y),AllPlanes); if(pdata->args.noshared){ GetZPixmap( pdata->dpy, pdata->specs.root, @@ -150,14 +128,14 @@ void *GetFrame(ProgData *pdata){ pdata->brwin.rgeom.height); } pthread_mutex_lock(&pdata->yuv_mutex); - UPDATE_YUV_BUFFER((&pdata->enc_data->yuv),dtap, - (pdata->enc_data->x_offset), - (pdata->enc_data->y_offset), - (pdata->brwin.rgeom.width), - (pdata->brwin.rgeom.height), - pdata->args.noshared, - pdata->args.no_quick_subsample, - pdata->specs.depth); + UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), + ((unsigned char*)pdata->image->data), + (pdata->enc_data->x_offset), + (pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width), + (pdata->brwin.rgeom.height), + pdata->args.no_quick_subsample, + pdata->specs.depth); pthread_mutex_unlock(&pdata->yuv_mutex); } if(pdata->args.xfixes_cursor){ diff --git a/recordmydesktop/src/getzpixmap.c b/recordmydesktop/src/getzpixmap.c index 6deaf15..38ef42d 100644 --- a/recordmydesktop/src/getzpixmap.c +++ b/recordmydesktop/src/getzpixmap.c @@ -59,3 +59,45 @@ int GetZPixmap(Display *dpy, return 0; } +int GetZPixmapSHM(Display *dpy, + Window root, + XShmSegmentInfo *shminfo, + int shm_opcode, + char *data, + int x, + int y, + int width, + int height){ + xShmGetImageReply reply; + xShmGetImageReq *request=NULL; + long nbytes; + + LockDisplay(dpy); + GetReq(ShmGetImage,request); + + request->reqType=shm_opcode; + request->shmReqType=X_ShmGetImage; + request->shmseg=shminfo->shmseg; + + request->drawable=root; + request->x=x; + request->y=y; + request->width=width; + request->height=height; + request->planeMask=AllPlanes; + request->format=ZPixmap; + request->offset=data-shminfo->shmaddr; + + if((!_XReply(dpy,(xReply *)&reply,0,xFalse))||(!reply.length)){ + UnlockDisplay(dpy); + SyncHandle(); + return 1; + } + + nbytes=(long)reply.length << 2; + _XReadPad(dpy,data,nbytes); + UnlockDisplay(dpy); + SyncHandle(); + + return 0; +} diff --git a/recordmydesktop/src/init_encoder.c b/recordmydesktop/src/init_encoder.c index 34775fd..2876c1c 100644 --- a/recordmydesktop/src/init_encoder.c +++ b/recordmydesktop/src/init_encoder.c @@ -95,7 +95,7 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ 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.dropframes_p=0; 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; diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 806ade5..ede8855 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -47,9 +47,6 @@ int InitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data){ int i; - unsigned char *dtap=NULL; //pointer switching among shared memory and - //normal buffer - //these are globals, look for them at the header frames_total=frames_lost=encoder_busy=capture_busy=0; @@ -63,10 +60,8 @@ int InitializeData(ProgData *pdata, } if((pdata->args.noshared)) - pdata->datamain=(char *)malloc(pdata->brwin.nbytes); + pdata->pxl_data=(char *)malloc(pdata->brwin.nbytes); - if(pdata->args.noshared) - pdata->datatemp=(char *)malloc(pdata->brwin.nbytes); pdata->rect_root[0]=pdata->rect_root[1]=NULL; pthread_mutex_init(&pdata->list_mutex[0],NULL); pthread_mutex_init(&pdata->list_mutex[1],NULL); @@ -100,7 +95,7 @@ int InitializeData(ProgData *pdata, pdata->specs.depth, ZPixmap, 0, - pdata->datamain, + pdata->pxl_data, pdata->brwin.rgeom.width, pdata->brwin.rgeom.height, 8, @@ -113,24 +108,25 @@ int InitializeData(ProgData *pdata, 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); + if((!pdata->args.noshared)){ + pdata->image=XShmCreateImage(pdata->dpy, + pdata->specs.visual, + pdata->specs.depth, + ZPixmap, + pdata->pxl_data, + &pdata->shminfo, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height); pdata->shminfo.shmid=shmget(IPC_PRIVATE, - pdata->shimage->bytes_per_line* - pdata->shimage->height, + pdata->image->bytes_per_line* + pdata->image->height, IPC_CREAT|0777); if(pdata->shminfo.shmid==-1){ fprintf(stderr,"Failed to obtain Shared Memory segment!\n"); return 12; } - pdata->shminfo.shmaddr=pdata->shimage->data=shmat(pdata->shminfo.shmid, - NULL,0); + pdata->shminfo.shmaddr=pdata->image->data=shmat(pdata->shminfo.shmid, + NULL,0); pdata->shminfo.readOnly = False; if(!XShmAttach(pdata->dpy,&pdata->shminfo)){ fprintf(stderr,"Failed to attach shared memory to proccess.\n"); @@ -138,7 +134,7 @@ int InitializeData(ProgData *pdata, } XShmGetImage(pdata->dpy, pdata->specs.root, - pdata->shimage, + pdata->image, pdata->brwin.rgeom.x, pdata->brwin.rgeom.y, AllPlanes); @@ -211,15 +207,11 @@ int InitializeData(ProgData *pdata, pdata->enc_data->yuv.v[i]=pdata->enc_data->yuv.u[i]=127; } - dtap=(((pdata->args.nocondshared)&&(!pdata->args.noshared))? - ((unsigned char*)pdata->shimage->data): - ((unsigned char*)pdata->image->data)); - - - UPDATE_YUV_BUFFER((&pdata->enc_data->yuv),dtap, + UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), + ((unsigned char*)pdata->image->data), (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height), - __X_IPC,(pdata->args.no_quick_subsample), + (pdata->args.no_quick_subsample), pdata->specs.depth); pdata->frametime=(1000000)/pdata->args.fps; diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c index 78c81c5..a992a21 100644 --- a/recordmydesktop/src/load_cache.c +++ b/recordmydesktop/src/load_cache.c @@ -150,7 +150,7 @@ void *LoadCache(ProgData *pdata){ VBlocks[(yuv->uv_width*yuv->uv_height)/UV_UNIT_BYTES]; //we allocate the frame that we will use INIT_FRAME(&frame,&fheader,yuv, - YBlocks,UBlocks,VBlocks) + YBlocks,UBlocks,VBlocks); //and the we open our files if(!pdata->args.zerocompression){ ifp=gzopen(pdata->cache_data->imgdata,"rb"); diff --git a/recordmydesktop/src/make_dummy_pointer.c b/recordmydesktop/src/make_dummy_pointer.c index 9e0ad3a..0932af6 100644 --- a/recordmydesktop/src/make_dummy_pointer.c +++ b/recordmydesktop/src/make_dummy_pointer.c @@ -35,22 +35,22 @@ unsigned char *MakeDummyPointer(DisplaySpecs *specs, unsigned long b=(color)?'w':'b', w=(color)?'b':'w'; char pmask[1][16][16]={{ - {w,w,w,w,w,w,o,o,o,o,o,o,o,o,o,o}, - {w,b,b,w,w,w,w,o,o,o,o,o,o,o,o,o}, - {w,b,b,b,w,w,w,w,o,o,o,o,o,o,o,o}, - {w,b,b,b,b,w,w,w,w,o,o,o,o,o,o,o}, + {w,w,o,o,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,w,o,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,w,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,w,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,w,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,w,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,w,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,b,w,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,b,b,w,o,o,o,o,o,o}, {w,b,b,b,b,b,w,w,w,w,o,o,o,o,o,o}, - {w,b,b,b,b,b,b,w,w,w,w,o,o,o,o,o}, - {w,b,b,b,b,b,b,b,w,w,w,w,o,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,b,w,w,w,w,o,o}, - {w,b,b,b,b,b,b,b,b,b,b,w,w,w,w,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,w,w,w,w,b,b,b,b,b,w,w,w,o,o,o}, - {w,w,w,w,w,w,b,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,w,w,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,o,w,w,w,w,w,w,w,o,o,o}} + {w,b,b,b,b,b,w,o,o,o,o,o,o,o,o,o}, + {w,b,b,w,w,b,b,w,o,o,o,o,o,o,o,o}, + {w,b,w,o,w,b,b,w,o,o,o,o,o,o,o,o}, + {w,w,o,o,o,w,b,b,w,o,o,o,o,o,o,o}, + {o,o,o,o,o,w,b,b,w,o,o,o,o,o,o,o}, + {o,o,o,o,o,o,w,w,o,o,o,o,o,o,o,o}} }; unsigned char *ret=malloc(size*sizeof(char[size*4])); unsigned char wp[4]={ diff --git a/recordmydesktop/src/parseargs.c b/recordmydesktop/src/parseargs.c index a2a55c4..1474838 100644 --- a/recordmydesktop/src/parseargs.c +++ b/recordmydesktop/src/parseargs.c @@ -64,14 +64,8 @@ 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--no-shared\t\tDisable usage of" + " MIT-shared memory extension(Not Recommended!).\n" "\t--full-shots\t\tTake full screenshot at every frame(Not recomended!).\n" "\t--quick-subsampling\tDo subsampling" @@ -104,7 +98,6 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ "\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" @@ -397,24 +390,6 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ } i++; } - else if(!strcmp(argv[i],"-shared-threshold")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>0)&&(num<100)) - arg_return->shared_thres=num; - else{ - 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"); - return 1; - } - i++; - } else if(!strcmp(argv[i],"-device")){ if(i+1<argc){ free(arg_return->device); @@ -514,17 +489,11 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ } else if(!strcmp(argv[i],"--no-sound")) arg_return->nosound=1; - else if(!strcmp(argv[i],"--drop-frames")) - arg_return->dropframes=1; - else if(!strcmp(argv[i],"--with-shared")){ - arg_return->noshared=0; - arg_return->nocondshared=1; + else if(!strcmp(argv[i],"--no-shared")){ + arg_return->noshared=1; } - else if(!strcmp(argv[i],"--no-cond-shared")) - arg_return->nocondshared=1; else if(!strcmp(argv[i],"--full-shots")){ arg_return->full_shots=1; - arg_return->nocondshared=1; } else if(!strcmp(argv[i],"--quick-subsampling")){ arg_return->no_quick_subsample=0; diff --git a/recordmydesktop/src/queryextensions.c b/recordmydesktop/src/queryextensions.c index 3c28a2a..8d6413c 100644 --- a/recordmydesktop/src/queryextensions.c +++ b/recordmydesktop/src/queryextensions.c @@ -30,22 +30,28 @@ void QueryExtensions(Display *dpy, ProgArgs *args, int *damage_event, - int *damage_error){ + int *damage_error, + int *shm_opcode){ int xf_event_basep, - xf_error_basep; + xf_error_basep, + shm_event_base, + shm_error_base; if(!XDamageQueryExtension( dpy, damage_event, damage_error)){ fprintf(stderr,"XDamage extension not found!!!\n"); exit(4); } - if((!args->noshared)&&(XShmQueryExtension(dpy)==False)){ + if((!args->noshared)&&(!XQueryExtension(dpy, + "MIT-SHM", + shm_opcode, + &shm_event_base, + &shm_error_base))){ args->noshared=1; 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"); + "Try again using the --no-shared option\n"); exit(5); } + if((args->xfixes_cursor)&& (XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)){ args->xfixes_cursor=0; diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index f30485c..036bf5a 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -90,13 +90,13 @@ int main(int argc,char **argv){ "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); + &pdata.damage_error, + &pdata.shm_opcode); if((exit_status=InitializeData(&pdata,&enc_data,&cache_data))!=0) @@ -106,7 +106,7 @@ int main(int argc,char **argv){ rmdThreads(&pdata); fprintf(stderr,"."); - if((!pdata.args.noshared)||(!pdata.args.nocondshared)){ + if(!pdata.args.noshared){ XShmDetach (pdata.dpy, &pdata.shminfo); shmdt (&pdata.shminfo.shmaddr); shmctl (pdata.shminfo.shmid, IPC_RMID, 0); diff --git a/recordmydesktop/src/update_image.c b/recordmydesktop/src/update_image.c index 9681ce7..7a2895f 100644 --- a/recordmydesktop/src/update_image.c +++ b/recordmydesktop/src/update_image.c @@ -36,6 +36,8 @@ void UpdateImage(Display * dpy, EncData *enc, char *datatemp, int noshmem, + XShmSegmentInfo *shminfo, + int shm_opcode, int no_quick_subsample){ RectArea *temp; unsigned char *dtap=(unsigned char*)datatemp; @@ -52,12 +54,22 @@ void UpdateImage(Display * dpy, temp->geom.width, temp->geom.height); } + else{ + GetZPixmapSHM(dpy, + specs->root, + shminfo, + shm_opcode, + datatemp,temp->geom.x, + temp->geom.y, + temp->geom.width, + temp->geom.height); + } pthread_mutex_lock(yuv_mutex); UPDATE_YUV_BUFFER(yuv,dtap, (temp->geom.x-brwin->rgeom.x+enc->x_offset), (temp->geom.y-brwin->rgeom.y+enc->y_offset), (temp->geom.width),(temp->geom.height), - noshmem,no_quick_subsample, + no_quick_subsample, specs->depth); pthread_mutex_unlock(yuv_mutex); temp=temp->next; |