Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

riff.h

Go to the documentation of this file.
00001 /*
00002 * riff.h library for RIFF file format i/o
00003 * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
00004 * Copyright (C) 2001-2007 Dan Dennedy <dan@dennedy.org>
00005 *
00006 * This program is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU General Public License
00017 * along with this program; if not, write to the Free Software Foundation,
00018 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef _RIFF_H
00022 #define _RIFF_H 1
00023 
00024 #include <vector>
00025 using std::vector;
00026 
00027 #include <pthread.h>
00028 
00029 #include "endian_types.h"
00030 
00031 #define QUADWORD int64_le_t
00032 #define DWORD int32_le_t
00033 #define LONG u_int32_le_t
00034 #define WORD int16_le_t
00035 #define BYTE u_int8_le_t
00036 #define FOURCC u_int32_t      // No endian conversion needed.
00037 
00038 #define RIFF_NO_PARENT (-1)
00039 #define RIFF_LISTSIZE (4)
00040 #define RIFF_HEADERSIZE (8)
00041 
00042 #ifdef __cplusplus
00043 extern "C"
00044 {
00045     FOURCC make_fourcc( char * s );
00046 }
00047 #endif
00048 
00049 class RIFFDirEntry
00050 {
00051 public:
00052     FOURCC type;
00053     FOURCC name;
00054     off_t length;
00055     off_t offset;
00056     int parent;
00057     int written;
00058 
00059     RIFFDirEntry();
00060     RIFFDirEntry( FOURCC t, FOURCC n, int l, int o, int p );
00061 };
00062 
00063 
00064 class RIFFFile
00065 {
00066 public:
00067     RIFFFile();
00068     RIFFFile( const RIFFFile& );
00069     virtual ~RIFFFile();
00070     RIFFFile& operator=( const RIFFFile& );
00071 
00072     virtual bool Open( const char *s );
00073     virtual bool Create( const char *s );
00074     virtual void Close();
00075     virtual int AddDirectoryEntry( FOURCC type, FOURCC name, off_t length, int list );
00076     virtual void SetDirectoryEntry( int i, FOURCC type, FOURCC name, off_t length, off_t offset, int list );
00077     virtual void SetDirectoryEntry( int i, RIFFDirEntry &entry );
00078     virtual void GetDirectoryEntry( int i, FOURCC &type, FOURCC &name, off_t &length, off_t &offset, int &list ) const;
00079     virtual RIFFDirEntry GetDirectoryEntry( int i ) const;
00080     virtual off_t GetFileSize( void ) const;
00081     virtual void PrintDirectoryEntry( int i ) const;
00082     virtual void PrintDirectoryEntryData( const RIFFDirEntry &entry ) const;
00083     virtual void PrintDirectory( void ) const;
00084     virtual int FindDirectoryEntry( FOURCC type, int n = 0 ) const;
00085     virtual void ParseChunk( int parent );
00086     virtual void ParseList( int parent );
00087     virtual void ParseRIFF( void );
00088     virtual bool ReadChunk( int chunk_index, void *data, off_t data_len );
00089     virtual void WriteChunk( int chunk_index, const void *data );
00090     virtual void WriteRIFF( void );
00091 
00092 protected:
00093     int fd;
00094     pthread_mutex_t file_mutex;
00095 
00096 private:
00097     vector<RIFFDirEntry> directory;
00098 };
00099 #endif

Generated on Sun Mar 11 22:11:47 2007 for Kino by  doxygen 1.4.2