apps/camogm2/camogm.c File Reference

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <time.h>
#include <string.h>
#include <sched.h>
#include <netinet/in.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <asm/elphel/c313a.h>
#include <asm/elphel/ext353.h>
#include <asm/byteorder.h>
#include <ogg/ogg.h>
#include "ogmstreams.h"
#include "camogm_ogm.h"
#include "camogm_jpeg.h"
#include "camogm_mov.h"
#include "camogm_kml.h"
#include "camogm.h"
#include "camogm_wav.h"

Include dependency graph for camogm.c:

Go to the source code of this file.

Defines

#define TRAILER_SIZE   0x02
#define MAP_OPTIONS   MAP_FILE|MAP_PRIVATE
#define DEFAULT_DURATION   600
#define DEFAULT_LENGTH   (700 * 1024 * 1024)
#define DEFAULT_FRAMES   16384
 Next 2 for Quicktime (mostly).
#define DEFAULT_FRAMES_PER_CHUNK   1
#define DEFAULT_EXIF   1
#define DEFAULT_AUDIO_RATE   44100
#define DEFAULT_AUDIO_CHANNELS   2
#define AUDIO_RATE_MAX   44100
#define AUDIO_RATE_MIN   11025
#define AUDIO_CHANNELS_MAX   2
#define AUDIO_CHANNELS_MIN   1
#define COMMAND_LOOP_DELAY   500000

Functions

int camogm_init (void)
int camogm_start (int by_command)
int camogm_stop (int by_command)
int camogm_reset (void)
int camogm_debug (const char *fname)
 reset circbuf read pointer
int camogm_debug_level (int d)
void camogm_set_segment_duration (int sd)
void camogm_set_segment_length (int sl)
void camogm_set_save_gp (int d)
void camogm_set_prefix (const char *p)
void camogm_set_exif (int d)
void camogm_set_timescale (double d)
void camogm_set_frames_skip (int d)
 set timescale, default=1.0
void camogm_set_format (int d)
 set number of frames to skip, if negative - seconds between frames
void camogm_kml_set_enable (int d)
 kml stuff
void camogm_kml_set_horHalfFov (double dd)
void camogm_kml_set_vertHalfFov (double dd)
void camogm_kml_set_height_mode (int d)
void camogm_kml_set_height (double dd)
void camogm_kml_set_period (int d)
void camogm_kml_set_near (double dd)
int parse_cmd (FILE *npipe)
char * getLineFromPipe (FILE *npipe)
 will read from pipe, return pointer to null terminated string if available, NULL otherwise
int sendImageFrame (void)
void camogm_set_max_frames (int d)
 needed for Quicktime - maybe something else?
void camogm_set_frames_per_chunk (int d)
void camogm_set_audio_state (char *args)
void camogm_set_audio_format (char *args)
void camogm_set_sync_state (char *args)
void audio_process (void)
void audio_init (int by_command)
void audio_start (int by_command)
void audio_end (int by_command)
void audio_free (void)
void camogm_audio_initialize (void)
int time_comp (struct timeval *t1, struct timeval *t2)
 ======================================================================================================
void time_normalize (struct timeval *tv)
timeval time_delta (struct timeval *t1, struct timeval *t2)
void put_uint16 (void *buf, u_int16_t val)
 ======================================================================================================
void put_uint32 (void *buf, u_int32_t val)
void put_uint64 (void *buf, u_int64_t val)
void audio_finish (int by_command)
void camogm_free ()
void camogm_status (char *fn, int xml)
int main (int argc, char *argv[])
void audio_init (by_command)

Variables

char trailer [TRAILER_SIZE] = {0xff,0xd9}
const char ExifFileName [] = "/dev/exif_exif"
const char HeadFileName [] = "/dev/jpeghead"
const char SensParsFileName [] = "/dev/sensorpars"
unsigned long * ccam_dma_buf
unsigned long * imageParamsR
int buff_size
static char cmdbuf [1024]
static int cmdbufp = 0
static int cmdstrt = 0
camogm_state sstate
camogm_statestate
int debug_level
FILE * debug_file
timeval v_ts


Define Documentation

#define AUDIO_CHANNELS_MAX   2

Definition at line 139 of file camogm.c.

Referenced by camogm_set_audio_format().

#define AUDIO_CHANNELS_MIN   1

Definition at line 140 of file camogm.c.

Referenced by camogm_set_audio_format().

#define AUDIO_RATE_MAX   44100

Definition at line 137 of file camogm.c.

Referenced by camogm_set_audio_format().

#define AUDIO_RATE_MIN   11025

Definition at line 138 of file camogm.c.

Referenced by camogm_set_audio_format().

#define COMMAND_LOOP_DELAY   500000

#define DEFAULT_AUDIO_CHANNELS   2

Definition at line 135 of file camogm.c.

#define DEFAULT_AUDIO_RATE   44100

Definition at line 134 of file camogm.c.

#define DEFAULT_DURATION   600

Definition at line 121 of file camogm.c.

#define DEFAULT_EXIF   1

Definition at line 132 of file camogm.c.

#define DEFAULT_FRAMES   16384

Next 2 for Quicktime (mostly).

Definition at line 127 of file camogm.c.

#define DEFAULT_FRAMES_PER_CHUNK   1

Definition at line 129 of file camogm.c.

#define DEFAULT_LENGTH   (700 * 1024 * 1024)

Definition at line 125 of file camogm.c.

#define MAP_OPTIONS   MAP_FILE|MAP_PRIVATE

Definition at line 109 of file camogm.c.

#define TRAILER_SIZE   0x02

*************************************************************************** ! FILE NAME : camogm.c ! DESCRIPTION: Program to write captured video (and audio) to camera file system ! using Ogg container. ! Original implementation will copy package data to a buffer to use library calls? ! Copyright (C) 2007 Elphel, Inc. ! -----------------------------------------------------------------------------** ! 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/>. ! -----------------------------------------------------------------------------** ! !

Log
camogm.c,v
! Revision 1.8 2008/06/06 10:53:32 spectr_rain ! clean ! ! Revision 1.7 2008/06/02 19:49:41 spectr_rain ! fixed QuickTime compatibility - need to cleanup ! ! Revision 1.4 2008/05/23 15:54:45 spectr_rain ! *** empty log message *** ! ! Revision 1.3 2008/05/23 15:42:10 spectr_rain ! *** empty log message *** ! ! Revision 1.2 2008/05/23 13:09:49 spectr_rain ! QuickTime support ! ! Revision 1.1 2008/05/02 12:45:57 spectr_rain ! initial revision with the sound support ! ! Revision 1.9 2008/04/13 21:05:19 elphel ! Fixing KML generation ! ! Revision 1.8 2008/04/11 23:09:33 elphel ! modified to handle kml generation ! ! Revision 1.7 2008/04/07 09:13:34 elphel ! Changes related to new Exif generation/processing ! ! Revision 1.6 2008/01/14 22:59:00 elphel ! 7.1.7.4 - added timelapse mode to camogm ! ! Revision 1.5 2007/12/03 08:28:45 elphel ! Multiple changes, mostly cleanup ! ! Revision 1.4 2007/11/29 00:38:57 elphel ! fixed timescale bug ! ! Revision 1.3 2007/11/19 05:07:19 elphel ! fixed 2 typos ! ! Revision 1.2 2007/11/19 03:23:21 elphel ! 7.1.5.5 Added support for *.mov files in camogm. ! ! Revision 1.1 2007/11/16 08:49:56 elphel ! Initial release of camogm - program to record video/image to the camera hard drive (or other storage) !

Definition at line 108 of file camogm.c.


Function Documentation

void audio_end ( int  by_command  ) 

Definition at line 1882 of file camogm.c.

References context_audio_t::audio_present, context_audio_t::audio_set, CAMOGM_FORMAT_JPEG, context_audio_t::capture_handle, ctx_a, DA, free(), context_audio_t::sbuffer, state, and stderr.

Referenced by audio_finish().

void audio_finish ( int  by_command  ) 

Definition at line 770 of file camogm.c.

References audio_end(), audio_process(), ctx_a, DA, EXT_GET_TIME_SYNC, fd_stream, context_audio_t::movie_start, state, stderr, context_audio_t::time_last, time_normalize(), and context_audio_t::to_finish_samples.

Referenced by camogm_stop().

void audio_free ( void   ) 

Definition at line 1909 of file camogm.c.

void audio_init ( by_command   ) 

Definition at line 1738 of file camogm.c.

References context_audio_t::audio_count, context_audio_t::audio_present, AUDIO_SBUFFER_PREFIX, context_audio_t::audio_set, context_audio_t::audio_skip_samples, context_audio_t::begin_of_stream_with_audio, context_audio_t::begin_of_stream_with_audio_trigger, CAMOGM_FORMAT_JPEG, context_audio_t::capture_handle, ctx_a, DA, EXT_GET_TIME_SYNC, fd_stream, malloc(), context_audio_t::sample_time, context_audio_t::sbuffer, context_audio_t::sbuffer_len, state, stderr, and time_normalize().

void audio_init ( int  by_command  ) 

Referenced by camogm_start().

void audio_process ( void   ) 

Definition at line 1606 of file camogm.c.

References context_audio_t::audio_count, context_audio_t::audio_present, AUDIO_SBUFFER_PREFIX, context_audio_t::audio_skip_samples, camogm_audio_mov(), camogm_audio_ogm_push(), CAMOGM_FORMAT_JPEG, CAMOGM_FORMAT_MOV, CAMOGM_FORMAT_OGM, context_audio_t::capture_handle, ctx_a, DA, context_audio_t::movie_start, context_audio_t::sample_time, context_audio_t::sbuffer, context_audio_t::sbuffer_len, state, stderr, time_comp(), context_audio_t::time_last, time_normalize(), and context_audio_t::to_finish_samples.

Referenced by audio_finish(), and main().

void audio_start ( int  by_command  ) 

Definition at line 1857 of file camogm.c.

References context_audio_t::audio_count, CAMOGM_FORMAT_JPEG, ctx_a, DA, state, stderr, context_audio_t::time_last, and context_audio_t::to_finish_samples.

Referenced by camogm_start().

void camogm_audio_initialize ( void   ) 

Definition at line 1598 of file camogm.c.

References context_audio_t::audio_present, context_audio_t::audio_set, context_audio_t::capture_handle, ctx_a, context_audio_t::sample_time, and context_audio_t::sbuffer.

int camogm_debug ( const char *  fname  ) 

reset circbuf read pointer

int camogm_debug_level ( int  d  ) 

void camogm_free (  ) 

Definition at line 864 of file camogm.c.

References CAMOGM_FORMAT_JPEG, CAMOGM_FORMAT_MOV, CAMOGM_FORMAT_NONE, CAMOGM_FORMAT_OGM, camogm_free_jpeg(), camogm_free_mov(), camogm_free_ogm(), and state.

int camogm_init ( void   ) 

void camogm_kml_set_enable ( int  d  ) 

kml stuff

void camogm_kml_set_height ( double  dd  ) 

void camogm_kml_set_height_mode ( int  d  ) 

void camogm_kml_set_horHalfFov ( double  dd  ) 

void camogm_kml_set_near ( double  dd  ) 

void camogm_kml_set_period ( int  d  ) 

void camogm_kml_set_vertHalfFov ( double  dd  ) 

int camogm_reset ( void   ) 

void camogm_set_audio_format ( char *  args  ) 

Definition at line 1565 of file camogm.c.

References AUDIO_CHANNELS_MAX, AUDIO_CHANNELS_MIN, AUDIO_RATE_MAX, AUDIO_RATE_MIN, buf, DA, state, and stderr.

void camogm_set_audio_state ( char *  args  ) 

Definition at line 1546 of file camogm.c.

References DA, state, and stderr.

void camogm_set_exif ( int  d  ) 

void camogm_set_format ( int  d  ) 

set number of frames to skip, if negative - seconds between frames

void camogm_set_frames_per_chunk ( int  d  ) 

void camogm_set_frames_skip ( int  d  ) 

set timescale, default=1.0

void camogm_set_max_frames ( int  d  ) 

needed for Quicktime - maybe something else?

void camogm_set_prefix ( const char *  p  ) 

void camogm_set_save_gp ( int  d  ) 

void camogm_set_segment_duration ( int  sd  ) 

void camogm_set_segment_length ( int  sl  ) 

void camogm_set_sync_state ( char *  args  ) 

Definition at line 1556 of file camogm.c.

References state.

void camogm_set_timescale ( double  d  ) 

int camogm_start ( int  by_command  ) 

Definition at line 371 of file camogm.c.

References audio_init(), audio_start(), CAMOGM_FORMAT_JPEG, CAMOGM_FORMAT_MOV, CAMOGM_FORMAT_NONE, CAMOGM_FORMAT_OGM, CAMOGM_FRAME_BROKEN, CAMOGM_FRAME_CHANGED, CAMOGM_FRAME_NOT_READY, camogm_init_jpeg(), camogm_init_kml(), camogm_init_mov(), camogm_init_ogm(), camogm_start_jpeg(), camogm_start_kml(), camogm_start_mov(), camogm_start_ogm(), ccam_dma_buf, CCAM_MMAP_META, CCAM_MMAP_META_SEC, CIRCLSEEK_LAST, CIRCLSEEK_NEXT, CIRCLSEEK_PREV, CIRCLSEEK_READY, CIRCLSEEK_VALID, D0, D1, D3, debug_file, autoexp_t::height, imageParamsR, memcpy(), P_FREECIRCBUF, read, state, timescale, and autoexp_t::width.

void camogm_status ( char *  fn,
int  xml 
)

Definition at line 978 of file camogm.c.

References CAMOGM_FORMAT_JPEG, CAMOGM_FORMAT_MOV, CAMOGM_FORMAT_OGM, CAMSEQ_JPEG, CAMSEQ_OFF, CAMSEQ_RUN, CAMSEQ_SINGLE, CAMSEQ_STOP, D0, debug_level, autoexp_t::height, imageParamsR, P_CAMSEQSTATE, P_CIRCBUFSIZE, P_FREECIRCBUF, state, stderr, stdout, and autoexp_t::width.

int camogm_stop ( int  by_command  ) 

Definition at line 826 of file camogm.c.

References audio_finish(), context_audio_t::audio_present, camogm_end_jpeg(), camogm_end_kml(), camogm_end_mov(), camogm_end_ogm(), CAMOGM_FORMAT_JPEG, CAMOGM_FORMAT_MOV, CAMOGM_FORMAT_NONE, CAMOGM_FORMAT_OGM, ctx_a, D1, D2, and state.

char* getLineFromPipe ( FILE *  npipe  ) 

will read from pipe, return pointer to null terminated string if available, NULL otherwise

int main ( int  argc,
char *  argv[] 
)

Definition at line 1332 of file camogm.c.

References audio_process(), CAMOGM_FRAME_BROKEN, CAMOGM_FRAME_CHANGED, CAMOGM_FRAME_FILE_ERR, CAMOGM_FRAME_INVALID, CAMOGM_FRAME_NEXTFILE, CAMOGM_FRAME_NOT_READY, CAMOGM_FRAME_OTHER, camogm_init(), camogm_start(), camogm_stop(), ccam_dma_buf, CIRCLSEEK_WAIT, COMMAND_LOOP_DELAY, D0, D1, ExifFileName, HeadFileName, imageParamsR, JPEG_HEADER_SIZE, parse_cmd(), sendImageFrame(), SensParsFileName, sstate, state, stderr, and usage.

int parse_cmd ( FILE *  npipe  ) 

void put_uint16 ( void *  buf,
u_int16_t  val 
)

======================================================================================================

Definition at line 230 of file camogm.c.

void put_uint32 ( void *  buf,
u_int32_t  val 
)

Definition at line 240 of file camogm.c.

void put_uint64 ( void *  buf,
u_int64_t  val 
)

Definition at line 252 of file camogm.c.

int sendImageFrame ( void   ) 

int time_comp ( struct timeval *  t1,
struct timeval *  t2 
)

======================================================================================================

Definition at line 199 of file camogm.c.

Referenced by audio_process().

struct timeval time_delta ( struct timeval *  t1,
struct timeval *  t2 
)

Definition at line 218 of file camogm.c.

void time_normalize ( struct timeval *  tv  ) 

Definition at line 211 of file camogm.c.

Referenced by audio_finish(), audio_init(), and audio_process().


Variable Documentation

int buff_size

Definition at line 119 of file camogm.c.

unsigned long* ccam_dma_buf

Definition at line 117 of file camogm.c.

char cmdbuf[1024] [static]

Definition at line 142 of file camogm.c.

int cmdbufp = 0 [static]

Definition at line 143 of file camogm.c.

int cmdstrt = 0 [static]

Definition at line 144 of file camogm.c.

FILE* debug_file

Definition at line 150 of file camogm.c.

int debug_level

Definition at line 149 of file camogm.c.

const char ExifFileName[] = "/dev/exif_exif"

Definition at line 113 of file camogm.c.

const char HeadFileName[] = "/dev/jpeghead"

Definition at line 115 of file camogm.c.

unsigned long* imageParamsR

Definition at line 118 of file camogm.c.

const char SensParsFileName[] = "/dev/sensorpars"

Definition at line 116 of file camogm.c.

camogm_state sstate

Definition at line 146 of file camogm.c.

camogm_state* state

Definition at line 147 of file camogm.c.

char trailer[TRAILER_SIZE] = {0xff,0xd9}

Definition at line 111 of file camogm.c.

struct timeval v_ts

Definition at line 521 of file camogm.c.


Generated on Thu Aug 7 16:19:21 2008 for elphel by  doxygen 1.5.1