Commit d28b8a87 authored by Mikhail Karpenko's avatar Mikhail Karpenko
Browse files

Create JPEG file names from Exif data

parent 13e03a7d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -714,7 +714,7 @@ WARNINGS = YES
# will automatically be disabled.
# will automatically be disabled.
# The default value is: YES.
# The default value is: YES.


WARN_IF_UNDOCUMENTED   = YES
WARN_IF_UNDOCUMENTED   = NO


# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some parameters
# potential errors in the documentation, such as not documenting some parameters
+2 −2
Original line number Original line Diff line number Diff line
@@ -17,9 +17,9 @@ PROGS = camogm
PHPFILES   = camogmstate.php
PHPFILES   = camogmstate.php




SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c
SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c camogm_read.c


OBJS = camogm.o camogm_ogm.o camogm_jpeg.o camogm_mov.o camogm_kml.o
OBJS = camogm.o camogm_ogm.o camogm_jpeg.o camogm_mov.o camogm_kml.o camogm_read.o


CFLAGS   += -Wall -I$(ELPHEL_KERNEL_DIR)/include/elphel
CFLAGS   += -Wall -I$(ELPHEL_KERNEL_DIR)/include/elphel
#CFLAGS   += -Wall -I$(INCDIR) -I$(ELPHEL_KERNEL_DIR)/include/elphel
#CFLAGS   += -Wall -I$(INCDIR) -I$(ELPHEL_KERNEL_DIR)/include/elphel
+8 −3
Original line number Original line Diff line number Diff line
@@ -123,16 +123,17 @@
#include <sys/mman.h>   /* mmap */
#include <sys/mman.h>   /* mmap */
#include <sys/ioctl.h>
#include <sys/ioctl.h>


#include <c313a.h>
//#include <c313a.h>
#include <exifa.h>
#include <exifa.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>


#include <ogg/ogg.h>    // has to be before ogmstreams.h
//#include <ogg/ogg.h>    // has to be before ogmstreams.h
#include "ogmstreams.h"
//#include "ogmstreams.h"
#include "camogm_ogm.h"
#include "camogm_ogm.h"
#include "camogm_jpeg.h"
#include "camogm_jpeg.h"
#include "camogm_mov.h"
#include "camogm_mov.h"
#include "camogm_kml.h"
#include "camogm_kml.h"
#include "camogm_read.h"
#include "camogm.h"
#include "camogm.h"


#define COMMAND_LOOP_DELAY 500000 //0.5sec
#define COMMAND_LOOP_DELAY 500000 //0.5sec
@@ -1343,6 +1344,10 @@ int parse_cmd(camogm_state *state, FILE* npipe)
			state->rawdev.rawdev_path[0] = '\0';
			state->rawdev.rawdev_path[0] = '\0';
		}
		}
		return 28;
		return 28;
	} else if (strcmp(cmd, "rawdev_read") == 0) {
		if (state->rawdev_op)
			camogm_read(state);
		return 29;
	}
	}


	return -1;
	return -1;
+23 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,9 @@


//#include "camogm_exif.h"
//#include "camogm_exif.h"
#include <exifa.h>
#include <exifa.h>
#include <c313a.h>
#include <ogg/ogg.h>    // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?




/*
/*
@@ -78,6 +81,25 @@
/** @brief Maximum length of file or raw device path */
/** @brief Maximum length of file or raw device path */
#define ELPHEL_PATH_MAX           300
#define ELPHEL_PATH_MAX           300


/**
 * @struct rawdev_buffer
 * @brief Holds pointers related to raw device buffer operation
 * @var rawdv_buffer::rawdev_fd
 * File descriptor of open raw device
 * @var rawdev_buffer::rawdev_path
 * A string containing full path to raw device
 * @var rawdev_buffer::overrun
 * The number of times the buffer has overrun during current work session
 * @var rawdev_buffer::start_pos
 * The start position of raw device buffer
 * @var rawdev_buffer::end_pos
 * The end position of raw device buffer
 * @var rawdev_buffer::curr_pos
 * Current read position in raw device buffer
 * @var rawdev_buffer::file_start
 * Pointer to the beginning of current file. This pointer is set during raw device reading and
 * updated every time new file is found.
 */
typedef struct {
typedef struct {
	int rawdev_fd;
	int rawdev_fd;
	char rawdev_path[ELPHEL_PATH_MAX];
	char rawdev_path[ELPHEL_PATH_MAX];
@@ -85,6 +107,7 @@ typedef struct {
	uint64_t start_pos;
	uint64_t start_pos;
	uint64_t end_pos;
	uint64_t end_pos;
	uint64_t curr_pos;
	uint64_t curr_pos;
	uint64_t file_start;
} rawdev_buffer;
} rawdev_buffer;


typedef struct {
typedef struct {
+19 −3
Original line number Original line Diff line number Diff line
@@ -57,11 +57,11 @@
//#include <sys/mman.h>   /* mmap */
//#include <sys/mman.h>   /* mmap */
//#include <sys/ioctl.h>
//#include <sys/ioctl.h>


#include <c313a.h>
//#include <c313a.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>


#include <ogg/ogg.h>    // has to be before ogmstreams.h
//#include <ogg/ogg.h>    // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?
//#include "ogmstreams.h" // move it to <>?


#include "camogm_jpeg.h"
#include "camogm_jpeg.h"


@@ -119,6 +119,17 @@ int camogm_start_jpeg(camogm_state *state)
	return 0;
	return 0;
}
}



void dump_chunk(struct iovec *vec)
{
	unsigned char *ptr = vec->iov_base;
	for (int i = 0; i < vec->iov_len; i++) {
		printf("0x%02x ", ptr[i]);
		if (i % 15 == 0)
			printf("\n");
	}
}

/**
/**
 * @brief Write single JPEG frame
 * @brief Write single JPEG frame
 *
 *
@@ -144,6 +155,11 @@ int camogm_frame_jpeg(camogm_state *state)
			l += chunks_iovec[i].iov_len;
			l += chunks_iovec[i].iov_len;
		}
		}


		printf("0 chunk dump:\n");
		dump_chunk(&chunks_iovec[0]);
		printf("1 chunk dump\n");
		dump_chunk(&chunks_iovec[1]);

		sprintf(state->path, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params[port].timestamp_sec, state->this_frame_params[port].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) {
		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));
			D0(fprintf(debug_file, "Error opening %s for writing, returned %d, errno=%d\n", state->path, state->ivf, errno));
Loading