//! find location of the timestamp and copy it to the frame_params structure
// find location of the timestamp and copy it to the frame_params structure
///==================================
//==================================
timestamp_start=(state->cirbuf_rp[chn])+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;//! magic shift - should index first byte of the time stamp
timestamp_start=(state->cirbuf_rp[chn])+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;// magic shift - should index first byte of the time stamp
@@ -429,22 +430,22 @@ int camogm_start(camogm_state *state)
...
@@ -429,22 +430,22 @@ int camogm_start(camogm_state *state)
state->width=state->frame_params[chn].width;
state->width=state->frame_params[chn].width;
state->height=state->frame_params[chn].height;
state->height=state->frame_params[chn].height;
//!read JPEG header - it should stay the same for the whole file (restart new file if any parameters changed)
//read JPEG header - it should stay the same for the whole file (restart new file if any parameters changed)
//!rebuild JPEG header:
//rebuild JPEG header:
lseek(state->fd_head[chn],state->cirbuf_rp[chn]+1,SEEK_END);//!+1 to avoid condition when jpeg_start==0. overloaded lseek will ignore 5 LSBs when SEEK_END
lseek(state->fd_head[chn],state->cirbuf_rp[chn]+1,SEEK_END);//+1 to avoid condition when jpeg_start==0. overloaded lseek will ignore 5 LSBs when SEEK_END
state->head_size[chn]=lseek(state->fd_head[chn],0,SEEK_END);/// In 8.0 the header size might change for some jp4 modes
state->head_size[chn]=lseek(state->fd_head[chn],0,SEEK_END);// In 8.0 the header size might change for some jp4 modes
if(state->head_size[chn]>JPEG_HEADER_MAXSIZE){
if(state->head_size[chn]>JPEG_HEADER_MAXSIZE){
D0(fprintf(debug_file,"%s:%d: Too big JPEG header (%d > %d)",__FILE__,__LINE__,state->head_size[chn],JPEG_HEADER_MAXSIZE));
D0(fprintf(debug_file,"%s:%d: Too big JPEG header (%d > %d)",__FILE__,__LINE__,state->head_size[chn],JPEG_HEADER_MAXSIZE));
D3(fprintf(debug_file,"?6,fp=0x%x ",fp));//frame not ready, frame pointer seems valid, but not ready
D3(fprintf(debug_file,"?6,fp=0x%x ",fp));//frame not ready, frame pointer seems valid, but not ready
return-CAMOGM_FRAME_NOT_READY;//! frame pointer valid, but no frames yet
return-CAMOGM_FRAME_NOT_READY;// frame pointer valid, but no frames yet
}
}
//! process skipping frames. TODO: add - skipping time between frames (or better - actual time period - use the nearest frame) instead of the frame number
// process skipping frames. TODO: add - skipping time between frames (or better - actual time period - use the nearest frame) instead of the frame number
if((state->frames_skip>0)&&(state->frames_skip_left[port]>0)){//!skipping frames, not seconds.
if((state->frames_skip>0)&&(state->frames_skip_left[port]>0)){//skipping frames, not seconds.
@@ -538,41 +539,41 @@ int sendImageFrame(camogm_state *state)
...
@@ -538,41 +539,41 @@ int sendImageFrame(camogm_state *state)
return-CAMOGM_FRAME_BROKEN;
return-CAMOGM_FRAME_BROKEN;
}
}
D3(fprintf(debug_file,"_2_"));
D3(fprintf(debug_file,"_2_"));
//! find location of the timestamp and copy it to the frame_params structure
// find location of the timestamp and copy it to the frame_params structure
timestamp_start=state->cirbuf_rp[port]+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;//! magic shift - should index first byte of the time stamp
timestamp_start=state->cirbuf_rp[port]+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;// magic shift - should index first byte of the time stamp
FOR_EACH_PORT(int,chn){if(state->buf_overruns[chn]>=0)state->buf_overruns[chn]=0;}//! resets overruns after reading status , so "overruns" means since last reading status
FOR_EACH_PORT(int,chn){if(state->buf_overruns[chn]>=0)state->buf_overruns[chn]=0;}// resets overruns after reading status , so "overruns" means since last reading status