OGGContainerFile.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: OGGContainerFile.hpp * 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 #ifndef VITOOKI_OGGCONTAINERFILE_HPP_ 00044 #define VITOOKI_OGGCONTAINERFILE_HPP_ 00045 00046 #ifdef ENABLE_OGG 00047 00062 #include "global.hpp" 00063 #include "VideoESInfo.hpp" 00064 #include "AudioESInfo.hpp" 00065 #include "io/ByteStream.hpp" 00066 #include "VMutex.hpp" 00067 #include <ogg/ogg.h> 00068 #include <theora/theora.h> 00069 #include <vorbis/codec.h> 00070 #include <Frame.hpp> 00071 00072 class ContainerInfo; 00073 class Url; 00074 00075 //The OGG Stream Type 00076 typedef enum OGGStreamType { OGG_VORBIS, OGG_THEORA, OGG_UNKNOWN } OGGStreamType; 00077 00078 class OGGStreamInfo { 00079 public: 00080 OGGStreamInfo(); 00081 ~OGGStreamInfo(); 00082 00083 void append(OGGStreamInfo* osi); 00084 00085 void setNext(OGGStreamInfo* osi); 00086 OGGStreamInfo* getNext(); 00087 00088 void setStreamID(long id); 00089 long getStreamID(); 00090 00091 ogg_stream_state* getStreamState(); 00092 ogg_stream_state* getStreamState(int serial); 00093 void setStreamState(ogg_stream_state *oss); 00094 00095 // vorbis_info / theora_info 00096 void setCodecInfo(void* ci); 00097 void* getCodecInfo(); 00098 00099 // vorbis_comment / theora_comment 00100 void setCodecComment(void* cc); 00101 void* getCodecComment(); 00102 00103 void setStreamType(OGGStreamType ost); 00104 OGGStreamType getStreamType(); 00105 00106 private: 00107 OGGStreamInfo *next; 00108 long streamid; 00109 ogg_stream_state *oss; 00110 void *codec_info; 00111 void *codec_comment; 00112 OGGStreamType streamtype; 00113 }; 00114 00115 00116 typedef struct OGGHandler{ 00117 ogg_sync_state oy; 00118 FILE *io; 00119 // list of known OGG_Streams 00120 OGGStreamInfo *osi; 00121 }OGGHandler; 00122 00123 class OGGContainerFile { 00124 public: 00125 00127 static ContainerInfo *loadContainerInfo(const Url* uri=NULL, ByteStream *stream = NULL); 00128 00132 static bool saveToContainerFile(const char *fileName, ContainerInfo *ci) { 00133 return false; 00134 }; 00135 00136 static OGGHandler* getOGGHandler(); 00137 00144 static int bufferData(ByteStream *stream, ogg_sync_state *oy); 00145 00146 static void oggMutexLock(const char* s); 00147 static void oggMutexRelease(const char* s); 00148 00149 static void printOggData(const char* c, const Frame* f); 00150 00151 private: 00152 00161 static int parseBOS(FILE *io, ogg_sync_state *oss); 00162 00167 static void initialize(); 00168 00169 };//OGGContainerFile 00170 00171 #endif 00172 #endif