SyncLayer.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: SyncLayer.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 00044 /**************************************************************** 00045 Project: MPEG-4 Environment 00046 Purpose: Define SL Stream interface 00047 Author: M. Ohlenroth 00048 Date: $Id: SyncLayer.hpp,v 1.5 2006/01/20 15:37:54 mkropfbe Exp $ 00049 ****************************************************************/ 00050 00051 00052 #ifndef _SyncLayer_HPP_ 00053 #define _SyncLayer_HPP_ 00054 00055 //#include <stdint.h> 00056 #ifndef WINCE 00057 #include <sys/types.h> 00058 #endif 00059 00060 #ifdef ISOMP4 00061 #include "ISOMovies.h" 00062 #else 00063 #include "global.hpp" 00064 #endif 00065 00066 00067 /* SLConfigDescriptor as defined in 14496-1 paragraph 10.2.3.1 00068 */ 00069 struct SLConfigDescriptor { 00070 u8 predefined; 00071 bool useAccessUnitStartFlag; 00072 bool useAccessUnitEndFlag; 00073 bool useRandomAccessPointFlag; 00074 bool hasRandomAccessUnitsOnlyFlag; 00075 bool usePaddingFlag; 00076 bool useTimeStampsFlag; 00077 bool useIdleFlag; 00078 bool durationFlag; 00079 u32 timeStampResolution; 00080 u32 OCRResolution; 00081 u8 timeStampLength; 00082 u8 OCRLength; 00083 u8 AU_Length; 00084 u8 instantBitrateLength; 00085 u8 degradationPriorityLength; 00086 u8 AU_seqNumLength; 00087 u8 packetSeqNumLength; 00088 u8 reserved; // = 0b11 00089 // if (durationFlag) 00090 u32 timeScale; 00091 u16 accessUnitDuration; 00092 u16 compositionUnitDuration; 00093 // } 00094 // if (!useTimeStampsFlag) { 00095 u64 startDecodingTimeStamp; 00096 u64 startCompositionTimeStamp; 00097 // } 00098 }; 00099 00100 // predefined SLConfigDescriptor for RFC 3016 mode: 00101 extern const SLConfigDescriptor slcd_rfc_3016; 00102 00103 typedef struct SLPacketHeader { 00104 SLPacketHeader() {}; 00105 00106 SLPacketHeader(const u16 seq) : packetSequenceNumber(seq) { 00107 accessUnitStartFlag = accessUnitEndFlag = 00108 OCRFlag = idleFlag = paddingFlag = false; 00109 paddingBits = 0; 00110 packetSequenceNumber = 0; 00111 DegPrioFlag = false; 00112 degradationPriority = 0; 00113 objectClockReference = 0; 00114 randomAccessPointFlag = false; 00115 AU_sequenceNumber = 0; 00116 decodingTimeStampFlag = 00117 compositionTimeStampFlag = instantBitrateFlag = false; 00118 decodingTimeStamp = compositionTimeStamp = 00119 accessUnitLength = instantBitrate = false; 00120 }; 00121 SLPacketHeader(const SLPacketHeader & Aslph) { 00122 *this = Aslph; 00123 }; 00124 00125 bool accessUnitStartFlag:1; 00126 bool accessUnitEndFlag:1; 00127 bool OCRFlag; 00128 bool idleFlag; 00129 bool paddingFlag; 00130 u8 paddingBits; 00131 u16 packetSequenceNumber; 00132 bool DegPrioFlag; 00133 u16 degradationPriority; 00134 u64 objectClockReference; 00135 00136 bool randomAccessPointFlag; 00137 u16 AU_sequenceNumber; 00138 bool decodingTimeStampFlag; 00139 bool compositionTimeStampFlag; 00140 bool instantBitrateFlag; 00141 u64 decodingTimeStamp; 00142 u64 compositionTimeStamp; 00143 u32 accessUnitLength; 00144 u64 instantBitrate; // could be up to 256 bits! 00145 } SLPacketHeader; 00146 00147 00148 bool operator == (SLPacketHeader const &first, 00149 SLPacketHeader const &second); 00150 00162 class SLPacket { 00163 public: 00164 SLPacket(SLPacketHeader Aslph, u8 * Apayload = 0, size_t Apl_size = 0, 00165 void * extra_data = NULL, u32 extra_data_size = 0); 00166 00167 virtual ~ SLPacket() { 00168 if (payload) 00169 delete payload; 00170 }; 00171 00172 size_t getPayloadSize() { 00173 return pl_size; 00174 }; 00175 00176 u8 *getPayload() { 00177 return payload; 00178 } 00179 00182 u8 *unsetPayload() { 00183 u8 *dummy = payload; 00184 payload = NULL; 00185 pl_size = 0; 00186 return dummy; 00187 } 00188 00192 bool deletePayload() { 00193 if (!payload) 00194 return false; 00195 delete payload; 00196 payload=NULL; 00197 pl_size = 0; 00198 return true; 00199 } 00200 00201 SLPacketHeader & getSLPacketHeader() { 00202 return slph; 00203 }; 00204 00205 protected: 00206 SLPacketHeader slph; 00207 u8 *payload; 00208 size_t pl_size; 00209 }; 00210 00211 #define SLPacketList list<SLPacket*> 00212 #define SLPacketHeaderList list<SLPacketHeader> 00213 00214 // 00216 // */ 00217 //class SLStreamReceiver { 00218 // protected: 00219 // // receive callback 00220 // virtual void receiveSLPackets(SLPacketList slpl) = 0; 00221 //}; 00222 00223 #endif