Commit 2e89b4c0 authored by Mikhail Karpenko's avatar Mikhail Karpenko

WIP: single threaded app

Record jpegs from all channels
parent c4ef6af1
This diff is collapsed.
......@@ -100,8 +100,8 @@ typedef struct {
int head_size[SENSOR_PORTS]; //! JPEG header size
unsigned char jpegHeader[SENSOR_PORTS][JPEG_HEADER_MAXSIZE];
int metadata_start;
struct interframe_params_t frame_params;
struct interframe_params_t this_frame_params;
struct interframe_params_t frame_params[SENSOR_PORTS];
struct interframe_params_t this_frame_params[SENSOR_PORTS];
int jpeg_len;
int frame_period[SENSOR_PORTS]; //!in microseconds (1/10 of what is needed for the Ogm header)
int width;
......
......@@ -134,6 +134,7 @@ int camogm_frame_jpeg(camogm_state *state)
struct iovec chunks_iovec[8];
unsigned char *split_ptr = NULL;
long split_cntr = 0;
int port = state->port_num;
if (!state->rawdev_op) {
l = 0;
......@@ -143,7 +144,7 @@ int camogm_frame_jpeg(camogm_state *state)
l += chunks_iovec[i].iov_len;
}
sprintf(state->path, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params.timestamp_sec, state->this_frame_params.timestamp_usec);
sprintf(state->path, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params[port].timestamp_sec, state->this_frame_params[port].timestamp_usec);
if (((state->ivf = open(state->path, O_RDWR | O_CREAT, 0777))) < 0) {
D0(fprintf(debug_file, "Error opening %s for writing, returned %d, errno=%d\n", state->path, state->ivf, errno));
return -CAMOGM_FRAME_FILE_ERR;
......
......@@ -139,7 +139,7 @@ int camogm_start_kml(camogm_state *state)
}
}
close(fd_ExifDir);
sprintf(state->kml_path, "%s%010ld_%06ld.kml", state->path_prefix, state->this_frame_params.timestamp_sec, state->this_frame_params.timestamp_usec);
sprintf(state->kml_path, "%s%010ld_%06ld.kml", state->path_prefix, state->this_frame_params[state->port_num].timestamp_sec, state->this_frame_params[state->port_num].timestamp_usec);
if (!((state->kml_file = fopen(state->kml_path, "w+"))) ) {
D0(fprintf(debug_file, "Error opening %s for writing\n", state->kml_path));
return -CAMOGM_FRAME_FILE_ERR;
......@@ -168,15 +168,15 @@ int camogm_frame_kml(camogm_state *state)
int port = state->port_num;
if (state->kml_file) { // probably not needed
i = state->this_frame_params.timestamp_sec - (state->kml_last_ts + state->kml_period);
if ((i > 1) || ((i == 0) && ( state->this_frame_params.timestamp_usec > state->kml_last_uts ))) {
i = state->this_frame_params[state->port_num].timestamp_sec - (state->kml_last_ts + state->kml_period);
if ((i > 1) || ((i == 0) && ( state->this_frame_params[state->port_num].timestamp_usec > state->kml_last_uts ))) {
// 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
state->kml_last_ts = state->this_frame_params.timestamp_sec;
state->kml_last_uts = state->this_frame_params.timestamp_usec;
state->kml_last_ts = state->this_frame_params[state->port_num].timestamp_sec;
state->kml_last_uts = state->this_frame_params[state->port_num].timestamp_usec;
if (state->format == CAMOGM_FORMAT_JPEG) {
strcpy(JPEGFileName, state->path);
} else {
sprintf(JPEGFileName, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params.timestamp_sec, state->this_frame_params.timestamp_usec);
sprintf(JPEGFileName, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params[state->port_num].timestamp_sec, state->this_frame_params[state->port_num].timestamp_usec);
if (((fd_JPEG = open(JPEGFileName, O_RDWR | O_CREAT, 0777))) >= 0) {
l = 0;
for (i = 0; i < (state->chunk_index) - 1; i++) {
......
......@@ -153,7 +153,7 @@ int camogm_start_mov(camogm_state *state)
//! allocate memory for the frame index table
if (!((state->frame_lengths = malloc(4 * state->max_frames)))) return -CAMOGM_FRAME_MALLOC;
//! open file for writing
sprintf(state->path, "%s%010ld_%06ld.mov", state->path_prefix, state->frame_params.timestamp_sec, state->frame_params.timestamp_usec);
sprintf(state->path, "%s%010ld_%06ld.mov", state->path_prefix, state->frame_params[state->port_num].timestamp_sec, state->frame_params[state->port_num].timestamp_usec);
if (((state->ivf = open(state->path, O_RDWR | O_CREAT, 0777))) < 0) {
D0(fprintf(debug_file, "Error opening %s for writing, returned %d, errno=%d\n", state->path, state->ivf, errno));
return -CAMOGM_FRAME_FILE_ERR;
......
......@@ -73,10 +73,10 @@ int camogm_start_ogm(camogm_state *state)
char vendor[] = "ElphelOgm v 0.1";
int pos;
stream_header sh;
char hdbuf[sizeof(sh) + 1];
unsigned char hdbuf[sizeof(sh) + 1];
ogg_packet ogg_header;
sprintf(state->path, "%s%010ld_%06ld.ogm", state->path_prefix, state->frame_params.timestamp_sec, state->frame_params.timestamp_usec);
sprintf(state->path, "%s%010ld_%06ld.ogm", state->path_prefix, state->frame_params[state->port_num].timestamp_sec, state->frame_params[state->port_num].timestamp_usec);
if (!((state->vf = fopen(state->path, "w+"))) ) {
D0(fprintf(debug_file, "Error opening %s for writing\n", state->path));
return -CAMOGM_FRAME_FILE_ERR;
......@@ -153,8 +153,8 @@ int camogm_start_ogm(camogm_state *state)
*/
//! calculate initial absolute granulepos (from 1970), then increment with each frame. Later try calculating granulepos of each frame
//! from the absolute time (actual timestamp)
state->granulepos = (ogg_int64_t)( (((double)state->frame_params.timestamp_usec) +
(((double)1000000) * ((double)state->frame_params.timestamp_sec))) *
state->granulepos = (ogg_int64_t)( (((double)state->frame_params[state->port_num].timestamp_usec) +
(((double)1000000) * ((double)state->frame_params[state->port_num].timestamp_sec))) *
((double)10) /
((double)state->time_unit) *
((double)state->timescale));
......
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