Commit d28b8a87 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Create JPEG file names from Exif data

parent 13e03a7d
......@@ -714,7 +714,7 @@ WARNINGS = YES
# will automatically be disabled.
# 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
# potential errors in the documentation, such as not documenting some parameters
......
......@@ -17,9 +17,9 @@ PROGS = camogm
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$(INCDIR) -I$(ELPHEL_KERNEL_DIR)/include/elphel
......
......@@ -123,16 +123,17 @@
#include <sys/mman.h> /* mmap */
#include <sys/ioctl.h>
#include <c313a.h>
//#include <c313a.h>
#include <exifa.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h> // has to be before ogmstreams.h
#include "ogmstreams.h"
//#include <ogg/ogg.h> // has to be before ogmstreams.h
//#include "ogmstreams.h"
#include "camogm_ogm.h"
#include "camogm_jpeg.h"
#include "camogm_mov.h"
#include "camogm_kml.h"
#include "camogm_read.h"
#include "camogm.h"
#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';
}
return 28;
} else if (strcmp(cmd, "rawdev_read") == 0) {
if (state->rawdev_op)
camogm_read(state);
return 29;
}
return -1;
......
......@@ -32,6 +32,9 @@
//#include "camogm_exif.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 */
#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 {
int rawdev_fd;
char rawdev_path[ELPHEL_PATH_MAX];
......@@ -85,6 +107,7 @@ typedef struct {
uint64_t start_pos;
uint64_t end_pos;
uint64_t curr_pos;
uint64_t file_start;
} rawdev_buffer;
typedef struct {
......
......@@ -57,11 +57,11 @@
//#include <sys/mman.h> /* mmap */
//#include <sys/ioctl.h>
#include <c313a.h>
//#include <c313a.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h> // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?
//#include <ogg/ogg.h> // has to be before ogmstreams.h
//#include "ogmstreams.h" // move it to <>?
#include "camogm_jpeg.h"
......@@ -119,6 +119,17 @@ int camogm_start_jpeg(camogm_state *state)
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
*
......@@ -144,6 +155,11 @@ int camogm_frame_jpeg(camogm_state *state)
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);
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));
......
......@@ -55,12 +55,12 @@
#include <sys/mman.h> /* mmap */
#include <sys/ioctl.h>
#include <c313a.h>
//#include <c313a.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h> // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?
//#include <ogg/ogg.h> // has to be before ogmstreams.h
//#include "ogmstreams.h" // move it to <>?
#include "camogm_kml.h"
......
......@@ -58,12 +58,12 @@
#include <sys/mman.h> /* mmap */
#include <sys/ioctl.h>
#include <c313a.h>
//#include <c313a.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h> // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?
//#include <ogg/ogg.h> // has to be before ogmstreams.h
//#include "ogmstreams.h" // move it to <>?
#include "camogm_mov.h"
......
......@@ -51,11 +51,11 @@
#include <sys/mman.h> /* mmap */
#include <sys/ioctl.h>
#include <c313a.h>
//#include <c313a.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h> // has to be before ogmstreams.h
#include "ogmstreams.h" // move it to <>?
//#include <ogg/ogg.h> // has to be before ogmstreams.h
//#include "ogmstreams.h" // move it to <>?
#include "camogm_ogm.h"
......
This diff is collapsed.
/** @file camogm_read.h
* @brief Provides reading data written to raw device storage and saving the data to a device with file system.
* @copyright Copyright (C) 2016 Elphel, Inc.
*
* <b>License:</b>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CAMOGM_READ_H
#define _CAMOGM_READ_H
#include "camogm.h"
int camogm_read(camogm_state *state);
#endif /* _CAMOGM_READ_H */
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