diff options
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/rmd_cache_audio.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_encode_sound_buffer.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_get_frame.c | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_init_encoder.c | 183 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_initialize_data.c | 6 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_types.h | 63 |
6 files changed, 131 insertions, 129 deletions
diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c index 042c734..71c9611 100644 --- a/recordmydesktop/src/rmd_cache_audio.c +++ b/recordmydesktop/src/rmd_cache_audio.c @@ -102,7 +102,7 @@ void *rmdCacheSoundBuffer(ProgData *pdata) { } #endif } - pdata->avd-=pdata->periodtime; + pdata->avd -= pdata->periodtime; } fclose(pdata->cache_data->afp); diff --git a/recordmydesktop/src/rmd_encode_sound_buffer.c b/recordmydesktop/src/rmd_encode_sound_buffer.c index c68eae0..3ea85f2 100644 --- a/recordmydesktop/src/rmd_encode_sound_buffer.c +++ b/recordmydesktop/src/rmd_encode_sound_buffer.c @@ -127,7 +127,7 @@ void *rmdEncodeSoundBuffer(ProgData *pdata) { } pthread_mutex_unlock(&pdata->libogg_mutex); - pdata->avd-=pdata->periodtime; + pdata->avd -= pdata->periodtime; } pdata->v_encoding_clean=1; diff --git a/recordmydesktop/src/rmd_get_frame.c b/recordmydesktop/src/rmd_get_frame.c index be199c0..aae7d09 100644 --- a/recordmydesktop/src/rmd_get_frame.c +++ b/recordmydesktop/src/rmd_get_frame.c @@ -249,7 +249,7 @@ static void rmdMoveCaptureArea( BRWindow *brwin, * * \param x_offset left x of the recording area * -* \param x_offset upper y of the recording area +* \param y_offset upper y of the recording area * * \param blocknum_x Width of image in blocks * @@ -527,7 +527,7 @@ void *rmdGetFrame(ProgData *pdata) { if (pdata->args.xfixes_cursor || pdata->args.have_dummy_cursor) { int mouse_xoffset, mouse_yoffset; //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&temp_brwin, &mouse_pos_temp); + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs, &temp_brwin, &mouse_pos_temp); mouse_xoffset=mouse_pos_temp.x-mouse_pos_abs.x; mouse_yoffset=mouse_pos_temp.y-mouse_pos_abs.y; if ((mouse_xoffset<0) || (mouse_xoffset>mouse_pos_abs.width)) diff --git a/recordmydesktop/src/rmd_init_encoder.c b/recordmydesktop/src/rmd_init_encoder.c index da442f2..2b2273e 100644 --- a/recordmydesktop/src/rmd_init_encoder.c +++ b/recordmydesktop/src/rmd_init_encoder.c @@ -83,7 +83,7 @@ static int rmdIncrementalNaming(char **name) { return 0; } -void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { +void rmdInitEncoder(ProgData *pdata, EncData *enc_data_t, int buffer_ready) { int y0, y1, y2, fname_length; ogg_stream_state m_ogg_skel; ogg_page skel_og_pg; @@ -91,13 +91,13 @@ void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { skel_fba; //audio fisbone packet const char *fname; - (pdata)->enc_data=enc_data_t; + pdata->enc_data = enc_data_t; fname = pdata->args.filename; - fname_length=strlen(fname); + fname_length = strlen(fname); if (!(fname_length>4 && !strcasecmp(&fname[fname_length-3], "ogv"))) { - char *new_name=malloc(fname_length+5); + char *new_name = malloc(fname_length + 5); strcpy(new_name,fname); strcat(new_name,".ogv"); @@ -110,34 +110,34 @@ void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { fprintf(stderr, "Output file: %s\n", pdata->args.filename); } - enc_data_t->fp=fopen((pdata)->args.filename,"w"); - if (enc_data_t->fp==NULL) { + enc_data_t->fp = fopen((pdata)->args.filename,"w"); + if (enc_data_t->fp == NULL) { fprintf(stderr,"Cannot open file %s for writting!\n", (pdata)->args.filename); exit(13); } //each stream must have a unique srand(time(NULL)); - y0=rand()+1; - y1=rand()+1; - y2=rand()+1; - y2+=(y1==y2); - y0=(((y0==y1)||(y0==y2))?(y1+y2):y0); + y0 = rand() + 1; + y1 = rand() + 1; + y2 = rand() + 1; + y2 += (y1 == y2); + y0 = (((y0 == y1) || (y0 == y2)) ? (y1 + y2) : y0); //init ogg streams //skeleton first ogg_stream_init(&m_ogg_skel, y0); m_add_fishead_packet(&m_ogg_skel); - if (ogg_stream_pageout(&m_ogg_skel,&skel_og_pg)!= 1) { + if (ogg_stream_pageout(&m_ogg_skel, &skel_og_pg) != 1) { fprintf (stderr, "Internal Ogg library error.\n"); exit (2); } - fwrite(skel_og_pg.header,1,skel_og_pg.header_len,enc_data_t->fp); - fwrite(skel_og_pg.body,1,skel_og_pg.body_len,enc_data_t->fp); + fwrite(skel_og_pg.header, 1, skel_og_pg.header_len, enc_data_t->fp); + fwrite(skel_og_pg.body, 1, skel_og_pg.body_len, enc_data_t->fp); - ogg_stream_init(&enc_data_t->m_ogg_ts,y1); + ogg_stream_init(&enc_data_t->m_ogg_ts, y1); if (!pdata->args.nosound) - ogg_stream_init(&enc_data_t->m_ogg_vs,y2); + ogg_stream_init(&enc_data_t->m_ogg_vs, y2); theora_info_init(&enc_data_t->m_th_inf); enc_data_t->m_th_inf.frame_width = pdata->brwin.rrect.width; @@ -168,9 +168,6 @@ void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { enc_data_t->m_th_inf.noise_sensitivity = 1; enc_data_t->m_th_inf.sharpness = 2; - theora_encode_init(&enc_data_t->m_th_st,&enc_data_t->m_th_inf); - - if (!pdata->args.nosound) { int ret; vorbis_info_init(&enc_data_t->m_vo_inf); @@ -183,134 +180,141 @@ void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { exit(2); } vorbis_comment_init(&enc_data_t->m_vo_cmmnt); - vorbis_analysis_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_inf); - vorbis_block_init(&enc_data_t->m_vo_dsp,&enc_data_t->m_vo_block); + vorbis_analysis_init(&enc_data_t->m_vo_dsp, &enc_data_t->m_vo_inf); + vorbis_block_init(&enc_data_t->m_vo_dsp, &enc_data_t->m_vo_block); + } + + if (theora_encode_init(&enc_data_t->m_th_st, &enc_data_t->m_th_inf)) { + fprintf(stderr, "Theora encoder initialization failure.\n"); + exit(2); } + if (theora_encode_header(&enc_data_t->m_th_st, &enc_data_t->m_ogg_pckt1)) { + fprintf(stderr, "Theora enocde header failure.\n"); + exit(2); + } - theora_encode_header(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1); - ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); - if (ogg_stream_pageout(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pg)!=1) { + ogg_stream_packetin(&enc_data_t->m_ogg_ts, &enc_data_t->m_ogg_pckt1); + if (ogg_stream_pageout(&enc_data_t->m_ogg_ts, &enc_data_t->m_ogg_pg) != 1) { fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - fwrite(enc_data_t->m_ogg_pg.header,1, + fwrite(enc_data_t->m_ogg_pg.header, 1, enc_data_t->m_ogg_pg.header_len, enc_data_t->fp); - fwrite(enc_data_t->m_ogg_pg.body,1, + fwrite(enc_data_t->m_ogg_pg.body, 1, enc_data_t->m_ogg_pg.body_len, enc_data_t->fp); theora_comment_init(&enc_data_t->m_th_cmmnt); - theora_comment_add_tag(&enc_data_t->m_th_cmmnt,"recordMyDesktop",VERSION); - theora_encode_comment(&enc_data_t->m_th_cmmnt,&enc_data_t->m_ogg_pckt1); - ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); - theora_encode_tables(&enc_data_t->m_th_st,&enc_data_t->m_ogg_pckt1); - ogg_stream_packetin(&enc_data_t->m_ogg_ts,&enc_data_t->m_ogg_pckt1); + theora_comment_add_tag(&enc_data_t->m_th_cmmnt, "recordMyDesktop", VERSION); + theora_encode_comment(&enc_data_t->m_th_cmmnt, &enc_data_t->m_ogg_pckt1); + ogg_stream_packetin(&enc_data_t->m_ogg_ts, &enc_data_t->m_ogg_pckt1); + theora_encode_tables(&enc_data_t->m_th_st, &enc_data_t->m_ogg_pckt1); + ogg_stream_packetin(&enc_data_t->m_ogg_ts, &enc_data_t->m_ogg_pckt1); if (!pdata->args.nosound) { ogg_packet header; ogg_packet header_comm; ogg_packet header_code; - vorbis_analysis_headerout(&enc_data_t->m_vo_dsp, - &enc_data_t->m_vo_cmmnt, - &header,&header_comm, - &header_code); - ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header); - if (ogg_stream_pageout(&enc_data_t->m_ogg_vs,&enc_data_t->m_ogg_pg)!=1) { + vorbis_analysis_headerout( &enc_data_t->m_vo_dsp, + &enc_data_t->m_vo_cmmnt, + &header, &header_comm, + &header_code); + ogg_stream_packetin(&enc_data_t->m_ogg_vs, &header); + if (ogg_stream_pageout(&enc_data_t->m_ogg_vs, &enc_data_t->m_ogg_pg) != 1) { fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - fwrite(enc_data_t->m_ogg_pg.header,1, + fwrite(enc_data_t->m_ogg_pg.header, 1, enc_data_t->m_ogg_pg.header_len, enc_data_t->fp); - fwrite(enc_data_t->m_ogg_pg.body,1, + fwrite(enc_data_t->m_ogg_pg.body, 1, enc_data_t->m_ogg_pg.body_len, enc_data_t->fp); - ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header_comm); - ogg_stream_packetin(&enc_data_t->m_ogg_vs,&header_code); + ogg_stream_packetin(&enc_data_t->m_ogg_vs, &header_comm); + ogg_stream_packetin(&enc_data_t->m_ogg_vs, &header_code); } //fishbone packets go here - memset(&skel_fbv,0,sizeof(skel_fbv)); - skel_fbv.serial_no=enc_data_t->m_ogg_ts.serialno; - skel_fbv.nr_header_packet=3; - skel_fbv.granule_rate_n=enc_data_t->m_th_inf.fps_numerator; - skel_fbv.granule_rate_d=enc_data_t->m_th_inf.fps_denominator; - skel_fbv.start_granule=0; - skel_fbv.preroll=0; - skel_fbv.granule_shift=theora_granule_shift(&enc_data_t->m_th_inf); + memset(&skel_fbv, 0, sizeof(skel_fbv)); + skel_fbv.serial_no = enc_data_t->m_ogg_ts.serialno; + skel_fbv.nr_header_packet = 3; + skel_fbv.granule_rate_n = enc_data_t->m_th_inf.fps_numerator; + skel_fbv.granule_rate_d = enc_data_t->m_th_inf.fps_denominator; + skel_fbv.start_granule = 0; + skel_fbv.preroll = 0; + skel_fbv.granule_shift = theora_granule_shift(&enc_data_t->m_th_inf); add_message_header_field(&skel_fbv, "Content-Type", "video/theora"); add_fisbone_to_stream(&m_ogg_skel,&skel_fbv); if (!pdata->args.nosound) { - memset(&skel_fba,0,sizeof(skel_fba)); - skel_fba.serial_no=enc_data_t->m_ogg_vs.serialno; - skel_fba.nr_header_packet=3; - skel_fba.granule_rate_n=pdata->args.frequency; - skel_fba.granule_rate_d=(ogg_int64_t)1; - skel_fba.start_granule=0; - skel_fba.preroll=2; - skel_fba.granule_shift=0; + memset(&skel_fba, 0, sizeof(skel_fba)); + skel_fba.serial_no = enc_data_t->m_ogg_vs.serialno; + skel_fba.nr_header_packet = 3; + skel_fba.granule_rate_n = pdata->args.frequency; + skel_fba.granule_rate_d = (ogg_int64_t)1; + skel_fba.start_granule = 0; + skel_fba.preroll = 2; + skel_fba.granule_shift = 0; add_message_header_field(&skel_fba, "Content-Type", "audio/vorbis"); - add_fisbone_to_stream(&m_ogg_skel,&skel_fba); + add_fisbone_to_stream(&m_ogg_skel, &skel_fba); } while (1) { int result = ogg_stream_flush(&m_ogg_skel, &skel_og_pg); - if (result<0) { + if (result < 0) { fprintf (stderr, "Internal Ogg library error.\n"); exit(2); } - if (result==0) + if (result == 0) break; - fwrite(skel_og_pg.header,1,skel_og_pg.header_len,enc_data_t->fp); - fwrite(skel_og_pg.body,1,skel_og_pg.body_len,enc_data_t->fp); + + fwrite(skel_og_pg.header, 1, skel_og_pg.header_len, enc_data_t->fp); + fwrite(skel_og_pg.body, 1, skel_og_pg.body_len, enc_data_t->fp); } while (1) { - int result = ogg_stream_flush(&enc_data_t->m_ogg_ts, - &enc_data_t->m_ogg_pg); - if (result<0) { + int result = ogg_stream_flush(&enc_data_t->m_ogg_ts, &enc_data_t->m_ogg_pg); + if (result < 0) { fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - if (result==0) + if (result == 0) break; - fwrite( enc_data_t->m_ogg_pg.header,1, + fwrite( enc_data_t->m_ogg_pg.header, 1, enc_data_t->m_ogg_pg.header_len, enc_data_t->fp); - fwrite( enc_data_t->m_ogg_pg.body,1, + fwrite( enc_data_t->m_ogg_pg.body, 1, enc_data_t->m_ogg_pg.body_len, enc_data_t->fp); } if (!pdata->args.nosound) { while (1) { - int result=ogg_stream_flush(&enc_data_t->m_ogg_vs, - &enc_data_t->m_ogg_pg); - if (result<0) { + int result = ogg_stream_flush(&enc_data_t->m_ogg_vs, &enc_data_t->m_ogg_pg); + if (result < 0) { fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - if (result==0) + if (result == 0) break; - fwrite( enc_data_t->m_ogg_pg.header,1, + fwrite( enc_data_t->m_ogg_pg.header, 1, enc_data_t->m_ogg_pg.header_len, enc_data_t->fp); - fwrite( enc_data_t->m_ogg_pg.body,1, + fwrite( enc_data_t->m_ogg_pg.body, 1, enc_data_t->m_ogg_pg.body_len, enc_data_t->fp); } @@ -318,29 +322,26 @@ void rmdInitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready) { //skeleton eos add_eos_packet_to_stream(&m_ogg_skel); - if (ogg_stream_flush(&m_ogg_skel,&skel_og_pg)<0) { + if (ogg_stream_flush(&m_ogg_skel, &skel_og_pg) < 0) { fprintf(stderr,"Internal Ogg library error.\n"); exit(2); } - fwrite(skel_og_pg.header,1,skel_og_pg.header_len,enc_data_t->fp); + fwrite(skel_og_pg.header, 1, skel_og_pg.header_len,enc_data_t->fp); //theora buffer allocation, if any 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.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.y = malloc(enc_data_t->m_th_inf.height * enc_data_t->m_th_inf.width); + enc_data_t->yuv.u = malloc(enc_data_t->m_th_inf.height * enc_data_t->m_th_inf.width / 4); + enc_data_t->yuv.v = 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; } theora_info_clear(&enc_data_t->m_th_inf); diff --git a/recordmydesktop/src/rmd_initialize_data.c b/recordmydesktop/src/rmd_initialize_data.c index ecf708a..166f8ea 100644 --- a/recordmydesktop/src/rmd_initialize_data.c +++ b/recordmydesktop/src/rmd_initialize_data.c @@ -176,11 +176,11 @@ int rmdInitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data) 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; - yblocks=malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* + yblocks = malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* (pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH)); - ublocks=malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* + ublocks = malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* (pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH)); - vblocks=malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* + vblocks = malloc(sizeof(u_int32_t)*(pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH)* (pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH)); pdata->frametime=(1000000)/pdata->args.fps; diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index b655d18..cbabb47 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -152,34 +152,34 @@ typedef struct _ProgArgs{ unsigned int jack_nports; char *jack_port_names[RMD_MAX_JACK_PORTS]; float jack_ringbuffer_secs; -}ProgArgs; +} ProgArgs; //this struct holds anything related to encoding AND //writting out to file. typedef struct _EncData{ - ogg_stream_state m_ogg_ts; //theora - ogg_stream_state m_ogg_vs; //vorbis - ogg_page m_ogg_pg; //this could be avoided since - // it is used only while initializing - ogg_packet m_ogg_pckt1; //theora stream - ogg_packet m_ogg_pckt2; //vorbis stream + ogg_stream_state m_ogg_ts; //theora + ogg_stream_state m_ogg_vs; //vorbis + ogg_page m_ogg_pg; //this could be avoided since + // it is used only while initializing + ogg_packet m_ogg_pckt1; //theora stream + ogg_packet m_ogg_pckt2; //vorbis stream //theora data - theora_state m_th_st; - theora_info m_th_inf; - theora_comment m_th_cmmnt; - yuv_buffer yuv; + theora_state m_th_st; + theora_info m_th_inf; + theora_comment m_th_cmmnt; + yuv_buffer yuv; //vorbis data - vorbis_info m_vo_inf; - vorbis_comment m_vo_cmmnt; - vorbis_dsp_state m_vo_dsp; - vorbis_block m_vo_block; + vorbis_info m_vo_inf; + vorbis_comment m_vo_cmmnt; + vorbis_dsp_state m_vo_dsp; + vorbis_block m_vo_block; //these should be 0, since area is quantized //before input - int x_offset, - y_offset; + int x_offset, + y_offset; //our file FILE *fp; -}EncData; +} EncData; //this struct will hold a few basic //information, needed for caching the frames. @@ -218,19 +218,20 @@ typedef struct _SndBuffer{ #ifdef HAVE_LIBJACK typedef struct _JackData{ - ProgData *pdata; //pointer to prog data - jack_client_t *client; - unsigned int buffersize, //buffer size for every port in frames. - frequency, //samplerate with which jack server was started. - nports; //number of ports. - float ringbuffer_secs; - char **port_names; //names of ports(as specified in args). - jack_port_t **ports; //connections to thes ports. - jack_default_audio_sample_t **portbuf; //retrieval of audio buffers. - pthread_mutex_t *snd_buff_ready_mutex; //mutex and cond_var - pthread_cond_t *sound_data_read; //in the pdata struct - jack_ringbuffer_t *sound_buffer; //data exchange happens through this - int capture_started; //used to hold recording in the beginning + ProgData *pdata; //pointer to prog data + jack_client_t *client; + unsigned int buffersize, //buffer size for every port in frames. + frequency, //samplerate with which jack server was started. + nports; //number of ports. + float ringbuffer_secs; + char **port_names; //names of ports(as specified in args). + jack_port_t **ports; //connections to thes ports. + jack_default_audio_sample_t + **portbuf; //retrieval of audio buffers. + pthread_mutex_t *snd_buff_ready_mutex; //mutex and cond_var + pthread_cond_t *sound_data_read; //in the pdata struct + jack_ringbuffer_t *sound_buffer; //data exchange happens through this + int capture_started; //used to hold recording in the beginning }JackData; #endif |