]> git.sesse.net Git - mlt/blob - src/modules/kino/riff.h
Initial version
[mlt] / 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.1  2005/04/15 14:28:26  lilo_booter
25 * Initial version
26 *
27 * Revision 1.14  2005/04/01 23:43:10  ddennedy
28 * apply endian fixes from Daniel Kobras
29 *
30 * Revision 1.13  2004/10/11 01:37:11  ddennedy
31 * mutex safety locks in RIFF and AVI classes, type 2 AVI optimization, mencoder export script
32 *
33 * Revision 1.12  2004/01/06 22:53:42  ddennedy
34 * metadata editing tweaks and bugfixes, new ui elements in preparation for publish functions
35 *
36 * Revision 1.11  2003/11/25 23:01:25  ddennedy
37 * cleanup and a few bugfixes
38 *
39 * Revision 1.10  2003/10/21 16:34:34  ddennedy
40 * GNOME2 port phase 1: initial checkin
41 *
42 * Revision 1.8.4.1  2002/11/25 04:48:31  ddennedy
43 * bugfix to report errors when loading files
44 *
45 * Revision 1.8  2002/04/21 06:36:40  ddennedy
46 * kindler avc and 1394 bus reset support in catpure page, honor max file size
47 *
48 * Revision 1.7  2002/04/09 06:53:42  ddennedy
49 * cleanup, new libdv 0.9.5, large AVI, dnd storyboard
50 *
51 * Revision 1.3  2002/03/25 21:34:25  arne
52 * Support for large (64 bit) files mostly completed
53 *
54 * Revision 1.2  2002/03/04 19:22:43  arne
55 * updated to latest Kino avi code
56 *
57 * Revision 1.1.1.1  2002/03/03 19:08:08  arne
58 * import of version 1.01
59 *
60 */
61
62 #ifndef _RIFF_H
63 #define _RIFF_H 1
64
65 #include <vector>
66 using std::vector;
67
68 #include <pthread.h>
69
70 #include "endian_types.h"
71
72 #define QUADWORD int64_le_t
73 #define DWORD int32_le_t
74 #define LONG u_int32_le_t
75 #define WORD int16_le_t
76 #define BYTE u_int8_le_t
77 #define FOURCC u_int32_t      // No endian conversion needed.
78
79 #define RIFF_NO_PARENT (-1)
80 #define RIFF_LISTSIZE (4)
81 #define RIFF_HEADERSIZE (8)
82
83 #ifdef __cplusplus
84 extern "C"
85 {
86         FOURCC make_fourcc( char * s );
87 }
88 #endif
89
90 class RIFFDirEntry
91 {
92 public:
93         FOURCC type;
94         FOURCC name;
95         off_t length;
96         off_t offset;
97         int parent;
98         int written;
99
100         RIFFDirEntry();
101         RIFFDirEntry( FOURCC t, FOURCC n, int l, int o, int p );
102 };
103
104
105 class RIFFFile
106 {
107 public:
108         RIFFFile();
109         RIFFFile( const RIFFFile& );
110         virtual ~RIFFFile();
111         RIFFFile& operator=( const RIFFFile& );
112
113         virtual bool Open( const char *s );
114         virtual bool Create( const char *s );
115         virtual void Close();
116         virtual int AddDirectoryEntry( FOURCC type, FOURCC name, off_t length, int list );
117         virtual void SetDirectoryEntry( int i, FOURCC type, FOURCC name, off_t length, off_t offset, int list );
118         virtual void SetDirectoryEntry( int i, RIFFDirEntry &entry );
119         virtual void GetDirectoryEntry( int i, FOURCC &type, FOURCC &name, off_t &length, off_t &offset, int &list ) const;
120         virtual RIFFDirEntry GetDirectoryEntry( int i ) const;
121         virtual off_t GetFileSize( void ) const;
122         virtual void PrintDirectoryEntry( int i ) const;
123         virtual void PrintDirectoryEntryData( const RIFFDirEntry &entry ) const;
124         virtual void PrintDirectory( void ) const;
125         virtual int FindDirectoryEntry( FOURCC type, int n = 0 ) const;
126         virtual void ParseChunk( int parent );
127         virtual void ParseList( int parent );
128         virtual void ParseRIFF( void );
129         virtual void ReadChunk( int chunk_index, void *data );
130         virtual void WriteChunk( int chunk_index, const void *data );
131         virtual void WriteRIFF( void );
132
133 protected:
134         int fd;
135         pthread_mutex_t file_mutex;
136
137 private:
138         vector<RIFFDirEntry> directory;
139 };
140 #endif