summaryrefslogtreecommitdiff
path: root/rMD-exp/src
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-10-26 01:45:04 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-10-26 01:45:04 +0000
commit3370b5318c1845704ae95f1d919a37bb881f52f9 (patch)
treed66c14908d44b7ad404abbaf5b70bc8726a80b4d /rMD-exp/src
parentba11f851311f9f92f92fcd8148a8f621b736e979 (diff)
cache initialization, image flushing
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@115 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'rMD-exp/src')
-rw-r--r--rMD-exp/src/Makefile.am3
-rw-r--r--rMD-exp/src/cache_frame.c7
-rw-r--r--rMD-exp/src/init_encoder.c27
-rw-r--r--rMD-exp/src/parseargs.c21
-rw-r--r--rMD-exp/src/recordmydesktop.c12
-rw-r--r--rMD-exp/src/rmd_cache.c90
6 files changed, 138 insertions, 22 deletions
diff --git a/rMD-exp/src/Makefile.am b/rMD-exp/src/Makefile.am
index 4315ab3..8332134 100644
--- a/rMD-exp/src/Makefile.am
+++ b/rMD-exp/src/Makefile.am
@@ -20,7 +20,8 @@ recordmydesktop_SOURCES= recordmydesktop.c\
capture_sound.c\
encode_sound_buffer.c\
init_encoder.c\
- cache_frame.c
+ cache_frame.c\
+ rmd_cache.c
INCLUDES= $(all_includes) -I../include -I$x_includes
diff --git a/rMD-exp/src/cache_frame.c b/rMD-exp/src/cache_frame.c
index 6b214e0..6f97723 100644
--- a/rMD-exp/src/cache_frame.c
+++ b/rMD-exp/src/cache_frame.c
@@ -25,7 +25,8 @@
**********************************************************************************/
#include <recordmydesktop.h>
-#include <zlib.h>
+
+
void MakeChecksums(unsigned char *buf,int width,int height,int divisor,unsigned short int *checksums){
int i,k,j,m;
@@ -60,8 +61,8 @@ void *CacheImageBuffer(void *pdata){
pthread_mutex_init(&pmut,NULL);
pthread_mutex_init(&imut,NULL);
yuv_buffer yuv[2];
- gzFile *fp;
- fp=gzopen("temp.out","wb1f");
+ gzFile *fp=((ProgData *)pdata)->cache_data->ifp;
+
if(fp==NULL)exit(13);
unsigned short int checksums_y[2][256],
diff --git a/rMD-exp/src/init_encoder.c b/rMD-exp/src/init_encoder.c
index ed1ad53..34db2a7 100644
--- a/rMD-exp/src/init_encoder.c
+++ b/rMD-exp/src/init_encoder.c
@@ -27,7 +27,7 @@
#include <recordmydesktop.h>
-void InitEncoder(ProgData *pdata,EncData *enc_data_t){
+void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){
int y1,y2;
(pdata)->enc_data=enc_data_t;
srand(time(NULL));
@@ -150,19 +150,20 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t){
}
+ 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.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.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);
}
diff --git a/rMD-exp/src/parseargs.c b/rMD-exp/src/parseargs.c
index a335b59..746df5c 100644
--- a/rMD-exp/src/parseargs.c
+++ b/rMD-exp/src/parseargs.c
@@ -32,11 +32,11 @@ 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)|\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)| -device SOUND_DEVICE|\n"
"\t --nosound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|\n"
- "\t --quick-subsampling| -o filename]^filename\n\n\n"
+ "\t --quick-subsampling| -workdir DIR| -o filename]^filename\n\n\n"
"General Options:\n"
"\t-h or --help\t\tPrint this help and exit.\n"
@@ -66,12 +66,14 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
"\t--nosound\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--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-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-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";
@@ -363,6 +365,18 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
}
i++;
}
+ else if(!strcmp(argv[i],"-workdir")){
+ if(i+1<argc){
+ free(arg_return->workdir);
+ arg_return->workdir=malloc(strlen(argv[i+1])+1);
+ strcpy(arg_return->workdir,argv[i+1]);
+ }
+ else{
+ fprintf(stderr,"Argument Usage: -workdir DIR\n");
+ return 1;
+ }
+ i++;
+ }
else if(!strcmp(argv[i],"--nosound"))
arg_return->nosound=1;
else if(!strcmp(argv[i],"--drop-frames"))
@@ -380,6 +394,9 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
else if(!strcmp(argv[i],"--quick-subsampling")){
arg_return->no_quick_subsample=0;
}
+ else if(!strcmp(argv[i],"--on-the-fly-encoding")){
+ arg_return->encOnTheFly=1;
+ }
else if(!strcmp(argv[i],"--help")||!strcmp(argv[i],"-h")){
fprintf(stderr,"%s",usage);
return 1;
diff --git a/rMD-exp/src/recordmydesktop.c b/rMD-exp/src/recordmydesktop.c
index c14f605..df7fbb3 100644
--- a/rMD-exp/src/recordmydesktop.c
+++ b/rMD-exp/src/recordmydesktop.c
@@ -51,6 +51,7 @@ int main(int argc,char **argv){
}
else{
EncData enc_data;
+ CacheData cache_data;
pthread_t poll_damage_t,
image_capture_t,
image_encode_t,
@@ -131,17 +132,22 @@ int main(int argc,char **argv){
if(!pdata.args.nosound){
pdata.sound_handle=OpenDev(pdata.args.device,&pdata.args.channels,&pdata.args.frequency,&pdata.periodsize, &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\nTry running with the --nosound or specify a correct device.\n",pdata.args.device);
exit(3);
}
}
+
+ if(pdata.args.encOnTheFly)
+ InitEncoder(&pdata,&enc_data,0);
+ else
+ InitCacheData(&pdata,&enc_data,&cache_data);
- InitEncoder(&pdata,&enc_data);
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++){
pdata.enc_data->yuv.v[i]=pdata.enc_data->yuv.u[i]=127;
}
+
if((pdata.args.nocondshared)&&(!pdata.args.noshared)){
if(pdata.args.no_quick_subsample){
UPDATE_YUV_BUFFER_IM_AVG((&pdata.enc_data->yuv),((unsigned char*)pdata.shimage->data),
@@ -199,7 +205,7 @@ int main(int argc,char **argv){
fprintf(stderr,".");
if(!pdata.args.nosound){
int *snd_exit;
- pthread_join(sound_capture_t,(&snd_exit));
+ pthread_join(sound_capture_t,(void *)(&snd_exit));
fprintf(stderr,".");
// if(!(*snd_exit))
// pthread_join(sound_encode_t,NULL);
diff --git a/rMD-exp/src/rmd_cache.c b/rMD-exp/src/rmd_cache.c
new file mode 100644
index 0000000..eb86aad
--- /dev/null
+++ b/rMD-exp/src/rmd_cache.c
@@ -0,0 +1,90 @@
+/*********************************************************************************
+* 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 *
+**********************************************************************************/
+
+#include <recordmydesktop.h>
+
+void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){
+ int width,height,offset_x,offset_y,pid;
+ char pidbuf[8];
+
+ //we set the buffer only since there's
+ //no need to initialize the encoder from now.
+ width=((pdata->brwin.rgeom.width + 15) >>4)<<4;
+ height=((pdata->brwin.rgeom.height + 15) >>4)<<4;
+ offset_x=((width-pdata->brwin.rgeom.width)/2)&~1;
+ offset_y=((height-pdata->brwin.rgeom.height)/2)&~1;
+
+ (pdata)->enc_data=enc_data_t;
+
+ enc_data_t->yuv.y=(unsigned char *)malloc(height*width);
+ enc_data_t->yuv.u=(unsigned char *)malloc(height*width/4);
+ enc_data_t->yuv.v=(unsigned char *)malloc(height*width/4);
+ enc_data_t->yuv.y_width=width;
+ enc_data_t->yuv.y_height=height;
+ enc_data_t->yuv.y_stride=width;
+
+ enc_data_t->yuv.uv_width=width/2;
+ enc_data_t->yuv.uv_height=height/2;
+ enc_data_t->yuv.uv_stride=width/2;
+ enc_data_t->x_offset=offset_x;
+ enc_data_t->y_offset=offset_y;
+
+
+ //now we set the cache files
+ (pdata)->cache_data=cache_data_t;
+
+ cache_data_t->workdir=(pdata->args).workdir;
+ pid=getpid();
+
+ 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);
+ //projname
+ strcpy(cache_data_t->projname,cache_data_t->workdir);
+ strcat(cache_data_t->projname,"/");
+ strcat(cache_data_t->projname,"rMD-session-");
+ strcat(cache_data_t->projname,pidbuf);
+ strcat(cache_data_t->projname,"/");
+ //image data
+ cache_data_t->imgdata=malloc(strlen(cache_data_t->projname)+11);
+ strcpy(cache_data_t->imgdata,cache_data_t->projname);
+ strcat(cache_data_t->imgdata,"img.out.gz");
+ //audio data
+ cache_data_t->audiodata=malloc(strlen(cache_data_t->projname)+10);
+ strcpy(cache_data_t->audiodata,cache_data_t->projname);
+ strcat(cache_data_t->audiodata,"audio.pcm");
+
+ //now that've got out buffers and our filenames we start
+ //creating the needed files
+
+ mkdir(cache_data_t->projname,0777);
+ cache_data_t->ifp=gzopen(cache_data_t->imgdata,"wb1f");
+ if(!pdata->args.nosound)
+ cache_data_t->afp=fopen(cache_data_t->audiodata,"wb");
+
+}
+
+
© All Rights Reserved