Commit 786c0e75 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Fix formatting

Fix source code formatting with 'uncrustify' command-line utility
parent 045b76e0
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*!***************************************************************************
*! FILE NAME : camogm_jpeg.c
*! DESCRIPTION: Provides writing to series of individual JPEG files for camogm
*! 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_jpeg.c,v $
*! Revision 1.2 2009/02/25 17:50:51 spectr_rain
*! removed deprecated dependency
*!
*! Revision 1.1.1.1 2008/11/27 20:04:01 elphel
*!
*!
*! Revision 1.3 2008/04/11 23:09:33 elphel
*! modified to handle kml generation
*!
*! 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:57 elphel
*! Initial release of camogm - program to record video/image to the camera hard drive (or other storage)
*!
*/
*! FILE NAME : camogm_jpeg.c
*! DESCRIPTION: Provides writing to series of individual JPEG files for camogm
*! 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_jpeg.c,v $
*! Revision 1.2 2009/02/25 17:50:51 spectr_rain
*! removed deprecated dependency
*!
*! Revision 1.1.1.1 2008/11/27 20:04:01 elphel
*!
*!
*! Revision 1.3 2008/04/11 23:09:33 elphel
*! modified to handle kml generation
*!
*! 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:57 elphel
*! Initial release of camogm - program to record video/image to the camera hard drive (or other storage)
*!
*/
//!Not all are needed, just copied from the camogm.c
#include <unistd.h>
#include <stdio.h>
......@@ -51,77 +51,84 @@
#include <string.h>
#include <netinet/in.h> /*little <-> big endian ?*/
#include <sys/mman.h> /* mmap */
#include <sys/mman.h> /* mmap */
#include <sys/ioctl.h>
#include <c313a.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 "camogm_jpeg.h"
#include "camogm.h"
//! may add something - called first time format is changed to this one (only once) recording is stopped
int camogm_init_jpeg(void) {
return 0;
int camogm_init_jpeg(void)
{
return 0;
}
void camogm_free_jpeg(void) {
void camogm_free_jpeg(void)
{
}
int camogm_start_jpeg(void) {
int camogm_start_jpeg(void)
{
//!TODO: make directory if it does not exist (find the last "/" in the state->path
char * slash;
int rslt;
strcpy (state->path,state->path_prefix); //!make state->path a directory name (will be replaced when the frames will be written)
slash=strrchr(state->path,'/');
D2(fprintf (debug_file, "camogm_start_jpeg\n"));
if (slash) {
D3(fprintf (debug_file, "Full path %s\n", state->path));
slash[0]='\0'; //! truncate path to the directory name
D3(fprintf (debug_file, "directory path %s\n", state->path));
rslt=mkdir(state->path, 0777);
D3(fprintf (debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno));
if ((rslt<0) && (errno != EEXIST)) { // already exists is OK
D0(fprintf (debug_file, "Error creating directory %s, errno=%d\n", state->path, errno));
return -CAMOGM_FRAME_FILE_ERR;
}
}
return 0;
char * slash;
int rslt;
strcpy(state->path, state->path_prefix); //!make state->path a directory name (will be replaced when the frames will be written)
slash = strrchr(state->path, '/');
D2(fprintf(debug_file, "camogm_start_jpeg\n"));
if (slash) {
D3(fprintf(debug_file, "Full path %s\n", state->path));
slash[0] = '\0'; //! truncate path to the directory name
D3(fprintf(debug_file, "directory path %s\n", state->path));
rslt = mkdir(state->path, 0777);
D3(fprintf(debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno));
if ((rslt < 0) && (errno != EEXIST)) { // already exists is OK
D0(fprintf(debug_file, "Error creating directory %s, errno=%d\n", state->path, errno));
return -CAMOGM_FRAME_FILE_ERR;
}
}
return 0;
}
int camogm_frame_jpeg(void){
int i,j;
int camogm_frame_jpeg(void)
{
int i, j;
// int fd;
ssize_t iovlen,l;
struct iovec chunks_iovec[7];
l=0;
for (i=0; i< (state->chunk_index)-1; i++) {
chunks_iovec[i].iov_base=state->packetchunks[i+1].chunk;
chunks_iovec[i].iov_len= state->packetchunks[i+1].bytes;
l+=chunks_iovec[i].iov_len;
}
ssize_t iovlen, l;
struct iovec chunks_iovec[7];
l = 0;
for (i = 0; i < (state->chunk_index) - 1; i++) {
chunks_iovec[i].iov_base = state->packetchunks[i + 1].chunk;
chunks_iovec[i].iov_len = state->packetchunks[i + 1].bytes;
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.timestamp_sec, state->this_frame_params.timestamp_usec);
// if ((devfd = open("/dev/fpgaio", O_RDWR))<0) {printf("error opening /dev/fpgaio\r\n"); return -1;}
//_1__12_Error opening /tmp/z/video1195147018_273452.jpeg for writing
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;
}
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;
}
iovlen=writev(state->ivf,chunks_iovec, (state->chunk_index)-1);
if (iovlen < l) {
j=errno;
D0(fprintf(debug_file,"writev error %d (returned %d, expected %d)\n",j,iovlen,l));
close (state->ivf);
return -CAMOGM_FRAME_FILE_ERR;
}
close (state->ivf);
return 0;
iovlen = writev(state->ivf, chunks_iovec, (state->chunk_index) - 1);
if (iovlen < l) {
j = errno;
D0(fprintf(debug_file, "writev error %d (returned %d, expected %d)\n", j, iovlen, l));
close(state->ivf);
return -CAMOGM_FRAME_FILE_ERR;
}
close(state->ivf);
return 0;
}
int camogm_end_jpeg(void){
return 0;
int camogm_end_jpeg(void)
{
return 0;
}
This diff is collapsed.
......@@ -15,74 +15,74 @@ void camogm_free_kml(void);
/*
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<PhotoOverlay>
<PhotoOverlay>
<TimeStamp>
<when>2007-01-14T21:05:02Z</when>
</TimeStamp>
<!-- inherited from Feature element -->
<name>...</name> <!-- string -->
<visibility>1</visibility> <!-- boolean -->
<open>0</open> <!-- boolean -->
<atom:author>...<atom:author> <!-- xmlns:atom -->
<atom:link>...</atom:link> <!-- xmlns:atom -->
<address>...</address> <!-- string -->
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">...
</AddressDetails> <!-- string -->
<phoneNumber>...</phoneNumber> <!-- string -->
<Snippet maxLines="2">...</Snippet> <!-- string -->
<description>...</description> <!-- string -->
<AbstractView>...</AbstractView> <!-- Camera or LookAt -->
<TimePrimitive>...</TimePrimitive>
<styleUrl>...</styleUrl> <!-- anyURI -->
<StyleSelector>...</StyleSelector>
<Region>...</Region>
<ExtendedData>...</ExtendedData>
<!-- inherited from Overlay element -->
<color>ffffffff</color> <!-- kml:color -->
<drawOrder>0</drawOrder> <!-- int -->
<Icon>
<!-- inherited from Feature element -->
<name>...</name> <!-- string -->
<visibility>1</visibility> <!-- boolean -->
<open>0</open> <!-- boolean -->
<atom:author>...<atom:author> <!-- xmlns:atom -->
<atom:link>...</atom:link> <!-- xmlns:atom -->
<address>...</address> <!-- string -->
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">...
</AddressDetails> <!-- string -->
<phoneNumber>...</phoneNumber> <!-- string -->
<Snippet maxLines="2">...</Snippet> <!-- string -->
<description>...</description> <!-- string -->
<AbstractView>...</AbstractView> <!-- Camera or LookAt -->
<TimePrimitive>...</TimePrimitive>
<styleUrl>...</styleUrl> <!-- anyURI -->
<StyleSelector>...</StyleSelector>
<Region>...</Region>
<ExtendedData>...</ExtendedData>
<!-- inherited from Overlay element -->
<color>ffffffff</color> <!-- kml:color -->
<drawOrder>0</drawOrder> <!-- int -->
<Icon>
<href>...</href> <!-- anyURI -->
...
</Icon>
</Icon>
<!-- specific to PhotoOverlay -->
<rotation>0</rotation> <!-- kml:angle180 -->
<ViewVolume>
<!-- specific to PhotoOverlay -->
<rotation>0</rotation> <!-- kml:angle180 -->
<ViewVolume>
<leftFov>0</leftFov> <!-- kml:angle180 -->
<rightFov>0</rightFov> <!-- kml:angle180 -->
<bottomFov>0</bottomFov> <!-- kml:angle90 -->
<topFov>0</topFov> <!-- kml:angle90 -->
<near>0</near> <!-- double -->
</ViewVolume>
<ImagePyramid>
</ViewVolume>
<ImagePyramid>
<tileSize>256</tileSize> <!-- int -->
<maxWidth>...</maxWidth> <!-- int -->
<maxHeight>...</maxHeight> <!-- int -->
<gridOrigin>lowerLeft</gridOrigin> <!-- lowerLeft or upperLeft-->
</ImagePyramid>
<Point>
<gridOrigin>lowerLeft</gridOrigin> <!-- lowerLeft or upperLeft-->
</ImagePyramid>
<Point>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</Point>
<shape>rectangle</shape> <!-- kml:shape -->
</PhotoOverlay>
</Point>
<shape>rectangle</shape> <!-- kml:shape -->
</PhotoOverlay>
<Camera id="ID">
<longitude>0</longitude> <!-- kml:angle180 -->
<Camera id="ID">
<longitude>0</longitude> <!-- kml:angle180 -->
<latitude>0</latitude> <!-- kml:angle90 -->
<altitude>0</altitude> <!-- double -->
<heading>0</heading> <!-- kml:angle360 -->
<tilt>0</tilt> <!-- kml:anglepos180 -->
<roll>0</roll> <!-- kml:angle180 -->
<altitudeMode>clampToGround</altitudeMode>
<altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: relativeToGround, clampToGround, or absolute -->
</Camera>
*/
</Camera>
*/
This diff is collapsed.
This diff is collapsed.
......@@ -4,33 +4,33 @@
/*
* Taken from http://tobias.everwicked.com/packfmt.htm
*
First packet (header)
---------------------
pos | content | description
-------+-------------------------+----------------------------------
0x0000 | 0x01 | indicates 'header packet'
-------+-------------------------+----------------------------------
0x0001 | stream_header | the size is indicated in the
First packet (header)
---------------------
pos | content | description
-------+-------------------------+----------------------------------
0x0000 | 0x01 | indicates 'header packet'
-------+-------------------------+----------------------------------
0x0001 | stream_header | the size is indicated in the
| | size member
Second packet (comment)
-----------------------
pos | content | description
-------+-------------------------+----------------------------------
0x0000 | 0x03 | indicates 'comment packet'
-------+-------------------------+----------------------------------
0x0001 | data | see vorbis doc on www.xiph.org
Data packets
------------
pos | content | description
---------+-------------------------+----------------------------------
0x0000 | Bit0 0 | indicates data packet
Second packet (comment)
-----------------------
pos | content | description
-------+-------------------------+----------------------------------
0x0000 | 0x03 | indicates 'comment packet'
-------+-------------------------+----------------------------------
0x0001 | data | see vorbis doc on www.xiph.org
Data packets
------------
pos | content | description
---------+-------------------------+----------------------------------
0x0000 | Bit0 0 | indicates data packet
| Bit1 Bit 2 of lenbytes |
| Bit2 unused |
| Bit3 keyframe |
......@@ -38,14 +38,14 @@
| Bit5 unused |
| Bit6 Bit 0 of lenbytes |
| Bit7 Bit 1 of lenbytes |
---------+-------------------------+----------------------------------
0x0001 | LowByte | Length of this packet in samples
---------+-------------------------+----------------------------------
0x0001 | LowByte | Length of this packet in samples
| ... | (frames for video, samples for
| HighByte | audio, 1ms units for text)
---------+-------------------------+----------------------------------
0x0001+ | data | packet contents
lenbytes | |
---------+-------------------------+----------------------------------
0x0001+ | data | packet contents
lenbytes | |
*
*
*/
......@@ -53,29 +53,29 @@
//// OggDS headers
// Header for the new header format
typedef struct stream_header_video {
ogg_int32_t width;
ogg_int32_t height;
ogg_int32_t width;
ogg_int32_t height;
} stream_header_video;
typedef struct stream_header_audio {
ogg_int16_t channels;
ogg_int16_t blockalign;
ogg_int32_t avgbytespersec;
ogg_int16_t channels;
ogg_int16_t blockalign;
ogg_int32_t avgbytespersec;
} stream_header_audio;
typedef struct stream_header {
char streamtype[8];
char subtype[4];
char streamtype[8];
char subtype[4];
ogg_int32_t size; // size of the structure
ogg_int32_t size; // size of the structure
ogg_int64_t time_unit; // in reference time
ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time
ogg_int64_t time_unit; // in reference time
ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time
ogg_int32_t buffersize;
ogg_int32_t buffersize;
// ogg_int16_t bits_per_sample;
ogg_int32_t bits_per_sample;
ogg_int32_t bits_per_sample;
union {
// Video specific
......@@ -85,24 +85,24 @@ typedef struct stream_header {
} sh;
// ogg_int16_t padding;
ogg_int32_t padding;
ogg_int32_t padding;
} stream_header;
typedef struct old_stream_header {
char streamtype[8];
char subtype[4];
char streamtype[8];
char subtype[4];
ogg_int32_t size; // size of the structure
ogg_int32_t size; // size of the structure
ogg_int64_t time_unit; // in reference time
ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time
ogg_int64_t time_unit; // in reference time
ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time
ogg_int32_t buffersize;
ogg_int16_t bits_per_sample;
ogg_int32_t buffersize;
ogg_int16_t bits_per_sample;
ogg_int16_t padding;
ogg_int16_t padding;
union {
// Video specific
......@@ -121,4 +121,4 @@ typedef struct old_stream_header {
#define PACKET_LEN_BITS2 0x02
#define PACKET_IS_SYNCPOINT 0x08
#endif /* __OGGSTREAMS_H */
#endif /* __OGGSTREAMS_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