summaryrefslogtreecommitdiff
path: root/recordmydesktop
diff options
context:
space:
mode:
Diffstat (limited to 'recordmydesktop')
-rw-r--r--recordmydesktop/doc/recordmydesktop.124
-rw-r--r--recordmydesktop/include/recordmydesktop.h11
-rw-r--r--recordmydesktop/src/get_frame.c27
-rw-r--r--recordmydesktop/src/parseargs.c41
-rw-r--r--recordmydesktop/src/recordmydesktop.c18
5 files changed, 93 insertions, 28 deletions
diff --git a/recordmydesktop/doc/recordmydesktop.1 b/recordmydesktop/doc/recordmydesktop.1
index 9001d56..0bffe9a 100644
--- a/recordmydesktop/doc/recordmydesktop.1
+++ b/recordmydesktop/doc/recordmydesktop.1
@@ -34,9 +34,7 @@ but this will notably increase the workload. In this case, enabling the
\-\-with\-shared
option is recommended
.br
-(by default this option is disabled since copying small areas of display is faster
-.br
-than uploading the whole image from video memory).
+(by default this option is switched on or off at every frame, according to the size of the area to be aquired).
.br
.br
recordMyDesktop doesn't have a commandline interface.
@@ -181,7 +179,17 @@ Image Options:
.TP
.B
\-\-with\-shared
- Enable usage of MIT\-shared memory extension.
+ 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
+.B
+ \-shared\-threshold n
+ Threshold over which shared memory is used(default 75).
.br
.TP
.B
@@ -283,11 +291,13 @@ If no other option is specified, filename can be given without the \-o switch.
.br
\-display DISPLAY| \-x X| \-y Y|\-width N| \-height N| \-fps N(number>0)|
.br
-\-v_quality n| \-s_quality n| \-v_bitrate n| \-\-drop\-frames| \-dummy\-cursor color| \-\-no\-dummy\-cursor|
+\-v_quality n| \-s_quality n| \-v_bitrate n| \-\-no\-framedrop| \-dummy\-cursor color|
+.br
+\-\-no\-dummy\-cursor| \-freq N(number>0)| \-channels N(number>0)| \-device SOUND_DEVICE|
.br
-\-freq N(number>0)| \-channels N(number>0)| \-device SOUND_DEVICE| \-\-nosound|
+\-\-nosound| \-\-with\-shared| \-\-no\-cond\-shared| \-shared\-threshold n| \-\-full\-shots|
.br
-\-\-with\-shared| \-\-full\-shots| \-\-scshot| \-scale\-shot N| \-o filename]^filename
+\-\-scshot| \-scale\-shot N| \-o filename]^filename
.br
.br
.br
diff --git a/recordmydesktop/include/recordmydesktop.h b/recordmydesktop/include/recordmydesktop.h
index f02161e..a3c9782 100644
--- a/recordmydesktop/include/recordmydesktop.h
+++ b/recordmydesktop/include/recordmydesktop.h
@@ -111,7 +111,9 @@ typedef struct _ProgArgs{
unsigned int channels; //no of channels(default 2)
char *device; //default sound device(default according to alsa or oss)
int nosound; //do not record sound(default 0)
- int noshared; //do not use shared memory extension(default disabled)
+ int noshared; //do not use shared memory extension(default 1)
+ int nocondshared; //de not use shared memory on large image aquititions
+ int shared_thres; //threshold to use shared memory
int full_shots; //do not poll damage, take full screenshots
int scshot; //take screenshot and exit(default 0)
int scale_shot; //screenshot subscale factor(default 1)
@@ -160,11 +162,13 @@ typedef struct _ProgData{
BRWindow brwin;//recording window
Display *dpy;//curtrent display
XImage *image;//the image that holds the current full screenshot
+ XImage *shimage;//the image that holds the current full screenshot(shared memory)
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 the image above
+ 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
@@ -267,11 +271,12 @@ unsigned char Yr[256],Yg[256],Yb[256],
=(args)->width=(args)->height=(args)->quietmode\
=(args)->nosound=(args)->scshot=(args)->full_shots=0;\
(args)->noshared=(args)->scale_shot=1;\
- (args)->dropframes=0;\
+ (args)->dropframes=(args)->nocondshared=0;\
(args)->filename=(char *)malloc(8);\
strcpy((args)->filename,"out.ogg");\
(args)->encoding=OGG_THEORA_VORBIS;\
(args)->cursor_color=1;\
+ (args)->shared_thres=75;\
(args)->have_dummy_cursor=1;\
(args)->device=(char *)malloc(8);\
strcpy((args)->device,"hw:0,0");\
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