Apply cosmetic cleanup part of ldflags_order patch from Alberto Villa.
[melted] / src / modules / kino / riff.h
1 /*
2 * riff.h library for RIFF file format i/o
3 * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * Tag: $Name$
20 *
21 * Change log:
22 *
23 * $Log$
24 * Revision 1.2 2005/07/25 07:21:39 lilo_booter
25 * + fixes for opendml dv avi
26 *
27 * Revision 1.1 2005/04/15 14:28:26 lilo_booter
28 * Initial version
29 *
30 * Revision 1.14 2005/04/01 23:43:10 ddennedy
31 * apply endian fixes from Daniel Kobras
32 *
33 * Revision 1.13 2004/10/11 01:37:11 ddennedy
34 * mutex safety locks in RIFF and AVI classes, type 2 AVI optimization, mencoder export script
35 *
36 * Revision 1.12 2004/01/06 22:53:42 ddennedy
37 * metadata editing tweaks and bugfixes, new ui elements in preparation for publish functions
38 *
39 * Revision 1.11 2003/11/25 23:01:25 ddennedy
40 * cleanup and a few bugfixes
41 *
42 * Revision 1.10 2003/10/21 16:34:34 ddennedy
43 * GNOME2 port phase 1: initial checkin
44 *
45 * Revision 1.8.4.1 2002/11/25 04:48:31 ddennedy
46 * bugfix to report errors when loading files
47 *
48 * Revision 1.8 2002/04/21 06:36:40 ddennedy
49 * kindler avc and 1394 bus reset support in catpure page, honor max file size
50 *
51 * Revision 1.7 2002/04/09 06:53:42 ddennedy
52 * cleanup, new libdv 0.9.5, large AVI, dnd storyboard
53 *
54 * Revision 1.3 2002/03/25 21:34:25 arne
55 * Support for large (64 bit) files mostly completed
56 *
57 * Revision 1.2 2002/03/04 19:22:43 arne
58 * updated to latest Kino avi code
59 *
60 * Revision 1.1.1.1 2002/03/03 19:08:08 arne
61 * import of version 1.01
62 *
63 */
64
65 #ifndef _RIFF_H
66 #define _RIFF_H 1
67
68 #include <vector>
69 using std::vector;
70
71 #include <pthread.h>
72
73 #include "endian_types.h"
74
75 #define QUADWORD int64_le_t
76 #define DWORD int32_le_t
77 #define LONG u_int32_le_t
78 #define WORD int16_le_t
79 #define BYTE u_int8_le_t
80 #define FOURCC u_int32_t // No endian conversion needed.
81
82 #define RIFF_NO_PARENT (-1)
83 #define RIFF_LISTSIZE (4)
84 #define RIFF_HEADERSIZE (8)
85
86 #ifdef __cplusplus
87 extern "C"
88 {
89 FOURCC make_fourcc( const char * s );
90 }
91 #endif
92
93 class RIFFDirEntry
94 {
95 public:
96 FOURCC type;
97 FOURCC name;
98 off_t length;
99 off_t offset;
100 int parent;
101 int written;
102
103 RIFFDirEntry();
104 RIFFDirEntry( FOURCC t, FOURCC n, int l, int o, int p );
105 };
106
107
108 class RIFFFile
109 {
110 public:
111 RIFFFile();
112 RIFFFile( const RIFFFile& );
113 virtual ~RIFFFile();
114 RIFFFile& operator=( const RIFFFile& );
115
116 virtual bool Open( const char *s );
117 virtual bool Create( const char *s );
118 virtual void Close();
119 virtual int AddDirectoryEntry( FOURCC type, FOURCC name, off_t length, int list );
120 virtual void SetDirectoryEntry( int i, FOURCC type, FOURCC name, off_t length, off_t offset, int list );
121 virtual void SetDirectoryEntry( int i, RIFFDirEntry &entry );
122 virtual void GetDirectoryEntry( int i, FOURCC &type, FOURCC &name, off_t &length, off_t &offset, int &list ) const;
123 virtual RIFFDirEntry GetDirectoryEntry( int i ) const;
124 virtual off_t GetFileSize( void ) const;
125 virtual void PrintDirectoryEntry( int i ) const;
126 virtual void PrintDirectoryEntryData( const RIFFDirEntry &entry ) const;
127 virtual void PrintDirectory( void ) const;
128 virtual int FindDirectoryEntry( FOURCC type, int n = 0 ) const;
129 virtual void ParseChunk( int parent );
130 virtual void ParseList( int parent );
131 virtual void ParseRIFF( void );
132 virtual void ReadChunk( int chunk_index, void *data, off_t data_len );
133 virtual void WriteChunk( int chunk_index, const void *data );
134 virtual void WriteRIFF( void );
135
136 protected:
137 int fd;
138 pthread_mutex_t file_mutex;
139
140 private:
141 vector<RIFFDirEntry> directory;
142 };
143 #endif