summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-12-13 14:53:02 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2007-12-13 14:53:02 +0000
commitbfc243a25074f519b994bb34143dc211961ccae0 (patch)
treebd39cbd75e70793b44f12bc43ac6130e7b11ca6f
parentdaac9c24a44eac7ba0a7ec292ee05117e06947bb (diff)
doc/recordmydesktop.1: added documentation about -restore option
include/rmdfunc.h: read and write specs file function protorypes include/rmdtypes.h, src/cache_audio.c src/capture_sound.c, src/encode_sound_buffer.c, src/initialize_data.c, src/load_cache.c: framesize moved to pdata struct(used to be initialized separately by every function that used it). src/Makefile.am: added src/rmd_restore.c src/parseargs.c: handle -restore option src/recordmydesktop.c: argument parsing moved before any X calls (restore doesn't need a running X server) src/rmd_restore.c: initialize all needed structs and data, for restore to be performed. Then EncodeCache routine and exit. src/specsfile.c: read and write specs file function bodies git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@474 f606c939-3180-4ac9-a4b8-4b8779d57d0a
-rw-r--r--recordmydesktop/doc/recordmydesktop.114
-rw-r--r--recordmydesktop/include/rmdfunc.h36
-rw-r--r--recordmydesktop/include/rmdtypes.h3
-rw-r--r--recordmydesktop/src/Makefile.am3
-rw-r--r--recordmydesktop/src/cache_audio.c20
-rw-r--r--recordmydesktop/src/capture_sound.c6
-rw-r--r--recordmydesktop/src/encode_sound_buffer.c11
-rw-r--r--recordmydesktop/src/initialize_data.c8
-rw-r--r--recordmydesktop/src/load_cache.c25
-rw-r--r--recordmydesktop/src/parseargs.c12
-rw-r--r--recordmydesktop/src/recordmydesktop.c9
-rw-r--r--recordmydesktop/src/rmd_restore.c98
-rw-r--r--recordmydesktop/src/specsfile.c148
13 files changed, 303 insertions, 90 deletions
diff --git a/recordmydesktop/doc/recordmydesktop.1 b/recordmydesktop/doc/recordmydesktop.1
index 7503868..2113cfe 100644
--- a/recordmydesktop/doc/recordmydesktop.1
+++ b/recordmydesktop/doc/recordmydesktop.1
@@ -352,6 +352,20 @@ Misc Options:
.br
.TP
.B
+ \-restore path_to_data
+ Encode cache data from a previous session, into an Ogg/Theora+Vorbis
+ file. The filename will be the one that was chosen initially.
+ Any other option specified with this one will be implicitly ignored
+ and recordMyDesktop will exit after the end of the encoding.
+ This option was added in recordMyDesktop 0.3.7 and it will not
+ work with cache files produced from earlier versions.
+ When using this option, remember that
+
+.B
+recordMyDesktop's cache is not safe, in respect to type-sizes and endianness.
+.br
+.TP
+.B
\-\-print\-config
Print compilation time options. Currently prints whether Jack capture is
enabled and if ALSA or OSS is used (may contain more information
diff --git a/recordmydesktop/include/rmdfunc.h b/recordmydesktop/include/rmdfunc.h
index f230287..30fe68d 100644
--- a/recordmydesktop/include/rmdfunc.h
+++ b/recordmydesktop/include/rmdfunc.h
@@ -792,6 +792,42 @@ void rmdDrawFrame(Display *dpy,
int height);
+/*
+ * Create a text file that holds the required
+ * capture attributes, in the cache directory.
+ *
+ * \param pdata ProgData struct containing all program data
+ *
+ * \returns 0 on Success, 1 on failure
+ *
+ */
+int WriteSpecsFile(ProgData *pdata);
+
+
+
+/*
+ * Read the text file that holds the required
+ * capture attributes, in the cache directory.
+ *
+ * \param pdata ProgData struct that will be fille
+ * with all program data
+ *
+ * \returns 0 on Success, 1 on failure
+ *
+ */
+int ReadSpecsFile(ProgData *pdata);
+
+
+/*
+ * Restore a previous recording, found in
+ * the given path.
+ *
+ * \param path Path to the cache folder.
+ *
+ * \returns 0 on Success, 1 on failure
+ *
+ */
+int rmdRestore(const char *path);
#endif
diff --git a/recordmydesktop/include/rmdtypes.h b/recordmydesktop/include/rmdtypes.h
index d7096ba..ebb2ebe 100644
--- a/recordmydesktop/include/rmdtypes.h
+++ b/recordmydesktop/include/rmdtypes.h
@@ -335,7 +335,8 @@ typedef struct _ProgData{
timer_alive, //determines loop of timer thread
hard_pause, //if sound device doesn't support pause
//we have to close and reopen
- avd; //syncronization among audio and video
+ avd, //syncronization among audio and video
+ sound_framesize; //size of each sound frame
#ifdef HAVE_LIBASOUND
snd_pcm_t *sound_handle;
snd_pcm_uframes_t periodsize;
diff --git a/recordmydesktop/src/Makefile.am b/recordmydesktop/src/Makefile.am
index a3a18ba..46d2e7a 100644
--- a/recordmydesktop/src/Makefile.am
+++ b/recordmydesktop/src/Makefile.am
@@ -34,7 +34,8 @@ recordmydesktop_SOURCES= recordmydesktop.c\
shortcuts.c\
rmd_error.c\
rmd_frame.c\
- rmd_timer.c
+ rmd_timer.c\
+ rmd_restore.c
INCLUDES= $(all_includes) -I$(top_srcdir)/include
diff --git a/recordmydesktop/src/cache_audio.c b/recordmydesktop/src/cache_audio.c
index 7896df7..d45e6ec 100644
--- a/recordmydesktop/src/cache_audio.c
+++ b/recordmydesktop/src/cache_audio.c
@@ -30,18 +30,10 @@ void *CacheSoundBuffer(ProgData *pdata){
//It's sound is tiny compared to that of image, so
//compressing would reducethe overall size by only an
//insignificant fraction.
-#ifdef HAVE_LIBASOUND
- int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*
- pdata->args.channels;
-#else
- int framesize=pdata->args.channels<<1;//Always signed 16 bit data
-#endif
#ifdef HAVE_JACK_H
void *jackbuf=NULL;
if(pdata->args.use_jack){
- framesize=sizeof(jack_default_audio_sample_t)*
- pdata->jdata->nports;
- jackbuf=malloc(framesize*pdata->jdata->buffersize);
+ jackbuf=malloc(pdata->sound_framesize*pdata->jdata->buffersize);
}
#endif
while((pdata->running)){
@@ -69,7 +61,7 @@ void *CacheSoundBuffer(ProgData *pdata){
//advance the list
pdata->sound_buffer=pdata->sound_buffer->next;
pthread_mutex_unlock(&pdata->sound_buffer_mutex);
- fwrite(buff->data,1,pdata->periodsize*framesize,
+ fwrite(buff->data,1,pdata->periodsize*pdata->sound_framesize,
pdata->cache_data->afp);
free(buff->data);
free(buff);
@@ -77,11 +69,13 @@ void *CacheSoundBuffer(ProgData *pdata){
else{
#ifdef HAVE_JACK_H
if((*jack_ringbuffer_read_space_p)(pdata->jdata->sound_buffer)>=
- (framesize*pdata->jdata->buffersize)){
+ (pdata->sound_framesize*pdata->jdata->buffersize)){
(*jack_ringbuffer_read_p)(pdata->jdata->sound_buffer,
jackbuf,
- (framesize*pdata->jdata->buffersize));
- fwrite(jackbuf,1,(framesize*pdata->jdata->buffersize),
+ (pdata->sound_framesize*
+ pdata->jdata->buffersize));
+ fwrite(jackbuf,1,(pdata->sound_framesize*
+ pdata->jdata->buffersize),
pdata->cache_data->afp);
}
else{
diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c
index 0e89e21..c89909e 100644
--- a/recordmydesktop/src/capture_sound.c
+++ b/recordmydesktop/src/capture_sound.c
@@ -31,8 +31,6 @@ void *CaptureSound(ProgData *pdata){
#ifdef HAVE_LIBASOUND
int frames=pdata->periodsize;
- int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*
- pdata->args.channels;
#endif
//start capturing only after first frame is taken
usleep(pdata->frametime);
@@ -92,7 +90,7 @@ void *CaptureSound(ProgData *pdata){
//create new buffer
newbuf=(SndBuffer *)malloc(sizeof(SndBuffer));
#ifdef HAVE_LIBASOUND
- newbuf->data=(signed char *)malloc(frames*framesize);
+ newbuf->data=(signed char *)malloc(frames*pdata->sound_framesize);
#else
newbuf->data=(signed char *)malloc(((pdata->args.buffsize<<1)*
pdata->args.channels));
@@ -103,7 +101,7 @@ void *CaptureSound(ProgData *pdata){
#ifdef HAVE_LIBASOUND
while(sret<frames){
int temp_sret=snd_pcm_readi(pdata->sound_handle,
- newbuf->data+framesize*sret,
+ newbuf->data+pdata->sound_framesize*sret,
frames-sret);
if(temp_sret==-EPIPE){
fprintf(stderr,"%s: Overrun occurred.\n",
diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c
index 7945567..1000743 100644
--- a/recordmydesktop/src/encode_sound_buffer.c
+++ b/recordmydesktop/src/encode_sound_buffer.c
@@ -31,12 +31,8 @@ void *EncodeSoundBuffer(ProgData *pdata){
int sampread=pdata->periodsize;
#ifdef HAVE_JACK_H
void *jackbuf=NULL;
- int framesize=sizeof(jack_default_audio_sample_t)*
- pdata->jdata->nports;
if(pdata->args.use_jack){
- framesize=sizeof(jack_default_audio_sample_t)*
- pdata->jdata->nports;
- jackbuf=malloc(framesize*pdata->jdata->buffersize);
+ jackbuf=malloc(pdata->sound_framesize*pdata->jdata->buffersize);
}
#endif
pdata->v_encoding_clean=0;
@@ -84,10 +80,11 @@ void *EncodeSoundBuffer(ProgData *pdata){
else{
#ifdef HAVE_JACK_H
if((*jack_ringbuffer_read_space_p)(pdata->jdata->sound_buffer)>=
- (framesize*pdata->jdata->buffersize)){
+ (pdata->sound_framesize*pdata->jdata->buffersize)){
(*jack_ringbuffer_read_p)(pdata->jdata->sound_buffer,
jackbuf,
- (framesize*pdata->jdata->buffersize));
+ (pdata->sound_framesize*
+ pdata->jdata->buffersize));
vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,
sampread);
for(j=0;j<pdata->args.channels;j++){
diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c
index a3566ba..2c2dad1 100644
--- a/recordmydesktop/src/initialize_data.c
+++ b/recordmydesktop/src/initialize_data.c
@@ -101,6 +101,10 @@ int InitializeData(ProgData *pdata,
&pdata->periodsize,
&pdata->periodtime,
&pdata->hard_pause);
+ pdata->sound_framesize=((snd_pcm_format_width(
+ SND_PCM_FORMAT_S16_LE))/8)*
+ pdata->args.channels;
+
if(pdata->sound_handle==NULL){
#else
pdata->sound_handle=OpenDev(pdata->args.device,
@@ -110,6 +114,7 @@ int InitializeData(ProgData *pdata,
((pdata->args.channels<<1)*pdata->args.frequency);
//when using OSS periodsize serves as an alias of buffsize
pdata->periodsize=pdata->args.buffsize;
+ pdata->sound_framesize=pdata->args.channels<<1;
if(pdata->sound_handle<0){
#endif
fprintf(stderr,"Error while opening/configuring soundcard %s\n"
@@ -138,6 +143,9 @@ int InitializeData(ProgData *pdata,
pdata->args.channels=pdata->jdata->nports;
pdata->periodtime=(1000000*pdata->args.buffsize)/
pdata->args.frequency;
+ pdata->sound_framesize=sizeof(jack_default_audio_sample_t)*
+ pdata->jdata->nports;
+
#else
fprintf(stderr,"Should not be here!\n");
exit(-1);
diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c
index a992a21..f67ae86 100644
--- a/recordmydesktop/src/load_cache.c
+++ b/recordmydesktop/src/load_cache.c
@@ -132,18 +132,8 @@ void *LoadCache(ProgData *pdata){
blocknum_y=pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH,
blockszy=Y_UNIT_BYTES,//size of y plane block in bytes
blockszuv=UV_UNIT_BYTES;//size of u,v plane blocks in bytes
-#ifdef HAVE_LIBASOUND
- int framesize=((snd_pcm_format_width(SND_PCM_FORMAT_S16_LE))/8)*
- pdata->args.channels;//audio frame size
-#else
- int framesize=pdata->args.channels<<1;//Always signed 16 bit data
-#endif
-#ifdef HAVE_JACK_H
- if(pdata->args.use_jack)
- framesize=sizeof(jack_default_audio_sample_t)*
- pdata->jdata->nports;
-#endif
- signed char *sound_data=(signed char *)malloc(pdata->periodsize*framesize);
+ signed char *sound_data=(signed char *)malloc(pdata->periodsize*
+ pdata->sound_framesize);
u_int32_t YBlocks[(yuv->y_width*yuv->y_height)/Y_UNIT_BYTES],
UBlocks[(yuv->uv_width*yuv->uv_height)/UV_UNIT_BYTES],
@@ -197,8 +187,12 @@ void *LoadCache(ProgData *pdata){
//sync
missing_frames+=frame.header->current_total-
(extra_frames+frame.header->frameno);
- fprintf(stdout,"\r[%d%%] ",
- ((frame.header->frameno+extra_frames)*100)/frames_total);
+ if(frames_total)
+ fprintf(stdout,"\r[%d%%] ",
+ ((frame.header->frameno+extra_frames)*100)/frames_total);
+ else
+ fprintf(stdout,"\r[%d frames rendered] ",
+ (frame.header->frameno+extra_frames));
fflush(stdout);
if( (frame.header->Ynum<=blocknum_x*blocknum_y) &&
(frame.header->Unum<=blocknum_x*blocknum_y) &&
@@ -260,7 +254,8 @@ void *LoadCache(ProgData *pdata){
//audio load and encoding
else{
if(!audio_end){
- int nbytes=fread(sound_data,1,pdata->periodsize*framesize,afp);
+ int nbytes=fread(sound_data,1,pdata->periodsize*
+ pdata->sound_framesize,afp);
if(nbytes<=0)
audio_end=1;
else
diff --git a/recordmydesktop/src/parseargs.c b/recordmydesktop/src/parseargs.c
index aeaa984..cebaf17 100644
--- a/recordmydesktop/src/parseargs.c
+++ b/recordmydesktop/src/parseargs.c
@@ -101,6 +101,7 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
"\t-s_quality n\t\tDesired audio quality(-1 to 10).\n\n"
"Misc Options:\n"
+ "\t-restore path_to_data\tRestore (encode) data from a previous session.\n"
"\t--no-wm-check\t\tDo not try to detect"
" the window manager(and set options according to it)\n"
@@ -516,6 +517,17 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){
}
i++;
}
+ else if(!strcmp(argv[i],"-restore")){
+ if(i+1<argc){
+ int ex_st=rmdRestore(argv[i+1]);
+ exit(ex_st);
+ }
+ else{
+ fprintf(stderr,"Argument Usage: -restore path_to_data\n");
+ return 1;
+ }
+ i++;
+ }
else if(!strcmp(argv[i],"--no-sound"))
arg_return->nosound=1;
else if(!strcmp(argv[i],"--no-shared")){
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index 2401dd0..a2d5e4f 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -32,14 +32,15 @@ int main(int argc,char **argv){
ProgData pdata;
exit_status=0;
- if(XInitThreads ()==0){
- fprintf(stderr,"Couldn't initialize thread support!\n");
- exit(7);
- }
+
DEFAULT_ARGS(&pdata.args);
if(ParseArgs(argc,argv,&pdata.args)){
exit(1);
}
+ if(XInitThreads ()==0){
+ fprintf(stderr,"Couldn't initialize thread support!\n");
+ exit(7);
+ }
if(pdata.args.display!=NULL){
pdata.dpy = XOpenDisplay(pdata.args.display);
XSetErrorHandler(rmdErrorHandler);
diff --git a/recordmydesktop/src/rmd_restore.c b/recordmydesktop/src/rmd_restore.c
index f080c61..3cba0db 100644
--- a/recordmydesktop/src/rmd_restore.c
+++ b/recordmydesktop/src/rmd_restore.c
@@ -25,19 +25,103 @@
******************************************************************************/
+
#include <recordmydesktop.h>
-int rmdRestore(char *path){
+int rmdRestore(const char *path){
+
+ int i=0,
+ width,
+ height,
+ offset_x,
+ offset_y;
+
+ ProgData pdata;
+ EncData enc_data;
+ CacheData cache_data;
+
+
+ DEFAULT_ARGS(&pdata.args);
+
+ pdata.enc_data=&enc_data;
+ pdata.cache_data=&cache_data;
+
+ //projname
+ cache_data.projname=malloc(strlen(path)+2);
+ strcpy(cache_data.projname,path);
+ strcat(cache_data.projname,"/");//having two of these doesn't hurt...
+ //image data
+ cache_data.imgdata=malloc(strlen(cache_data.projname)+11);
+ strcpy(cache_data.imgdata,cache_data.projname);
+ strcat(cache_data.imgdata,"img.out");
+ //audio data
+ cache_data.audiodata=malloc(strlen(cache_data.projname)+10);
+ strcpy(cache_data.audiodata,cache_data.projname);
+ strcat(cache_data.audiodata,"audio.pcm");
+ //specsfile
+ cache_data.specsfile=malloc(strlen(cache_data.projname)+10);
+ strcpy(cache_data.specsfile,cache_data.projname);
+ strcat(cache_data.specsfile,"specs.txt");
+
+
+ if(ReadSpecsFile(&pdata))
+ return 1;
+
+
+ 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;
+
+ enc_data.yuv.y=(unsigned char *)malloc(height*width);
+ enc_data.yuv.u=(unsigned char *)malloc(height*width/4);
+ enc_data.yuv.v=(unsigned char *)malloc(height*width/4);
+ enc_data.yuv.y_width=width;
+ enc_data.yuv.y_height=height;
+ enc_data.yuv.y_stride=width;
+
+ enc_data.yuv.uv_width=width/2;
+ enc_data.yuv.uv_height=height/2;
+ enc_data.yuv.uv_stride=width/2;
+ enc_data.x_offset=offset_x;
+ enc_data.y_offset=offset_y;
+
+ for(i=0;i<(enc_data.yuv.y_width*enc_data.yuv.y_height);i++)
+ enc_data.yuv.y[i]=0;
+ for(i=0;i<(enc_data.yuv.uv_width*enc_data.yuv.uv_height);i++){
+ enc_data.yuv.v[i]=enc_data.yuv.u[i]=127;
+ }
+
+ yblocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)*
+ (enc_data.yuv.y_height/Y_UNIT_WIDTH));
+ ublocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)*
+ (enc_data.yuv.y_height/Y_UNIT_WIDTH));
+ vblocks=malloc(sizeof(u_int32_t)*(enc_data.yuv.y_width/Y_UNIT_WIDTH)*
+ (enc_data.yuv.y_height/Y_UNIT_WIDTH));
+
+ pdata.frametime=(1000000)/pdata.args.fps;
+
+ pthread_mutex_init(&pdata.theora_lib_mutex,NULL);
+ pthread_mutex_init(&pdata.vorbis_lib_mutex,NULL);
+ pthread_mutex_init(&pdata.libogg_mutex,NULL);
+ pthread_cond_init(&pdata.theora_lib_clean,NULL);
+ pthread_cond_init(&pdata.vorbis_lib_clean,NULL);
+ pdata.th_encoding_clean=pdata.v_encoding_clean=1;
+ Aborted=pdata.avd=0;
+ pdata.sound_buffer=NULL;
+ pdata.running=1;
+ Running=&pdata.running;
+
+ RegisterCallbacks(NULL);
+ fprintf(stderr,"Restoring %s!!!\n",path);
+ EncodeCache(&pdata);
-/*
-EncodeCache(&pdata);
-fprintf(stderr,"Done!!!\n");
-fprintf(stderr,"Goodbye!\n");
-CleanUp();
-*/
+ fprintf(stderr,"Done!!!\n");
+ fprintf(stderr,"Goodbye!\n");
+ CleanUp();
return 0;
}
diff --git a/recordmydesktop/src/specsfile.c b/recordmydesktop/src/specsfile.c
index 09c0f25..89b50d8 100644
--- a/recordmydesktop/src/specsfile.c
+++ b/recordmydesktop/src/specsfile.c
@@ -24,48 +24,17 @@
* For further information contact me at johnvarouhakis@gmail.com *
******************************************************************************/
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+
#include <stdlib.h>
#include <stdio.h>
#include <rmdtypes.h>
-
-int WriteStrOpt(FILE *fp,char *desc,char delim,char *val){
-
-
-
-}
-
-int WriteIntOpt(FILE *fp,char *desc,char delim,int val){
-
-
-
-}
-
-int WriteFloatOpt(FILE *fp,char *desc,char delim,int val){
-
-
-
-}
-
-
-char *ReadStrOpt(FILE *fp,char delim){
-
-
-}
-
-int ReadIntOpt(FILE *fp,char delim){
-
-
-}
-
-float ReadFloatOpt(FILE *fp,char delim){
-
-
-}
-
-
int WriteSpecsFile(ProgData *pdata){
FILE *fp;
@@ -74,8 +43,27 @@ int WriteSpecsFile(ProgData *pdata){
fp=fopen(pdata->cache_data->specsfile,"wb");
if(fp==NULL)
return 1;
-
-
+ else{
+
+ fprintf(fp,"recordMyDesktop = %s\n",VERSION);
+ fprintf(fp,"Width = %d\n",pdata->brwin.rgeom.width);
+ fprintf(fp,"Height = %d\n",pdata->brwin.rgeom.height);
+ fprintf(fp,"Filename = %s\n",pdata->args.filename);
+ fprintf(fp,"FPS = %f\n",pdata->args.fps);
+ fprintf(fp,"NoSound = %d\n",pdata->args.nosound);
+ fprintf(fp,"Frequency = %d\n",pdata->args.frequency);
+ fprintf(fp,"Channels = %d\n",pdata->args.channels);
+ fprintf(fp,"BufferSize = %d\n",pdata->args.buffsize);
+ fprintf(fp,"SoundFrameSize = %d\n",pdata->sound_framesize);
+ fprintf(fp,"PeriodSize = %u\n",pdata->periodsize);
+ fprintf(fp,"UsedJack = %d\n",pdata->args.use_jack);
+ fprintf(fp,"v_bitrate = %d\n",pdata->args.v_bitrate);
+ fprintf(fp,"v_quality = %d\n",pdata->args.v_quality);
+ fprintf(fp,"s_quality = %d\n",pdata->args.s_quality);
+ fprintf(fp,"ZeroCompression = %d\n",pdata->args.zerocompression);
+
+
+ }
fclose(fp);
return 0;
@@ -85,8 +73,92 @@ int WriteSpecsFile(ProgData *pdata){
int ReadSpecsFile(ProgData *pdata){
+ FILE *fp;
+
+ fp=fopen(pdata->cache_data->specsfile,"rb");
+ if(fp==NULL)
+ return 1;
+ else{
+
+ char Cached_Version[256];
+ free(pdata->args.filename);
+ pdata->args.filename=malloc(512);
+
+ //Take that single-point-of-exit advocates !!!
+ //15 points of exit, just for your pleasure.
+ //Also, Vi(m) rules, emacs sucks.
+
+ if(fscanf(fp,"recordMyDesktop = %s\n",Cached_Version)!=1){
+ fprintf(stderr,"Error reading VERSION attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"Width = %d\n",&pdata->brwin.rgeom.width)!=1){
+ fprintf(stderr,"Error reading Width attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"Height = %d\n",&pdata->brwin.rgeom.height)!=1){
+ fprintf(stderr,"Error reading Height attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"Filename = %s\n",pdata->args.filename)!=1){
+ fprintf(stderr,"Error reading Filename attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"FPS = %f\n",&pdata->args.fps)!=1){
+ fprintf(stderr,"Error reading FPS attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"NoSound = %d\n",&pdata->args.nosound)!=1){
+ fprintf(stderr,"Error reading NoSound attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"Frequency = %d\n",&pdata->args.frequency)!=1){
+ fprintf(stderr,"Error reading Frequency attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"Channels = %d\n",&pdata->args.channels)!=1){
+ fprintf(stderr,"Error reading Channels attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"BufferSize = %d\n",&pdata->args.buffsize)!=1){
+ fprintf(stderr,"Error reading BufferSize attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"SoundFrameSize = %d\n",&pdata->sound_framesize)!=1){
+ fprintf(stderr,"Error reading SoundFrameSize attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"PeriodSize = %u\n",&pdata->periodsize)!=1){
+ fprintf(stderr,"Error reading PeriodSize attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"UsedJack = %u\n",&pdata->args.use_jack)!=1){
+ fprintf(stderr,"Error reading UsedJack attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"v_bitrate = %d\n",&pdata->args.v_bitrate)!=1){
+ fprintf(stderr,"Error reading v_bitrate attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"v_quality = %d\n",&pdata->args.v_quality)!=1){
+ fprintf(stderr,"Error reading v_quality attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"s_quality = %d\n",&pdata->args.s_quality)!=1){
+ fprintf(stderr,"Error reading s_quality attribute!!!\n");
+ return 1;
+ }
+ if(fscanf(fp,"ZeroCompression = %d\n",&pdata->args.zerocompression)!=1){
+ fprintf(stderr,"Error reading ZeroCompression attribute!!!\n");
+ return 1;
+ }
+
+
+ }
+ fclose(fp);
+ return 0;
}
© All Rights Reserved