//! 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[chn])+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;//! magic shift - should index first byte of the time stamp
//!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[port],state->cirbuf_rp[port]+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[port]=lseek(state->fd_head[port],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[port]>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[port],JPEG_HEADER_MAXSIZE));
D0(fprintf(debug_file,"%s:%d: Too big JPEG header (%d > %d)",__FILE__,__LINE__,state->head_size[chn],JPEG_HEADER_MAXSIZE));
@@ -600,21 +606,21 @@ int sendImageFrame(camogm_state *state)
...
@@ -600,21 +606,21 @@ int sendImageFrame(camogm_state *state)
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
// if (state->this_frame_params.timestamp_sec > (state->kml_last_ts + state->kml_period)) { // this way it is safe to put kml_period=1000, then kml_period=1
// if (state->this_frame_params.timestamp_sec > (state->kml_last_ts + state->kml_period)) { // this way it is safe to put kml_period=1000, then kml_period=1