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 *! FILE NAME : camogm_jpeg.c
*! DESCRIPTION: Provides writing to series of individual JPEG files for camogm *! DESCRIPTION: Provides writing to series of individual JPEG files for camogm
*! Copyright (C) 2007 Elphel, Inc. *! Copyright (C) 2007 Elphel, Inc.
*! -----------------------------------------------------------------------------** *! -----------------------------------------------------------------------------**
*! This program is free software: you can redistribute it and/or modify *! 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 *! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or *! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version. *! (at your option) any later version.
*! *!
*! This program is distributed in the hope that it will be useful, *! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of *! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details. *! GNU General Public License for more details.
*! *!
*! You should have received a copy of the GNU General Public License *! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>. *! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------** *! -----------------------------------------------------------------------------**
*! *!
*! $Log: camogm_jpeg.c,v $ *! $Log: camogm_jpeg.c,v $
*! Revision 1.2 2009/02/25 17:50:51 spectr_rain *! Revision 1.2 2009/02/25 17:50:51 spectr_rain
*! removed deprecated dependency *! removed deprecated dependency
*! *!
*! Revision 1.1.1.1 2008/11/27 20:04:01 elphel *! Revision 1.1.1.1 2008/11/27 20:04:01 elphel
*! *!
*! *!
*! Revision 1.3 2008/04/11 23:09:33 elphel *! Revision 1.3 2008/04/11 23:09:33 elphel
*! modified to handle kml generation *! modified to handle kml generation
*! *!
*! Revision 1.2 2007/11/19 03:23:21 elphel *! Revision 1.2 2007/11/19 03:23:21 elphel
*! 7.1.5.5 Added support for *.mov files in camogm. *! 7.1.5.5 Added support for *.mov files in camogm.
*! *!
*! Revision 1.1 2007/11/16 08:49:57 elphel *! 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) *! 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 //!Not all are needed, just copied from the camogm.c
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
...@@ -51,77 +51,84 @@ ...@@ -51,77 +51,84 @@
#include <string.h> #include <string.h>
#include <netinet/in.h> /*little <-> big endian ?*/ #include <netinet/in.h> /*little <-> big endian ?*/
#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"
#include "camogm.h" #include "camogm.h"
//! may add something - called first time format is changed to this one (only once) recording is stopped //! may add something - called first time format is changed to this one (only once) recording is stopped
int camogm_init_jpeg(void) { int camogm_init_jpeg(void)
return 0; {
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 //!TODO: make directory if it does not exist (find the last "/" in the state->path
char * slash; char * slash;
int rslt; 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,'/'); strcpy(state->path, state->path_prefix); //!make state->path a directory name (will be replaced when the frames will be written)
D2(fprintf (debug_file, "camogm_start_jpeg\n")); slash = strrchr(state->path, '/');
if (slash) { D2(fprintf(debug_file, "camogm_start_jpeg\n"));
D3(fprintf (debug_file, "Full path %s\n", state->path)); if (slash) {
slash[0]='\0'; //! truncate path to the directory name D3(fprintf(debug_file, "Full path %s\n", state->path));
D3(fprintf (debug_file, "directory path %s\n", state->path)); slash[0] = '\0'; //! truncate path to the directory name
rslt=mkdir(state->path, 0777); D3(fprintf(debug_file, "directory path %s\n", state->path));
D3(fprintf (debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno)); rslt = mkdir(state->path, 0777);
if ((rslt<0) && (errno != EEXIST)) { // already exists is OK D3(fprintf(debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno));
D0(fprintf (debug_file, "Error creating directory %s, errno=%d\n", state->path, errno)); if ((rslt < 0) && (errno != EEXIST)) { // already exists is OK
return -CAMOGM_FRAME_FILE_ERR; D0(fprintf(debug_file, "Error creating directory %s, errno=%d\n", state->path, errno));
} return -CAMOGM_FRAME_FILE_ERR;
} }
return 0; }
return 0;
} }
int camogm_frame_jpeg(void){ int camogm_frame_jpeg(void)
int i,j; {
int i, j;
// int fd; // int fd;
ssize_t iovlen,l; ssize_t iovlen, l;
struct iovec chunks_iovec[7]; struct iovec chunks_iovec[7];
l=0;
for (i=0; i< (state->chunk_index)-1; i++) { l = 0;
chunks_iovec[i].iov_base=state->packetchunks[i+1].chunk; for (i = 0; i < (state->chunk_index) - 1; i++) {
chunks_iovec[i].iov_len= state->packetchunks[i+1].bytes; chunks_iovec[i].iov_base = state->packetchunks[i + 1].chunk;
l+=chunks_iovec[i].iov_len; 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;} // 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 //_1__12_Error opening /tmp/z/video1195147018_273452.jpeg for writing
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));
return -CAMOGM_FRAME_FILE_ERR; return -CAMOGM_FRAME_FILE_ERR;
} }
iovlen=writev(state->ivf,chunks_iovec, (state->chunk_index)-1); iovlen = writev(state->ivf, chunks_iovec, (state->chunk_index) - 1);
if (iovlen < l) { if (iovlen < l) {
j=errno; j = errno;
D0(fprintf(debug_file,"writev error %d (returned %d, expected %d)\n",j,iovlen,l)); D0(fprintf(debug_file, "writev error %d (returned %d, expected %d)\n", j, iovlen, l));
close (state->ivf); close(state->ivf);
return -CAMOGM_FRAME_FILE_ERR; return -CAMOGM_FRAME_FILE_ERR;
} }
close (state->ivf); close(state->ivf);
return 0; return 0;
} }
int camogm_end_jpeg(void){ int camogm_end_jpeg(void)
return 0; {
return 0;
} }
This diff is collapsed.
...@@ -15,74 +15,74 @@ void camogm_free_kml(void); ...@@ -15,74 +15,74 @@ void camogm_free_kml(void);
/* /*
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2"> <kml xmlns="http://earth.google.com/kml/2.2">
<Document> <Document>
<PhotoOverlay> <PhotoOverlay>
<TimeStamp> <TimeStamp>
<when>2007-01-14T21:05:02Z</when> <when>2007-01-14T21:05:02Z</when>
</TimeStamp> </TimeStamp>
<!-- inherited from Feature element --> <!-- inherited from Feature element -->
<name>...</name> <!-- string --> <name>...</name> <!-- string -->
<visibility>1</visibility> <!-- boolean --> <visibility>1</visibility> <!-- boolean -->
<open>0</open> <!-- boolean --> <open>0</open> <!-- boolean -->
<atom:author>...<atom:author> <!-- xmlns:atom --> <atom:author>...<atom:author> <!-- xmlns:atom -->
<atom:link>...</atom:link> <!-- xmlns:atom --> <atom:link>...</atom:link> <!-- xmlns:atom -->
<address>...</address> <!-- string --> <address>...</address> <!-- string -->
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">... <AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">...
</AddressDetails> <!-- string --> </AddressDetails> <!-- string -->
<phoneNumber>...</phoneNumber> <!-- string --> <phoneNumber>...</phoneNumber> <!-- string -->
<Snippet maxLines="2">...</Snippet> <!-- string --> <Snippet maxLines="2">...</Snippet> <!-- string -->
<description>...</description> <!-- string --> <description>...</description> <!-- string -->
<AbstractView>...</AbstractView> <!-- Camera or LookAt --> <AbstractView>...</AbstractView> <!-- Camera or LookAt -->
<TimePrimitive>...</TimePrimitive> <TimePrimitive>...</TimePrimitive>
<styleUrl>...</styleUrl> <!-- anyURI --> <styleUrl>...</styleUrl> <!-- anyURI -->
<StyleSelector>...</StyleSelector> <StyleSelector>...</StyleSelector>
<Region>...</Region> <Region>...</Region>
<ExtendedData>...</ExtendedData> <ExtendedData>...</ExtendedData>
<!-- inherited from Overlay element --> <!-- inherited from Overlay element -->
<color>ffffffff</color> <!-- kml:color --> <color>ffffffff</color> <!-- kml:color -->
<drawOrder>0</drawOrder> <!-- int --> <drawOrder>0</drawOrder> <!-- int -->
<Icon> <Icon>
<href>...</href> <!-- anyURI --> <href>...</href> <!-- anyURI -->
... ...
</Icon> </Icon>
<!-- specific to PhotoOverlay --> <!-- specific to PhotoOverlay -->
<rotation>0</rotation> <!-- kml:angle180 --> <rotation>0</rotation> <!-- kml:angle180 -->
<ViewVolume> <ViewVolume>
<leftFov>0</leftFov> <!-- kml:angle180 --> <leftFov>0</leftFov> <!-- kml:angle180 -->
<rightFov>0</rightFov> <!-- kml:angle180 --> <rightFov>0</rightFov> <!-- kml:angle180 -->
<bottomFov>0</bottomFov> <!-- kml:angle90 --> <bottomFov>0</bottomFov> <!-- kml:angle90 -->
<topFov>0</topFov> <!-- kml:angle90 --> <topFov>0</topFov> <!-- kml:angle90 -->
<near>0</near> <!-- double --> <near>0</near> <!-- double -->
</ViewVolume> </ViewVolume>
<ImagePyramid> <ImagePyramid>
<tileSize>256</tileSize> <!-- int --> <tileSize>256</tileSize> <!-- int -->
<maxWidth>...</maxWidth> <!-- int --> <maxWidth>...</maxWidth> <!-- int -->
<maxHeight>...</maxHeight> <!-- int --> <maxHeight>...</maxHeight> <!-- int -->
<gridOrigin>lowerLeft</gridOrigin> <!-- lowerLeft or upperLeft--> <gridOrigin>lowerLeft</gridOrigin> <!-- lowerLeft or upperLeft-->
</ImagePyramid> </ImagePyramid>
<Point> <Point>
<coordinates>...</coordinates> <!-- lon,lat[,alt] --> <coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</Point> </Point>
<shape>rectangle</shape> <!-- kml:shape --> <shape>rectangle</shape> <!-- kml:shape -->
</PhotoOverlay> </PhotoOverlay>
<Camera id="ID"> <Camera id="ID">
<longitude>0</longitude> <!-- kml:angle180 --> <longitude>0</longitude> <!-- kml:angle180 -->
<latitude>0</latitude> <!-- kml:angle90 --> <latitude>0</latitude> <!-- kml:angle90 -->
<altitude>0</altitude> <!-- double --> <altitude>0</altitude> <!-- double -->
<heading>0</heading> <!-- kml:angle360 --> <heading>0</heading> <!-- kml:angle360 -->
<tilt>0</tilt> <!-- kml:anglepos180 --> <tilt>0</tilt> <!-- kml:anglepos180 -->
<roll>0</roll> <!-- kml:angle180 --> <roll>0</roll> <!-- kml:angle180 -->
<altitudeMode>clampToGround</altitudeMode> <altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: relativeToGround, clampToGround, or absolute --> <!-- kml:altitudeModeEnum: relativeToGround, clampToGround, or absolute -->
</Camera> </Camera>
*/ */
This diff is collapsed.
This diff is collapsed.
...@@ -4,33 +4,33 @@ ...@@ -4,33 +4,33 @@
/* /*
* Taken from http://tobias.everwicked.com/packfmt.htm * Taken from http://tobias.everwicked.com/packfmt.htm
* *
First packet (header) First packet (header)
--------------------- ---------------------
pos | content | description pos | content | description
-------+-------------------------+---------------------------------- -------+-------------------------+----------------------------------
0x0000 | 0x01 | indicates 'header packet' 0x0000 | 0x01 | indicates 'header packet'
-------+-------------------------+---------------------------------- -------+-------------------------+----------------------------------
0x0001 | stream_header | the size is indicated in the 0x0001 | stream_header | the size is indicated in the
| | size member | | size member
Second packet (comment) Second packet (comment)
----------------------- -----------------------
pos | content | description pos | content | description
-------+-------------------------+---------------------------------- -------+-------------------------+----------------------------------
0x0000 | 0x03 | indicates 'comment packet' 0x0000 | 0x03 | indicates 'comment packet'
-------+-------------------------+---------------------------------- -------+-------------------------+----------------------------------
0x0001 | data | see vorbis doc on www.xiph.org 0x0001 | data | see vorbis doc on www.xiph.org
Data packets Data packets
------------ ------------
pos | content | description pos | content | description
---------+-------------------------+---------------------------------- ---------+-------------------------+----------------------------------
0x0000 | Bit0 0 | indicates data packet 0x0000 | Bit0 0 | indicates data packet
| Bit1 Bit 2 of lenbytes | | Bit1 Bit 2 of lenbytes |
| Bit2 unused | | Bit2 unused |
| Bit3 keyframe | | Bit3 keyframe |
...@@ -38,14 +38,14 @@ ...@@ -38,14 +38,14 @@
| Bit5 unused | | Bit5 unused |
| Bit6 Bit 0 of lenbytes | | Bit6 Bit 0 of lenbytes |
| Bit7 Bit 1 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 | ... | (frames for video, samples for
| HighByte | audio, 1ms units for text) | HighByte | audio, 1ms units for text)
---------+-------------------------+---------------------------------- ---------+-------------------------+----------------------------------
0x0001+ | data | packet contents 0x0001+ | data | packet contents
lenbytes | | lenbytes | |
* *
* *
*/ */
...@@ -53,29 +53,29 @@ ...@@ -53,29 +53,29 @@
//// OggDS headers //// OggDS headers
// Header for the new header format // Header for the new header format
typedef struct stream_header_video { typedef struct stream_header_video {
ogg_int32_t width; ogg_int32_t width;
ogg_int32_t height; ogg_int32_t height;
} stream_header_video; } stream_header_video;
typedef struct stream_header_audio { typedef struct stream_header_audio {
ogg_int16_t channels; ogg_int16_t channels;
ogg_int16_t blockalign; ogg_int16_t blockalign;
ogg_int32_t avgbytespersec; ogg_int32_t avgbytespersec;
} stream_header_audio; } stream_header_audio;
typedef struct stream_header { typedef struct stream_header {
char streamtype[8]; char streamtype[8];
char subtype[4]; 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 time_unit; // in reference time
ogg_int64_t samples_per_unit; ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time ogg_int32_t default_len; // in media time
ogg_int32_t buffersize; ogg_int32_t buffersize;
// ogg_int16_t bits_per_sample; // ogg_int16_t bits_per_sample;
ogg_int32_t bits_per_sample; ogg_int32_t bits_per_sample;
union { union {
// Video specific // Video specific
...@@ -85,24 +85,24 @@ typedef struct stream_header { ...@@ -85,24 +85,24 @@ typedef struct stream_header {
} sh; } sh;
// ogg_int16_t padding; // ogg_int16_t padding;
ogg_int32_t padding; ogg_int32_t padding;
} stream_header; } stream_header;
typedef struct old_stream_header { typedef struct old_stream_header {
char streamtype[8]; char streamtype[8];
char subtype[4]; 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 time_unit; // in reference time
ogg_int64_t samples_per_unit; ogg_int64_t samples_per_unit;
ogg_int32_t default_len; // in media time ogg_int32_t default_len; // in media time
ogg_int32_t buffersize; ogg_int32_t buffersize;
ogg_int16_t bits_per_sample; ogg_int16_t bits_per_sample;
ogg_int16_t padding; ogg_int16_t padding;
union { union {
// Video specific // Video specific
...@@ -121,4 +121,4 @@ typedef struct old_stream_header { ...@@ -121,4 +121,4 @@ typedef struct old_stream_header {
#define PACKET_LEN_BITS2 0x02 #define PACKET_LEN_BITS2 0x02
#define PACKET_IS_SYNCPOINT 0x08 #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