summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r--recordmydesktop/src/get_frame.c27
-rw-r--r--recordmydesktop/src/parseargs.c41
-rw-r--r--recordmydesktop/src/recordmydesktop.c18
3 files changed, 68 insertions, 18 deletions
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 44f2ec4..1d6a126 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -33,6 +33,8 @@ void *GetFrame(void *pdata){
uint msk_ret;
WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp;
Window root_ret,child_ret;
+ int pixel_total=((ProgData *)pdata)->brwin.rgeom.width*((ProgData *)pdata)->brwin.rgeom.height;
+
mouse_pos_abs.x=0;
mouse_pos_abs.y=0;
mouse_pos_abs.width=((ProgData *)pdata)->dummy_p_size;
@@ -52,7 +54,24 @@ void *GetFrame(void *pdata){
((ProgData *)pdata)->list_selector=((((ProgData *)pdata)->list_selector+1)%2);
pthread_mutex_lock(&((ProgData *)pdata)->list_mutex[tlist_sel]);
}
-
+ //here we measure the list and decide which way we will go
+ if(!((ProgData *)pdata)->args.nocondshared){
+ int level=0;
+ RectArea *temp=((ProgData *)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;
+ ((ProgData *)pdata)->args.noshared=(level<((ProgData *)pdata)->args.shared_thres);
+// if(!((ProgData *)pdata)->args.noshared){
+// fprintf(stderr,"shared screenshot with %d\n",level);
+// }
+ }
+ }
if(((ProgData *)pdata)->args.have_dummy_cursor){
//dummy pointer sequence
//update previous_position
@@ -70,7 +89,7 @@ void *GetFrame(void *pdata){
&mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret);
}
if(!((ProgData *)pdata)->args.noshared)
- XShmGetImage(((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root,((ProgData *)pdata)->image,(((ProgData *)pdata)->brwin.rgeom.x),(((ProgData *)pdata)->brwin.rgeom.y),AllPlanes);
+ XShmGetImage(((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root,((ProgData *)pdata)->shimage,(((ProgData *)pdata)->brwin.rgeom.x),(((ProgData *)pdata)->brwin.rgeom.y),AllPlanes);
if(!((ProgData *)pdata)->args.full_shots)
UpdateImage(((ProgData *)pdata)->dpy,
&((ProgData *)pdata)->enc_data->yuv,
@@ -79,7 +98,7 @@ void *GetFrame(void *pdata){
&((ProgData *)pdata)->rect_root[tlist_sel],
&((ProgData *)pdata)->brwin,
((ProgData *)pdata)->enc_data,
- ((((ProgData *)pdata)->args.noshared)?(((ProgData *)pdata)->datatemp):((ProgData *)pdata)->image->data),
+ ((((ProgData *)pdata)->args.noshared)?(((ProgData *)pdata)->datatemp):((ProgData *)pdata)->shimage->data),
((ProgData *)pdata)->args.noshared);
else{
if(((ProgData *)pdata)->args.noshared){
@@ -96,7 +115,7 @@ void *GetFrame(void *pdata){
}
else{
pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex);
- XImageToYUV(((ProgData *)pdata)->image,&((ProgData *)pdata)->enc_data->yuv);
+ XImageToYUV(((ProgData *)pdata)->shimage,&((ProgData *)pdata)->enc_data->yuv);
pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
}
}
diff --git a/recordmydesktop/src/parseargs.c b/recordmydesktop/src/parseargs.c
index fd1f776..500b778 100644
--- a/recordmydesktop/src/parseargs.c
+++ b/recordmydesktop/src/parseargs.c
@@ -33,9 +33,10 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
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)|\n"
- "\t -v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color| --no-dummy-cursor|\n"
- "\t -freq N(number>0)| -channels N(number>0)| -device SOUND_DEVICE| --nosound|\n"
- "\t --with-shared| --full-shots| --scshot| -scale-shot N| -o filename]^filename\n\n\n"
+ "\t -v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color|\n"
+ "\t --no-dummy-cursor| -freq N(number>0)| -channels N(number>0)| -device SOUND_DEVICE|\n"
+ "\t --nosound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|\n"
+ "\t --scshot| -scale-shot N| -o filename]^filename\n\n\n"
"General Options:\n"
"\t-h or --help\t\tPrint this help and exit.\n"
@@ -51,7 +52,9 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
"\t-dummy-cursor color\tColor of the dummy cursor [black|white](default black)\n"
"\t--no-dummy-cursor\tDisable drawing of a dummy cursor.\n"
- "\t--with-shared\t\tEnable usage of MIT-shared memory extension.\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-fps N(number>0.0)\tA positive number denoting desired framerate.\n\n"
@@ -327,6 +330,22 @@ 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: -channels N(number>0)\n");
+ return 1;
+ }
+ i++;
+ }
else if(!strcmp(argv[i],"-scale-shot")){
if(i+1<argc){
int num=atoi(argv[i+1]);
@@ -360,12 +379,20 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
arg_return->nosound=1;
else if(!strcmp(argv[i],"--drop-frames"))
arg_return->dropframes=1;
- else if(!strcmp(argv[i],"--with-shared"))
+ else if(!strcmp(argv[i],"--with-shared")){
arg_return->noshared=0;
- else if(!strcmp(argv[i],"--full-shots"))
+ arg_return->nocondshared=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;
- else if(!strcmp(argv[i],"--scshot"))
+ arg_return->nocondshared=1;
+ }
+ else if(!strcmp(argv[i],"--scshot")){
arg_return->scshot=1;
+ arg_return->nocondshared=1;
+ }
else if(!strcmp(argv[i],"--help")||!strcmp(argv[i],"-h")){
fprintf(stderr,"%s",usage);
return 1;
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index 7eb76df..5588b52 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -67,6 +67,7 @@ int main(int argc,char **argv){
//init data
+
if(!pdata.args.scshot){
fprintf(stderr,"Initializing...\n");
MakeMatrices();
@@ -104,19 +105,19 @@ int main(int argc,char **argv){
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);
}
- else{
- pdata.image=XShmCreateImage (pdata.dpy,pdata.specs.visual,pdata.specs.depth,ZPixmap,pdata.datamain,
+ if((!pdata.args.noshared)||(!pdata.args.nocondshared)){
+ pdata.shimage=XShmCreateImage (pdata.dpy,pdata.specs.visual,pdata.specs.depth,ZPixmap,pdata.datash,
&shminfo, pdata.brwin.rgeom.width,pdata.brwin.rgeom.height);
shminfo.shmid = shmget (IPC_PRIVATE,
- pdata.image->bytes_per_line * pdata.image->height,
+ pdata.shimage->bytes_per_line * pdata.shimage->height,
IPC_CREAT|0777);
- shminfo.shmaddr = pdata.image->data = shmat (shminfo.shmid, 0, 0);
+ shminfo.shmaddr = pdata.shimage->data = shmat (shminfo.shmid, 0, 0);
shminfo.readOnly = False;
if(!XShmAttach(pdata.dpy,&shminfo)){
fprintf(stderr,"Failed to attach shared memory to proccess.\n");
exit(1);
}
- XShmGetImage(pdata.dpy,pdata.specs.root,pdata.image,0,0,AllPlanes);
+ XShmGetImage(pdata.dpy,pdata.specs.root,pdata.shimage,0,0,AllPlanes);
}
if(pdata.args.scshot){
@@ -138,7 +139,10 @@ int main(int argc,char **argv){
pdata.args.nosound=1;
}
InitEncoder(&pdata,&enc_data);
- XImageToYUV(pdata.image,&pdata.enc_data->yuv);
+ if((pdata.args.nocondshared)&&(!pdata.args.noshared))
+ XImageToYUV(pdata.shimage,&pdata.enc_data->yuv);
+ else
+ XImageToYUV(pdata.shimage,&pdata.enc_data->yuv);
pdata.frametime=(1000000)/pdata.args.fps;
@@ -181,7 +185,7 @@ int main(int argc,char **argv){
if(!pdata.args.full_shots)
pthread_join(poll_damage_t,NULL);
fprintf(stderr,".");
- if(!(pdata.args.noshared)){
+ if((!pdata.args.noshared)||(!pdata.args.nocondshared)){
XShmDetach (pdata.dpy, &shminfo);
// XDestroyImage (pdata.image);
shmdt (&shminfo.shmaddr);
© All Rights Reserved