00001 /*===========================================================================*/ 00002 /* 00003 * This file is part of libogg++ - a c++ library for the Ogg transport format 00004 * 00005 * Copyright (C) 2006, 2007, 2008 Elaine Tsiang YueLien 00006 * 00007 * libogg++ is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the 00019 * Free Software Foundation, Inc. 00020 * 51 Franklin Street, Fifth Floor 00021 * Boston, MA 02110-1301, USA 00022 * 00023 *===========================================================================*/ 00028 /*===========================================================================*/ 00029 #ifndef TransportToApplicationInterface 00030 #define TransportToApplicationInterface 00031 00032 #ifdef __GNUG__ 00033 #pragma interface 00034 #endif 00035 00036 namespace Ogg 00037 { 00038 class Transport; 00039 class Page; 00040 } 00041 00042 #include <Ogg/Ogg.H> 00043 #include <Ogg/Logical.H> 00044 #include <Ogg/Exception.H> 00045 00046 namespace Ogg 00047 { 00048 00050 00051 00057 class Page 00058 { 00059 public: 00060 void 00061 data(void * 00062 ,size_t 00063 ); 00064 00065 void * 00066 data(); 00067 00068 size_t 00069 size() const; 00070 00071 bool 00072 ending() const; 00073 00074 Position 00075 granulePosition() const; 00076 00077 bool 00078 isHeader()const ; 00079 00080 long 00081 pageNo() const; 00082 00083 long 00084 serialNo() const; 00085 00086 long 00087 pageOrderNo() const; 00088 00089 }; 00090 00098 class Transport 00099 { 00100 private: 00101 void * impl_; 00102 00104 Transport(const Transport &); 00105 00106 Transport & 00107 operator=(const Transport &); 00108 00109 protected: 00111 Transport( 00112 int dummy 00113 ) 00114 : impl_(0) 00115 {} 00116 00117 public: 00118 void * 00119 impl() 00120 { 00121 return(impl_); 00122 } 00123 00124 static 00125 const unsigned char CurrentVersion = 0x00; 00126 00127 /*----- Exceptions thrown by a Transport thread ---------------------------------*/ 00128 00130 class NoDeletion : public Exception 00131 { 00132 public: 00133 NoDeletion() throw() 00134 : Exception("Sorry, you can't delete Transport instances") 00135 { 00136 *this << std::endl; 00137 } 00138 00139 NoDeletion( 00140 const NoDeletion & ex 00141 ) throw() 00142 : Exception(ex) 00143 {} 00144 00145 ~NoDeletion() throw() 00146 {} 00147 } 00148 ; 00149 00154 class PrematureEndOfOggStream : public Exception 00155 { 00156 public: 00157 PrematureEndOfOggStream() throw() 00158 : Exception("Premature end of transport stream.") 00159 { 00160 *this << std::endl; 00161 } 00162 00163 PrematureEndOfOggStream( 00164 const PrematureEndOfOggStream & ex 00165 ) throw() 00166 : Exception(ex) 00167 {} 00168 00169 ~PrematureEndOfOggStream() throw() 00170 {} 00171 } 00172 ; 00173 00174 /*- end Exceptions thrown by a Transport thread ---------------------------------*/ 00175 00177 Transport( 00178 bool encapsulating 00179 ); 00180 00182 virtual 00183 ~Transport(); 00184 00191 long 00192 serialNo(long); 00193 00195 Logical * 00196 logical( 00197 long serialNo 00198 ); 00199 00212 void 00213 loop(); 00214 00220 void 00221 terminate(); 00222 00232 virtual 00233 void 00234 sendCallback( 00235 Page & 00236 ); 00237 00250 virtual 00251 size_t 00252 recvCallback( 00253 Page & 00254 ); 00255 00267 virtual 00268 bool 00269 laterThan ( 00270 const Page & p1 00271 ,const Page & p2 00272 ); 00273 00274 } 00275 ; 00276 00278 }; 00279 #endif