Commit 47834f84 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Calculate total data size recorded to raw partition

parent ac64468a
......@@ -942,7 +942,7 @@ void camogm_set_start_after_timestamp(camogm_state *state, double d)
*/
void camogm_status(camogm_state *state, char * fn, int xml)
{
int _len = 0;
int64_t _len = 0;
int _dur = 0, _udur = 0, _dur_raw, _udur_raw;
FILE* f;
char *_state, *_output_format, *_using_exif, *_using_global_pointer, *_compressor_state[SENSOR_PORTS];
......@@ -999,8 +999,10 @@ void camogm_status(camogm_state *state, char * fn, int xml)
return;
}
}
if (state->vf) _len = ftell(state->vf); // for ogm
else if ((state->ivf) >= 0) _len = lseek(state->ivf, 0, SEEK_CUR); //for mov
if (state->rawdev_op)
_len = state->rawdev.total_rec_len;
else if (state->vf) _len = (int64_t)ftell(state->vf); // for ogm
else if ((state->ivf) >= 0) _len = (int64_t)lseek(state->ivf, 0, SEEK_CUR); //for mov
switch (state->prog_state) {
case STATE_STOPPED:
_state = "stopped";
......@@ -1036,7 +1038,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
" <frame_number>%d</frame_number>\n" \
" <start_after_timestamp>%f</start_after_timestamp>\n" \
" <file_duration>%d.%06d</file_duration>\n" \
" <file_length>%d</file_length>\n" \
" <file_length>%" PRId64 "</file_length>\n" \
" <frames_skip_left>%d</frames_skip_left>\n" \
" <seconds_skip_left>%d</seconds_skip_left>\n" \
" <frame_width>%d</frame_width>\n" \
......@@ -1118,7 +1120,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
fprintf(f, "frame \t%d\n", state->frameno);
fprintf(f, "start_after_timestamp \t%f\n", state->start_after_timestamp);
fprintf(f, "file duration \t%d.%06d sec\n", _dur, _udur);
fprintf(f, "file length \t%d B\n", _len);
fprintf(f, "file length \t%" PRId64 " B\n", _len);
fprintf(f, "width \t%d (0x%x)\n", state->width, state->width);
fprintf(f, "height \t%d (0x%x)\n", state->height, state->height);
fprintf(f, "\n");
......
......@@ -123,6 +123,7 @@ typedef struct {
uint64_t mmap_current_size;
uint64_t mmap_offset;
uint64_t file_start;
int64_t total_rec_len;
pthread_t tid;
volatile int thread_state;
unsigned char *disk_mmap;
......
......@@ -41,6 +41,18 @@ void camogm_free_jpeg(void)
{
}
/** Calculate the total length of current frame */
int64_t camogm_get_jpeg_size(camogm_state *state)
{
int64_t len = 0;
for (int i = 0; i < state->chunk_index - 1; i++) {
len += state->packetchunks[i + 1].bytes;
}
return len;
}
/**
* @brief Called every time the JPEG files recording is started.
*
......@@ -135,6 +147,8 @@ int camogm_frame_jpeg(camogm_state *state)
D0(fprintf(debug_file, "Can not pass IO vector to driver: %s\n", strerror(errno)));
return -CAMOGM_FRAME_FILE_ERR;
}
// update statistics
state->rawdev.total_rec_len += camogm_get_jpeg_size(state);
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment