MP7Parser.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: MP7File.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #include <expat.h> 00045 #include <stdio.h> 00046 #include <string> 00047 //#include "MP7Time.hpp" 00048 00049 // define at what level (=depth) 00050 // VariationDescriptionType starts 00051 #define VARDESCR_STARTLEVEL 1 00052 00053 #define BUFFSIZE 50000 00054 00055 // errors 00056 #define ERR__OK 0 00057 #define ERR__NO_VARDESCRTYPE -1 00058 #define ERR__NO_VARIATIONSET_DEF -2 00059 #define ERR__SOURCE_OR_VAR_DEF -3 00060 #define ERR__READ_ERROR -4 00061 #define ERR__PARSE_ERROR -5 00062 #define ERR__PARSER_CREATE_ERROR -6 00063 #define ERR__NO_SUCH_VARSET -7 00064 #define ERR__NO_SUCH_VARIATION -8 00065 #define ERR__INVALID_DATA -9 00066 #define ERR__NO_VERTDECOMP -10 00067 #define ERR__ALLOC -11 00068 00069 00070 00071 class MP7Parser { 00072 public: 00073 00074 00075 class MP7_Sourcedata { 00076 public: 00077 std::string id; 00078 std::string video_codec; 00079 bool has_audio; 00080 std::string audio_codec; 00081 int video_height; 00082 int video_width; 00083 float video_rate; 00084 std::string fileformat; 00085 long filesize; 00086 long bitrate; 00087 std::string path; 00088 // constructor 00089 MP7_Sourcedata(); 00090 }; 00091 00092 class MP7_Variationdata:public MP7_Sourcedata { 00093 public: 00094 std::string variation_id; 00095 float fidelity; 00096 int priority; 00097 std::string variation_relationship; 00098 // constructor 00099 MP7_Variationdata(); 00100 }; 00101 00102 class MP7_Metadata { 00103 public: 00104 std::string title; 00105 std::string title_image; 00106 std::string free_text_annotations; 00107 std::string keywords; 00108 std::string creator_name; 00109 std::string location_name; 00110 std::string location_region; 00111 std::string date; 00112 std::string semantic_place; 00113 std::string semantic_region; 00114 std::string semantic_time; 00115 00116 std::string copyright; 00117 // constructor 00118 MP7_Metadata(); 00119 }; 00120 00121 class MP7_MediaTime { 00122 public: 00123 std::string mediatimepoint_alpha; 00124 std::string mediaduration_alpha; 00125 // constructor 00126 MP7_MediaTime(); 00127 // returns mediatimepoint as double, converted from string 00128 double tpAsDouble(); 00129 // returns mediaduration as double, converted from string 00130 double durAsDouble(); 00131 }; 00132 00133 class MP7_VideoSegmentData { 00134 public: 00135 std::string title; 00136 std::string title_image; 00137 std::string free_text_annotations; 00138 std::string keywords; 00139 MP7_MediaTime mediatime; 00140 std::string semantic_place; 00141 std::string semantic_region; 00142 std::string semantic_time; 00143 // constructor 00144 MP7_VideoSegmentData(); 00145 }; 00146 00147 class MP7_VideoSegmentList { 00148 public: 00149 MP7_VideoSegmentData vseg_data; 00150 MP7_VideoSegmentList *next; 00151 MP7_VideoSegmentList *children; 00152 // constructor 00153 MP7_VideoSegmentList(); 00154 }; 00155 00156 class MP7_TemporalDecomposition { 00157 public: 00158 int errorcode; 00159 MP7_VideoSegmentList *vseg_list; 00160 // constructor 00161 MP7_TemporalDecomposition(); 00162 }; 00163 00164 class MP7_VarList { 00165 public: 00166 MP7_Variationdata vdata; 00167 MP7_VarList *next; 00168 // constructor 00169 MP7_VarList(); 00170 }; 00171 00172 class MP7_Variations { 00173 public: 00174 int errorcode; 00175 MP7_VarList *var_list; 00176 // constructor 00177 MP7_Variations(); 00178 }; 00179 00180 class MP7_VarSetList { 00181 public: 00182 MP7_Sourcedata sdata; 00183 MP7_Metadata mdata; 00184 MP7_MediaTime mtime; 00185 MP7_TemporalDecomposition tmpdec; 00186 MP7_Variations vdata; 00187 MP7_VarSetList *next; 00188 int nr_variations; 00189 // constructor 00190 MP7_VarSetList(); 00191 // destructor 00192 }; 00193 00194 class MP7_VarDescrData { 00195 public: 00196 int errorcode; 00197 int nr_varsets; 00198 MP7_VarSetList *vsl_pointer; 00199 // constructor 00200 MP7_VarDescrData(); 00201 // destructor 00202 ~MP7_VarDescrData(); 00203 // copy constructor 00204 MP7_VarDescrData(const MP7_VarDescrData & other); 00205 // assignment operator 00206 MP7_VarDescrData & operator= (const MP7_VarDescrData & other); 00207 }; 00208 00209 00210 // open a given filename and return the handle 00211 static FILE *MP7Open(const char *filename); 00212 00213 // close a handle 00214 static bool MP7Close(FILE *fp); 00215 00216 // main method 00217 // check MPEG-7 Definition 00218 // return list of VariationSets, each containing information about 00219 // Source, Variations, Creation, MediaTime and TemporalDecomposition 00220 static MP7_VarDescrData MP7GetVarDescrData(FILE *fp); 00221 00222 };