shithub: aacdec

Download patch

ref: e021cc2bc392b43b187846a154b18f448ba549aa
parent: 877579bfaf220ce9d28f5254b4893ed136a03b3a
author: menno <menno>
date: Tue Mar 30 03:16:09 EST 2004

Updated mpeg4ip libraries to version 1.0
This may require some fixing in makefiles, etc

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 
+- 30 mar 2004: Updated mpeg4ip libraries to version 1.0
+- xx mar 2004: First PS (Parametric Stereo) checkin
 
 - 26 feb 2004: Added downsampled SBR support
 - 26 feb 2004: Optimised Low Power QMF filterbank
-
--- a/common/mp4av/aac.cpp
+++ b/common/mp4av/aac.cpp
@@ -131,50 +131,49 @@
 	return true;
 }
 
-
 extern "C" bool MP4AV_AacGetConfiguration_SBR(
-	u_int8_t** ppConfig,
-	u_int32_t* pConfigLength,
-	u_int8_t profile,
-	u_int32_t samplingRate,
-	u_int8_t channels)
+					      u_int8_t** ppConfig,
+					      u_int32_t* pConfigLength,
+					      u_int8_t profile,
+					      u_int32_t samplingRate,
+					      u_int8_t channels)
 {
-	/* create the appropriate decoder config */
+  /* create the appropriate decoder config */
 
-	u_int8_t* pConfig = (u_int8_t*)malloc(5);
-    pConfig[0] = 0;
-    pConfig[1] = 0;
-    pConfig[2] = 0;
-    pConfig[3] = 0;
-    pConfig[4] = 0;
+  u_int8_t* pConfig = (u_int8_t*)malloc(5);
+  pConfig[0] = 0;
+  pConfig[1] = 0;
+  pConfig[2] = 0;
+  pConfig[3] = 0;
+  pConfig[4] = 0;
 
-	if (pConfig == NULL) {
-		return false;
-	}
-
-	u_int8_t samplingRateIndex = 
-		MP4AV_AdtsFindSamplingRateIndex(samplingRate);
+  if (pConfig == NULL) {
+    return false;
+  }
 
-	pConfig[0] =
-		((profile + 1) << 3) | ((samplingRateIndex & 0xe) >> 1);
-	pConfig[1] =
-		((samplingRateIndex & 0x1) << 7) | (channels << 3);
+  u_int8_t samplingRateIndex = 
+    MP4AV_AdtsFindSamplingRateIndex(samplingRate);
 
-    /* pConfig[0] & pConfig[1] now contain the backward compatible
-       AudioSpecificConfig
-    */
+  pConfig[0] =
+    ((profile + 1) << 3) | ((samplingRateIndex & 0xe) >> 1);
+  pConfig[1] =
+    ((samplingRateIndex & 0x1) << 7) | (channels << 3);
 
-    /* SBR stuff */
-    const u_int16_t syncExtensionType = 0x2B7;
-	u_int8_t extensionSamplingRateIndex = 
-		MP4AV_AdtsFindSamplingRateIndex(2*samplingRate);
+  /* pConfig[0] & pConfig[1] now contain the backward compatible
+     AudioSpecificConfig
+  */
 
-    pConfig[2] = (syncExtensionType >> 3) & 0xFF;
-    pConfig[3] = ((syncExtensionType & 0x7) << 5) | 5 /* ext ot id */;
-    pConfig[4] = ((1 & 0x1) << 7) | (extensionSamplingRateIndex << 3);
+  /* SBR stuff */
+  const u_int16_t syncExtensionType = 0x2B7;
+  u_int8_t extensionSamplingRateIndex = 
+    MP4AV_AdtsFindSamplingRateIndex(2*samplingRate);
 
-	*ppConfig = pConfig;
-	*pConfigLength = 5;
+  pConfig[2] = (syncExtensionType >> 3) & 0xFF;
+  pConfig[3] = ((syncExtensionType & 0x7) << 5) | 5 /* ext ot id */;
+  pConfig[4] = ((1 & 0x1) << 7) | (extensionSamplingRateIndex << 3);
 
-	return true;
+  *ppConfig = pConfig;
+  *pConfigLength = 5;
+
+  return true;
 }
--- a/common/mp4av/libmp4av_st.dsp
+++ b/common/mp4av/libmp4av_st.dsp
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "libmp4av_st - Win32 Release"
@@ -40,8 +40,8 @@
 # PROP Output_Dir "Release"
 # PROP Intermediate_Dir "Release"
 # PROP Target_Dir ""
-MTL=midl.exe
 F90=df.exe
+MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD CPP /nologo /MD /W3 /GX /O1 /I "..\mp4v2" /I "." /I "..\..\include" /I "..\..\lib\mp4v2" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -65,8 +65,8 @@
 # PROP Output_Dir "Debug"
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
-MTL=midl.exe
 F90=df.exe
+MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
 # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\mp4v2" /I "." /I "..\..\include" /I "..\..\lib\mp4v2" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
--- a/common/mp4av/mp4av_aac.h
+++ b/common/mp4av/mp4av_aac.h
@@ -54,6 +54,12 @@
 	u_int8_t profile,
 	u_int32_t samplingRate,
 	u_int8_t channels);
+bool MP4AV_AacGetConfiguration_SBR(
+				   u_int8_t** ppConfig,
+				   u_int32_t* pConfigLength,
+				   u_int8_t profile,
+				   u_int32_t samplingRate,
+				   u_int8_t channels);
 
 #ifdef __cplusplus
 }
--- a/common/mp4av/mp4av_hinters.h
+++ b/common/mp4av/mp4av_hinters.h
@@ -50,6 +50,18 @@
 
 
 // Video Hinters
+MP4TrackId MP4AV_Rfc3016_HintTrackCreate(MP4FileHandle mp4File,
+ 				         MP4TrackId mediaTrackId);
+void MP4AV_Rfc3016_HintAddSample (
+				  MP4FileHandle mp4File,
+				  MP4TrackId hintTrackId,
+				  MP4SampleId sampleId,
+				  uint8_t *pSampleBuffer,
+				  uint32_t sampleSize,
+				  MP4Duration duration,
+				  MP4Duration renderingOffset,
+				  bool isSyncSample,
+				  uint16_t maxPayloadSize);
 
 bool MP4AV_Rfc3016Hinter(
 	MP4FileHandle mp4File, 
--- a/common/mp4av/mp4av_mpeg4.h
+++ b/common/mp4av/mp4av_mpeg4.h
@@ -23,12 +23,15 @@
 #define __MP4AV_MPEG4_INCLUDED__
 
 #define MP4AV_MPEG4_SYNC		0x000001
-#define MP4AV_MPEG4_VOSH_START	0xB0
 #define MP4AV_MPEG4_VOL_START	0x20
+#define MP4AV_MPEG4_VOSH_START	0xB0
+#define MP4AV_MPEG4_VOSH_END    0xB1
+#define MP4AV_MPEG4_USER_DATA_START 0xB2
 #define MP4AV_MPEG4_GOV_START	0xB3
 #define MP4AV_MPEG4_VO_START	0xB5
 #define MP4AV_MPEG4_VOP_START	0xB6
 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -58,8 +61,10 @@
 	u_int16_t* pTimeTicks, 
 	u_int16_t* pFrameDuration, 
 	u_int16_t* pFrameWidth, 
-	u_int16_t* pFrameHeight);
-
+	u_int16_t* pFrameHeight,
+	u_int8_t * aspectRatioDefine DEFAULT_PARM(NULL),
+	u_int8_t * aspectRatioWidth DEFAULT_PARM(NULL),
+	u_int8_t * aspectRatioHeight DEFAULT_PARM(NULL));
 bool MP4AV_Mpeg4CreateVol(
 	u_int8_t** ppBytes,
 	u_int32_t* pNumBytes,
@@ -79,6 +84,7 @@
 	u_int8_t* pMinutes, 
 	u_int8_t* pSeconds);
 
+  uint8_t *MP4AV_Mpeg4FindVop(uint8_t *pBuf, uint32_t buflen);
 bool MP4AV_Mpeg4ParseVop(
 	u_int8_t* pVopBuf, 
 	u_int32_t vopSize,
@@ -87,13 +93,11 @@
 	u_int16_t timeTicks, 
 	u_int32_t* pVopTimeIncrement);
 
-u_int8_t MP4AV_Mpeg4VideoToSystemsProfileLevel(
-	u_int8_t videoProfileLevel);
-
 u_char MP4AV_Mpeg4GetVopType(
 	u_int8_t* pVopBuf, 
 	u_int32_t vopSize);
 
+  const char *MP4AV_Mpeg4VisualProfileName (uint8_t profile);
 #ifdef __cplusplus
 }
 #endif
--- a/common/mp4av/mpeg3.cpp
+++ b/common/mp4av/mpeg3.cpp
@@ -341,11 +341,11 @@
     rfc2250[0] = (*pstart >> 6) & 0x3;
     rfc2250[1] = (pstart[0] << 2) | ((pstart[1] >> 6) & 0x3); // temporal ref
     rfc2250[2] = type;
+    rfc2250_2 = rfc2250[2];
     if (have_seq != 0) {
       rfc2250[2] |= 0x20;
       have_seq = 0;
     }
-    rfc2250_2 = rfc2250[2];
 
     rfc2250[3] = 0;
     if (type == 2 || type == 3) {
--- a/common/mp4av/mpeg4.cpp
+++ b/common/mp4av/mpeg4.cpp
@@ -139,6 +139,20 @@
   }
   return NULL;
 }
+extern "C" uint8_t *MP4AV_Mpeg4FindVop (uint8_t *pBuf, uint32_t buflen)
+{
+  while (buflen > 4) {
+    if (pBuf[0] == 0x0 &&
+	pBuf[1] == 0x0 &&
+	pBuf[2] == 0x1 &&
+	pBuf[3] == MP4AV_MPEG4_VOP_START) {
+      return pBuf;
+    }
+    pBuf++;
+    buflen--;
+  }
+  return NULL;
+}
 
 extern "C" bool MP4AV_Mpeg4ParseVol(
 	u_int8_t* pVolBuf, 
@@ -147,9 +161,14 @@
 	u_int16_t* pTimeTicks, 
 	u_int16_t* pFrameDuration, 
 	u_int16_t* pFrameWidth, 
-	u_int16_t* pFrameHeight)
+	u_int16_t* pFrameHeight,
+	u_int8_t * aspectRatioDefine,
+	u_int8_t * aspectRatioWidth,
+	u_int8_t * aspectRatioHeight)
+
 {
 	CMemoryBitstream vol;
+	uint8_t aspect;
 
 	vol.SetBytes(pVolBuf, volSize);
 
@@ -163,9 +182,18 @@
 			verid = vol.GetBits(4);			// object layer verid
 			vol.SkipBits(3);				// object layer priority
 		}
-		if (vol.GetBits(4) == 0xF) { 	// aspect ratio info
-			vol.SkipBits(8);				// par width
-			vol.SkipBits(8);				// par height
+		aspect = vol.GetBits(4);
+		if (aspectRatioDefine != NULL)
+		  *aspectRatioDefine = aspect;
+		if (aspect == 0xF) { 	// aspect ratio info
+		  if (aspectRatioWidth != NULL) 
+		    *aspectRatioWidth = vol.GetBits(8);
+		  else
+		    vol.SkipBits(8);				// par width
+		  if (aspectRatioHeight != NULL) 
+		    *aspectRatioHeight = vol.GetBits(8);
+		  else
+		    vol.SkipBits(8);				// par height
 		}
 		if (vol.GetBits(1)) {			// vol control parameters
 			vol.SkipBits(2);				// chroma format
@@ -479,113 +507,6 @@
 	return true;
 }
 
-// Map from ISO IEC 14496-2:2000 Appendix G 
-// to ISO IEC 14496-1:2001 8.6.4.2 Table 6
-extern "C" u_int8_t 
-MP4AV_Mpeg4VideoToSystemsProfileLevel(u_int8_t videoProfileLevel)
-{
-	switch (videoProfileLevel) {
-	// Simple Profile
-	case 0x01: // L1
-		return 0x03;
-	case 0x02: // L2
-		return 0x02;
-	case 0x03: // L3
-		return 0x01;
-	// Simple Scalable Profile
-	case 0x11: // L1
-		return 0x05;
-	case 0x12: // L2
-		return 0x04;
-	// Core Profile
-	case 0x21: // L1
-		return 0x07;
-	case 0x22: // L2
-		return 0x06;
-	// Main Profile
-	case 0x32: // L2
-		return 0x0A;
-	case 0x33: // L3
-		return 0x09;
-	case 0x34: // L4
-		return 0x08;
-	// N-bit Profile
-	case 0x42: // L2
-		return 0x0B;
-	// Scalable Texture
-	case 0x51: // L1
-		return 0x12;
-	case 0x52: // L2
-		return 0x11;
-	case 0x53: // L3
-		return 0x10;
-	// Simple Face Animation Profile
-	case 0x61: // L1
-		return 0x14;
-	case 0x62: // L2
-		return 0x13;
-	// Simple FBA Profile
-	case 0x63: // L1
-	case 0x64: // L2
-		return 0xFE;
-	// Basic Animated Texture Profile
-	case 0x71: // L1
-		return 0x0F;
-	case 0x72: // L2
-		return 0x0E;
-	// Hybrid Profile
-	case 0x81: // L1
-		return 0x0D;
-	case 0x82: // L2
-		return 0x0C;
-	// Advanced Real Time Simple Profile
-	case 0x91: // L1
-	case 0x92: // L2
-	case 0x93: // L3
-	case 0x94: // L4
-	// Core Scalable Profile
-	case 0xA1: // L1
-	case 0xA2: // L2
-	case 0xA3: // L3
-	// Advanced Coding Efficiency Profle
-	case 0xB1: // L1
-	case 0xB2: // L2
-	case 0xB3: // L3
-	case 0xB4: // L4
-	// Advanced Core Profile
-	case 0xC1: // L1
-	case 0xC2: // L2
-	// Advanced Scalable Texture Profile
-	case 0xD1: // L1
-	case 0xD2: // L2
-	case 0xD3: // L3
-	// from draft amendments
-	// Simple Studio
-	case 0xE1: // L1
-	case 0xE2: // L2
-	case 0xE3: // L3
-	case 0xE4: // L4
-	// Core Studio Profile
-	case 0xE5: // L1
-	case 0xE6: // L2
-	case 0xE7: // L3
-	case 0xE8: // L4
-	// Advanced Simple Profile
-	case 0xF1: // L0
-	case 0xF2: // L1
-	case 0xF3: // L2
-	case 0xF4: // L3
-	case 0xF5: // L4
-	// Fine Granularity Scalable Profile
-	case 0xF6: // L0
-	case 0xF7: // L1
-	case 0xF8: // L2
-	case 0xF9: // L3
-	case 0xFA: // L4
-	default:
-		return 0xFE;
-	}
-}
 
 extern "C" u_char MP4AV_Mpeg4GetVopType(u_int8_t* pVopBuf, u_int32_t vopSize)
 {
--- a/common/mp4av/rfc3016.cpp
+++ b/common/mp4av/rfc3016.cpp
@@ -27,23 +27,14 @@
 #include <mp4av_common.h>
 #include <mp4av_mpeg4.h>
 
-extern "C" bool MP4AV_Rfc3016Hinter(
-	MP4FileHandle mp4File, 
-	MP4TrackId mediaTrackId, 
-	u_int16_t maxPayloadSize)
+extern "C" MP4TrackId MP4AV_Rfc3016_HintTrackCreate (MP4FileHandle mp4File,
+						     MP4TrackId mediaTrackId)
 {
-	u_int32_t numSamples = MP4GetTrackNumberOfSamples(mp4File, mediaTrackId);
-	u_int32_t maxSampleSize = MP4GetTrackMaxSampleSize(mp4File, mediaTrackId);
-	
-	if (numSamples == 0 || maxSampleSize == 0) {
-		return false;
-	}
-
 	MP4TrackId hintTrackId =
 		MP4AddHintTrack(mp4File, mediaTrackId);
 
 	if (hintTrackId == MP4_INVALID_TRACK_ID) {
-		return false;
+		return MP4_INVALID_TRACK_ID;
 	}
 
 	u_int8_t payloadNumber = MP4_SET_DYNAMIC_PAYLOAD;
@@ -64,8 +55,7 @@
 			0x00, 0x00, 0x01, MP4AV_MPEG4_VOSH_START 
 		};
 		if (configSize >= 5 && !memcmp(pConfig, voshStartCode, 4)) {
-			systemsProfileLevel = 
-				MP4AV_Mpeg4VideoToSystemsProfileLevel(pConfig[4]);
+			systemsProfileLevel = pConfig[4];
 		} 
 		if (systemsProfileLevel == 0xFE) {
 			u_int8_t iodProfileLevel = MP4GetVideoProfileLevel(mp4File);
@@ -80,7 +70,8 @@
 		char* sConfig = MP4BinaryToBase16(pConfig, configSize);
 		if (sConfig == NULL) {
 			MP4DeleteTrack(mp4File, hintTrackId);
-			return false;
+			free(pConfig);
+			return MP4_INVALID_TRACK_ID;
 		}
 
 		/* create the appropriate SDP attribute */
@@ -97,10 +88,80 @@
 
 		free(sConfig);
 		free(sdpBuf);
+		free(pConfig);
+	}
+	return hintTrackId;
+}
+						
+extern "C" void MP4AV_Rfc3016_HintAddSample (
+					     MP4FileHandle mp4File,
+					     MP4TrackId hintTrackId,
+					     MP4SampleId sampleId,
+					     uint8_t *pSampleBuffer,
+					     uint32_t sampleSize,
+					     MP4Duration duration,
+					     MP4Duration renderingOffset,
+					     bool isSyncSample,
+					     uint16_t maxPayloadSize)
+{
+  bool isBFrame = 
+    (MP4AV_Mpeg4GetVopType(pSampleBuffer, sampleSize) == 'B');
 
+  MP4AddRtpVideoHint(mp4File, hintTrackId, isBFrame, renderingOffset);
+
+  if (sampleId == 1) {
+    MP4AddRtpESConfigurationPacket(mp4File, hintTrackId);
+  }
+
+  u_int32_t offset = 0;
+  u_int32_t remaining = sampleSize;
+
+  // TBD should scan for resync markers (if enabled in ES config)
+  // and packetize on those boundaries
+
+  while (remaining) {
+    bool isLastPacket = false;
+    u_int32_t length;
+
+    if (remaining <= maxPayloadSize) {
+      length = remaining;
+      isLastPacket = true;
+    } else {
+      length = maxPayloadSize;
+    }
+
+    MP4AddRtpPacket(mp4File, hintTrackId, isLastPacket);
+			
+    MP4AddRtpSampleData(mp4File, hintTrackId, sampleId, 
+			offset, length);
+
+    offset += length;
+    remaining -= length;
+  }
+
+  MP4WriteRtpHint(mp4File, hintTrackId, duration, isSyncSample);
+}
+
+extern "C" bool MP4AV_Rfc3016Hinter(
+	MP4FileHandle mp4File, 
+	MP4TrackId mediaTrackId, 
+	u_int16_t maxPayloadSize)
+{
+	u_int32_t numSamples = MP4GetTrackNumberOfSamples(mp4File, mediaTrackId);
+	u_int32_t maxSampleSize = MP4GetTrackMaxSampleSize(mp4File, mediaTrackId);
+	
+	if (numSamples == 0 || maxSampleSize == 0) {
+		return false;
 	}
 
-	u_int8_t* pSampleBuffer = (u_int8_t*)malloc(maxSampleSize);
+	MP4TrackId hintTrackId = 
+	  MP4AV_Rfc3016_HintTrackCreate(mp4File, mediaTrackId);
+
+	if (hintTrackId == MP4_INVALID_TRACK_ID) {
+	  return false;
+	}
+
+ 	u_int8_t* pSampleBuffer = (u_int8_t*)malloc(maxSampleSize);
 	if (pSampleBuffer == NULL) {
 		MP4DeleteTrack(mp4File, hintTrackId);
 		return false;
@@ -121,46 +182,21 @@
 
 		if (!rc) {
 			MP4DeleteTrack(mp4File, hintTrackId);
+			CHECK_AND_FREE(pSampleBuffer);
 			return false;
 		}
 
-		bool isBFrame = 
-			(MP4AV_Mpeg4GetVopType(pSampleBuffer, sampleSize) == 'B');
-
-		MP4AddRtpVideoHint(mp4File, hintTrackId, isBFrame, renderingOffset);
-
-		if (sampleId == 1) {
-			MP4AddRtpESConfigurationPacket(mp4File, hintTrackId);
-		}
-
-		u_int32_t offset = 0;
-		u_int32_t remaining = sampleSize;
-
-		// TBD should scan for resync markers (if enabled in ES config)
-		// and packetize on those boundaries
-
-		while (remaining) {
-			bool isLastPacket = false;
-			u_int32_t length;
-
-			if (remaining <= maxPayloadSize) {
-				length = remaining;
-				isLastPacket = true;
-			} else {
-				length = maxPayloadSize;
-			}
-
-			MP4AddRtpPacket(mp4File, hintTrackId, isLastPacket);
-			
-			MP4AddRtpSampleData(mp4File, hintTrackId, sampleId, 
-				offset, length);
-
-			offset += length;
-			remaining -= length;
-		}
-
-		MP4WriteRtpHint(mp4File, hintTrackId, duration, isSyncSample);
+		MP4AV_Rfc3016_HintAddSample(mp4File,
+					    hintTrackId,
+					    sampleId,
+					    pSampleBuffer,
+					    sampleSize,
+					    duration,
+					    renderingOffset,
+					    isSyncSample,
+					    maxPayloadSize);
 	}
+	CHECK_AND_FREE(pSampleBuffer);
 
 	return true;
 }
--- a/common/mp4v2/API_CHANGES
+++ b/common/mp4v2/API_CHANGES
@@ -1,3 +1,42 @@
+Changes in xxxx
+---------------
+Change to MP4Create and MP4Modify to allow flags to be set for 64 bit
+to allow Quicktime compatibility
+Change to MP4CloneTrack and MP4CopyTrack for when you copy a hint
+track - you must now specify the track ID in the new file for the
+reference track.
+
+Changes in 0.9.9
+---------------------------
+Added support for ISMA's Ismacrypt specification:
+  MP4GetTrackEsdsObjectTypeId replaces MP4GetTrackAudioType 
+  and MP4GetTrackVideoType.
+  MP4EncAndCloneTrack is used instead of MP4CloneTrack to encrypt a track
+  while cloning it.
+  MP4EncAndCopyTrack is used instead of MP4CopyTrack to encrypt a track 
+  while copying it.
+  MP4AddEncAudioTrack adds an encrypted audio track.
+  MP4AddEncVideoTrack adds an encrypted video track. 
+  
+
+Changes in 0.9.8
+---------------------------
+  MP4WriteSample - changed "uint8_t * data" to "const uint8_t *data"
+
+Changes from 0.9.6
+---------------------------
+Modified
+  MP4SetHintTrackRtpPayload
+    payload parameter to get a dynamic payload is MP4_SET_DYNAMIC_PAYLOAD
+    (value 0xff) instead of 0.
+
+Changes from 0.9.5 to 0.9.6
+---------------------------
+Modified
+    MP4GetHintTrackRtpPayload
+    MP4SetHintTrackRtpPayload
+       get/set the encoding params (a=rtpmap <payloadname>/<timescale>[/<encoding params>])
+
 Changes from 0.9.4 to 0.9.5
 ---------------------------
 Added
--- a/common/mp4v2/INTERNALS
+++ b/common/mp4v2/INTERNALS
@@ -3,7 +3,7 @@
 MP4V2 LIBRARY INTERNALS
 =======================
 
-This document provides an overview of the interals of the mp4v2 library 
+This document provides an overview of the internals of the mp4v2 library 
 to aid those who wish to modify and extend it. Before reading this document,
 I recommend familiarizing yourself with the MP4 (or Quicktime) file format 
 standard and the mp4v2 library API. The API is described in a set of man pages
--- /dev/null
+++ b/common/mp4v2/README
@@ -1,0 +1,30 @@
+July 18, 2002
+
+MP4V2 Library
+=============
+
+This library provides functions to read, create, and modify mp4 files.
+
+The detailed documentation of the library is available as a set of man pages 
+in mpeg4ip/doc/mp4v2. The MP4.3 man page gives an overview of the library.
+
+Alternately mp4.h in this directory specifies the complete API.
+
+The file INTERNALS provides an overview of what is happening behind the API. 
+Note that although we using C++ object oriented features internally, that's 
+all hidden behind a flat C style API (with C linkage conventions).
+
+The test and util subdirectories contain some simple programs that use 
+this library.
+
+To use this library in your application, it should be sufficient to:
+
+1) add mpeg4ip/include and mpeg4ip/lib/mp4v2 to your INCLUDE path,
+	e.g. gcc -Impeg4ip/include -Impeg4ip/lib/mp4v2 ...
+
+2) add mpeg4ip/lib/mp4v2/libmp4v2.la (or /usr/local/lib/libmp4v2.la)
+	e.g. gcc ... -o foo foo.cpp mpeg4ip/lib/mp4v2/libmp4v2.a
+
+3) include mp4.h into your code,
+	e.g. #include <mp4.h>
+
--- a/common/mp4v2/TODO
+++ b/common/mp4v2/TODO
@@ -1,11 +1,9 @@
 
-Extended format (v2) support
+Add ability to create samples referenced in multiple tracks
 
-Means to dump all possible atoms/properties with types
+Add ability to create atoms/properties via set or add operations
 
-Wrap printf's for verbosity - see example is player/lib/http/http_util.c
+Exploit extended format (ISO v2)
 
-Distinguish cases of no ES Config and error parsing esds
-
-Improve error recovery when length of atom/descriptor is larger than parent/file, resync on parent.
+List all possible atoms/properties with types
 
--- a/common/mp4v2/atom_mdhd.cpp
+++ b/common/mp4v2/atom_mdhd.cpp
@@ -59,7 +59,7 @@
 
 void MP4MdhdAtom::Generate() 
 {
-	u_int8_t version = m_pFile->Use64Bits() ? 1 : 0;
+	u_int8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0;
 	SetVersion(version);
 	AddProperties(version);
 
--- a/common/mp4v2/atom_meta.cpp
+++ b/common/mp4v2/atom_meta.cpp
@@ -100,7 +100,6 @@
     ExpectChildAtom("gnre", Optional, OnlyOne); /* genre (ID3v1 index + 1) */
     ExpectChildAtom("cpil", Optional, OnlyOne); /* compilation */
     ExpectChildAtom("tmpo", Optional, OnlyOne); /* BPM */
-    ExpectChildAtom("covr", Optional, OnlyOne); /* cover art */
     ExpectChildAtom("----", Optional, Many); /* ---- free form */
 }
 
@@ -186,12 +185,6 @@
 
 MP4TmpoAtom::MP4TmpoAtom()
     : MP4Atom("tmpo")
-{
-    ExpectChildAtom("data", Required, OnlyOne);
-}
-
-MP4CovrAtom::MP4CovrAtom()
-    : MP4Atom("covr")
 {
     ExpectChildAtom("data", Required, OnlyOne);
 }
--- a/common/mp4v2/atom_mvhd.cpp
+++ b/common/mp4v2/atom_mvhd.cpp
@@ -70,7 +70,7 @@
 
 void MP4MvhdAtom::Generate() 
 {
-	u_int8_t version = m_pFile->Use64Bits() ? 1 : 0;
+	u_int8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0;
 	SetVersion(version);
 	AddProperties(version);
 
--- a/common/mp4v2/atom_root.cpp
+++ b/common/mp4v2/atom_root.cpp
@@ -38,7 +38,7 @@
 	// only call under MP4Create() control
 	WriteAtomType("ftyp", OnlyOne);
 
-	m_pChildAtoms[GetLastMdatIndex()]->BeginWrite(m_pFile->Use64Bits());
+	m_pChildAtoms[GetLastMdatIndex()]->BeginWrite(m_pFile->Use64Bits("mdat"));
 }
 
 void MP4RootAtom::Write()
@@ -50,7 +50,7 @@
 {
 	// finish writing last mdat atom
 	u_int32_t mdatIndex = GetLastMdatIndex();
-	m_pChildAtoms[mdatIndex]->FinishWrite(m_pFile->Use64Bits());
+	m_pChildAtoms[mdatIndex]->FinishWrite(m_pFile->Use64Bits("mdat"));
 
 	// write all atoms after last mdat
 	u_int32_t size = m_pChildAtoms.Size();
@@ -65,13 +65,13 @@
 	WriteAtomType("moov", OnlyOne);
 	WriteAtomType("udta", Many);
 
-	m_pChildAtoms[GetLastMdatIndex()]->BeginWrite(m_pFile->Use64Bits());
+	m_pChildAtoms[GetLastMdatIndex()]->BeginWrite(m_pFile->Use64Bits("mdat"));
 }
 
 void MP4RootAtom::FinishOptimalWrite() 
 {
 	// finish writing mdat
-	m_pChildAtoms[GetLastMdatIndex()]->FinishWrite(m_pFile->Use64Bits());
+	m_pChildAtoms[GetLastMdatIndex()]->FinishWrite(m_pFile->Use64Bits("mdat"));
 
 	// find moov atom
 	u_int32_t size = m_pChildAtoms.Size();
--- a/common/mp4v2/atom_stbl.cpp
+++ b/common/mp4v2/atom_stbl.cpp
@@ -43,7 +43,7 @@
 
 	// but we also need one of the chunk offset atoms
 	MP4Atom* pChunkOffsetAtom;
-	if (m_pFile->Use64Bits()) {
+	if (m_pFile->Use64Bits(GetType())) {
 		pChunkOffsetAtom = CreateAtom("co64");
 	} else {
 		pChunkOffsetAtom = CreateAtom("stco");
--- a/common/mp4v2/atom_tkhd.cpp
+++ b/common/mp4v2/atom_tkhd.cpp
@@ -74,7 +74,7 @@
 
 void MP4TkhdAtom::Generate() 
 {
-	u_int8_t version = m_pFile->Use64Bits() ? 1 : 0;
+	u_int8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0;
 	SetVersion(version);
 	AddProperties(version);
 
--- a/common/mp4v2/atoms.h
+++ b/common/mp4v2/atoms.h
@@ -540,11 +540,6 @@
 	MP4AlbAtom();
 };
 
-class MP4GenAtom : public MP4Atom {
-public:
-	MP4GenAtom();
-};
-
 class MP4TrknAtom : public MP4Atom {
 public:
 	MP4TrknAtom();
@@ -555,6 +550,11 @@
 	MP4DayAtom();
 };
 
+class MP4GenAtom : public MP4Atom {
+public:
+	MP4GenAtom();
+};
+
 class MP4TooAtom : public MP4Atom {
 public:
 	MP4TooAtom();
@@ -573,11 +573,6 @@
 class MP4TmpoAtom : public MP4Atom {
 public:
 	MP4TmpoAtom();
-};
-
-class MP4CovrAtom : public MP4Atom {
-public:
-	MP4CovrAtom();
 };
 
 class MP4CmtAtom : public MP4Atom {
--- a/common/mp4v2/libmp4v2_cb.dsp
+++ /dev/null
@@ -1,556 +1,0 @@
-# Microsoft Developer Studio Project File - Name="libmp4v2_cb" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libmp4v2_cb - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2_cb.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libmp4v2_cb.mak" CFG="libmp4v2_cb - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libmp4v2_cb - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libmp4v2_cb - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libmp4v2_cb - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "CB_Release"
-# PROP Intermediate_Dir "CB_Release"
-# PROP Target_Dir ""
-MTL=midl.exe
-F90=df.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /I ".\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /c
-# ADD BASE RSC /l 0x413 /d "NDEBUG"
-# ADD RSC /l 0x413 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ELSEIF  "$(CFG)" == "libmp4v2_cb - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "CB_Debug"
-# PROP Intermediate_Dir "CB_Debug"
-# PROP Target_Dir ""
-MTL=midl.exe
-F90=df.exe
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_FILE_CALLBACKS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x413 /d "_DEBUG"
-# ADD RSC /l 0x413 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libmp4v2_cb - Win32 Release"
-# Name "libmp4v2_cb - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\atom_co64.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_cprt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ctts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dimm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dmed.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_dref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_drep.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_edts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_elst.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_enca.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_encv.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_esds.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_free.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_frma.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_ftyp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hdlr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_hnti.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iKMS.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iods.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_iSFM.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_maxr.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdat.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mdia.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_meta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_minf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moof.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_moov.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4a.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4s.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mp4v.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_mvhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_nump.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_payt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_pmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_root.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_rtp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_schi.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_schm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_sdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_sinf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_smhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_snro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stbl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stco.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stdp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsh.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stss.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stsz.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_stts.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tfhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tims.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tkhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmax.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tmin.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tpyl.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_traf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trak.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tref.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_treftype.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trpy.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_trun.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_tsro.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_udta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_url.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_urn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\atom_vmhd.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isma.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file_io.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4info.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4meta.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\need_for_win32.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\acconfig.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\atoms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\descriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4array.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4atom.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4common.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4container.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4descriptor.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4file.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4property.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4track.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp4util.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mpeg4ip.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ocidescriptors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\odcommands.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\qosqualifiers.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\rtphint.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\systems.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32_ver.h
-# End Source File
-# End Group
-# End Target
-# End Project
--- a/common/mp4v2/libmp4v2_cb.vcproj
+++ /dev/null
@@ -1,359 +1,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="7.00"
-	Name="libmp4v2_cb"
-	ProjectGUID="{FAEB6203-052A-4073-AC1C-9CF6FB5B40CC}"
-	SccProjectName=""
-	SccLocalPath="">
-	<Platforms>
-		<Platform
-			Name="Win32"/>
-	</Platforms>
-	<Configurations>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\CB_Release"
-			IntermediateDirectory=".\CB_Release"
-			ConfigurationType="4"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE">
-			<Tool
-				Name="VCCLCompilerTool"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories=".\"
-				PreprocessorDefinitions="NDEBUG,WIN32,_WINDOWS,USE_FILE_CALLBACKS"
-				StringPooling="TRUE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="TRUE"
-				UsePrecompiledHeader="2"
-				PrecompiledHeaderFile=".\CB_Release/libmp4v2_cb.pch"
-				AssemblerListingLocation=".\CB_Release/"
-				ObjectFile=".\CB_Release/"
-				ProgramDataBaseFileName=".\CB_Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				CompileAs="0"
-				AdditionalOptions="">
-				<IntelOptions
-					Optimization="2"
-					InlineFuncExpansion="1"
-					OmitFramePtrs="1"
-					StringPooling="1"
-					RuntimeLibrary="0"
-					BufferSecurityCheck="1"
-					FunctionLevelLinking="1"
-					AllOptions="/c  /I &quot;.\\&quot; /nologo /W3 /O2 /Ob1 /Oy /D &quot;NDEBUG&quot; /D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;USE_FILE_CALLBACKS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\CB_Release/libmp4v2_cb.pch&quot; /Fo&quot;.\CB_Release/&quot; /Fd&quot;.\CB_Release/&quot; /Gd"
-					MSOriginalAdditionalOptions=""/>
-			</Tool>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile=".\CB_Release\libmp4v2_cb.lib"
-				SuppressStartupBanner="TRUE"
-				AdditionalOptions="">
-				<IntelOptions
-					AllOptions="/OUT:&quot;.\CB_Release\libmp4v2_cb.lib&quot; /NOLOGO"
-					MSOriginalAdditionalOptions=""/>
-			</Tool>
-			<Tool
-				Name="VCMIDLTool"/>
-			<Tool
-				Name="VCPostBuildEventTool"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1043"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-			<IntelOptions
-				CompilerName="0"/>
-		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\CB_Debug"
-			IntermediateDirectory=".\CB_Debug"
-			ConfigurationType="4"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE">
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=".\"
-				PreprocessorDefinitions="_DEBUG,WIN32,_WINDOWS,USE_FILE_CALLBACKS"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				UsePrecompiledHeader="2"
-				PrecompiledHeaderFile=".\CB_Debug/libmp4v2_cb.pch"
-				AssemblerListingLocation=".\CB_Debug/"
-				ObjectFile=".\CB_Debug/"
-				ProgramDataBaseFileName=".\CB_Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="TRUE"
-				DebugInformationFormat="4"
-				CompileAs="0"
-				AdditionalOptions="">
-				<IntelOptions
-					Optimization="0"
-					MinimalRebuild="1"
-					BasicRuntimeChecks="3"
-					RuntimeLibrary="3"
-					AllOptions="/c  /I &quot;.\\&quot; /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;USE_FILE_CALLBACKS&quot; /Gm /EHsc /RTC1 /MDd /YX&quot;StdAfx.h&quot; /Fp&quot;.\CB_Debug/libmp4v2_cb.pch&quot; /Fo&quot;.\CB_Debug/&quot; /Fd&quot;.\CB_Debug/&quot; /Gd &lt;?ICLPrjArgs?&gt; /Qvc7 /Qlocation,link,&quot;E:\Program Files\Microsoft Visual Studio .NET\Vc7\Bin&quot; /c  /I &quot;.\\&quot; /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_WINDOWS&quot; /D &quot;USE_FILE_CALLBACKS&quot; /Gm /EHsc /RTC1 /MDd /YX&quot;StdAfx.h&quot; /Fp&quot;.\CB_Debug/libmp4v2_cb.pch&quot; /Fo&quot;.\CB_Debug/&quot; /Fd&quot;.\CB_Debug/&quot; /Gd &lt;?/ICLPrjArgs?&gt; &lt;?IVCSpawnPrjArgs?&gt; #$UseIntelTool #$BinPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Bin;E:\Program Files\Common Files\Intel\Shared Files\IA32\Bin;E:\Program Files\Microsoft Visual Studio .NET\Common7\IDE&quot; #$LibPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Lib;E:\Program Files\Common Files\Intel\Shared Files\IA32\Lib&quot; #$IncPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Include&quot; &lt;?/IVCSpawnPrjArgs?&gt;"
-					MSOriginalAdditionalOptions=""/>
-			</Tool>
-			<Tool
-				Name="VCCustomBuildTool"/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile=".\CB_Debug\libmp4v2_cb.lib"
-				SuppressStartupBanner="TRUE"
-				AdditionalOptions="">
-				<IntelOptions
-					AllOptions="/OUT:&quot;.\CB_Debug\libmp4v2_cb.lib&quot; /NOLOGO &lt;?ICLPrjArgs?&gt; /OUT:&quot;.\CB_Debug\libmp4v2_cb.lib&quot; /NOLOGO &lt;?/ICLPrjArgs?&gt; &lt;?IVCSpawnPrjArgs?&gt; #$UseIntelTool #$BinPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Bin;E:\Program Files\Common Files\Intel\Shared Files\IA32\Bin;E:\Program Files\Microsoft Visual Studio .NET\Common7\IDE&quot; #$LibPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Lib;E:\Program Files\Common Files\Intel\Shared Files\IA32\Lib&quot; #$IncPath:&quot;E:\Program Files\Intel\Compiler70\IA32\Include&quot; &lt;?/IVCSpawnPrjArgs?&gt;"
-					MSOriginalAdditionalOptions=""/>
-			</Tool>
-			<Tool
-				Name="VCMIDLTool"/>
-			<Tool
-				Name="VCPostBuildEventTool"/>
-			<Tool
-				Name="VCPreBuildEventTool"/>
-			<Tool
-				Name="VCPreLinkEventTool"/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1043"/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"/>
-		</Configuration>
-	</Configurations>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
-			<File
-				RelativePath=".\atom_co64.cpp"/>
-			<File
-				RelativePath=".\atom_cprt.cpp"/>
-			<File
-				RelativePath=".\atom_ctts.cpp"/>
-			<File
-				RelativePath=".\atom_dimm.cpp"/>
-			<File
-				RelativePath=".\atom_dinf.cpp"/>
-			<File
-				RelativePath=".\atom_dmax.cpp"/>
-			<File
-				RelativePath=".\atom_dmed.cpp"/>
-			<File
-				RelativePath=".\atom_dref.cpp"/>
-			<File
-				RelativePath=".\atom_drep.cpp"/>
-			<File
-				RelativePath=".\atom_edts.cpp"/>
-			<File
-				RelativePath=".\atom_elst.cpp"/>
-			<File
-				RelativePath=".\atom_esds.cpp"/>
-			<File
-				RelativePath=".\atom_free.cpp"/>
-			<File
-				RelativePath=".\atom_ftyp.cpp"/>
-			<File
-				RelativePath=".\atom_hdlr.cpp"/>
-			<File
-				RelativePath=".\atom_hinf.cpp"/>
-			<File
-				RelativePath=".\atom_hmhd.cpp"/>
-			<File
-				RelativePath=".\atom_hnti.cpp"/>
-			<File
-				RelativePath=".\atom_iods.cpp"/>
-			<File
-				RelativePath=".\atom_maxr.cpp"/>
-			<File
-				RelativePath=".\atom_mdat.cpp"/>
-			<File
-				RelativePath=".\atom_mdhd.cpp"/>
-			<File
-				RelativePath=".\atom_mdia.cpp"/>
-			<File
-				RelativePath=".\atom_mfhd.cpp"/>
-			<File
-				RelativePath=".\atom_minf.cpp"/>
-			<File
-				RelativePath=".\atom_moof.cpp"/>
-			<File
-				RelativePath=".\atom_moov.cpp"/>
-			<File
-				RelativePath=".\atom_mp4a.cpp"/>
-			<File
-				RelativePath=".\atom_mp4s.cpp"/>
-			<File
-				RelativePath=".\atom_mp4v.cpp"/>
-			<File
-				RelativePath=".\atom_mvex.cpp"/>
-			<File
-				RelativePath=".\atom_mvhd.cpp"/>
-			<File
-				RelativePath=".\atom_nmhd.cpp"/>
-			<File
-				RelativePath=".\atom_nump.cpp"/>
-			<File
-				RelativePath=".\atom_payt.cpp"/>
-			<File
-				RelativePath=".\atom_pmax.cpp"/>
-			<File
-				RelativePath=".\atom_root.cpp"/>
-			<File
-				RelativePath=".\atom_rtp.cpp"/>
-			<File
-				RelativePath=".\atom_sdp.cpp"/>
-			<File
-				RelativePath=".\atom_smhd.cpp"/>
-			<File
-				RelativePath=".\atom_snro.cpp"/>
-			<File
-				RelativePath=".\atom_stbl.cpp"/>
-			<File
-				RelativePath=".\atom_stco.cpp"/>
-			<File
-				RelativePath=".\atom_stdp.cpp"/>
-			<File
-				RelativePath=".\atom_stsc.cpp"/>
-			<File
-				RelativePath=".\atom_stsd.cpp"/>
-			<File
-				RelativePath=".\atom_stsh.cpp"/>
-			<File
-				RelativePath=".\atom_stss.cpp"/>
-			<File
-				RelativePath=".\atom_stsz.cpp"/>
-			<File
-				RelativePath=".\atom_stts.cpp"/>
-			<File
-				RelativePath="atom_tag4.cpp"/>
-			<File
-				RelativePath=".\atom_tfhd.cpp"/>
-			<File
-				RelativePath=".\atom_tims.cpp"/>
-			<File
-				RelativePath=".\atom_tkhd.cpp"/>
-			<File
-				RelativePath=".\atom_tmax.cpp"/>
-			<File
-				RelativePath=".\atom_tmin.cpp"/>
-			<File
-				RelativePath=".\atom_tpyl.cpp"/>
-			<File
-				RelativePath=".\atom_traf.cpp"/>
-			<File
-				RelativePath=".\atom_trak.cpp"/>
-			<File
-				RelativePath=".\atom_tref.cpp"/>
-			<File
-				RelativePath=".\atom_treftype.cpp"/>
-			<File
-				RelativePath=".\atom_trex.cpp"/>
-			<File
-				RelativePath=".\atom_trpy.cpp"/>
-			<File
-				RelativePath=".\atom_trun.cpp"/>
-			<File
-				RelativePath=".\atom_tsro.cpp"/>
-			<File
-				RelativePath=".\atom_udta.cpp"/>
-			<File
-				RelativePath=".\atom_url.cpp"/>
-			<File
-				RelativePath=".\atom_urn.cpp"/>
-			<File
-				RelativePath=".\atom_vmhd.cpp"/>
-			<File
-				RelativePath=".\descriptors.cpp"/>
-			<File
-				RelativePath=".\isma.cpp"/>
-			<File
-				RelativePath=".\mp4.cpp"/>
-			<File
-				RelativePath=".\mp4atom.cpp"/>
-			<File
-				RelativePath=".\mp4container.cpp"/>
-			<File
-				RelativePath=".\mp4descriptor.cpp"/>
-			<File
-				RelativePath=".\mp4file.cpp"/>
-			<File
-				RelativePath=".\mp4file_io.cpp"/>
-			<File
-				RelativePath=".\mp4info.cpp"/>
-			<File
-				RelativePath=".\mp4property.cpp"/>
-			<File
-				RelativePath=".\mp4track.cpp"/>
-			<File
-				RelativePath=".\mp4util.cpp"/>
-			<File
-				RelativePath=".\need_for_win32.c"/>
-			<File
-				RelativePath=".\ocidescriptors.cpp"/>
-			<File
-				RelativePath=".\odcommands.cpp"/>
-			<File
-				RelativePath=".\qosqualifiers.cpp"/>
-			<File
-				RelativePath=".\rtphint.cpp"/>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl">
-			<File
-				RelativePath=".\acconfig.h"/>
-			<File
-				RelativePath=".\atoms.h"/>
-			<File
-				RelativePath=".\descriptors.h"/>
-			<File
-				RelativePath=".\mp4.h"/>
-			<File
-				RelativePath=".\mp4array.h"/>
-			<File
-				RelativePath=".\mp4atom.h"/>
-			<File
-				RelativePath=".\mp4common.h"/>
-			<File
-				RelativePath=".\mp4container.h"/>
-			<File
-				RelativePath=".\mp4descriptor.h"/>
-			<File
-				RelativePath=".\mp4file.h"/>
-			<File
-				RelativePath=".\mp4property.h"/>
-			<File
-				RelativePath=".\mp4track.h"/>
-			<File
-				RelativePath=".\mp4util.h"/>
-			<File
-				RelativePath=".\mpeg4ip.h"/>
-			<File
-				RelativePath=".\ocidescriptors.h"/>
-			<File
-				RelativePath=".\odcommands.h"/>
-			<File
-				RelativePath=".\qosqualifiers.h"/>
-			<File
-				RelativePath=".\rtphint.h"/>
-			<File
-				RelativePath=".\systems.h"/>
-			<File
-				RelativePath=".\win32_ver.h"/>
-		</Filter>
-	</Files>
-	<Globals/>
-</VisualStudioProject>
--- a/common/mp4v2/libmp4v2_st60.dsp
+++ b/common/mp4v2/libmp4v2_st60.dsp
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "libmp4v2_st - Win32 Release"
@@ -35,15 +35,16 @@
 # PROP BASE Output_Dir "Release"
 # PROP BASE Intermediate_Dir "Release"
 # PROP BASE Target_Dir ""
-# PROP Use_MFC 0
+# PROP Use_MFC 1
 # PROP Use_Debug_Libraries 0
 # PROP Output_Dir "ST_Release"
 # PROP Intermediate_Dir "ST_Release"
 # PROP Target_Dir ""
-MTL=midl.exe
 F90=df.exe
+MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O1 /I ".\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O1 /I ".\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /YX /FD /c
+# SUBTRACT CPP /Fr
 # ADD BASE RSC /l 0x409
 # ADD RSC /l 0x409
 BSC32=bscmake.exe
@@ -60,17 +61,17 @@
 # PROP BASE Output_Dir "Debug"
 # PROP BASE Intermediate_Dir "Debug"
 # PROP BASE Target_Dir ""
-# PROP Use_MFC 0
+# PROP Use_MFC 2
 # PROP Use_Debug_Libraries 1
 # PROP Output_Dir "ST_Debug"
 # PROP Intermediate_Dir "ST_Debug"
 # PROP Target_Dir ""
-MTL=midl.exe
 F90=df.exe
+MTL=midl.exe
 # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I ".\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I ".\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
 # ADD BASE RSC /l 0x409
-# ADD RSC /l 0x409
+# ADD RSC /l 0x409 /d "_AFXDLL"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
@@ -517,10 +518,6 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\mpeg4ip.h
-# End Source File
-# Begin Source File
-
 SOURCE=.\ocidescriptors.h
 # End Source File
 # Begin Source File
@@ -534,14 +531,6 @@
 # Begin Source File
 
 SOURCE=.\rtphint.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\systems.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\win32_ver.h
 # End Source File
 # End Group
 # Begin Source File
--- a/common/mp4v2/mp4.cpp
+++ b/common/mp4v2/mp4.cpp
@@ -51,122 +51,15 @@
 	}
 }
 
-#ifdef USE_FILE_CALLBACKS
-extern "C" MP4FileHandle MP4CreateCb(u_int32_t verbosity,
-                                     bool use64bits,
-                                     bool useExtensibleFormat,
-                                     MP4OpenCallback MP4fopen,
-                                     MP4CloseCallback MP4fclose,
-                                     MP4ReadCallback MP4fread,
-                                     MP4WriteCallback MP4fwrite,
-                                     MP4SetposCallback MP4fsetpos,
-                                     MP4GetposCallback MP4fgetpos,
-                                     MP4FilesizeCallback MP4filesize,
-                                     void *userData)
-{
-	MP4File* pFile = NULL;
-	try {
-		pFile = new MP4File(verbosity);
-		// LATER useExtensibleFormat, moov first, then mvex's
-
-        // Set user data and callbacks
-        pFile->m_userData = userData;
-        pFile->m_MP4fopen = MP4fopen;
-        pFile->m_MP4fclose = MP4fclose;
-        pFile->m_MP4fread = MP4fread;
-        pFile->m_MP4fwrite = MP4fwrite;
-        pFile->m_MP4fsetpos = MP4fsetpos;
-        pFile->m_MP4fgetpos = MP4fgetpos;
-        pFile->m_MP4filesize = MP4filesize;
-		pFile->Create("", use64bits);
-		return (MP4FileHandle)pFile;
-	}
-	catch (MP4Error* e) {
-		VERBOSE_ERROR(verbosity, e->Print());
-		delete e;
-		delete pFile;
-		return MP4_INVALID_FILE_HANDLE;
-	}
-}
-
-extern "C" MP4FileHandle MP4ReadCb(u_int32_t verbosity,
-                                   MP4OpenCallback MP4fopen,
-                                   MP4CloseCallback MP4fclose,
-                                   MP4ReadCallback MP4fread,
-                                   MP4WriteCallback MP4fwrite,
-                                   MP4SetposCallback MP4fsetpos,
-                                   MP4GetposCallback MP4fgetpos,
-                                   MP4FilesizeCallback MP4filesize,
-                                   void *userData
-                                   )
-{
-	MP4File* pFile = NULL;
-	try {
-		pFile = new MP4File(verbosity);
-
-        // Set user data and callbacks
-        pFile->m_userData = userData;
-        pFile->m_MP4fopen = MP4fopen;
-        pFile->m_MP4fclose = MP4fclose;
-        pFile->m_MP4fread = MP4fread;
-        pFile->m_MP4fwrite = MP4fwrite;
-        pFile->m_MP4fsetpos = MP4fsetpos;
-        pFile->m_MP4fgetpos = MP4fgetpos;
-        pFile->m_MP4filesize = MP4filesize;
-
-		pFile->Read("");
-		return (MP4FileHandle)pFile;
-	}
-	catch (MP4Error* e) {
-		VERBOSE_ERROR(verbosity, e->Print());
-		delete e;
-		delete pFile;
-		return MP4_INVALID_FILE_HANDLE;
-	}
-}
-
-extern "C" MP4FileHandle MP4ModifyCb(int32_t verbosity,
-    bool useExtensibleFormat,
-    MP4OpenCallback MP4fopen, MP4CloseCallback MP4fclose,
-    MP4ReadCallback MP4fread, MP4WriteCallback MP4fwrite,
-    MP4SetposCallback MP4fsetpos, MP4GetposCallback MP4fgetpos,
-    MP4FilesizeCallback MP4filesize, void *userData)
-{
-	MP4File* pFile = NULL;
-	try {
-		pFile = new MP4File(verbosity);
-
-        // Set user data and callbacks
-        pFile->m_userData = userData;
-        pFile->m_MP4fopen = MP4fopen;
-        pFile->m_MP4fclose = MP4fclose;
-        pFile->m_MP4fread = MP4fread;
-        pFile->m_MP4fwrite = MP4fwrite;
-        pFile->m_MP4fsetpos = MP4fsetpos;
-        pFile->m_MP4fgetpos = MP4fgetpos;
-        pFile->m_MP4filesize = MP4filesize;
-
-		// LATER useExtensibleFormat, moov first, then mvex's
-		pFile->Modify("");
-		return (MP4FileHandle)pFile;
-	}
-	catch (MP4Error* e) {
-		VERBOSE_ERROR(verbosity, e->Print());
-		delete e;
-		delete pFile;
-		return MP4_INVALID_FILE_HANDLE;
-	}
-}
-#endif
-
 extern "C" MP4FileHandle MP4Create(const char* fileName, 
-	u_int32_t verbosity, bool use64bits, bool useExtensibleFormat)
+				   u_int32_t verbosity, 
+				   u_int32_t flags)
 {
 	MP4File* pFile = NULL;
 	try {
 		pFile = new MP4File(verbosity);
 		// LATER useExtensibleFormat, moov first, then mvex's
-		pFile->Create(fileName, use64bits);
+		pFile->Create(fileName, flags);
 		return (MP4FileHandle)pFile;
 	}
 	catch (MP4Error* e) {
@@ -178,7 +71,7 @@
 }
 
 extern "C" MP4FileHandle MP4Modify(const char* fileName, 
-	u_int32_t verbosity, bool useExtensibleFormat)
+	u_int32_t verbosity, u_int32_t flags)
 {
 	MP4File* pFile = NULL;
 	try {
@@ -676,15 +569,17 @@
 	return MP4_INVALID_TRACK_ID;
 }
 
+#ifdef ISMACRYP
 extern "C" MP4TrackId MP4AddEncAudioTrack(MP4FileHandle hFile, 
 					  u_int32_t timeScale, 
-					  MP4Duration sampleDuration, 
+					  MP4Duration sampleDuration,
+					  ismacryp_session_id_t ismaCryptSId,
 					  u_int8_t audioType)
 {
   if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
     try {
       return ((MP4File*)hFile)->
-	AddEncAudioTrack(timeScale, sampleDuration, audioType);
+	AddEncAudioTrack(timeScale, sampleDuration, audioType, ismaCryptSId);
     }
     catch (MP4Error* e) {
       PRINT_ERROR(e);
@@ -693,6 +588,7 @@
   }
   return MP4_INVALID_TRACK_ID;
 }
+#endif
 
 extern "C" MP4TrackId MP4AddVideoTrack(
 	MP4FileHandle hFile, 
@@ -715,17 +611,20 @@
 	return MP4_INVALID_TRACK_ID;
 }
 
+#ifdef ISMACRYP
 extern "C" MP4TrackId MP4AddEncVideoTrack(MP4FileHandle hFile, 
 					  u_int32_t timeScale, 
 					  MP4Duration sampleDuration,
 					  u_int16_t width, 
 					  u_int16_t height, 
+					  ismacryp_session_id_t ismaCryptSId, 
 					  u_int8_t videoType)
 {
   if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
     try {
       return ((MP4File*)hFile)->AddEncVideoTrack(timeScale, sampleDuration, 
-						 width, height, videoType);
+						 width, height, videoType,
+						 ismaCryptSId);
     }
     catch (MP4Error* e) {
       PRINT_ERROR(e);
@@ -734,6 +633,7 @@
   }
   return MP4_INVALID_TRACK_ID;
 }
+#endif
 
 extern "C" MP4TrackId MP4AddHintTrack(
 	MP4FileHandle hFile, MP4TrackId refTrackId)
@@ -753,7 +653,8 @@
 extern "C" MP4TrackId MP4CloneTrack(
 	MP4FileHandle srcFile, 
 	MP4TrackId srcTrackId,
-	MP4FileHandle dstFile)
+	MP4FileHandle dstFile,
+	MP4TrackId dstHintTrackReferenceTrack)
 {
 	MP4TrackId dstTrackId = MP4_INVALID_TRACK_ID;
 
@@ -795,9 +696,13 @@
 		dstTrackId = MP4AddSceneTrack(dstFile);
 
 	} else if (MP4_IS_HINT_TRACK_TYPE(trackType)) {
+	  if (dstHintTrackReferenceTrack == MP4_INVALID_TRACK_ID) {
+	    dstTrackId = MP4_INVALID_TRACK_ID;
+	  } else {
 		dstTrackId = MP4AddHintTrack(
 			dstFile,
-			MP4GetHintTrackReferenceTrackId(srcFile, srcTrackId));
+			dstHintTrackReferenceTrack);
+	  }
 
 	} else if (MP4_IS_SYSTEMS_TRACK_TYPE(trackType)) {
 		dstTrackId = MP4AddSystemsTrack(dstFile, trackType);
@@ -860,16 +765,18 @@
 			&payloadNumber,
 			maxPayloadSize,
 			encodingParms);
-
+#if 0
 		MP4SetHintTrackSdp(
 			dstFile,
 			dstTrackId,
 			MP4GetHintTrackSdp(srcFile, srcTrackId));
+#endif
 	}
 
 	return dstTrackId;
 }
 
+#ifdef ISMACRYP
 // Given a track, make an encrypted clone of it in the dest. file
 extern "C" MP4TrackId MP4EncAndCloneTrack(MP4FileHandle srcFile, 
 					  MP4TrackId srcTrackId,
@@ -953,16 +860,18 @@
 
   return dstTrackId;
 }
+#endif
 
 extern "C" MP4TrackId MP4CopyTrack(MP4FileHandle srcFile, 
 				   MP4TrackId srcTrackId,
 				   MP4FileHandle dstFile, 
-				   bool applyEdits)
+				   bool applyEdits,
+				   MP4TrackId dstHintTrackReferenceTrack)
 {
   bool copySamples = true;	// LATER allow false => reference samples
 
   MP4TrackId dstTrackId =
-    MP4CloneTrack(srcFile, srcTrackId, dstFile);
+    MP4CloneTrack(srcFile, srcTrackId, dstFile, dstHintTrackReferenceTrack);
 
   if (dstTrackId == MP4_INVALID_TRACK_ID) {
     return dstTrackId;
@@ -1039,11 +948,13 @@
 }
 
 
+#ifdef ISMACRYP
 // Given a source track in a source file, make an encrypted copy of 
 // the track in the destination file, including sample encryption
 extern "C" MP4TrackId MP4EncAndCopyTrack(MP4FileHandle srcFile, 
 				      MP4TrackId srcTrackId,
-				      MP4FileHandle dstFile, 
+				      ismacryp_session_id_t ismaCryptSId,
+				      MP4FileHandle dstFile,
 				      bool applyEdits)
 {
   bool copySamples = true;	// LATER allow false => reference samples
@@ -1097,15 +1008,17 @@
     bool rc = false;
 
     if (copySamples) {
-      // will need to encrypt the sample here
-      rc = MP4CopySample(srcFile,
+      // encrypt and copy
+      rc = MP4EncAndCopySample(srcFile,
 			 srcTrackId,
 			 sampleId,
+			 ismaCryptSId,
 			 dstFile,
 			 dstTrackId,
 			 sampleDuration);
 
     } else {
+      // not sure what these are - encrypt?
       rc = MP4ReferenceSample(srcFile,
 			      srcTrackId,
 			      sampleId,
@@ -1122,6 +1035,7 @@
 
   return dstTrackId;
 }
+#endif
 
 extern "C" bool MP4DeleteTrack(
 	MP4FileHandle hFile, 
@@ -1759,6 +1673,74 @@
 	return rc;
 }
 
+#ifdef ISMACRYP
+extern "C" bool MP4EncAndCopySample(
+	MP4FileHandle srcFile,
+	MP4TrackId srcTrackId, 
+	MP4SampleId srcSampleId,
+	ismacryp_session_id_t ismaCryptSId,
+	MP4FileHandle dstFile,
+	MP4TrackId dstTrackId,
+	MP4Duration dstSampleDuration)
+{
+	bool rc;
+	u_int8_t* pBytes = NULL; 
+	u_int32_t numBytes = 0;
+	MP4Duration sampleDuration;
+	MP4Duration renderingOffset;
+	bool isSyncSample;
+
+	// Note: we leave it up to the caller to ensure that the
+	// source and destination tracks are compatible.
+	// i.e. copying audio samples into a video track 
+	// is unlikely to do anything useful
+
+	rc = MP4ReadSample(
+		srcFile,
+		srcTrackId,
+		srcSampleId,
+		&pBytes,
+		&numBytes,
+		NULL,
+		&sampleDuration,
+		&renderingOffset,
+		&isSyncSample);
+
+	if (!rc) {
+		return false;
+	}
+
+	if (dstFile == MP4_INVALID_FILE_HANDLE) {
+		dstFile = srcFile;
+	}
+	if (dstTrackId == MP4_INVALID_TRACK_ID) {
+		dstTrackId = srcTrackId;
+	}
+	if (dstSampleDuration != MP4_INVALID_DURATION) {
+		sampleDuration = dstSampleDuration;
+	}
+
+	if (ismacrypEncryptSample(ismaCryptSId, numBytes, 
+				  pBytes) != 0) {
+	  fprintf(stderr,	
+		  "Can't encrypt the sample %u\n", srcSampleId);
+	}
+
+	rc = MP4WriteSample(
+		dstFile,
+		dstTrackId,
+		pBytes,
+		numBytes,
+		sampleDuration,
+		renderingOffset,		
+		isSyncSample);
+
+	free(pBytes);
+
+	return rc;
+}
+#endif
+
 extern "C" bool MP4ReferenceSample(
 	MP4FileHandle srcFile,
 	MP4TrackId srcTrackId, 
@@ -2795,449 +2777,448 @@
 	return NULL;
 }
 
-
 /* iTunes meta data handling */
 extern "C" bool MP4GetMetadataByIndex(MP4FileHandle hFile, u_int32_t index,
-                                       const char** ppName,
-                                       u_int8_t** ppValue, u_int32_t* pValueSize)
+				      const char** ppName,
+				      u_int8_t** ppValue, u_int32_t* pValueSize)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataByIndex(
-                index, ppName, ppValue, pValueSize);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataByIndex(
+						   index, ppName, ppValue, pValueSize);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4MetadataDelete(MP4FileHandle hFile)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->MetadataDelete();
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->MetadataDelete();
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataName(MP4FileHandle hFile,
-                                  const char* value)
+                                   const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataName(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataName(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataName(MP4FileHandle hFile,
-                                   char** value)
+				   char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataName(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataName(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataWriter(MP4FileHandle hFile,
-                                     const char* value)
+				     const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataWriter(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataWriter(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataWriter(MP4FileHandle hFile,
-                                   char** value)
+				     char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataWriter(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataWriter(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataAlbum(MP4FileHandle hFile,
-                                    const char* value)
+				    const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataAlbum(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataAlbum(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataAlbum(MP4FileHandle hFile,
-                                    char** value)
+				    char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataAlbum(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataAlbum(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataArtist(MP4FileHandle hFile,
-                                     const char* value)
+				     const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataArtist(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataArtist(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataArtist(MP4FileHandle hFile,
-                                     char** value)
+				     char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataArtist(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataArtist(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataTool(MP4FileHandle hFile,
-                                   const char* value)
+				   const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataTool(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataTool(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataTool(MP4FileHandle hFile,
-                                   char** value)
+				   char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataTool(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataTool(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataComment(MP4FileHandle hFile,
-                                      const char* value)
+				      const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataComment(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataComment(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataComment(MP4FileHandle hFile,
-                                      char** value)
+				      char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataComment(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataComment(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataYear(MP4FileHandle hFile,
-                                   const char* value)
+				   const char* value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataYear(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataYear(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataYear(MP4FileHandle hFile,
-                                   char** value)
+				   char** value)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataYear(value);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataYear(value);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataTrack(MP4FileHandle hFile,
-                                    u_int16_t track, u_int16_t totalTracks)
+				    u_int16_t track, u_int16_t totalTracks)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataTrack(track, totalTracks);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataTrack(track, totalTracks);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataTrack(MP4FileHandle hFile,
-                                    u_int16_t* track, u_int16_t* totalTracks)
+				    u_int16_t* track, u_int16_t* totalTracks)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataTrack(track, totalTracks);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataTrack(track, totalTracks);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataDisk(MP4FileHandle hFile,
-                                   u_int16_t disk, u_int16_t totalDisks)
+				   u_int16_t disk, u_int16_t totalDisks)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataDisk(disk, totalDisks);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataDisk(disk, totalDisks);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataDisk(MP4FileHandle hFile,
-                                   u_int16_t* disk, u_int16_t* totalDisks)
+				   u_int16_t* disk, u_int16_t* totalDisks)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataDisk(disk, totalDisks);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataDisk(disk, totalDisks);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
-extern "C" bool MP4SetMetadataGenre(MP4FileHandle hFile, const char* genre)
+ 
+extern "C" bool MP4SetMetadataGenre(MP4FileHandle hFile, const char *genre)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataGenre(genre);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataGenre(genre);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
-extern "C" bool MP4GetMetadataGenre(MP4FileHandle hFile, char** genre)
+ 
+extern "C" bool MP4GetMetadataGenre(MP4FileHandle hFile, char **genre)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataGenre(genre);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataGenre(genre);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataTempo(MP4FileHandle hFile, u_int16_t tempo)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataTempo(tempo);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataTempo(tempo);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataTempo(MP4FileHandle hFile, u_int16_t* tempo)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataTempo(tempo);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataTempo(tempo);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataCompilation(MP4FileHandle hFile, u_int8_t cpl)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataCompilation(cpl);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataCompilation(cpl);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataCompilation(MP4FileHandle hFile, u_int8_t* cpl)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataCompilation(cpl);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataCompilation(cpl);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataCoverArt(MP4FileHandle hFile,
-                                       u_int8_t *coverArt, u_int32_t size)
+				       u_int8_t *coverArt, u_int32_t size)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataCoverArt(coverArt, size);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataCoverArt(coverArt, size);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataCoverArt(MP4FileHandle hFile,
-                                       u_int8_t **coverArt, u_int32_t* size)
+				       u_int8_t **coverArt, u_int32_t* size)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataCoverArt(coverArt, size);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataCoverArt(coverArt, size);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4SetMetadataFreeForm(MP4FileHandle hFile, char *name,
-                                       u_int8_t* pValue, u_int32_t valueSize)
+				       u_int8_t* pValue, u_int32_t valueSize)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->SetMetadataFreeForm(name, pValue, valueSize);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->SetMetadataFreeForm(name, pValue, valueSize);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
-
+ 
 extern "C" bool MP4GetMetadataFreeForm(MP4FileHandle hFile, char *name,
-                                       u_int8_t** pValue, u_int32_t* valueSize)
+				       u_int8_t** pValue, u_int32_t* valueSize)
 {
-	if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
-		try {
-			return ((MP4File*)hFile)->GetMetadataFreeForm(name, pValue, valueSize);
-		}
-		catch (MP4Error* e) {
-			PRINT_ERROR(e);
-			delete e;
-		}
-	}
-    return false;
+  if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+    try {
+      return ((MP4File*)hFile)->GetMetadataFreeForm(name, pValue, valueSize);
+    }
+    catch (MP4Error* e) {
+      PRINT_ERROR(e);
+      delete e;
+    }
+  }
+  return false;
 }
--- a/common/mp4v2/mp4.h
+++ b/common/mp4v2/mp4.h
@@ -3,21 +3,21 @@
  * License Version 1.1 (the "License"); you may not use this file
  * except in compliance with the License. You may obtain a copy of
  * the License at http://www.mozilla.org/MPL/
- *
+ * 
  * Software distributed under the License is distributed on an "AS
  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * rights and limitations under the License.
- *
+ * 
  * The Original Code is MPEG4IP.
- *
+ * 
  * The Initial Developer of the Original Code is Cisco Systems Inc.
  * Portions created by Cisco Systems Inc. are
  * Copyright (C) Cisco Systems Inc. 2001.  All Rights Reserved.
- *
- * Contributor(s):
- *      Dave Mackie         dmackie@cisco.com
- *      Alix Marchandise-Franquet   alix@cisco.com
+ * 
+ * Contributor(s): 
+ *		Dave Mackie			dmackie@cisco.com
+ *		Alix Marchandise-Franquet	alix@cisco.com
  */
 
 #ifndef __MP4_INCLUDED__
@@ -24,9 +24,12 @@
 #define __MP4_INCLUDED__
 
 /* include system and project specific headers */
-#include <mpeg4ip.h>
+#include "mpeg4ip.h"
+#ifdef ISMACRYP
+#include "../ismacryp/ismacryplib.h"
+#endif
 
-#include <math.h>   /* to define float HUGE_VAL and/or NAN */
+#include <math.h>	/* to define float HUGE_VAL and/or NAN */
 #ifndef NAN
 #define NAN HUGE_VAL
 #endif
@@ -33,178 +36,237 @@
 
 #ifdef __cplusplus
 /* exploit C++ ability of default values for function parameters */
-#define DEFAULT(x)  =x
+#define DEFAULT(x)	=x
 #else
 #define DEFAULT(x)
 #endif
 
 /* MP4 API types */
-typedef void*       MP4FileHandle;
-typedef u_int32_t   MP4TrackId;
-typedef u_int32_t   MP4SampleId;
-typedef u_int64_t   MP4Timestamp;
-typedef u_int64_t   MP4Duration;
-typedef u_int32_t   MP4EditId;
+typedef void*		MP4FileHandle;
+typedef u_int32_t	MP4TrackId;
+typedef u_int32_t	MP4SampleId;
+typedef u_int64_t	MP4Timestamp;
+typedef u_int64_t	MP4Duration;
+typedef u_int32_t	MP4EditId;
 
 /* Invalid values for API types */
-#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL)
-#define MP4_INVALID_TRACK_ID    ((MP4TrackId)0)
-#define MP4_INVALID_SAMPLE_ID   ((MP4SampleId)0)
-#define MP4_INVALID_TIMESTAMP   ((MP4Timestamp)-1)
-#define MP4_INVALID_DURATION    ((MP4Duration)-1)
-#define MP4_INVALID_EDIT_ID     ((MP4EditId)0)
+#define MP4_INVALID_FILE_HANDLE	((MP4FileHandle)NULL)
+#define MP4_INVALID_TRACK_ID	((MP4TrackId)0)
+#define MP4_INVALID_SAMPLE_ID	((MP4SampleId)0)
+#define MP4_INVALID_TIMESTAMP	((MP4Timestamp)-1)
+#define MP4_INVALID_DURATION	((MP4Duration)-1)
+#define MP4_INVALID_EDIT_ID		((MP4EditId)0)
 
 /* Macros to test for API type validity */
-#define MP4_IS_VALID_FILE_HANDLE(x) ((x) != MP4_INVALID_FILE_HANDLE)
-#define MP4_IS_VALID_TRACK_ID(x)    ((x) != MP4_INVALID_TRACK_ID)
-#define MP4_IS_VALID_SAMPLE_ID(x)   ((x) != MP4_INVALID_SAMPLE_ID)
-#define MP4_IS_VALID_TIMESTAMP(x)   ((x) != MP4_INVALID_TIMESTAMP)
-#define MP4_IS_VALID_DURATION(x)    ((x) != MP4_INVALID_DURATION)
-#define MP4_IS_VALID_EDIT_ID(x)     ((x) != MP4_INVALID_EDIT_ID)
+#define MP4_IS_VALID_FILE_HANDLE(x)	((x) != MP4_INVALID_FILE_HANDLE) 
+#define MP4_IS_VALID_TRACK_ID(x)	((x) != MP4_INVALID_TRACK_ID) 
+#define MP4_IS_VALID_SAMPLE_ID(x)	((x) != MP4_INVALID_SAMPLE_ID) 
+#define MP4_IS_VALID_TIMESTAMP(x)	((x) != MP4_INVALID_TIMESTAMP) 
+#define MP4_IS_VALID_DURATION(x)	((x) != MP4_INVALID_DURATION) 
+#define MP4_IS_VALID_EDIT_ID(x)		((x) != MP4_INVALID_EDIT_ID) 
 
 /* MP4 verbosity levels - e.g. MP4SetVerbosity() */
-#define MP4_DETAILS_ALL             0xFFFFFFFF
-#define MP4_DETAILS_ERROR           0x00000001
-#define MP4_DETAILS_WARNING         0x00000002
-#define MP4_DETAILS_READ            0x00000004
-#define MP4_DETAILS_WRITE           0x00000008
-#define MP4_DETAILS_FIND            0x00000010
-#define MP4_DETAILS_TABLE           0x00000020
-#define MP4_DETAILS_SAMPLE          0x00000040
-#define MP4_DETAILS_HINT            0x00000080
-#define MP4_DETAILS_ISMA            0x00000100
-#define MP4_DETAILS_EDIT            0x00000200
+#define MP4_DETAILS_ALL				0xFFFFFFFF
+#define MP4_DETAILS_ERROR			0x00000001
+#define MP4_DETAILS_WARNING			0x00000002
+#define MP4_DETAILS_READ			0x00000004
+#define MP4_DETAILS_WRITE			0x00000008
+#define MP4_DETAILS_FIND			0x00000010
+#define MP4_DETAILS_TABLE			0x00000020
+#define MP4_DETAILS_SAMPLE			0x00000040
+#define MP4_DETAILS_HINT			0x00000080
+#define MP4_DETAILS_ISMA			0x00000100
+#define MP4_DETAILS_EDIT			0x00000200
 
-#define MP4_DETAILS_READ_ALL        \
-    (MP4_DETAILS_READ | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
-#define MP4_DETAILS_WRITE_ALL       \
-    (MP4_DETAILS_WRITE | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
+#define MP4_DETAILS_READ_ALL		\
+	(MP4_DETAILS_READ | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
+#define MP4_DETAILS_WRITE_ALL		\
+	(MP4_DETAILS_WRITE | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
 
 /*
- * MP4 Known track type names - e.g. MP4GetNumberOfTracks(type)
+ * MP4 Known track type names - e.g. MP4GetNumberOfTracks(type) 
  *
- * Note this first group of track types should be created
+ * Note this first group of track types should be created 
  * via the MP4Add<Type>Track() functions, and not MP4AddTrack(type)
  */
-#define MP4_OD_TRACK_TYPE       "odsm"
-#define MP4_SCENE_TRACK_TYPE    "sdsm"
-#define MP4_AUDIO_TRACK_TYPE    "soun"
-#define MP4_VIDEO_TRACK_TYPE    "vide"
-#define MP4_HINT_TRACK_TYPE     "hint"
+#define MP4_OD_TRACK_TYPE		"odsm"
+#define MP4_SCENE_TRACK_TYPE	"sdsm"
+#define MP4_AUDIO_TRACK_TYPE	"soun"
+#define MP4_VIDEO_TRACK_TYPE	"vide"
+#define MP4_HINT_TRACK_TYPE		"hint"
 /*
- * This second set of track types should be created
+ * This second set of track types should be created 
  * via MP4AddSystemsTrack(type)
  */
-#define MP4_CLOCK_TRACK_TYPE    "crsm"
-#define MP4_MPEG7_TRACK_TYPE    "m7sm"
-#define MP4_OCI_TRACK_TYPE      "ocsm"
-#define MP4_IPMP_TRACK_TYPE     "ipsm"
-#define MP4_MPEGJ_TRACK_TYPE    "mjsm"
+#define MP4_CLOCK_TRACK_TYPE	"crsm"
+#define MP4_MPEG7_TRACK_TYPE	"m7sm"
+#define MP4_OCI_TRACK_TYPE		"ocsm"
+#define MP4_IPMP_TRACK_TYPE		"ipsm"
+#define MP4_MPEGJ_TRACK_TYPE	"mjsm"
 
 #define MP4_IS_VIDEO_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_VIDEO_TRACK_TYPE))
+	(!strcasecmp(type, MP4_VIDEO_TRACK_TYPE))
 
 #define MP4_IS_AUDIO_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_AUDIO_TRACK_TYPE))
+	(!strcasecmp(type, MP4_AUDIO_TRACK_TYPE))
 
 #define MP4_IS_OD_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_OD_TRACK_TYPE))
+	(!strcasecmp(type, MP4_OD_TRACK_TYPE))
 
 #define MP4_IS_SCENE_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_SCENE_TRACK_TYPE))
+	(!strcasecmp(type, MP4_SCENE_TRACK_TYPE))
 
 #define MP4_IS_HINT_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_HINT_TRACK_TYPE))
+	(!strcasecmp(type, MP4_HINT_TRACK_TYPE))
 
 #define MP4_IS_SYSTEMS_TRACK_TYPE(type) \
-    (!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \
-    || !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \
-    || !strcasecmp(type, MP4_OCI_TRACK_TYPE) \
-    || !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \
-    || !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE))
+	(!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \
+	|| !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \
+	|| !strcasecmp(type, MP4_OCI_TRACK_TYPE) \
+	|| !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \
+	|| !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE))
 
 /* MP4 Audio track types - see MP4AddAudioTrack()*/
-#define MP4_INVALID_AUDIO_TYPE          0x00
-#define MP4_MPEG1_AUDIO_TYPE            0x6B
-#define MP4_MPEG2_AUDIO_TYPE            0x69
-#define MP4_MP3_AUDIO_TYPE              MP4_MPEG2_AUDIO_TYPE
-#define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE   0x66
-#define MP4_MPEG2_AAC_LC_AUDIO_TYPE     0x67
-#define MP4_MPEG2_AAC_SSR_AUDIO_TYPE    0x68
-#define MP4_MPEG2_AAC_AUDIO_TYPE        MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
-#define MP4_MPEG4_AUDIO_TYPE            0x40
-#define MP4_PRIVATE_AUDIO_TYPE          0xC0
-#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE  0xE0    /* a private definition */
-#define MP4_VORBIS_AUDIO_TYPE           0xE1    /* a private definition */
-#define MP4_AC3_AUDIO_TYPE              0xE2    /* a private definition */
-#define MP4_ALAW_AUDIO_TYPE             0xE3    /* a private definition */
-#define MP4_ULAW_AUDIO_TYPE             0xE4    /* a private definition */
+#define MP4_INVALID_AUDIO_TYPE			0x00
+#define MP4_MPEG1_AUDIO_TYPE			0x6B
+#define MP4_MPEG2_AUDIO_TYPE			0x69
+#define MP4_MP3_AUDIO_TYPE				MP4_MPEG2_AUDIO_TYPE
+#define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE	0x66
+#define MP4_MPEG2_AAC_LC_AUDIO_TYPE		0x67
+#define MP4_MPEG2_AAC_SSR_AUDIO_TYPE	0x68
+#define MP4_MPEG2_AAC_AUDIO_TYPE		MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
+#define MP4_MPEG4_AUDIO_TYPE			0x40
+#define MP4_PRIVATE_AUDIO_TYPE			0xC0
+#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE	0xE0	/* a private definition */
+#define MP4_VORBIS_AUDIO_TYPE			0xE1	/* a private definition */
+#define MP4_AC3_AUDIO_TYPE				0xE2	/* a private definition */
+#define MP4_ALAW_AUDIO_TYPE				0xE3	/* a private definition */
+#define MP4_ULAW_AUDIO_TYPE				0xE4	/* a private definition */
 #define MP4_G723_AUDIO_TYPE                             0xE5    /* a private definition */
 #define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE         0xE6 /* a private definition */
 
 /* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */
-#define MP4_MPEG4_INVALID_AUDIO_TYPE        0
-#define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE       1
-#define MP4_MPEG4_AAC_LC_AUDIO_TYPE         2
-#define MP4_MPEG4_AAC_SSR_AUDIO_TYPE        3
-#define MP4_MPEG4_AAC_LTP_AUDIO_TYPE        4
-#define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE   6
-#define MP4_MPEG4_CELP_AUDIO_TYPE           8
-#define MP4_MPEG4_HVXC_AUDIO_TYPE           9
-#define MP4_MPEG4_TTSI_AUDIO_TYPE           12
-#define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE 13
-#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE      14
-#define MP4_MPEG4_MIDI_AUDIO_TYPE           15
-#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16
+#define MP4_MPEG4_INVALID_AUDIO_TYPE		0
+#define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE		1
+#define MP4_MPEG4_AAC_LC_AUDIO_TYPE			2
+#define MP4_MPEG4_AAC_SSR_AUDIO_TYPE		3
+#define MP4_MPEG4_AAC_LTP_AUDIO_TYPE		4
+#define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE	6
+#define MP4_MPEG4_CELP_AUDIO_TYPE			8
+#define MP4_MPEG4_HVXC_AUDIO_TYPE			9
+#define MP4_MPEG4_TTSI_AUDIO_TYPE			12
+#define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE	13
+#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE		14
+#define MP4_MPEG4_MIDI_AUDIO_TYPE			15
+#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE	16
 
 /* MP4 Audio type utilities following common usage */
 #define MP4_IS_MP3_AUDIO_TYPE(type) \
-    ((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE)
+	((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE) 
 
 #define MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
-    (((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \
-        && (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE))
+	(((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \
+		&& (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE))
 
 #define MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg4Type) \
-    (((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \
-        && (mpeg4Type) <= MP4_MPEG4_AAC_LTP_AUDIO_TYPE) \
-      || (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \
+	(((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \
+		&& (mpeg4Type) <= MP4_MPEG4_AAC_LTP_AUDIO_TYPE) \
+	  || (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \
           || (mpeg4Type) == 17)
 
 #define MP4_IS_AAC_AUDIO_TYPE(type) \
-    (MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
-    || (type) == MP4_MPEG4_AUDIO_TYPE)
+	(MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
+	|| (type) == MP4_MPEG4_AUDIO_TYPE)
 
 /* MP4 Video track types - see MP4AddVideoTrack() */
-#define MP4_INVALID_VIDEO_TYPE          0x00
-#define MP4_MPEG1_VIDEO_TYPE            0x6A
-#define MP4_MPEG2_SIMPLE_VIDEO_TYPE     0x60
-#define MP4_MPEG2_MAIN_VIDEO_TYPE       0x61
-#define MP4_MPEG2_SNR_VIDEO_TYPE        0x62
-#define MP4_MPEG2_SPATIAL_VIDEO_TYPE    0x63
-#define MP4_MPEG2_HIGH_VIDEO_TYPE       0x64
-#define MP4_MPEG2_442_VIDEO_TYPE        0x65
-#define MP4_MPEG2_VIDEO_TYPE            MP4_MPEG2_MAIN_VIDEO_TYPE
-#define MP4_MPEG4_VIDEO_TYPE            0x20
-#define MP4_JPEG_VIDEO_TYPE             0x6C
-#define MP4_PRIVATE_VIDEO_TYPE          0xD0
-#define MP4_YUV12_VIDEO_TYPE            0xF0    /* a private definition */
-#define MP4_H264_VIDEO_TYPE             0xF1    /* a private definition */
-#define MP4_H263_VIDEO_TYPE             0xF2    /* a private definition */
-#define MP4_H261_VIDEO_TYPE             0xF3    /* a private definition */
+#define MP4_INVALID_VIDEO_TYPE			0x00
+#define MP4_MPEG1_VIDEO_TYPE			0x6A
+#define MP4_MPEG2_SIMPLE_VIDEO_TYPE		0x60
+#define MP4_MPEG2_MAIN_VIDEO_TYPE		0x61
+#define MP4_MPEG2_SNR_VIDEO_TYPE		0x62
+#define MP4_MPEG2_SPATIAL_VIDEO_TYPE	0x63
+#define MP4_MPEG2_HIGH_VIDEO_TYPE		0x64
+#define MP4_MPEG2_442_VIDEO_TYPE		0x65
+#define MP4_MPEG2_VIDEO_TYPE			MP4_MPEG2_MAIN_VIDEO_TYPE
+#define MP4_MPEG4_VIDEO_TYPE			0x20
+#define MP4_JPEG_VIDEO_TYPE				0x6C
+#define MP4_PRIVATE_VIDEO_TYPE			0xD0
+#define MP4_YUV12_VIDEO_TYPE			0xF0	/* a private definition */
+#define MP4_H264_VIDEO_TYPE				0xF1	/* a private definition */
+#define MP4_H263_VIDEO_TYPE				0xF2	/* a private definition */
+#define MP4_H261_VIDEO_TYPE				0xF3	/* a private definition */
 
 /* MP4 Video type utilities */
 #define MP4_IS_MPEG1_VIDEO_TYPE(type) \
-    ((type) == MP4_MPEG1_VIDEO_TYPE)
+	((type) == MP4_MPEG1_VIDEO_TYPE)
 
 #define MP4_IS_MPEG2_VIDEO_TYPE(type) \
-    (((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \
-        && (type) <= MP4_MPEG2_442_VIDEO_TYPE) \
-      || MP4_IS_MPEG1_VIDEO_TYPE(type))
+	(((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \
+		&& (type) <= MP4_MPEG2_442_VIDEO_TYPE) \
+	  || MP4_IS_MPEG1_VIDEO_TYPE(type))
 
 #define MP4_IS_MPEG4_VIDEO_TYPE(type) \
-    ((type) == MP4_MPEG4_VIDEO_TYPE)
+	((type) == MP4_MPEG4_VIDEO_TYPE)
 
+/* Mpeg4 Visual Profile Defines - ISO/IEC 14496-2:2001/Amd.2:2002(E) */
+#define MPEG4_SP_L1 (0x1)
+#define MPEG4_SP_L2 (0x2)
+#define MPEG4_SP_L3 (0x3)
+#define MPEG4_SP_L0 (0x8)
+#define MPEG4_SSP_L1 (0x11)
+#define MPEG4_SSP_L2 (0x12)
+#define MPEG4_CP_L1 (0x21)
+#define MPEG4_CP_L2 (0x22)
+#define MPEG4_MP_L2 (0x32)
+#define MPEG4_MP_L3 (0x33)
+#define MPEG4_MP_L4 (0x34)
+#define MPEG4_NBP_L2 (0x42)
+#define MPEG4_STP_L1 (0x51)
+#define MPEG4_SFAP_L1 (0x61)
+#define MPEG4_SFAP_L2 (0x62)
+#define MPEG4_SFBAP_L1 (0x63)
+#define MPEG4_SFBAP_L2 (0x64)
+#define MPEG4_BATP_L1 (0x71)
+#define MPEG4_BATP_L2 (0x72)
+#define MPEG4_HP_L1 (0x81)
+#define MPEG4_HP_L2 (0x82)
+#define MPEG4_ARTSP_L1 (0x91)
+#define MPEG4_ARTSP_L2 (0x92)
+#define MPEG4_ARTSP_L3 (0x93)
+#define MPEG4_ARTSP_L4 (0x94)
+#define MPEG4_CSP_L1 (0xa1)
+#define MPEG4_CSP_L2 (0xa2)
+#define MPEG4_CSP_L3 (0xa3)
+#define MPEG4_ACEP_L1 (0xb1)
+#define MPEG4_ACEP_L2 (0xb2)
+#define MPEG4_ACEP_L3 (0xb3)
+#define MPEG4_ACEP_L4 (0xb4)
+#define MPEG4_ACP_L1 (0xc1)
+#define MPEG4_ACP_L2 (0xc2)
+#define MPEG4_AST_L1 (0xd1)
+#define MPEG4_AST_L2 (0xd2)
+#define MPEG4_AST_L3 (0xd3)
+#define MPEG4_S_STUDIO_P_L1 (0xe1)
+#define MPEG4_S_STUDIO_P_L2 (0xe2)
+#define MPEG4_S_STUDIO_P_L3 (0xe3)
+#define MPEG4_S_STUDIO_P_L4 (0xe4)
+#define MPEG4_C_STUDIO_P_L1 (0xe5)
+#define MPEG4_C_STUDIO_P_L2 (0xe6)
+#define MPEG4_C_STUDIO_P_L3 (0xe7)
+#define MPEG4_C_STUDIO_P_L4 (0xe8)
+#define MPEG4_ASP_L0 (0xF0)
+#define MPEG4_ASP_L1 (0xF1)
+#define MPEG4_ASP_L2 (0xF2)
+#define MPEG4_ASP_L3 (0xF3)
+#define MPEG4_ASP_L4 (0xF4)
+#define MPEG4_ASP_L5 (0xF5)
+#define MPEG4_ASP_L3B (0xF7)
+#define MPEG4_FGSP_L0 (0xf8)
+#define MPEG4_FGSP_L1 (0xf9)
+#define MPEG4_FGSP_L2 (0xfa)
+#define MPEG4_FGSP_L3 (0xfb)
+#define MPEG4_FGSP_L4 (0xfc)
+#define MPEG4_FGSP_L5 (0xfd)
 
 /* MP4 API declarations */
 
@@ -213,42 +275,45 @@
 #endif
 
 /* file operations */
+#define MP4_CREATE_64BIT_DATA (0x01)
+#define MP4_CREATE_64BIT_TIME (0x02) // Quicktime is not compatible with this
+#define MP4_CREATE_64BIT (MP4_CREATE_64BIT_DATA | MP4_CREATE_64BIT_TIME)
+#define MP4_CREATE_EXTENSIBLE_FORMAT (0x04)
 
 MP4FileHandle MP4Create(
-    const char* fileName,
-    u_int32_t verbosity DEFAULT(0),
-    bool use64bits DEFAULT(0),
-    bool useExtensibleFormat DEFAULT(0));
+	const char* fileName, 
+	u_int32_t verbosity DEFAULT(0),
+	u_int32_t flags DEFAULT(0));
 
 MP4FileHandle MP4Modify(
-    const char* fileName,
-    u_int32_t verbosity DEFAULT(0),
-    bool useExtensibleFormat DEFAULT(0));
+	const char* fileName, 
+	u_int32_t verbosity DEFAULT(0),
+	u_int32_t flags DEFAULT(0));
 
 MP4FileHandle MP4Read(
-    const char* fileName,
-    u_int32_t verbosity DEFAULT(0));
+	const char* fileName, 
+	u_int32_t verbosity DEFAULT(0));
 
 bool MP4Close(
-    MP4FileHandle hFile);
+	MP4FileHandle hFile);
 
 bool MP4Optimize(
-    const char* existingFileName,
-    const char* newFileName DEFAULT(NULL),
-    u_int32_t verbosity DEFAULT(0));
+	const char* existingFileName, 
+	const char* newFileName DEFAULT(NULL), 
+	u_int32_t verbosity DEFAULT(0));
 
 bool MP4Dump(
-    MP4FileHandle hFile,
-    FILE* pDumpFile DEFAULT(NULL),
-    bool dumpImplicits DEFAULT(0));
+	MP4FileHandle hFile, 
+	FILE* pDumpFile DEFAULT(NULL), 
+	bool dumpImplicits DEFAULT(0));
 
 char* MP4Info(
-    MP4FileHandle hFile,
-    MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
+	MP4FileHandle hFile, 
+	MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
 
 char* MP4FileInfo(
-    const char* fileName,
-    MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
+	const char* fileName,
+	MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
 
 /* file properties */
 
@@ -287,128 +352,139 @@
 /* generic file properties */
 
 u_int64_t MP4GetIntegerProperty(
-    MP4FileHandle hFile,
-    const char* propName);
+	MP4FileHandle hFile, 
+	const char* propName);
 
 float MP4GetFloatProperty(
-    MP4FileHandle hFile,
-    const char* propName);
+	MP4FileHandle hFile, 
+	const char* propName);
 
 const char* MP4GetStringProperty(
-    MP4FileHandle hFile,
-    const char* propName);
+	MP4FileHandle hFile, 
+	const char* propName);
 
 void MP4GetBytesProperty(
-    MP4FileHandle hFile,
-    const char* propName,
-    u_int8_t** ppValue,
-    u_int32_t* pValueSize);
+	MP4FileHandle hFile, 
+	const char* propName,
+	u_int8_t** ppValue, 
+	u_int32_t* pValueSize);
 
 bool MP4SetIntegerProperty(
-    MP4FileHandle hFile,
-    const char* propName,
-    int64_t value);
+	MP4FileHandle hFile, 
+	const char* propName, 
+	int64_t value);
 
 bool MP4SetFloatProperty(
-    MP4FileHandle hFile,
-    const char* propName,
-    float value);
+	MP4FileHandle hFile, 
+	const char* propName, 
+	float value);
 
 bool MP4SetStringProperty(
-    MP4FileHandle hFile, const char* propName, const char* value);
+	MP4FileHandle hFile, const char* propName, const char* value);
 
 bool MP4SetBytesProperty(
-    MP4FileHandle hFile, const char* propName,
-    const u_int8_t* pValue, u_int32_t valueSize);
+	MP4FileHandle hFile, const char* propName, 
+	const u_int8_t* pValue, u_int32_t valueSize);
 
 /* track operations */
 
 MP4TrackId MP4AddTrack(
-    MP4FileHandle hFile,
-    const char* type);
+	MP4FileHandle hFile, 
+	const char* type);
 
 MP4TrackId MP4AddSystemsTrack(
-    MP4FileHandle hFile,
-    const char* type);
+	MP4FileHandle hFile, 
+	const char* type);
 
 MP4TrackId MP4AddODTrack(
-    MP4FileHandle hFile);
+	MP4FileHandle hFile);
 
 MP4TrackId MP4AddSceneTrack(
-    MP4FileHandle hFile);
+	MP4FileHandle hFile);
 
 MP4TrackId MP4AddAudioTrack(
-    MP4FileHandle hFile,
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+	MP4FileHandle hFile, 
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration,
+	u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
 
+#ifdef ISMACRYP
 MP4TrackId MP4AddEncAudioTrack(
-    MP4FileHandle hFile,
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+	MP4FileHandle hFile, 
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration,
+	ismacryp_session_id_t ismaCryptSId,
+	u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+#endif
 
 MP4TrackId MP4AddVideoTrack(
-    MP4FileHandle hFile,
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int16_t width,
-    u_int16_t height,
-    u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
+	MP4FileHandle hFile, 
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration,
+	u_int16_t width, 
+	u_int16_t height,
+	u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
 
+#ifdef ISMACRYP
 MP4TrackId MP4AddEncVideoTrack(
-    MP4FileHandle hFile,
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int16_t width,
-    u_int16_t height,
-    u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
+	MP4FileHandle hFile, 
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration,
+	u_int16_t width, 
+	u_int16_t height,
+	ismacryp_session_id_t ismaCryptSId, 
+	u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
+#endif
 
 MP4TrackId MP4AddHintTrack(
-    MP4FileHandle hFile,
-    MP4TrackId refTrackId);
+	MP4FileHandle hFile, 
+	MP4TrackId refTrackId);
 
 MP4TrackId MP4CloneTrack(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE));
+	MP4FileHandle srcFile, 
+	MP4TrackId srcTrackId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
+	MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
 
 MP4TrackId MP4EncAndCloneTrack(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE));
+	MP4FileHandle srcFile, 
+	MP4TrackId srcTrackId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE));
 
 MP4TrackId MP4CopyTrack(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
-    bool applyEdits DEFAULT(false));
+	MP4FileHandle srcFile, 
+	MP4TrackId srcTrackId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE), 
+	bool applyEdits DEFAULT(false),
+	MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
 
+#ifdef ISMACRYP
 MP4TrackId MP4EncAndCopyTrack(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
-    bool applyEdits DEFAULT(false));
+	MP4FileHandle srcFile, 
+	MP4TrackId srcTrackId,
+	ismacryp_session_id_t ismaCryptSId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
+	bool applyEdits DEFAULT(false));
+#endif
 
 bool MP4DeleteTrack(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int32_t MP4GetNumberOfTracks(
-    MP4FileHandle hFile,
-    const char* type DEFAULT(NULL),
-    u_int8_t subType DEFAULT(0));
+	MP4FileHandle hFile, 
+	const char* type DEFAULT(NULL),
+	u_int8_t subType DEFAULT(0));
 
 MP4TrackId MP4FindTrackId(
-    MP4FileHandle hFile,
-    u_int16_t index,
-    const char* type DEFAULT(NULL),
-    u_int8_t subType DEFAULT(0));
+	MP4FileHandle hFile, 
+	u_int16_t index, 
+	const char* type DEFAULT(NULL),
+	u_int8_t subType DEFAULT(0));
 
 u_int16_t MP4FindTrackIndex(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 /* track properties */
 
@@ -415,512 +491,472 @@
 /* specific track properties */
 
 const char* MP4GetTrackType(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 MP4Duration MP4GetTrackDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int32_t MP4GetTrackTimeScale(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 bool MP4SetTrackTimeScale(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    u_int32_t value);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	u_int32_t value);
 
 // Should not be used, replace with MP4GetTrackEsdsObjectTypeId
 u_int8_t MP4GetTrackAudioType(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int8_t MP4GetTrackAudioMpeg4Type(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 // Should not be used, replace with MP4GetTrackEsdsObjectTypeId
 u_int8_t MP4GetTrackVideoType(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int8_t MP4GetTrackEsdsObjectTypeId(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 /* returns MP4_INVALID_DURATION if track samples do not have a fixed duration */
 MP4Duration MP4GetTrackFixedSampleDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int32_t MP4GetTrackBitRate(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 bool MP4GetTrackESConfiguration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    u_int8_t** ppConfig,
-    u_int32_t* pConfigSize);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	u_int8_t** ppConfig, 
+	u_int32_t* pConfigSize);
 
 bool MP4SetTrackESConfiguration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const u_int8_t* pConfig,
-    u_int32_t configSize);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const u_int8_t* pConfig, 
+	u_int32_t configSize);
 
 MP4SampleId MP4GetTrackNumberOfSamples(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int16_t MP4GetTrackVideoWidth(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 u_int16_t MP4GetTrackVideoHeight(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 float MP4GetTrackVideoFrameRate(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId);
 
 /* generic track properties */
 
 u_int64_t MP4GetTrackIntegerProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName);
 
 float MP4GetTrackFloatProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName);
 
 const char* MP4GetTrackStringProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName);
 
 void MP4GetTrackBytesProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName,
-    u_int8_t** ppValue,
-    u_int32_t* pValueSize);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName,
+	u_int8_t** ppValue, 
+	u_int32_t* pValueSize);
 
 bool MP4SetTrackIntegerProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName,
-    int64_t value);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName, 
+	int64_t value);
 
 bool MP4SetTrackFloatProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName,
-    float value);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName, 
+	float value);
 
 bool MP4SetTrackStringProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName,
-    const char* value);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName, 
+	const char* value);
 
 bool MP4SetTrackBytesProperty(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const char* propName,
-    const u_int8_t* pValue,
-    u_int32_t valueSize);
+	MP4FileHandle hFile, 
+	MP4TrackId trackId, 
+	const char* propName, 
+	const u_int8_t* pValue, 
+	u_int32_t valueSize);
 
 /* sample operations */
 
 bool MP4ReadSample(
-    /* input parameters */
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId,
-    /* input/output parameters */
-    u_int8_t** ppBytes,
-    u_int32_t* pNumBytes,
-    /* output parameters */
-    MP4Timestamp* pStartTime DEFAULT(NULL),
-    MP4Duration* pDuration DEFAULT(NULL),
-    MP4Duration* pRenderingOffset DEFAULT(NULL),
-    bool* pIsSyncSample DEFAULT(NULL));
+	/* input parameters */
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId,
+	/* input/output parameters */
+	u_int8_t** ppBytes, 
+	u_int32_t* pNumBytes, 
+	/* output parameters */
+	MP4Timestamp* pStartTime DEFAULT(NULL), 
+	MP4Duration* pDuration DEFAULT(NULL),
+	MP4Duration* pRenderingOffset DEFAULT(NULL), 
+	bool* pIsSyncSample DEFAULT(NULL));
 
 /* uses (unedited) time to specify sample instead of sample id */
 bool MP4ReadSampleFromTime(
-    /* input parameters */
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Timestamp when,
-    /* input/output parameters */
-    u_int8_t** ppBytes,
-    u_int32_t* pNumBytes,
-    /* output parameters */
-    MP4Timestamp* pStartTime DEFAULT(NULL),
-    MP4Duration* pDuration DEFAULT(NULL),
-    MP4Duration* pRenderingOffset DEFAULT(NULL),
-    bool* pIsSyncSample DEFAULT(NULL));
+	/* input parameters */
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Timestamp when,
+	/* input/output parameters */
+	u_int8_t** ppBytes, 
+	u_int32_t* pNumBytes, 
+	/* output parameters */
+	MP4Timestamp* pStartTime DEFAULT(NULL), 
+	MP4Duration* pDuration DEFAULT(NULL),
+	MP4Duration* pRenderingOffset DEFAULT(NULL), 
+	bool* pIsSyncSample DEFAULT(NULL));
 
 bool MP4WriteSample(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    const u_int8_t* pBytes,
-    u_int32_t numBytes,
-    MP4Duration duration DEFAULT(MP4_INVALID_DURATION),
-    MP4Duration renderingOffset DEFAULT(0),
-    bool isSyncSample DEFAULT(true));
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	const u_int8_t* pBytes, 
+	u_int32_t numBytes,
+	MP4Duration duration DEFAULT(MP4_INVALID_DURATION),
+	MP4Duration renderingOffset DEFAULT(0), 
+	bool isSyncSample DEFAULT(true));
 
 bool MP4CopySample(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4SampleId srcSampleId,
-    MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
-    MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
-    MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
+	MP4FileHandle srcFile,
+	MP4TrackId srcTrackId, 
+	MP4SampleId srcSampleId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
+	MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
+	MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
 
+#ifdef ISMACRYP
+bool MP4EncAndCopySample(
+	MP4FileHandle srcFile,
+	MP4TrackId srcTrackId, 
+	MP4SampleId srcSampleId,
+	ismacryp_session_id_t ismaCryptSId,
+	MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
+	MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
+	MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
+#endif
+
 /* Note this function is not yet implemented */
 bool MP4ReferenceSample(
-    MP4FileHandle srcFile,
-    MP4TrackId srcTrackId,
-    MP4SampleId srcSampleId,
-    MP4FileHandle dstFile,
-    MP4TrackId dstTrackId,
-    MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
+	MP4FileHandle srcFile,
+	MP4TrackId srcTrackId, 
+	MP4SampleId srcSampleId,
+	MP4FileHandle dstFile,
+	MP4TrackId dstTrackId,
+	MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
 
 u_int32_t MP4GetSampleSize(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId);
 
 u_int32_t MP4GetTrackMaxSampleSize(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId); 
 
 MP4SampleId MP4GetSampleIdFromTime(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Timestamp when,
-    bool wantSyncSample DEFAULT(false));
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Timestamp when, 
+	bool wantSyncSample DEFAULT(false));
 
 MP4Timestamp MP4GetSampleTime(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId);
 
 MP4Duration MP4GetSampleDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId);
 
 MP4Duration MP4GetSampleRenderingOffset(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId);
 
 bool MP4SetSampleRenderingOffset(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId,
-    MP4Duration renderingOffset);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId,
+	MP4Duration renderingOffset);
 
 int8_t MP4GetSampleSync(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4SampleId sampleId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4SampleId sampleId);
 
 /* rtp hint track operations */
 
 bool MP4GetHintTrackRtpPayload(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    char** ppPayloadName DEFAULT(NULL),
-    u_int8_t* pPayloadNumber DEFAULT(NULL),
-    u_int16_t* pMaxPayloadSize DEFAULT(NULL),
-    char **ppEncodingParams DEFAULT(NULL));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	char** ppPayloadName DEFAULT(NULL),
+	u_int8_t* pPayloadNumber DEFAULT(NULL),
+	u_int16_t* pMaxPayloadSize DEFAULT(NULL),
+	char **ppEncodingParams DEFAULT(NULL));
 
 #define MP4_SET_DYNAMIC_PAYLOAD 0xff
 
 bool MP4SetHintTrackRtpPayload(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    const char* pPayloadName,
-    u_int8_t* pPayloadNumber,
-    u_int16_t maxPayloadSize DEFAULT(0),
-    const char *encode_params DEFAULT(NULL),
-    bool include_rtp_map DEFAULT(true),
-    bool include_mpeg4_esid DEFAULT(true));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	const char* pPayloadName,
+	u_int8_t* pPayloadNumber,
+	u_int16_t maxPayloadSize DEFAULT(0),
+	const char *encode_params DEFAULT(NULL),
+	bool include_rtp_map DEFAULT(true),
+	bool include_mpeg4_esid DEFAULT(true));
 
 const char* MP4GetSessionSdp(
-    MP4FileHandle hFile);
+	MP4FileHandle hFile);
 
 bool MP4SetSessionSdp(
-    MP4FileHandle hFile,
-    const char* sdpString);
+	MP4FileHandle hFile,
+	const char* sdpString);
 
 bool MP4AppendSessionSdp(
-    MP4FileHandle hFile,
-    const char* sdpString);
+	MP4FileHandle hFile,
+	const char* sdpString);
 
 const char* MP4GetHintTrackSdp(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 bool MP4SetHintTrackSdp(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    const char* sdpString);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	const char* sdpString);
 
 bool MP4AppendHintTrackSdp(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    const char* sdpString);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	const char* sdpString);
 
 MP4TrackId MP4GetHintTrackReferenceTrackId(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 bool MP4ReadRtpHint(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    MP4SampleId hintSampleId,
-    u_int16_t* pNumPackets DEFAULT(NULL));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	MP4SampleId hintSampleId,
+	u_int16_t* pNumPackets DEFAULT(NULL));
 
 u_int16_t MP4GetRtpHintNumberOfPackets(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 int8_t MP4GetRtpPacketBFrame(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex);
 
 int32_t MP4GetRtpPacketTransmitOffset(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex);
 
 bool MP4ReadRtpPacket(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex,
-    u_int8_t** ppBytes,
-    u_int32_t* pNumBytes,
-    u_int32_t ssrc DEFAULT(0),
-    bool includeHeader DEFAULT(true),
-    bool includePayload DEFAULT(true));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex,
+	u_int8_t** ppBytes, 
+	u_int32_t* pNumBytes,
+	u_int32_t ssrc DEFAULT(0),
+	bool includeHeader DEFAULT(true),
+	bool includePayload DEFAULT(true));
 
 MP4Timestamp MP4GetRtpTimestampStart(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 bool MP4SetRtpTimestampStart(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    MP4Timestamp rtpStart);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	MP4Timestamp rtpStart);
 
 bool MP4AddRtpHint(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 bool MP4AddRtpVideoHint(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    bool isBframe DEFAULT(false),
-    u_int32_t timestampOffset DEFAULT(0));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	bool isBframe DEFAULT(false), 
+	u_int32_t timestampOffset DEFAULT(0));
 
 bool MP4AddRtpPacket(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    bool setMbit DEFAULT(false),
-    int32_t transmitOffset DEFAULT(0));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	bool setMbit DEFAULT(false),
+	int32_t transmitOffset DEFAULT(0));
 
 bool MP4AddRtpImmediateData(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    const u_int8_t* pBytes,
-    u_int32_t numBytes);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	const u_int8_t* pBytes,
+	u_int32_t numBytes);
 
 bool MP4AddRtpSampleData(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    MP4SampleId sampleId,
-    u_int32_t dataOffset,
-    u_int32_t dataLength);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	MP4SampleId sampleId,
+	u_int32_t dataOffset,
+	u_int32_t dataLength);
 
 bool MP4AddRtpESConfigurationPacket(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId);
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId);
 
 bool MP4WriteRtpHint(
-    MP4FileHandle hFile,
-    MP4TrackId hintTrackId,
-    MP4Duration duration,
-    bool isSyncSample DEFAULT(true));
+	MP4FileHandle hFile,
+	MP4TrackId hintTrackId,
+	MP4Duration duration,
+	bool isSyncSample DEFAULT(true));
 
 /* ISMA specific utilities */
 
-bool MP4MakeIsmaCompliant(const char* fileName,
-    u_int32_t verbosity DEFAULT(0),
-    bool addIsmaComplianceSdp DEFAULT(true));
+bool MP4MakeIsmaCompliant(const char* fileName, 
+	u_int32_t verbosity DEFAULT(0),
+	bool addIsmaComplianceSdp DEFAULT(true));
 
 char* MP4MakeIsmaSdpIod(
-    u_int8_t videoProfile,
-    u_int32_t videoBitrate,
-    u_int8_t* videoConfig,
-    u_int32_t videoConfigLength,
-    u_int8_t audioProfile,
-    u_int32_t audioBitrate,
-    u_int8_t* audioConfig,
-    u_int32_t audioConfigLength,
-    u_int32_t verbosity DEFAULT(0));
+	u_int8_t videoProfile,
+	u_int32_t videoBitrate,
+	u_int8_t* videoConfig,
+	u_int32_t videoConfigLength,
+	u_int8_t audioProfile,
+	u_int32_t audioBitrate,
+	u_int8_t* audioConfig,
+	u_int32_t audioConfigLength,
+	u_int32_t verbosity DEFAULT(0));
 
 /* edit list */
 
-/* NOTE this section of functionality
- * has not yet been fully tested
+/* NOTE this section of functionality 
+ * has not yet been fully tested 
  */
 
 MP4EditId MP4AddTrackEdit(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID),
-    MP4Timestamp startTime DEFAULT(0),
-    MP4Duration duration DEFAULT(0),
-    bool dwell DEFAULT(false));
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID),
+	MP4Timestamp startTime DEFAULT(0),
+	MP4Duration duration DEFAULT(0),
+	bool dwell DEFAULT(false));
 
 bool MP4DeleteTrackEdit(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId);
 
 u_int32_t MP4GetTrackNumberOfEdits(
-    MP4FileHandle hFile,
-    MP4TrackId trackId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId);
 
 MP4Timestamp MP4GetTrackEditStart(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId);
 
 MP4Duration MP4GetTrackEditTotalDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID));
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID));
 
 MP4Timestamp MP4GetTrackEditMediaStart(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId);
 
 bool MP4SetTrackEditMediaStart(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId,
-    MP4Timestamp startTime);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId,
+	MP4Timestamp startTime);
 
 MP4Duration MP4GetTrackEditDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId);
 
 bool MP4SetTrackEditDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId,
-    MP4Duration duration);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId,
+	MP4Duration duration);
 
 int8_t MP4GetTrackEditDwell(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId);
 
 bool MP4SetTrackEditDwell(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4EditId editId,
-    bool dwell);
+	MP4FileHandle hFile,
+	MP4TrackId trackId,
+	MP4EditId editId,
+	bool dwell);
 
 bool MP4ReadSampleFromEditTime(
-    /* input parameters */
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Timestamp when,
-    /* input/output parameters */
-    u_int8_t** ppBytes,
-    u_int32_t* pNumBytes,
-    /* output parameters */
-    MP4Timestamp* pStartTime DEFAULT(NULL),
-    MP4Duration* pDuration DEFAULT(NULL),
-    MP4Duration* pRenderingOffset DEFAULT(NULL),
-    bool* pIsSyncSample DEFAULT(NULL));
+	/* input parameters */
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Timestamp when, 
+	/* input/output parameters */
+	u_int8_t** ppBytes, 
+	u_int32_t* pNumBytes, 
+	/* output parameters */
+	MP4Timestamp* pStartTime DEFAULT(NULL), 
+	MP4Duration* pDuration DEFAULT(NULL),
+	MP4Duration* pRenderingOffset DEFAULT(NULL), 
+	bool* pIsSyncSample DEFAULT(NULL));
 
 MP4SampleId MP4GetSampleIdFromEditTime(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Timestamp when,
-    MP4Timestamp* pStartTime DEFAULT(NULL),
-    MP4Duration* pDuration DEFAULT(NULL));
-
-/* time conversion utilties */
-
-/* predefined values for timeScale parameter below */
-#define MP4_SECONDS_TIME_SCALE      1
-#define MP4_MILLISECONDS_TIME_SCALE 1000
-#define MP4_MICROSECONDS_TIME_SCALE 1000000
-#define MP4_NANOSECONDS_TIME_SCALE  1000000000
-
-#define MP4_SECS_TIME_SCALE     MP4_SECONDS_TIME_SCALE
-#define MP4_MSECS_TIME_SCALE    MP4_MILLISECONDS_TIME_SCALE
-#define MP4_USECS_TIME_SCALE    MP4_MICROSECONDS_TIME_SCALE
-#define MP4_NSECS_TIME_SCALE    MP4_NANOSECONDS_TIME_SCALE
-
-u_int64_t MP4ConvertFromMovieDuration(
-    MP4FileHandle hFile,
-    MP4Duration duration,
-    u_int32_t timeScale);
-
-u_int64_t MP4ConvertFromTrackTimestamp(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Timestamp timeStamp,
-    u_int32_t timeScale);
-
-MP4Timestamp MP4ConvertToTrackTimestamp(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    u_int64_t timeStamp,
-    u_int32_t timeScale);
-
-u_int64_t MP4ConvertFromTrackDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    MP4Duration duration,
-    u_int32_t timeScale);
-
-MP4Duration MP4ConvertToTrackDuration(
-    MP4FileHandle hFile,
-    MP4TrackId trackId,
-    u_int64_t duration,
-    u_int32_t timeScale);
-
-char* MP4BinaryToBase16(
-    const u_int8_t* pData,
-    u_int32_t dataSize);
-
-char* MP4BinaryToBase64(
-    const u_int8_t* pData,
-    u_int32_t dataSize);
-
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Timestamp when, 
+	MP4Timestamp* pStartTime DEFAULT(NULL), 
+	MP4Duration* pDuration DEFAULT(NULL));
 /* iTunes metadata handling */
 bool MP4MetadataDelete(MP4FileHandle hFile);
 bool MP4GetMetadataByIndex(MP4FileHandle hFile, u_int32_t index,
-                           const char** ppName,
-                           u_int8_t** ppValue, u_int32_t* pValueSize);
+			   const char** ppName,
+			   u_int8_t** ppValue, u_int32_t* pValueSize);
 bool MP4SetMetadataName(MP4FileHandle hFile, const char* value);
 bool MP4GetMetadataName(MP4FileHandle hFile, char** value);
 bool MP4SetMetadataArtist(MP4FileHandle hFile, const char* value);
@@ -936,65 +972,78 @@
 bool MP4SetMetadataAlbum(MP4FileHandle hFile, const char* value);
 bool MP4GetMetadataAlbum(MP4FileHandle hFile, char** value);
 bool MP4SetMetadataTrack(MP4FileHandle hFile,
-                         u_int16_t track, u_int16_t totalTracks);
+			 u_int16_t track, u_int16_t totalTracks);
 bool MP4GetMetadataTrack(MP4FileHandle hFile,
-                         u_int16_t* track, u_int16_t* totalTracks);
+			 u_int16_t* track, u_int16_t* totalTracks);
 bool MP4SetMetadataDisk(MP4FileHandle hFile,
-                        u_int16_t disk, u_int16_t totalDisks);
+			u_int16_t disk, u_int16_t totalDisks);
 bool MP4GetMetadataDisk(MP4FileHandle hFile,
-                        u_int16_t* disk, u_int16_t* totalDisks);
-bool MP4SetMetadataGenre(MP4FileHandle hFile, const char* genre);
-bool MP4GetMetadataGenre(MP4FileHandle hFile, char** genre);
+			u_int16_t* disk, u_int16_t* totalDisks);
+bool MP4SetMetadataGenre(MP4FileHandle hFile, const char *genre);
+bool MP4GetMetadataGenre(MP4FileHandle hFile, char **genre);
 bool MP4SetMetadataTempo(MP4FileHandle hFile, u_int16_t tempo);
 bool MP4GetMetadataTempo(MP4FileHandle hFile, u_int16_t* tempo);
 bool MP4SetMetadataCompilation(MP4FileHandle hFile, u_int8_t cpl);
 bool MP4GetMetadataCompilation(MP4FileHandle hFile, u_int8_t* cpl);
 bool MP4SetMetadataCoverArt(MP4FileHandle hFile,
-                            u_int8_t *coverArt, u_int32_t size);
+			    u_int8_t *coverArt, u_int32_t size);
 bool MP4GetMetadataCoverArt(MP4FileHandle hFile,
-                            u_int8_t **coverArt, u_int32_t* size);
+			    u_int8_t **coverArt, u_int32_t* size);
 bool MP4SetMetadataFreeForm(MP4FileHandle hFile, char *name,
-                            u_int8_t* pValue, u_int32_t valueSize);
+			    u_int8_t* pValue, u_int32_t valueSize);
 bool MP4GetMetadataFreeForm(MP4FileHandle hFile, char *name,
-                            u_int8_t** pValue, u_int32_t* valueSize);
+			    u_int8_t** pValue, u_int32_t* valueSize);
+ 
 
-//#ifdef USE_FILE_CALLBACKS
-typedef u_int32_t (*MP4OpenCallback)(const char *pName, const char *mode, void *userData);
-typedef void (*MP4CloseCallback)(void *userData);
-typedef u_int32_t (*MP4ReadCallback)(void *pBuffer, unsigned int nBytesToRead, void *userData);
-typedef u_int32_t (*MP4WriteCallback)(void *pBuffer, unsigned int nBytesToWrite, void *userData);
-typedef int32_t (*MP4SetposCallback)(u_int32_t pos, void *userData);
-typedef int64_t (*MP4GetposCallback)(void *userData);
-typedef int64_t (*MP4FilesizeCallback)(void *userData);
+/* time conversion utilties */
 
-MP4FileHandle MP4CreateCb(u_int32_t verbosity,
-                          bool use64bits,
-                          bool useExtensibleFormat,
-                          MP4OpenCallback MP4fopen,
-                          MP4CloseCallback MP4fclose,
-                          MP4ReadCallback MP4fread,
-                          MP4WriteCallback MP4fwrite,
-                          MP4SetposCallback MP4fsetpos,
-                          MP4GetposCallback MP4fgetpos,
-                          MP4FilesizeCallback MP4filesize,
-                          void *userData);
+/* predefined values for timeScale parameter below */
+#define MP4_SECONDS_TIME_SCALE		1
+#define MP4_MILLISECONDS_TIME_SCALE 1000
+#define MP4_MICROSECONDS_TIME_SCALE 1000000
+#define MP4_NANOSECONDS_TIME_SCALE 	1000000000
 
-MP4FileHandle MP4ReadCb(u_int32_t verbosity,
-                        MP4OpenCallback MP4fopen,
-                        MP4CloseCallback MP4fclose,
-                        MP4ReadCallback MP4fread,
-                        MP4WriteCallback MP4fwrite,
-                        MP4SetposCallback MP4fsetpos,
-                        MP4GetposCallback MP4fgetpos,
-                        MP4FilesizeCallback MP4filesize,
-                        void *userData);
-MP4FileHandle MP4ModifyCb(int32_t verbosity,
-                          bool useExtensibleFormat,
-                          MP4OpenCallback MP4fopen, MP4CloseCallback MP4fclose,
-                          MP4ReadCallback MP4fread, MP4WriteCallback MP4fwrite,
-                          MP4SetposCallback MP4fsetpos, MP4GetposCallback MP4fgetpos,
-                          MP4FilesizeCallback MP4filesize, void *userData);
-//#endif
+#define MP4_SECS_TIME_SCALE 	MP4_SECONDS_TIME_SCALE
+#define MP4_MSECS_TIME_SCALE	MP4_MILLISECONDS_TIME_SCALE
+#define MP4_USECS_TIME_SCALE	MP4_MICROSECONDS_TIME_SCALE
+#define MP4_NSECS_TIME_SCALE	MP4_NANOSECONDS_TIME_SCALE
+
+u_int64_t MP4ConvertFromMovieDuration(
+	MP4FileHandle hFile,
+	MP4Duration duration,
+	u_int32_t timeScale);
+
+u_int64_t MP4ConvertFromTrackTimestamp(
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Timestamp timeStamp,
+	u_int32_t timeScale);
+
+MP4Timestamp MP4ConvertToTrackTimestamp(
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	u_int64_t timeStamp,
+	u_int32_t timeScale);
+
+u_int64_t MP4ConvertFromTrackDuration(
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	MP4Duration duration,
+	u_int32_t timeScale);
+
+MP4Duration MP4ConvertToTrackDuration(
+	MP4FileHandle hFile,
+	MP4TrackId trackId, 
+	u_int64_t duration,
+	u_int32_t timeScale);
+
+char* MP4BinaryToBase16(
+	const u_int8_t* pData, 
+	u_int32_t dataSize);
+
+char* MP4BinaryToBase64(
+	const u_int8_t* pData, 
+	u_int32_t dataSize);
 
 #ifdef __cplusplus
 }
--- a/common/mp4v2/mp4atom.cpp
+++ b/common/mp4v2/mp4atom.cpp
@@ -65,7 +65,7 @@
   if (type == NULL) {
     pAtom = new MP4RootAtom();
   } else {
-    switch(type[0]) {
+    switch((uint8_t)type[0]) {
     case 'c':
       if (ATOMID(type) == ATOMID("ctts")) {
 	pAtom = new MP4CttsAtom();
@@ -75,8 +75,6 @@
 	pAtom = new MP4CprtAtom();
       } else if (ATOMID(type) == ATOMID("cpil")) { /* Apple iTunes */
 	pAtom = new MP4CpilAtom();
-      } else if (ATOMID(type) == ATOMID("covr")) { /* Apple iTunes */
-	pAtom = new MP4CovrAtom();
       }
       break;
     case 'd':
@@ -123,7 +121,7 @@
       }
       break;
     case 'g':
-      if (ATOMID(type) == ATOMID("gnre")) { /* Apple iTunes */
+      if (ATOMID(type) == ATOMID("gnre")) { // Apple iTunes 
 	pAtom = new MP4GnreAtom();
       }
       break;
@@ -149,7 +147,7 @@
 	pAtom = new MP4IodsAtom();
       } else if (ATOMID(type) == ATOMID("ipir")) {
 	pAtom = new MP4TrefTypeAtom(type);
-      } else if (ATOMID(type) == ATOMID("ilst")) { /* Apple iTunes */
+      } else if (ATOMID(type) == ATOMID("ilst")) {
 	pAtom = new MP4IlstAtom();
       }
       break;
@@ -182,9 +180,9 @@
 	pAtom = new MP4MvexAtom();
       } else if (ATOMID(type) == ATOMID("maxr")) {
 	pAtom = new MP4MaxrAtom();
-      } else if (ATOMID(type) == ATOMID("meta")) { /* Apple iTunes */
+      } else if (ATOMID(type) == ATOMID("meta")) { // iTunes
 	pAtom = new MP4MetaAtom();
-      } else if (ATOMID(type) == ATOMID("mean")) { /* Apple iTunes */
+      } else if (ATOMID(type) == ATOMID("mean")) { // iTunes
 	pAtom = new MP4MeanAtom();
       }
       break;
@@ -193,7 +191,7 @@
 	pAtom = new MP4NmhdAtom();
       } else if (ATOMID(type) == ATOMID("nump")) {
 	pAtom = new MP4NumpAtom();
-      } else if (ATOMID(type) == ATOMID("name")) {
+      } else if (ATOMID(type) == ATOMID("name")) { // iTunes
 	pAtom = new MP4NameAtom();
       }
       break;
@@ -274,9 +272,9 @@
 	pAtom = new MP4TimsAtom();
       } else if (ATOMID(type) == ATOMID("tsro")) {
 	pAtom = new MP4TsroAtom();
-      } else if (ATOMID(type) == ATOMID("trkn")) { /* Apple iTunes */
+      } else if (ATOMID(type) == ATOMID("trkn")) { // iTunes
 	pAtom = new MP4TrknAtom();
-      } else if (ATOMID(type) == ATOMID("tmpo")) { /* Apple iTunes */
+      } else if (ATOMID(type) == ATOMID("tmpo")) { // iTunes
 	pAtom = new MP4TmpoAtom();
       }
       break;
@@ -294,28 +292,34 @@
 	pAtom = new MP4VmhdAtom();
       }
       break;
-    case '�':
-      if (ATOMID(type) == ATOMID("�nam")) {
-	pAtom = new MP4NamAtom();
-      } else if (ATOMID(type) == ATOMID("�ART")) { /* Apple iTunes */
-	pAtom = new MP4ArtAtom();
-      } else if (ATOMID(type) == ATOMID("�wrt")) { /* Apple iTunes */
-	pAtom = new MP4WrtAtom();
-      } else if (ATOMID(type) == ATOMID("�alb")) { /* Apple iTunes */
-	pAtom = new MP4AlbAtom();
-      } else if (ATOMID(type) == ATOMID("�day")) { /* Apple iTunes */
-	pAtom = new MP4DayAtom();
-      } else if (ATOMID(type) == ATOMID("�too")) { /* Apple iTunes */
-	pAtom = new MP4TooAtom();
-      } else if (ATOMID(type) == ATOMID("�cmt")) { /* Apple iTunes */
-	pAtom = new MP4CmtAtom();
-      } else if (ATOMID(type) == ATOMID("�gen")) { /* Apple iTunes */
-	pAtom = new MP4GenAtom();
+    case 0251: { // copyright symbol 
+static const char name[5]={0251,'n', 'a', 'm', '\0'};
+static const char art[5]={0251,'A', 'R', 'T', '\0'};
+static const char wrt[5]={0251,'w', 'r', 't', '\0'};
+static const char alb[5]={0251,'a', 'l', 'b', '\0'};
+static const char day[5]={0251,'d', 'a', 'y', '\0'};
+static const char too[5]={0251,'t', 'o', 'o', '\0'};
+static const char cmt[5]={0251,'c', 'm', 't', '\0'};
+      if (ATOMID(type) == ATOMID(name)) {
+ 	pAtom = new MP4NamAtom();
+      } else if (ATOMID(type) == ATOMID(art)) { /* Apple iTunes */
+ 	pAtom = new MP4ArtAtom();
+      } else if (ATOMID(type) == ATOMID(wrt)) { /* Apple iTunes */
+ 	pAtom = new MP4WrtAtom();
+      } else if (ATOMID(type) == ATOMID(alb)) { /* Apple iTunes */
+ 	pAtom = new MP4AlbAtom();
+      } else if (ATOMID(type) == ATOMID(day)) { /* Apple iTunes */
+ 	pAtom = new MP4DayAtom();
+      } else if (ATOMID(type) == ATOMID(too)) { /* Apple iTunes */
+ 	pAtom = new MP4TooAtom();
+      } else if (ATOMID(type) == ATOMID(cmt)) { /* Apple iTunes */
+ 	pAtom = new MP4CmtAtom();
       }
       break;
+    }
     case '-':
       if (ATOMID(type) == ATOMID("----")) { /* Apple iTunes */
-	pAtom = new MP4DashAtom();
+ 	pAtom = new MP4DashAtom();
       }
     }
   }
@@ -366,7 +370,7 @@
 	u_int64_t pos = pFile->GetPosition();
 
 	VERBOSE_READ(pFile->GetVerbosity(), 
-		printf("ReadAtom: pos = 0x"LLX"\n", pos));
+		printf("ReadAtom: pos = 0x"X64"\n", pos));
 
 	u_int64_t dataSize = pFile->ReadUInt32();
 
@@ -394,7 +398,7 @@
 	dataSize -= hdrSize;
 
 	VERBOSE_READ(pFile->GetVerbosity(), 
-		printf("ReadAtom: type = %s data-size = "LLU" (0x"LLX")\n", 
+		printf("ReadAtom: type = %s data-size = "U64" (0x"X64")\n", 
 			type, dataSize, dataSize));
 
 	if (pos + hdrSize + dataSize > pParentAtom->GetEnd()) {
@@ -455,7 +459,7 @@
 
 	if (ATOMID(m_type) != 0 && m_size > 1000000) {
 		VERBOSE_READ(GetVerbosity(), 
-			printf("Warning: %s atom size "LLU" is suspect\n",
+			printf("Warning: %s atom size "U64" is suspect\n",
 				m_type, m_size));
 	}
 
@@ -473,7 +477,7 @@
 {
 	if (m_pFile->GetPosition() != m_end) {
 		VERBOSE_READ(m_pFile->GetVerbosity(),
-			printf("Skip: "LLU" bytes\n", m_end - m_pFile->GetPosition()));
+			printf("Skip: "U64" bytes\n", m_end - m_pFile->GetPosition()));
 	}
 	m_pFile->SetPosition(m_end);
 }
@@ -609,7 +613,7 @@
 
 		if (m_pFile->GetPosition() > m_end) {
 			VERBOSE_READ(GetVerbosity(), 
-				printf("ReadProperties: insufficient data for property: %s pos 0x"LLX" atom end 0x"LLX"\n",
+				printf("ReadProperties: insufficient data for property: %s pos 0x"X64" atom end 0x"X64"\n",
 					m_pProperties[i]->GetName(), 
 					m_pFile->GetPosition(), m_end)); 
 
--- a/common/mp4v2/mp4atom.h
+++ b/common/mp4v2/mp4atom.h
@@ -88,7 +88,7 @@
 		return m_type;
 	};
 	void SetType(const char* type) {
-		if (type) {
+		if (type && *type != '\0') {
 			ASSERT(strlen(type) == 4);
 			memcpy(m_type, type, 4);
 			m_type[4] = '\0';
--- a/common/mp4v2/mp4common.h
+++ b/common/mp4v2/mp4common.h
@@ -16,7 +16,7 @@
  * Copyright (C) Cisco Systems Inc. 2001.  All Rights Reserved.
  * 
  * Contributor(s): 
- *		Dave Mackie		dmackie@cisco.com
+ *		Dave Mackie			dmackie@cisco.com
  */
 
 #ifndef __MP4_COMMON_INCLUDED__
@@ -46,5 +46,8 @@
 #include "odcommands.h"
 
 #include "rtphint.h"
+#ifdef ISMACRYP
+#include <ismacryplib.h>
+#endif
 
 #endif /* __MP4_COMMON_INCLUDED__ */
--- a/common/mp4v2/mp4file.cpp
+++ b/common/mp4v2/mp4file.cpp
@@ -3,20 +3,20 @@
  * License Version 1.1 (the "License"); you may not use this file
  * except in compliance with the License. You may obtain a copy of
  * the License at http://www.mozilla.org/MPL/
- *
+ * 
  * Software distributed under the License is distributed on an "AS
  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * rights and limitations under the License.
- *
+ * 
  * The Original Code is MPEG4IP.
- *
+ * 
  * The Initial Developer of the Original Code is Cisco Systems Inc.
  * Portions created by Cisco Systems Inc. are
  * Copyright (C) Cisco Systems Inc. 2001.  All Rights Reserved.
- *
- * Contributor(s):
- *      Dave Mackie       dmackie@cisco.com
+ * 
+ * Contributor(s): 
+ *		Dave Mackie		  dmackie@cisco.com
  *              Alix Marchandise-Franquet alix@cisco.com
  */
 
@@ -24,837 +24,816 @@
 
 MP4File::MP4File(u_int32_t verbosity)
 {
-    m_fileName = NULL;
-    m_pFile = NULL;
-    m_orgFileSize = 0;
-    m_fileSize = 0;
-    m_pRootAtom = NULL;
-    m_odTrackId = MP4_INVALID_TRACK_ID;
+	m_fileName = NULL;
+	m_pFile = NULL;
+	m_orgFileSize = 0;
+	m_fileSize = 0;
+	m_pRootAtom = NULL;
+	m_odTrackId = MP4_INVALID_TRACK_ID;
 
-    m_verbosity = verbosity;
-    m_mode = 0;
-    m_use64bits = false;
-    m_useIsma = false;
+	m_verbosity = verbosity;
+	m_mode = 0;
+	m_createFlags = 0;
+	m_useIsma = false;
 
-    m_pModificationProperty = NULL;
-    m_pTimeScaleProperty = NULL;
-    m_pDurationProperty = NULL;
+	m_pModificationProperty = NULL;
+	m_pTimeScaleProperty = NULL;
+	m_pDurationProperty = NULL;
 
-    m_memoryBuffer = NULL;
-    m_memoryBufferSize = 0;
-    m_memoryBufferPosition = 0;
+	m_memoryBuffer = NULL;
+	m_memoryBufferSize = 0;
+	m_memoryBufferPosition = 0;
 
-    m_numReadBits = 0;
-    m_bufReadBits = 0;
-    m_numWriteBits = 0;
-    m_bufWriteBits = 0;
-
-#ifdef USE_FILE_CALLBACKS
-    // These are the default for when no callbacks are specified
-    m_userData = (void*)this;
-    m_MP4fopen = MP4fopen_cb;
-    m_MP4fclose = MP4fclose_cb;
-    m_MP4fread = MP4fread_cb;
-    m_MP4fwrite = MP4fwrite_cb;
-    m_MP4fgetpos = MP4fgetpos_cb;
-    m_MP4fsetpos = MP4fsetpos_cb;
-    m_MP4filesize = MP4filesize_cb;
-#endif
+	m_numReadBits = 0;
+	m_bufReadBits = 0;
+	m_numWriteBits = 0;
+	m_bufWriteBits = 0;
 }
 
 MP4File::~MP4File()
 {
-    MP4Free(m_fileName);
-    delete m_pRootAtom;
-    for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
-        delete m_pTracks[i];
-    }
-    MP4Free(m_memoryBuffer);    // just in case
+	MP4Free(m_fileName);
+	delete m_pRootAtom;
+	for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
+		delete m_pTracks[i];
+	}
+	MP4Free(m_memoryBuffer);	// just in case
 }
 
 void MP4File::Read(const char* fileName)
 {
-    m_fileName = MP4Stralloc(fileName);
-    m_mode = 'r';
+	m_fileName = MP4Stralloc(fileName);
+	m_mode = 'r';
 
-    Open("rb");
+	Open("rb");
 
-    ReadFromFile();
+	ReadFromFile();
 
-    CacheProperties();
+	CacheProperties();
 }
 
-void MP4File::Create(const char* fileName, bool use64bits)
+void MP4File::Create(const char* fileName, u_int32_t flags)
 {
-    m_fileName = MP4Stralloc(fileName);
-    m_mode = 'w';
-    m_use64bits = use64bits;
+	m_fileName = MP4Stralloc(fileName);
+	m_mode = 'w';
+	m_createFlags = flags;
 
-    Open("wb+");
+	Open("wb+");
 
-    // generate a skeletal atom tree
-    m_pRootAtom = MP4Atom::CreateAtom(NULL);
-    m_pRootAtom->SetFile(this);
-    m_pRootAtom->Generate();
+	// generate a skeletal atom tree
+	m_pRootAtom = MP4Atom::CreateAtom(NULL);
+	m_pRootAtom->SetFile(this);
+	m_pRootAtom->Generate();
 
-    CacheProperties();
+	CacheProperties();
 
-    // create mdat, and insert it after ftyp, and before moov
-    InsertChildAtom(m_pRootAtom, "mdat", 1);
+	// create mdat, and insert it after ftyp, and before moov
+	InsertChildAtom(m_pRootAtom, "mdat", 1);
 
-    // start writing
-    m_pRootAtom->BeginWrite();
+	// start writing
+	m_pRootAtom->BeginWrite();
 }
 
-void MP4File::Modify(const char* fileName)
+bool MP4File::Use64Bits (const char *atomName)
 {
-    m_fileName = MP4Stralloc(fileName);
-    m_mode = 'r';
+  if (!strcmp(atomName, "mdat") || !strcmp(atomName, "stbl")) {
+    return (m_createFlags & MP4_CREATE_64BIT_DATA) == MP4_CREATE_64BIT_DATA;
+  }
 
-    Open("rb+");
-    ReadFromFile();
+  if (!strcmp(atomName, "mvhd") || 
+      !strcmp(atomName, "tkhd") ||
+      !strcmp(atomName, "mdhd")) {
+    return (m_createFlags & MP4_CREATE_64BIT_TIME) == MP4_CREATE_64BIT_TIME;
+  }
+  return false;
+}
 
-    m_mode = 'w';
+    
+void MP4File::Modify(const char* fileName)
+{
+	m_fileName = MP4Stralloc(fileName);
+	m_mode = 'r';
 
-    // find the moov atom
-    MP4Atom* pMoovAtom = m_pRootAtom->FindAtom("moov");
-    u_int32_t numAtoms;
+	Open("rb+");
+	ReadFromFile();
 
-    if (pMoovAtom == NULL) {
-        // there isn't one, odd but we can still proceed
-        pMoovAtom = AddChildAtom(m_pRootAtom, "moov");
-    } else {
-        numAtoms = m_pRootAtom->GetNumberOfChildAtoms();
+	m_mode = 'w';
 
-        // work backwards thru the top level atoms
-        int32_t i;
-        bool lastAtomIsMoov = true;
-        MP4Atom* pLastAtom = NULL;
+	// find the moov atom
+	MP4Atom* pMoovAtom = m_pRootAtom->FindAtom("moov");
+	u_int32_t numAtoms;
 
-        for (i = numAtoms - 1; i >= 0; i--) {
-            MP4Atom* pAtom = m_pRootAtom->GetChildAtom(i);
-            const char* type = pAtom->GetType();
+	if (pMoovAtom == NULL) {
+		// there isn't one, odd but we can still proceed
+		pMoovAtom = AddChildAtom(m_pRootAtom, "moov");
+	} else {
+		numAtoms = m_pRootAtom->GetNumberOfChildAtoms();
 
-            // get rid of any trailing free or skips
-            if (!strcmp(type, "free") || !strcmp(type, "skip")) {
-                m_pRootAtom->DeleteChildAtom(pAtom);
-                continue;
-            }
+		// work backwards thru the top level atoms
+		int32_t i;
+		bool lastAtomIsMoov = true;
+		MP4Atom* pLastAtom = NULL;
 
-            if (strcmp(type, "moov")) {
-                if (pLastAtom == NULL) {
-                    pLastAtom = pAtom;
-                    lastAtomIsMoov = false;
-                }
-                continue;
-            }
+		for (i = numAtoms - 1; i >= 0; i--) {
+			MP4Atom* pAtom = m_pRootAtom->GetChildAtom(i);
+			const char* type = pAtom->GetType();
+			
+			// get rid of any trailing free or skips
+			if (!strcmp(type, "free") || !strcmp(type, "skip")) {
+				m_pRootAtom->DeleteChildAtom(pAtom);
+				continue;
+			}
 
-            // now at moov atom
+			if (strcmp(type, "moov")) {
+				if (pLastAtom == NULL) {
+					pLastAtom = pAtom;
+					lastAtomIsMoov = false;
+				}
+				continue;
+			}
 
-            // multiple moov atoms?!?
-            if (pAtom != pMoovAtom) {
-                throw new MP4Error(
-                    "Badly formed mp4 file, multiple moov atoms",
-                    "MP4Modify");
-            }
+			// now at moov atom
 
-            if (lastAtomIsMoov) {
-                // position to start of moov atom,
-                // effectively truncating file
-                // prior to adding new mdat
-                SetPosition(pMoovAtom->GetStart());
+			// multiple moov atoms?!?
+			if (pAtom != pMoovAtom) {
+				throw new MP4Error(
+					"Badly formed mp4 file, multiple moov atoms", 
+					"MP4Modify");
+			}
 
-            } else { // last atom isn't moov
-                // need to place a free atom
-                MP4Atom* pFreeAtom = MP4Atom::CreateAtom("free");
+			if (lastAtomIsMoov) {
+				// position to start of moov atom,
+				// effectively truncating file 
+				// prior to adding new mdat
+				SetPosition(pMoovAtom->GetStart());
 
-                // in existing position of the moov atom
-                m_pRootAtom->InsertChildAtom(pFreeAtom, i);
-                m_pRootAtom->DeleteChildAtom(pMoovAtom);
-                m_pRootAtom->AddChildAtom(pMoovAtom);
+			} else { // last atom isn't moov
+				// need to place a free atom 
+				MP4Atom* pFreeAtom = MP4Atom::CreateAtom("free");
 
-                // write free atom to disk
-                SetPosition(pMoovAtom->GetStart());
-                pFreeAtom->SetSize(pMoovAtom->GetSize());
-                pFreeAtom->Write();
+				// in existing position of the moov atom
+				m_pRootAtom->InsertChildAtom(pFreeAtom, i);
+				m_pRootAtom->DeleteChildAtom(pMoovAtom);
+				m_pRootAtom->AddChildAtom(pMoovAtom);
 
-                // finally set our file position to the end of the last atom
-                SetPosition(pLastAtom->GetEnd());
-            }
+				// write free atom to disk
+				SetPosition(pMoovAtom->GetStart());
+				pFreeAtom->SetSize(pMoovAtom->GetSize());
+				pFreeAtom->Write();
 
-            break;
-        }
-        ASSERT(i != -1);
-    }
+				// finally set our file position to the end of the last atom
+				SetPosition(pLastAtom->GetEnd());
+			}
 
-    CacheProperties();  // of moov atom
+			break;
+		}
+		ASSERT(i != -1);
+	}
 
-    numAtoms = m_pRootAtom->GetNumberOfChildAtoms();
+	CacheProperties();	// of moov atom
 
-    // insert another mdat prior to moov atom (the last atom)
-    MP4Atom* pMdatAtom = InsertChildAtom(m_pRootAtom, "mdat", numAtoms - 1);
+	numAtoms = m_pRootAtom->GetNumberOfChildAtoms();
 
-    // start writing new mdat
-    pMdatAtom->BeginWrite();
+	// insert another mdat prior to moov atom (the last atom)
+	MP4Atom* pMdatAtom = InsertChildAtom(m_pRootAtom, "mdat", numAtoms - 1);
+
+	// start writing new mdat
+	pMdatAtom->BeginWrite();
 }
 
 void MP4File::Optimize(const char* orgFileName, const char* newFileName)
 {
-#if 1//ndef USE_FILE_CALLBACKS
-    m_fileName = MP4Stralloc(orgFileName);
-    m_mode = 'r';
+	m_fileName = MP4Stralloc(orgFileName);
+	m_mode = 'r';
 
-    // first load meta-info into memory
-    Open("rb");
-    ReadFromFile();
+	// first load meta-info into memory
+	Open("rb");
+	ReadFromFile();
 
-    CacheProperties();  // of moov atom
+	CacheProperties();	// of moov atom
 
-    // now switch over to writing the new file
-    MP4Free(m_fileName);
+	// now switch over to writing the new file
+	MP4Free(m_fileName);
 
-    // create a temporary file if necessary
-    if (newFileName == NULL) {
-        m_fileName = MP4Stralloc(TempFileName());
-    } else {
-        m_fileName = MP4Stralloc(newFileName);
-    }
+	// create a temporary file if necessary
+	if (newFileName == NULL) {
+		m_fileName = MP4Stralloc(TempFileName());
+	} else {
+		m_fileName = MP4Stralloc(newFileName);
+	}
 
-    FILE* pReadFile = m_pFile;
-    m_pFile = NULL;
-    m_mode = 'w';
+	FILE* pReadFile = m_pFile;
+	m_pFile = NULL;
+	m_mode = 'w';
 
-    Open("wb");
+	Open("wb");
 
-    SetIntegerProperty("moov.mvhd.modificationTime",
-        MP4GetAbsTimestamp());
+	SetIntegerProperty("moov.mvhd.modificationTime", 
+		MP4GetAbsTimestamp());
 
-    // writing meta info in the optimal order
-    ((MP4RootAtom*)m_pRootAtom)->BeginOptimalWrite();
+	// writing meta info in the optimal order
+	((MP4RootAtom*)m_pRootAtom)->BeginOptimalWrite();
 
-    // write data in optimal order
-    RewriteMdat(pReadFile, m_pFile);
+	// write data in optimal order
+	RewriteMdat(pReadFile, m_pFile);
 
-    // finish writing
-    ((MP4RootAtom*)m_pRootAtom)->FinishOptimalWrite();
+	// finish writing
+	((MP4RootAtom*)m_pRootAtom)->FinishOptimalWrite();
 
-    // cleanup
-    fclose(m_pFile);
-    m_pFile = NULL;
-    fclose(pReadFile);
+	// cleanup
+	fclose(m_pFile);
+	m_pFile = NULL;
+	fclose(pReadFile);
 
-    // move temporary file into place
-    if (newFileName == NULL) {
-        Rename(m_fileName, orgFileName);
-    }
-#else
-    throw new MP4Error(errno, "Function not supported when using callbacks", "MP4Optimize");
-#endif
+	// move temporary file into place
+	if (newFileName == NULL) {
+		Rename(m_fileName, orgFileName);
+	}
 }
 
 void MP4File::RewriteMdat(FILE* pReadFile, FILE* pWriteFile)
 {
-    u_int32_t numTracks = m_pTracks.Size();
+	u_int32_t numTracks = m_pTracks.Size();
 
-    MP4ChunkId* chunkIds = new MP4ChunkId[numTracks];
-    MP4ChunkId* maxChunkIds = new MP4ChunkId[numTracks];
-    MP4Timestamp* nextChunkTimes = new MP4Timestamp[numTracks];
+	MP4ChunkId* chunkIds = new MP4ChunkId[numTracks];
+	MP4ChunkId* maxChunkIds = new MP4ChunkId[numTracks];
+	MP4Timestamp* nextChunkTimes = new MP4Timestamp[numTracks];
 
-    for (u_int32_t i = 0; i < numTracks; i++) {
-        chunkIds[i] = 1;
-        maxChunkIds[i] = m_pTracks[i]->GetNumberOfChunks();
-        nextChunkTimes[i] = MP4_INVALID_TIMESTAMP;
-    }
+	for (u_int32_t i = 0; i < numTracks; i++) {
+		chunkIds[i] = 1;
+		maxChunkIds[i] = m_pTracks[i]->GetNumberOfChunks();
+		nextChunkTimes[i] = MP4_INVALID_TIMESTAMP;
+	}
 
-    while (true) {
-        u_int32_t nextTrackIndex = (u_int32_t)-1;
-        MP4Timestamp nextTime = MP4_INVALID_TIMESTAMP;
+	while (true) {
+		u_int32_t nextTrackIndex = (u_int32_t)-1;
+		MP4Timestamp nextTime = MP4_INVALID_TIMESTAMP;
 
-        for (u_int32_t i = 0; i < numTracks; i++) {
-            if (chunkIds[i] > maxChunkIds[i]) {
-                continue;
-            }
+		for (u_int32_t i = 0; i < numTracks; i++) {
+			if (chunkIds[i] > maxChunkIds[i]) {
+				continue;
+			}
 
-            if (nextChunkTimes[i] == MP4_INVALID_TIMESTAMP) {
-                MP4Timestamp chunkTime =
-                    m_pTracks[i]->GetChunkTime(chunkIds[i]);
+			if (nextChunkTimes[i] == MP4_INVALID_TIMESTAMP) {
+				MP4Timestamp chunkTime =
+					m_pTracks[i]->GetChunkTime(chunkIds[i]);
 
-                nextChunkTimes[i] = MP4ConvertTime(chunkTime,
-                    m_pTracks[i]->GetTimeScale(), GetTimeScale());
-            }
+				nextChunkTimes[i] = MP4ConvertTime(chunkTime,
+					m_pTracks[i]->GetTimeScale(), GetTimeScale());
+			}
 
-            // time is not earliest so far
-            if (nextChunkTimes[i] > nextTime) {
-                continue;
-            }
+			// time is not earliest so far
+			if (nextChunkTimes[i] > nextTime) {
+				continue;
+			}
 
-            // prefer hint tracks to media tracks if times are equal
-            if (nextChunkTimes[i] == nextTime
-              && strcmp(m_pTracks[i]->GetType(), MP4_HINT_TRACK_TYPE)) {
-                continue;
-            }
+			// prefer hint tracks to media tracks if times are equal
+			if (nextChunkTimes[i] == nextTime 
+			  && strcmp(m_pTracks[i]->GetType(), MP4_HINT_TRACK_TYPE)) {
+				continue;
+			}
 
-            // this is our current choice of tracks
-            nextTime = nextChunkTimes[i];
-            nextTrackIndex = i;
-        }
+			// this is our current choice of tracks
+			nextTime = nextChunkTimes[i];
+			nextTrackIndex = i;
+		}
 
-        if (nextTrackIndex == (u_int32_t)-1) {
-            break;
-        }
+		if (nextTrackIndex == (u_int32_t)-1) {
+			break;
+		}
 
-        // point into original mp4 file for read chunk call
-        m_pFile = pReadFile;
-        m_mode = 'r';
+		// point into original mp4 file for read chunk call
+		m_pFile = pReadFile;
+		m_mode = 'r';
 
-        u_int8_t* pChunk;
-        u_int32_t chunkSize;
+		u_int8_t* pChunk;
+		u_int32_t chunkSize;
 
-        m_pTracks[nextTrackIndex]->
-            ReadChunk(chunkIds[nextTrackIndex], &pChunk, &chunkSize);
+		m_pTracks[nextTrackIndex]->
+			ReadChunk(chunkIds[nextTrackIndex], &pChunk, &chunkSize);
 
-        // point back at the new mp4 file for write chunk
-        m_pFile = pWriteFile;
-        m_mode = 'w';
+		// point back at the new mp4 file for write chunk
+		m_pFile = pWriteFile;
+		m_mode = 'w';
 
-        m_pTracks[nextTrackIndex]->
-            RewriteChunk(chunkIds[nextTrackIndex], pChunk, chunkSize);
+		m_pTracks[nextTrackIndex]->
+			RewriteChunk(chunkIds[nextTrackIndex], pChunk, chunkSize);
 
-        MP4Free(pChunk);
+		MP4Free(pChunk);
 
-        chunkIds[nextTrackIndex]++;
-        nextChunkTimes[nextTrackIndex] = MP4_INVALID_TIMESTAMP;
-    }
+		chunkIds[nextTrackIndex]++;
+		nextChunkTimes[nextTrackIndex] = MP4_INVALID_TIMESTAMP;
+	}
 
-    delete [] chunkIds;
-    delete [] maxChunkIds;
-    delete [] nextChunkTimes;
+	delete [] chunkIds;
+	delete [] maxChunkIds;
+	delete [] nextChunkTimes;
 }
 
 void MP4File::Open(const char* fmode)
 {
-    ASSERT(m_pFile == NULL);
+	ASSERT(m_pFile == NULL);
 
-#ifndef USE_FILE_CALLBACKS
 #ifdef O_LARGEFILE
-    // UGH! fopen doesn't open a file in 64-bit mode, period.
-    // So we need to use open() and then fdopen()
-    int fd;
-    int flags = O_LARGEFILE;
+	// UGH! fopen doesn't open a file in 64-bit mode, period.
+	// So we need to use open() and then fdopen()
+	int fd;
+	int flags = O_LARGEFILE;
 
-    if (strchr(fmode, '+')) {
-        flags |= O_CREAT | O_RDWR;
-        if (fmode[0] == 'w') {
-            flags |= O_TRUNC;
-        }
-    } else {
-        if (fmode[0] == 'w') {
-            flags |= O_CREAT | O_TRUNC | O_WRONLY;
-        } else {
-            flags |= O_RDONLY;
-        }
-    }
-    fd = open(m_fileName, flags, 0666);
+	if (strchr(fmode, '+')) {
+		flags |= O_CREAT | O_RDWR;
+		if (fmode[0] == 'w') {
+			flags |= O_TRUNC;
+		}
+	} else {
+		if (fmode[0] == 'w') {
+			flags |= O_CREAT | O_TRUNC | O_WRONLY;
+		} else {
+			flags |= O_RDONLY;
+		}
+	}
+	fd = open(m_fileName, flags, 0666); 
 
-    if (fd >= 0) {
-        m_pFile = fdopen(fd, fmode);
-    }
+	if (fd >= 0) {
+		m_pFile = fdopen(fd, fmode);
+	}
 #else
-    m_pFile = fopen(m_fileName, fmode);
+	m_pFile = fopen(m_fileName, fmode);
 #endif
-    if (m_pFile == NULL) {
-        throw new MP4Error(errno, "failed", "MP4Open");
-    }
-#else
-    u_int32_t rc = m_MP4fopen(m_fileName, fmode, m_userData);
-    if (rc == 0) {
-        throw new MP4Error(errno, "failed", "MP4Open");
-    }
-#endif
+	if (m_pFile == NULL) {
+		throw new MP4Error(errno, "failed", "MP4Open");
+	}
 
-    if (m_mode == 'r') {
-#ifndef USE_FILE_CALLBACKS
-        struct stat s;
-        if (fstat(fileno(m_pFile), &s) < 0) {
-            throw new MP4Error(errno, "stat failed", "MP4Open");
-        }
-        m_orgFileSize = m_fileSize = s.st_size;
-#else
-        int64_t s = m_MP4filesize(m_userData);
-        if (s < 0) {
-            throw new MP4Error(errno, "retreiving filesize failed", "MP4Open");
-        }
-        m_orgFileSize = m_fileSize = (u_int64_t)s;
-#endif
-    } else {
-        m_orgFileSize = m_fileSize = 0;
-    }
+	if (m_mode == 'r') {
+		struct stat s;
+		if (fstat(fileno(m_pFile), &s) < 0) {
+			throw new MP4Error(errno, "stat failed", "MP4Open");
+		}
+		m_orgFileSize = m_fileSize = s.st_size;
+	} else {
+		m_orgFileSize = m_fileSize = 0;
+	}
 }
 
 void MP4File::ReadFromFile()
 {
-    // ensure we start at beginning of file
-    SetPosition(0);
+	// ensure we start at beginning of file
+	SetPosition(0);
 
-    // create a new root atom
-    ASSERT(m_pRootAtom == NULL);
-    m_pRootAtom = MP4Atom::CreateAtom(NULL);
+	// create a new root atom
+	ASSERT(m_pRootAtom == NULL);
+	m_pRootAtom = MP4Atom::CreateAtom(NULL);
 
-    u_int64_t fileSize = GetSize();
+	u_int64_t fileSize = GetSize();
 
-    m_pRootAtom->SetFile(this);
-    m_pRootAtom->SetStart(0);
-    m_pRootAtom->SetSize(fileSize);
-    m_pRootAtom->SetEnd(fileSize);
+	m_pRootAtom->SetFile(this);
+	m_pRootAtom->SetStart(0);
+	m_pRootAtom->SetSize(fileSize);
+	m_pRootAtom->SetEnd(fileSize);
 
-    m_pRootAtom->Read();
+	m_pRootAtom->Read();
 
-    // create MP4Track's for any tracks in the file
-    GenerateTracks();
+	// create MP4Track's for any tracks in the file
+	GenerateTracks();
 }
 
 void MP4File::GenerateTracks()
 {
-    u_int32_t trackIndex = 0;
+	u_int32_t trackIndex = 0;
 
-    while (true) {
-        char trackName[32];
-        snprintf(trackName, sizeof(trackName), "moov.trak[%u]", trackIndex);
+	while (true) {
+		char trackName[32];
+		snprintf(trackName, sizeof(trackName), "moov.trak[%u]", trackIndex);
 
-        // find next trak atom
-        MP4Atom* pTrakAtom = m_pRootAtom->FindAtom(trackName);
+		// find next trak atom
+		MP4Atom* pTrakAtom = m_pRootAtom->FindAtom(trackName);
 
-        // done, no more trak atoms
-        if (pTrakAtom == NULL) {
-            break;
-        }
+		// done, no more trak atoms
+		if (pTrakAtom == NULL) {
+			break;
+		}
 
-        // find track id property
-        MP4Integer32Property* pTrackIdProperty = NULL;
-        pTrakAtom->FindProperty(
-            "trak.tkhd.trackId",
-            (MP4Property**)&pTrackIdProperty);
+		// find track id property
+		MP4Integer32Property* pTrackIdProperty = NULL;
+		pTrakAtom->FindProperty(
+			"trak.tkhd.trackId",
+			(MP4Property**)&pTrackIdProperty);
 
-        // find track type property
-        MP4StringProperty* pTypeProperty = NULL;
-        pTrakAtom->FindProperty(
-            "trak.mdia.hdlr.handlerType",
-            (MP4Property**)&pTypeProperty);
+		// find track type property
+		MP4StringProperty* pTypeProperty = NULL;
+		pTrakAtom->FindProperty(
+			"trak.mdia.hdlr.handlerType",
+			(MP4Property**)&pTypeProperty);
 
-        // ensure we have the basics properties
-        if (pTrackIdProperty && pTypeProperty) {
+		// ensure we have the basics properties
+		if (pTrackIdProperty && pTypeProperty) {
 
-            m_trakIds.Add(pTrackIdProperty->GetValue());
+			m_trakIds.Add(pTrackIdProperty->GetValue());
 
-            MP4Track* pTrack = NULL;
-            try {
-                if (!strcmp(pTypeProperty->GetValue(), MP4_HINT_TRACK_TYPE)) {
-                    pTrack = new MP4RtpHintTrack(this, pTrakAtom);
-                } else {
-                    pTrack = new MP4Track(this, pTrakAtom);
-                }
-                m_pTracks.Add(pTrack);
-            }
-            catch (MP4Error* e) {
-                VERBOSE_ERROR(m_verbosity, e->Print());
-                delete e;
-            }
+			MP4Track* pTrack = NULL;
+			try {
+				if (!strcmp(pTypeProperty->GetValue(), MP4_HINT_TRACK_TYPE)) {
+					pTrack = new MP4RtpHintTrack(this, pTrakAtom);
+				} else {
+					pTrack = new MP4Track(this, pTrakAtom);
+				}
+				m_pTracks.Add(pTrack);
+			}
+			catch (MP4Error* e) {
+				VERBOSE_ERROR(m_verbosity, e->Print());
+				delete e;
+			}
 
-            // remember when we encounter the OD track
-            if (pTrack && !strcmp(pTrack->GetType(), MP4_OD_TRACK_TYPE)) {
-                if (m_odTrackId == MP4_INVALID_TRACK_ID) {
-                    m_odTrackId = pTrackIdProperty->GetValue();
-                } else {
-                    VERBOSE_READ(GetVerbosity(),
-                        printf("Warning: multiple OD tracks present\n"));
-                }
-            }
-        } else {
-            m_trakIds.Add(0);
-        }
+			// remember when we encounter the OD track
+			if (pTrack && !strcmp(pTrack->GetType(), MP4_OD_TRACK_TYPE)) {
+				if (m_odTrackId == MP4_INVALID_TRACK_ID) {
+					m_odTrackId = pTrackIdProperty->GetValue();
+				} else {
+					VERBOSE_READ(GetVerbosity(),
+						printf("Warning: multiple OD tracks present\n"));
+				}
+			}
+		} else {
+			m_trakIds.Add(0);
+		}
 
-        trackIndex++;
-    }
+		trackIndex++;
+	}
 }
 
 void MP4File::CacheProperties()
 {
-    FindIntegerProperty("moov.mvhd.modificationTime",
-        (MP4Property**)&m_pModificationProperty);
+	FindIntegerProperty("moov.mvhd.modificationTime", 
+		(MP4Property**)&m_pModificationProperty);
 
-    FindIntegerProperty("moov.mvhd.timeScale",
-        (MP4Property**)&m_pTimeScaleProperty);
+	FindIntegerProperty("moov.mvhd.timeScale", 
+		(MP4Property**)&m_pTimeScaleProperty);
 
-    FindIntegerProperty("moov.mvhd.duration",
-        (MP4Property**)&m_pDurationProperty);
+	FindIntegerProperty("moov.mvhd.duration", 
+		(MP4Property**)&m_pDurationProperty);
 }
 
 void MP4File::BeginWrite()
 {
-    m_pRootAtom->BeginWrite();
+	m_pRootAtom->BeginWrite();
 }
 
 void MP4File::FinishWrite()
 {
-    // for all tracks, flush chunking buffers
-    for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
-        ASSERT(m_pTracks[i]);
-        m_pTracks[i]->FinishWrite();
-    }
+	// for all tracks, flush chunking buffers
+	for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
+		ASSERT(m_pTracks[i]);
+		m_pTracks[i]->FinishWrite();
+	}
 
-    // ask root atom to write
-    m_pRootAtom->FinishWrite();
+	// ask root atom to write
+	m_pRootAtom->FinishWrite();
 
-    // check if file shrunk, e.g. we deleted a track
-    if (GetSize() < m_orgFileSize) {
-        // just use a free atom to mark unused space
-        // MP4Optimize() should be used to clean up this space
-        MP4Atom* pFreeAtom = MP4Atom::CreateAtom("free");
-        ASSERT(pFreeAtom);
-        pFreeAtom->SetFile(this);
-        pFreeAtom->SetSize((u_int64_t)MAX((int64_t)m_orgFileSize - ((int64_t)m_fileSize + 8), 0));
-        pFreeAtom->Write();
-        delete pFreeAtom;
-    }
+	// check if file shrunk, e.g. we deleted a track
+	if (GetSize() < m_orgFileSize) {
+		// just use a free atom to mark unused space
+		// MP4Optimize() should be used to clean up this space
+		MP4Atom* pFreeAtom = MP4Atom::CreateAtom("free");
+		ASSERT(pFreeAtom);
+		pFreeAtom->SetFile(this);
+		int64_t size = m_orgFileSize - (m_fileSize + 8);
+		if (size < 0) size = 0;
+		pFreeAtom->SetSize(size);
+		pFreeAtom->Write();
+		delete pFreeAtom;
+	}
 }
 
 MP4Duration MP4File::UpdateDuration(MP4Duration duration)
 {
-    MP4Duration currentDuration = GetDuration();
-    if (duration > currentDuration) {
-        SetDuration(duration);
-        return duration;
-    }
-    return currentDuration;
+	MP4Duration currentDuration = GetDuration();
+	if (duration > currentDuration) {
+		SetDuration(duration);
+		return duration;
+	}
+	return currentDuration;
 }
 
 void MP4File::Dump(FILE* pDumpFile, bool dumpImplicits)
 {
-    if (pDumpFile == NULL) {
-        pDumpFile = stdout;
-    }
+	if (pDumpFile == NULL) {
+		pDumpFile = stdout;
+	}
 
-    fprintf(pDumpFile, "Dumping %s meta-information...\n", m_fileName);
-    m_pRootAtom->Dump(pDumpFile, 0, dumpImplicits);
+	fprintf(pDumpFile, "Dumping %s meta-information...\n", m_fileName);
+	m_pRootAtom->Dump(pDumpFile, 0, dumpImplicits);
 }
 
 void MP4File::Close()
 {
-    if (m_mode == 'w') {
-        SetIntegerProperty("moov.mvhd.modificationTime",
-            MP4GetAbsTimestamp());
+	if (m_mode == 'w') {
+		SetIntegerProperty("moov.mvhd.modificationTime", 
+			MP4GetAbsTimestamp());
 
-        FinishWrite();
-    }
+		FinishWrite();
+	}
 
-#ifndef USE_FILE_CALLBACKS
-    fclose(m_pFile);
-    m_pFile = NULL;
-#else
-    m_MP4fclose(m_userData);
-#endif
+	fclose(m_pFile);
+	m_pFile = NULL;
 }
 
 const char* MP4File::TempFileName()
 {
-    // there are so many attempts in libc to get this right
-    // that for portablity reasons, it's best just to roll our own
+	// there are so many attempts in libc to get this right
+	// that for portablity reasons, it's best just to roll our own
 #ifndef _WIN32
-    static char tempFileName[64];
-    u_int32_t i;
-    for (i = getpid(); i < 0xFFFFFFFF; i++) {
-        sprintf(tempFileName, "./tmp%u.mp4", i);
-        if (access(tempFileName, F_OK) != 0) {
-            break;
-        }
-    }
-    if (i == 0xFFFFFFFF) {
-        throw new MP4Error("can't create temporary file", "TempFileName");
-    }
+	static char tempFileName[64];
+	u_int32_t i;
+	for (i = getpid(); i < 0xFFFFFFFF; i++) {
+		sprintf(tempFileName, "./tmp%u.mp4", i);
+		if (access(tempFileName, F_OK) != 0) {
+			break;
+		}
+	}
+	if (i == 0xFFFFFFFF) {
+		throw new MP4Error("can't create temporary file", "TempFileName");
+	}
 #else
-    static char tempFileName[MAX_PATH + 3];
-    GetTempFileName(".", // dir. for temp. files
-                    "mp4",                // temp. filename prefix
-                    0,                    // create unique name
-                    tempFileName);        // buffer for name
+	static char tempFileName[MAX_PATH + 3];
+	GetTempFileName(".", // dir. for temp. files 
+					"mp4",                // temp. filename prefix 
+					0,                    // create unique name 
+					tempFileName);        // buffer for name 
 #endif
 
-    return tempFileName;
+	return tempFileName;
 }
 
 void MP4File::Rename(const char* oldFileName, const char* newFileName)
 {
-    int rc;
+	int rc;
 
 #ifdef _WIN32
-    rc = remove(newFileName);
-    if (rc == 0) {
-        rc = rename(oldFileName, newFileName);
-    }
-    else
-        remove(oldFileName);
-
+	rc = remove(newFileName);
+	if (rc == 0) {
+		rc = rename(oldFileName, newFileName);
+	}
 #else
-    rc = rename(oldFileName, newFileName);
+	rc = rename(oldFileName, newFileName);
 #endif
-    if (rc != 0) {
-        throw new MP4Error(errno, "can't overwrite existing file", "Rename");
-    }
+	if (rc != 0) {
+		throw new MP4Error(errno, "can't overwrite existing file", "Rename");
+	}
 }
 
 void MP4File::ProtectWriteOperation(char* where)
 {
-    if (m_mode == 'r') {
-        throw new MP4Error("operation not permitted in read mode", where);
-    }
+	if (m_mode == 'r') {
+		throw new MP4Error("operation not permitted in read mode", where);
+	}
 }
 
 MP4Track* MP4File::GetTrack(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)];
+	return m_pTracks[FindTrackIndex(trackId)];
 }
 
 MP4Atom* MP4File::FindAtom(const char* name)
 {
-    MP4Atom* pAtom = NULL;
-    if (!name || !strcmp(name, "")) {
-        pAtom = m_pRootAtom;
-    } else {
-        pAtom = m_pRootAtom->FindAtom(name);
-    }
-    return pAtom;
+	MP4Atom* pAtom = NULL;
+	if (!name || !strcmp(name, "")) {
+		pAtom = m_pRootAtom;
+	} else {
+		pAtom = m_pRootAtom->FindAtom(name);
+	}
+	return pAtom;
 }
 
 MP4Atom* MP4File::AddChildAtom(
-    const char* parentName,
-    const char* childName)
+	const char* parentName, 
+	const char* childName)
 {
-    return AddChildAtom(FindAtom(parentName), childName);
+	return AddChildAtom(FindAtom(parentName), childName);
 }
 
 MP4Atom* MP4File::AddChildAtom(
-    MP4Atom* pParentAtom,
-    const char* childName)
+	MP4Atom* pParentAtom, 
+	const char* childName)
 {
-    return InsertChildAtom(pParentAtom, childName,
-        pParentAtom->GetNumberOfChildAtoms());
+	return InsertChildAtom(pParentAtom, childName, 
+		pParentAtom->GetNumberOfChildAtoms());
 }
 
 MP4Atom* MP4File::InsertChildAtom(
-    const char* parentName,
-    const char* childName,
-    u_int32_t index)
+	const char* parentName, 
+	const char* childName, 
+	u_int32_t index)
 {
-    return InsertChildAtom(FindAtom(parentName), childName, index);
+	return InsertChildAtom(FindAtom(parentName), childName, index); 
 }
 
 MP4Atom* MP4File::InsertChildAtom(
-    MP4Atom* pParentAtom,
-    const char* childName,
-    u_int32_t index)
+	MP4Atom* pParentAtom, 
+	const char* childName, 
+	u_int32_t index)
 {
-    MP4Atom* pChildAtom = MP4Atom::CreateAtom(childName);
+	MP4Atom* pChildAtom = MP4Atom::CreateAtom(childName);
 
-    ASSERT(pParentAtom);
-    pParentAtom->InsertChildAtom(pChildAtom, index);
+	ASSERT(pParentAtom);
+	pParentAtom->InsertChildAtom(pChildAtom, index);
 
-    pChildAtom->Generate();
+	pChildAtom->Generate();
 
-    return pChildAtom;
+	return pChildAtom;
 }
 
 MP4Atom* MP4File::AddDescendantAtoms(
-    const char* ancestorName,
-    const char* descendantNames)
+	const char* ancestorName, 
+	const char* descendantNames)
 {
-    return AddDescendantAtoms(FindAtom(ancestorName), descendantNames);
+	return AddDescendantAtoms(FindAtom(ancestorName), descendantNames);
 }
 
 MP4Atom* MP4File::AddDescendantAtoms(
-    MP4Atom* pAncestorAtom, const char* descendantNames)
+	MP4Atom* pAncestorAtom, const char* descendantNames)
 {
-    ASSERT(pAncestorAtom);
+	ASSERT(pAncestorAtom);
 
-    MP4Atom* pParentAtom = pAncestorAtom;
-    MP4Atom* pChildAtom = NULL;
+	MP4Atom* pParentAtom = pAncestorAtom;
+	MP4Atom* pChildAtom = NULL;
 
-    while (true) {
-        char* childName = MP4NameFirst(descendantNames);
+	while (true) {
+		char* childName = MP4NameFirst(descendantNames);
 
-        if (childName == NULL) {
-            break;
-        }
+		if (childName == NULL) {
+			break;
+		}
 
-        descendantNames = MP4NameAfterFirst(descendantNames);
+		descendantNames = MP4NameAfterFirst(descendantNames);
 
-        pChildAtom = pParentAtom->FindChildAtom(childName);
+		pChildAtom = pParentAtom->FindChildAtom(childName);
 
-        if (pChildAtom == NULL) {
-            pChildAtom = AddChildAtom(pParentAtom, childName);
-        }
+		if (pChildAtom == NULL) {
+			pChildAtom = AddChildAtom(pParentAtom, childName);
+		}
 
-        pParentAtom = pChildAtom;
+		pParentAtom = pChildAtom;
 
-        MP4Free(childName);
-    }
+		MP4Free(childName);
+	}
 
-    return pChildAtom;
+	return pChildAtom;
 }
 
-bool MP4File::FindProperty(const char* name,
-    MP4Property** ppProperty, u_int32_t* pIndex)
+bool MP4File::FindProperty(const char* name, 
+	MP4Property** ppProperty, u_int32_t* pIndex)
 {
-    if (pIndex) {
-        *pIndex = 0;    // set the default answer for index
-    }
+	if (pIndex) {
+		*pIndex = 0;	// set the default answer for index
+	}
 
-    return m_pRootAtom->FindProperty(name, ppProperty, pIndex);
+	return m_pRootAtom->FindProperty(name, ppProperty, pIndex);
 }
 
-void MP4File::FindIntegerProperty(const char* name,
-    MP4Property** ppProperty, u_int32_t* pIndex)
+void MP4File::FindIntegerProperty(const char* name, 
+	MP4Property** ppProperty, u_int32_t* pIndex)
 {
-    if (!FindProperty(name, ppProperty, pIndex)) {
-        throw new MP4Error("no such property - %s", "MP4File::FindIntegerProperty", name);
-    }
+	if (!FindProperty(name, ppProperty, pIndex)) {
+		throw new MP4Error("no such property - %s", "MP4File::FindIntegerProperty", name);
+	}
 
-    switch ((*ppProperty)->GetType()) {
-    case Integer8Property:
-    case Integer16Property:
-    case Integer24Property:
-    case Integer32Property:
-    case Integer64Property:
-        break;
-    default:
-      throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindIntegerProperty", name, (*ppProperty)->GetType());
-    }
+	switch ((*ppProperty)->GetType()) {
+	case Integer8Property:
+	case Integer16Property:
+	case Integer24Property:
+	case Integer32Property:
+	case Integer64Property:
+		break;
+	default:
+	  throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindIntegerProperty", name, (*ppProperty)->GetType());
+	}
 }
 
 u_int64_t MP4File::GetIntegerProperty(const char* name)
 {
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindIntegerProperty(name, &pProperty, &index);
+	FindIntegerProperty(name, &pProperty, &index);
 
-    return ((MP4IntegerProperty*)pProperty)->GetValue(index);
+	return ((MP4IntegerProperty*)pProperty)->GetValue(index);
 }
 
 void MP4File::SetIntegerProperty(const char* name, u_int64_t value)
 {
-    ProtectWriteOperation("SetIntegerProperty");
+	ProtectWriteOperation("SetIntegerProperty");
 
-    MP4Property* pProperty = NULL;
-    u_int32_t index = 0;
+	MP4Property* pProperty = NULL;
+	u_int32_t index = 0;
 
-    FindIntegerProperty(name, &pProperty, &index);
+	FindIntegerProperty(name, &pProperty, &index);
 
-    ((MP4IntegerProperty*)pProperty)->SetValue(value, index);
+	((MP4IntegerProperty*)pProperty)->SetValue(value, index);
 }
 
-void MP4File::FindFloatProperty(const char* name,
-    MP4Property** ppProperty, u_int32_t* pIndex)
+void MP4File::FindFloatProperty(const char* name, 
+	MP4Property** ppProperty, u_int32_t* pIndex)
 {
-    if (!FindProperty(name, ppProperty, pIndex)) {
-        throw new MP4Error("no such property - %s", "MP4File::FindFloatProperty", name);
-    }
-    if ((*ppProperty)->GetType() != Float32Property) {
-        throw new MP4Error("type mismatch - property %s type %d",
-                   "MP4File::FindFloatProperty",
-                   name,
-                   (*ppProperty)->GetType());
-    }
+	if (!FindProperty(name, ppProperty, pIndex)) {
+		throw new MP4Error("no such property - %s", "MP4File::FindFloatProperty", name);
+	}
+	if ((*ppProperty)->GetType() != Float32Property) {
+		throw new MP4Error("type mismatch - property %s type %d", 
+				   "MP4File::FindFloatProperty",
+				   name, 
+				   (*ppProperty)->GetType());
+	}
 }
 
 float MP4File::GetFloatProperty(const char* name)
 {
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindFloatProperty(name, &pProperty, &index);
+	FindFloatProperty(name, &pProperty, &index);
 
-    return ((MP4Float32Property*)pProperty)->GetValue(index);
+	return ((MP4Float32Property*)pProperty)->GetValue(index);
 }
 
 void MP4File::SetFloatProperty(const char* name, float value)
 {
-    ProtectWriteOperation("SetFloatProperty");
+	ProtectWriteOperation("SetFloatProperty");
 
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindFloatProperty(name, &pProperty, &index);
+	FindFloatProperty(name, &pProperty, &index);
 
-    ((MP4Float32Property*)pProperty)->SetValue(value, index);
+	((MP4Float32Property*)pProperty)->SetValue(value, index);
 }
 
-void MP4File::FindStringProperty(const char* name,
-    MP4Property** ppProperty, u_int32_t* pIndex)
+void MP4File::FindStringProperty(const char* name, 
+	MP4Property** ppProperty, u_int32_t* pIndex)
 {
-    if (!FindProperty(name, ppProperty, pIndex)) {
-        throw new MP4Error("no such property - %s", "MP4File::FindStringProperty", name);
-    }
-    if ((*ppProperty)->GetType() != StringProperty) {
-        throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindStringProperty",
-                   name, (*ppProperty)->GetType());
-    }
+	if (!FindProperty(name, ppProperty, pIndex)) {
+		throw new MP4Error("no such property - %s", "MP4File::FindStringProperty", name);
+	}
+	if ((*ppProperty)->GetType() != StringProperty) {
+		throw new MP4Error("type mismatch - property %s type %d", "MP4File::FindStringProperty",
+				   name, (*ppProperty)->GetType());
+	}
 }
 
 const char* MP4File::GetStringProperty(const char* name)
 {
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindStringProperty(name, &pProperty, &index);
+	FindStringProperty(name, &pProperty, &index);
 
-    return ((MP4StringProperty*)pProperty)->GetValue(index);
+	return ((MP4StringProperty*)pProperty)->GetValue(index);
 }
 
 void MP4File::SetStringProperty(const char* name, const char* value)
 {
-    ProtectWriteOperation("SetStringProperty");
+	ProtectWriteOperation("SetStringProperty");
 
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindStringProperty(name, &pProperty, &index);
+	FindStringProperty(name, &pProperty, &index);
 
-    ((MP4StringProperty*)pProperty)->SetValue(value, index);
+	((MP4StringProperty*)pProperty)->SetValue(value, index);
 }
 
-void MP4File::FindBytesProperty(const char* name,
-    MP4Property** ppProperty, u_int32_t* pIndex)
+void MP4File::FindBytesProperty(const char* name, 
+	MP4Property** ppProperty, u_int32_t* pIndex)
 {
-    if (!FindProperty(name, ppProperty, pIndex)) {
-        throw new MP4Error("no such property %s", "MP4File::FindBytesProperty", name);
-    }
-    if ((*ppProperty)->GetType() != BytesProperty) {
-        throw new MP4Error("type mismatch - property %s - type %d", "MP4File::FindBytesProperty", name, (*ppProperty)->GetType());
-    }
+	if (!FindProperty(name, ppProperty, pIndex)) {
+		throw new MP4Error("no such property %s", "MP4File::FindBytesProperty", name);
+	}
+	if ((*ppProperty)->GetType() != BytesProperty) {
+		throw new MP4Error("type mismatch - property %s - type %d", "MP4File::FindBytesProperty", name, (*ppProperty)->GetType());
+	}
 }
 
-void MP4File::GetBytesProperty(const char* name,
-    u_int8_t** ppValue, u_int32_t* pValueSize)
+void MP4File::GetBytesProperty(const char* name, 
+	u_int8_t** ppValue, u_int32_t* pValueSize)
 {
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindBytesProperty(name, &pProperty, &index);
+	FindBytesProperty(name, &pProperty, &index);
 
-    ((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index);
+	((MP4BytesProperty*)pProperty)->GetValue(ppValue, pValueSize, index);
 }
 
-void MP4File::SetBytesProperty(const char* name,
-    const u_int8_t* pValue, u_int32_t valueSize)
+void MP4File::SetBytesProperty(const char* name, 
+	const u_int8_t* pValue, u_int32_t valueSize)
 {
-    ProtectWriteOperation("SetBytesProperty");
+	ProtectWriteOperation("SetBytesProperty");
 
-    MP4Property* pProperty;
-    u_int32_t index;
+	MP4Property* pProperty;
+	u_int32_t index;
 
-    FindBytesProperty(name, &pProperty, &index);
+	FindBytesProperty(name, &pProperty, &index);
 
-    ((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index);
+	((MP4BytesProperty*)pProperty)->SetValue(pValue, valueSize, index);
 }
 
 
@@ -862,341 +841,358 @@
 
 MP4TrackId MP4File::AddTrack(const char* type, u_int32_t timeScale)
 {
-    ProtectWriteOperation("AddTrack");
+#if 0
+        ismacryp_rc_t rc = error1;
+        ismacryp_session_id_t mySession1 = 7;
+        rc=ismacrypInitSession(&mySession1);
+#endif
 
-    // create and add new trak atom
-    MP4Atom* pTrakAtom = AddChildAtom("moov", "trak");
+	ProtectWriteOperation("AddTrack");
 
-    // allocate a new track id
-    MP4TrackId trackId = AllocTrackId();
+	// create and add new trak atom
+	MP4Atom* pTrakAtom = AddChildAtom("moov", "trak");
 
-    m_trakIds.Add(trackId);
+	// allocate a new track id
+	MP4TrackId trackId = AllocTrackId();
 
-    // set track id
-    MP4Integer32Property* pInteger32Property = NULL;
-    pTrakAtom->FindProperty(
-        "trak.tkhd.trackId", (MP4Property**)&pInteger32Property);
-    ASSERT(pInteger32Property);
-    pInteger32Property->SetValue(trackId);
+	m_trakIds.Add(trackId);
 
-    // set track type
-    const char* normType = MP4Track::NormalizeTrackType(type);
+	// set track id
+	MP4Integer32Property* pInteger32Property = NULL;
+	pTrakAtom->FindProperty(
+		"trak.tkhd.trackId", (MP4Property**)&pInteger32Property);
+	ASSERT(pInteger32Property);
+	pInteger32Property->SetValue(trackId);
 
-    // sanity check for user defined types
-    if (strlen(normType) > 4) {
-        VERBOSE_WARNING(m_verbosity,
-            printf("AddTrack: type truncated to four characters\n"));
-        // StringProperty::SetValue() will do the actual truncation
-    }
+	// set track type
+	const char* normType = MP4Track::NormalizeTrackType(type);
 
-    MP4StringProperty* pStringProperty = NULL;
-    pTrakAtom->FindProperty(
-        "trak.mdia.hdlr.handlerType", (MP4Property**)&pStringProperty);
-    ASSERT(pStringProperty);
-    pStringProperty->SetValue(normType);
+	// sanity check for user defined types
+	if (strlen(normType) > 4) {
+		VERBOSE_WARNING(m_verbosity, 
+			printf("AddTrack: type truncated to four characters\n"));
+		// StringProperty::SetValue() will do the actual truncation
+	}
 
-    // set track time scale
-    pInteger32Property = NULL;
-    pTrakAtom->FindProperty(
-        "trak.mdia.mdhd.timeScale", (MP4Property**)&pInteger32Property);
-    ASSERT(pInteger32Property);
-    pInteger32Property->SetValue(timeScale ? timeScale : 1000);
+	MP4StringProperty* pStringProperty = NULL;
+	pTrakAtom->FindProperty(
+		"trak.mdia.hdlr.handlerType", (MP4Property**)&pStringProperty);
+	ASSERT(pStringProperty);
+	pStringProperty->SetValue(normType);
 
-    // now have enough to create MP4Track object
-    MP4Track* pTrack = NULL;
-    if (!strcmp(normType, MP4_HINT_TRACK_TYPE)) {
-        pTrack = new MP4RtpHintTrack(this, pTrakAtom);
-    } else {
-        pTrack = new MP4Track(this, pTrakAtom);
-    }
-    m_pTracks.Add(pTrack);
+	// set track time scale
+	pInteger32Property = NULL;
+	pTrakAtom->FindProperty(
+		"trak.mdia.mdhd.timeScale", (MP4Property**)&pInteger32Property);
+	ASSERT(pInteger32Property);
+	pInteger32Property->SetValue(timeScale ? timeScale : 1000);
 
-    // mark non-hint tracks as enabled
-    if (strcmp(normType, MP4_HINT_TRACK_TYPE)) {
-        SetTrackIntegerProperty(trackId, "tkhd.flags", 1);
-    }
+	// now have enough to create MP4Track object
+	MP4Track* pTrack = NULL;
+	if (!strcmp(normType, MP4_HINT_TRACK_TYPE)) {
+	  pTrack = new MP4RtpHintTrack(this, pTrakAtom);
+	} else {
+	  pTrack = new MP4Track(this, pTrakAtom);
+	}
+	m_pTracks.Add(pTrack);
 
-    // mark track as contained in this file
-    // LATER will provide option for external data references
-    AddDataReference(trackId, NULL);
+	// mark non-hint tracks as enabled
+	if (strcmp(normType, MP4_HINT_TRACK_TYPE)) {
+	  SetTrackIntegerProperty(trackId, "tkhd.flags", 1);
+	}
 
-    return trackId;
+	// mark track as contained in this file
+	// LATER will provide option for external data references
+	AddDataReference(trackId, NULL);
+
+	return trackId;
 }
 
 void MP4File::AddTrackToIod(MP4TrackId trackId)
 {
-    MP4DescriptorProperty* pDescriptorProperty = NULL;
-    m_pRootAtom->FindProperty("moov.iods.esIds",
-        (MP4Property**)&pDescriptorProperty);
-    ASSERT(pDescriptorProperty);
+	MP4DescriptorProperty* pDescriptorProperty = NULL;
+	m_pRootAtom->FindProperty("moov.iods.esIds", 
+		(MP4Property**)&pDescriptorProperty);
+	ASSERT(pDescriptorProperty);
 
-    MP4Descriptor* pDescriptor =
-        pDescriptorProperty->AddDescriptor(MP4ESIDIncDescrTag);
-    ASSERT(pDescriptor);
+	MP4Descriptor* pDescriptor = 
+		pDescriptorProperty->AddDescriptor(MP4ESIDIncDescrTag);
+	ASSERT(pDescriptor);
 
-    MP4Integer32Property* pIdProperty = NULL;
-    pDescriptor->FindProperty("id",
-        (MP4Property**)&pIdProperty);
-    ASSERT(pIdProperty);
+	MP4Integer32Property* pIdProperty = NULL;
+	pDescriptor->FindProperty("id", 
+		(MP4Property**)&pIdProperty);
+	ASSERT(pIdProperty);
 
-    pIdProperty->SetValue(trackId);
+	pIdProperty->SetValue(trackId);
 }
 
 void MP4File::RemoveTrackFromIod(MP4TrackId trackId)
 {
-    MP4DescriptorProperty* pDescriptorProperty = NULL;
-    m_pRootAtom->FindProperty("moov.iods.esIds",
-        (MP4Property**)&pDescriptorProperty);
-    ASSERT(pDescriptorProperty);
+	MP4DescriptorProperty* pDescriptorProperty = NULL;
+	m_pRootAtom->FindProperty("moov.iods.esIds",
+		(MP4Property**)&pDescriptorProperty);
+	ASSERT(pDescriptorProperty);
 
-    for (u_int32_t i = 0; i < pDescriptorProperty->GetCount(); i++) {
-        static char name[32];
-        snprintf(name, sizeof(name), "esIds[%u].id", i);
+	for (u_int32_t i = 0; i < pDescriptorProperty->GetCount(); i++) {
+		static char name[32];
+		snprintf(name, sizeof(name), "esIds[%u].id", i);
 
-        MP4Integer32Property* pIdProperty = NULL;
-        pDescriptorProperty->FindProperty(name,
-            (MP4Property**)&pIdProperty);
-        ASSERT(pIdProperty);
+		MP4Integer32Property* pIdProperty = NULL;
+		pDescriptorProperty->FindProperty(name, 
+			(MP4Property**)&pIdProperty);
+		ASSERT(pIdProperty);
 
-        if (pIdProperty->GetValue() == trackId) {
-            pDescriptorProperty->DeleteDescriptor(i);
-            break;
-        }
-    }
+		if (pIdProperty->GetValue() == trackId) {
+			pDescriptorProperty->DeleteDescriptor(i);
+			break;
+		}
+	}
 }
 
 void MP4File::AddTrackToOd(MP4TrackId trackId)
 {
-    if (!m_odTrackId) {
-        return;
-    }
+	if (!m_odTrackId) {
+		return;
+	}
 
-    AddTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId);
+	AddTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId);
 }
 
 void MP4File::RemoveTrackFromOd(MP4TrackId trackId)
 {
-    if (!m_odTrackId) {
-        return;
-    }
+	if (!m_odTrackId) {
+		return;
+	}
 
-    RemoveTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId);
+	RemoveTrackReference(MakeTrackName(m_odTrackId, "tref.mpod"), trackId);
 }
 
 void MP4File::GetTrackReferenceProperties(const char* trefName,
-    MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty)
+	MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty)
 {
-    char propName[1024];
+	char propName[1024];
 
-    snprintf(propName, sizeof(propName), "%s.%s", trefName, "entryCount");
-    m_pRootAtom->FindProperty(propName, ppCountProperty);
-    ASSERT(*ppCountProperty);
+	snprintf(propName, sizeof(propName), "%s.%s", trefName, "entryCount");
+	m_pRootAtom->FindProperty(propName, ppCountProperty);
+	ASSERT(*ppCountProperty);
 
-    snprintf(propName, sizeof(propName), "%s.%s", trefName, "entries.trackId");
-    m_pRootAtom->FindProperty(propName, ppTrackIdProperty);
-    ASSERT(*ppTrackIdProperty);
+	snprintf(propName, sizeof(propName), "%s.%s", trefName, "entries.trackId");
+	m_pRootAtom->FindProperty(propName, ppTrackIdProperty);
+	ASSERT(*ppTrackIdProperty);
 }
 
 void MP4File::AddTrackReference(const char* trefName, MP4TrackId refTrackId)
 {
-    MP4Integer32Property* pCountProperty = NULL;
-    MP4Integer32Property* pTrackIdProperty = NULL;
+	MP4Integer32Property* pCountProperty = NULL;
+	MP4Integer32Property* pTrackIdProperty = NULL;
 
-    GetTrackReferenceProperties(trefName,
-        (MP4Property**)&pCountProperty,
-        (MP4Property**)&pTrackIdProperty);
+	GetTrackReferenceProperties(trefName,
+		(MP4Property**)&pCountProperty, 
+		(MP4Property**)&pTrackIdProperty);
 
-    pTrackIdProperty->AddValue(refTrackId);
-    pCountProperty->IncrementValue();
+	pTrackIdProperty->AddValue(refTrackId);
+	pCountProperty->IncrementValue();
 }
 
-u_int32_t MP4File::FindTrackReference(const char* trefName,
-    MP4TrackId refTrackId)
+u_int32_t MP4File::FindTrackReference(const char* trefName, 
+	MP4TrackId refTrackId)
 {
-    MP4Integer32Property* pCountProperty = NULL;
-    MP4Integer32Property* pTrackIdProperty = NULL;
+	MP4Integer32Property* pCountProperty = NULL;
+	MP4Integer32Property* pTrackIdProperty = NULL;
 
-    GetTrackReferenceProperties(trefName,
-        (MP4Property**)&pCountProperty,
-        (MP4Property**)&pTrackIdProperty);
+	GetTrackReferenceProperties(trefName, 
+		(MP4Property**)&pCountProperty, 
+		(MP4Property**)&pTrackIdProperty);
 
-    for (u_int32_t i = 0; i < pCountProperty->GetValue(); i++) {
-        if (refTrackId == pTrackIdProperty->GetValue(i)) {
-            return i + 1;   // N.B. 1 not 0 based index
-        }
-    }
-    return 0;
+	for (u_int32_t i = 0; i < pCountProperty->GetValue(); i++) {
+		if (refTrackId == pTrackIdProperty->GetValue(i)) {
+			return i + 1;	// N.B. 1 not 0 based index
+		}
+	}
+	return 0;
 }
 
 void MP4File::RemoveTrackReference(const char* trefName, MP4TrackId refTrackId)
 {
-    MP4Integer32Property* pCountProperty = NULL;
-    MP4Integer32Property* pTrackIdProperty = NULL;
+	MP4Integer32Property* pCountProperty = NULL;
+	MP4Integer32Property* pTrackIdProperty = NULL;
 
-    GetTrackReferenceProperties(trefName,
-        (MP4Property**)&pCountProperty,
-        (MP4Property**)&pTrackIdProperty);
+	GetTrackReferenceProperties(trefName,
+		(MP4Property**)&pCountProperty, 
+		(MP4Property**)&pTrackIdProperty);
 
-    for (u_int32_t i = 0; i < pCountProperty->GetValue(); i++) {
-        if (refTrackId == pTrackIdProperty->GetValue(i)) {
-            pTrackIdProperty->DeleteValue(i);
-            pCountProperty->IncrementValue(-1);
-        }
-    }
+	for (u_int32_t i = 0; i < pCountProperty->GetValue(); i++) {
+		if (refTrackId == pTrackIdProperty->GetValue(i)) {
+			pTrackIdProperty->DeleteValue(i);
+			pCountProperty->IncrementValue(-1);
+		}
+	}
 }
 
 void MP4File::AddDataReference(MP4TrackId trackId, const char* url)
 {
-    MP4Atom* pDrefAtom =
-        FindAtom(MakeTrackName(trackId, "mdia.minf.dinf.dref"));
-    ASSERT(pDrefAtom);
+	MP4Atom* pDrefAtom = 
+		FindAtom(MakeTrackName(trackId, "mdia.minf.dinf.dref"));
+	ASSERT(pDrefAtom);
 
-    MP4Integer32Property* pCountProperty = NULL;
-    pDrefAtom->FindProperty("dref.entryCount",
-        (MP4Property**)&pCountProperty);
-    ASSERT(pCountProperty);
-    pCountProperty->IncrementValue();
+	MP4Integer32Property* pCountProperty = NULL;
+	pDrefAtom->FindProperty("dref.entryCount", 
+		(MP4Property**)&pCountProperty);
+	ASSERT(pCountProperty);
+	pCountProperty->IncrementValue();
 
-    MP4Atom* pUrlAtom = AddChildAtom(pDrefAtom, "url ");
+	MP4Atom* pUrlAtom = AddChildAtom(pDrefAtom, "url ");
 
-    if (url && url[0] != '\0') {
-        pUrlAtom->SetFlags(pUrlAtom->GetFlags() & 0xFFFFFE);
+	if (url && url[0] != '\0') {
+		pUrlAtom->SetFlags(pUrlAtom->GetFlags() & 0xFFFFFE);
 
-        MP4StringProperty* pUrlProperty = NULL;
-        pUrlAtom->FindProperty("url .location",
-            (MP4Property**)&pUrlProperty);
-        ASSERT(pUrlProperty);
-        pUrlProperty->SetValue(url);
-    } else {
-        pUrlAtom->SetFlags(pUrlAtom->GetFlags() | 1);
-    }
+		MP4StringProperty* pUrlProperty = NULL;
+		pUrlAtom->FindProperty("url .location",
+			(MP4Property**)&pUrlProperty);
+		ASSERT(pUrlProperty);
+		pUrlProperty->SetValue(url);
+	} else {
+		pUrlAtom->SetFlags(pUrlAtom->GetFlags() | 1);
+	}
 }
 
 MP4TrackId MP4File::AddSystemsTrack(const char* type)
 {
-    const char* normType = MP4Track::NormalizeTrackType(type);
+	const char* normType = MP4Track::NormalizeTrackType(type); 
 
-    // TBD if user type, fix name to four chars, and warn
+	// TBD if user type, fix name to four chars, and warn
 
-    MP4TrackId trackId = AddTrack(type, MP4_MSECS_TIME_SCALE);
+	MP4TrackId trackId = AddTrack(type, MP4_MSECS_TIME_SCALE);
 
-    InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0);
+	InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "nmhd", 0);
 
-    AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4s");
+	AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4s");
 
-    // stsd is a unique beast in that it has a count of the number
-    // of child atoms that needs to be incremented after we add the mp4s atom
-    MP4Integer32Property* pStsdCountProperty;
-    FindIntegerProperty(
-        MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-        (MP4Property**)&pStsdCountProperty);
-    pStsdCountProperty->IncrementValue();
+	// stsd is a unique beast in that it has a count of the number 
+	// of child atoms that needs to be incremented after we add the mp4s atom
+	MP4Integer32Property* pStsdCountProperty;
+	FindIntegerProperty(
+		MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		(MP4Property**)&pStsdCountProperty);
+	pStsdCountProperty->IncrementValue();
 
-    SetTrackIntegerProperty(trackId,
-                "mdia.minf.stbl.stsd.mp4s.esds.ESID",
+	SetTrackIntegerProperty(trackId, 
+				"mdia.minf.stbl.stsd.mp4s.esds.ESID", 
 #if 0
-                // note - for a file, these values need to
-                // be 0 - wmay - 04/16/2003
-                trackId
+				// note - for a file, these values need to 
+				// be 0 - wmay - 04/16/2003
+				trackId
 #else
-                0
+				0
 #endif
-                );
+				);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.objectTypeId",
-        MP4SystemsV1ObjectType);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.objectTypeId", 
+		MP4SystemsV1ObjectType);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.streamType",
-        ConvertTrackTypeToStreamType(normType));
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4s.esds.decConfigDescr.streamType", 
+		ConvertTrackTypeToStreamType(normType));
 
-    return trackId;
+	return trackId;
 }
 
 MP4TrackId MP4File::AddODTrack()
 {
-    // until a demonstrated need emerges
-    // we limit ourselves to one object description track
-    if (m_odTrackId != MP4_INVALID_TRACK_ID) {
-        throw new MP4Error("object description track already exists",
-            "AddObjectDescriptionTrack");
-    }
+	// until a demonstrated need emerges
+	// we limit ourselves to one object description track
+	if (m_odTrackId != MP4_INVALID_TRACK_ID) {
+		throw new MP4Error("object description track already exists",
+			"AddObjectDescriptionTrack");
+	}
 
-    m_odTrackId = AddSystemsTrack(MP4_OD_TRACK_TYPE);
+	m_odTrackId = AddSystemsTrack(MP4_OD_TRACK_TYPE);
 
-    AddTrackToIod(m_odTrackId);
+	AddTrackToIod(m_odTrackId);
 
-    AddDescendantAtoms(MakeTrackName(m_odTrackId, NULL), "tref.mpod");
+	AddDescendantAtoms(MakeTrackName(m_odTrackId, NULL), "tref.mpod");
 
-    return m_odTrackId;
+	return m_odTrackId;
 }
 
 MP4TrackId MP4File::AddSceneTrack()
 {
-    MP4TrackId trackId = AddSystemsTrack(MP4_SCENE_TRACK_TYPE);
+	MP4TrackId trackId = AddSystemsTrack(MP4_SCENE_TRACK_TYPE);
 
-    AddTrackToIod(trackId);
-    AddTrackToOd(trackId);
+	AddTrackToIod(trackId);
+	AddTrackToOd(trackId);
 
-    return trackId;
+	return trackId;
 }
 
 MP4TrackId MP4File::AddAudioTrack(
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int8_t audioType)
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration, 
+	u_int8_t audioType)
 {
-    MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale);
+	MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale);
 
-    AddTrackToOd(trackId);
+	AddTrackToOd(trackId);
 
-    SetTrackFloatProperty(trackId, "tkhd.volume", 1.0);
+	SetTrackFloatProperty(trackId, "tkhd.volume", 1.0);
 
-    InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0);
+	InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0);
 
-    AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4a");
+	AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4a");
 
-    // stsd is a unique beast in that it has a count of the number
-    // of child atoms that needs to be incremented after we add the mp4a atom
-    MP4Integer32Property* pStsdCountProperty;
-    FindIntegerProperty(
-        MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-        (MP4Property**)&pStsdCountProperty);
-    pStsdCountProperty->IncrementValue();
+	// stsd is a unique beast in that it has a count of the number 
+	// of child atoms that needs to be incremented after we add the mp4a atom
+	MP4Integer32Property* pStsdCountProperty;
+	FindIntegerProperty(
+		MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		(MP4Property**)&pStsdCountProperty);
+	pStsdCountProperty->IncrementValue();
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4a.timeScale", timeScale);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4a.timeScale", timeScale);
 
-    SetTrackIntegerProperty(trackId,
-                "mdia.minf.stbl.stsd.mp4a.esds.ESID",
+	SetTrackIntegerProperty(trackId, 
+				"mdia.minf.stbl.stsd.mp4a.esds.ESID", 
 #if 0
-                // note - for a file, these values need to
-                // be 0 - wmay - 04/16/2003
-                trackId
+				// note - for a file, these values need to 
+				// be 0 - wmay - 04/16/2003
+				trackId
 #else
-                0
+				0
 #endif
-                );
+				);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.objectTypeId",
-        audioType);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.objectTypeId", 
+		audioType);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.streamType",
-        MP4AudioStreamType);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.streamType", 
+		MP4AudioStreamType);
 
-    m_pTracks[FindTrackIndex(trackId)]->
-        SetFixedSampleDuration(sampleDuration);
+	m_pTracks[FindTrackIndex(trackId)]->
+		SetFixedSampleDuration(sampleDuration);
 
-    return trackId;
+	return trackId;
 }
 
-MP4TrackId MP4File::AddEncAudioTrack(u_int32_t timeScale,
-                     MP4Duration sampleDuration,
-                     u_int8_t audioType)
+#ifdef ISMACRYP
+MP4TrackId MP4File::AddEncAudioTrack(u_int32_t timeScale, 
+				     MP4Duration sampleDuration, 
+				     u_int8_t audioType,
+				     ismacryp_session_id_t ismaCryptSId)
 {
+  ismacryp_scheme_t scheme_type;
+  ismacryp_schemeversion_t scheme_version;
+  u_int32_t original_fmt = 0;
+  u_int8_t key_ind_len = 0;
+  u_int8_t iv_len = 0;
+  bool selective_enc = FALSE;
+  char *kms_uri = NULL;
+  /**/
+
   MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale);
 
   AddTrackToOd(trackId);
@@ -1207,35 +1203,91 @@
 
   AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "enca");
 
-  // stsd is a unique beast in that it has a count of the number
+  // stsd is a unique beast in that it has a count of the number 
   // of child atoms that needs to be incremented after we add the enca atom
   MP4Integer32Property* pStsdCountProperty;
-  FindIntegerProperty(
-              MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-              (MP4Property**)&pStsdCountProperty);
+  FindIntegerProperty(MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		      (MP4Property**)&pStsdCountProperty);
   pStsdCountProperty->IncrementValue();
 
+
+  /* set all the ismacryp-specific values */
+  // original format is mp4a
+  original_fmt = ('m'<<24 | 'p'<<16 | '4'<<8 | 'a');
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsd.enca.timeScale", timeScale);
+			  "mdia.minf.stbl.stsd.enca.sinf.frma.data-format", 
+			  original_fmt);
 
+  if (ismacrypGetScheme(ismaCryptSId, &scheme_type) != 0) {
+    throw new MP4Error("can't get the ismacryp scheme type", "AddEncAudioTrack");
+  }
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsd.enca.esds.ESID",
+			  "mdia.minf.stbl.stsd.enca.sinf.schm.scheme_type", 
+			  scheme_type);
+
+  if (ismacrypGetSchemeVersion(ismaCryptSId, &scheme_version) != 0) {
+    throw new MP4Error("can't get the ismacryp scheme version", "AddEncAudioTrack");
+  }
+  SetTrackIntegerProperty(trackId,
+			  "mdia.minf.stbl.stsd.enca.sinf.schm.scheme_version", 
+			  scheme_version);
+  
+  if (ismacrypGetKMSUri(ismaCryptSId, &kms_uri) != 0) {
+    if (kms_uri != NULL) {
+      free(kms_uri);
+    }
+    throw new MP4Error("can't get the ismacryp KMS URI", "AddEncAudioTrack");
+  }
+  SetTrackStringProperty(trackId,
+			 "mdia.minf.stbl.stsd.enca.sinf.schi.iKMS.kms_URI", 
+			 kms_uri);
+  if (kms_uri != NULL) {
+    free(kms_uri);
+  }  
+
+  if (ismacrypGetSelectiveEncryption(ismaCryptSId, &selective_enc) != 0) {
+    throw new MP4Error("can't get the ismacryp selective encryption flag", "AddEncAudioTrack");
+  }
+  SetTrackIntegerProperty(trackId,
+			  "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.selective-encryption", 
+			  selective_enc);
+
+  if (ismacrypGetKeyIndicatorLength(ismaCryptSId, &key_ind_len) != 0) {
+    throw new MP4Error("can't get the ismacryp key indicator length", "AddEncAudioTrack");
+  }
+  SetTrackIntegerProperty(trackId,
+			  "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.key-indicator-length", 
+			  key_ind_len);
+
+  if (ismacrypGetIVLength(ismaCryptSId, &iv_len) != 0) {
+    throw new MP4Error("can't get the ismacryp IV length", "AddEncAudioTrack");
+  }
+  SetTrackIntegerProperty(trackId,
+			  "mdia.minf.stbl.stsd.enca.sinf.schi.iSFM.IV-length", 
+			  iv_len);
+  /* end ismacryp */
+
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.enca.timeScale", timeScale);
+
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.enca.esds.ESID", 
 #if 0
-              // note - for a file, these values need to
-              // be 0 - wmay - 04/16/2003
-              trackId
+			  // note - for a file, these values need to 
+			  // be 0 - wmay - 04/16/2003
+			  trackId
 #else
-              0
+			  0
 #endif
-              );
+			  );
 
-  SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.objectTypeId",
-              audioType);
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.objectTypeId", 
+			  audioType);
 
-  SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.streamType",
-              MP4AudioStreamType);
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.enca.esds.decConfigDescr.streamType", 
+			  MP4AudioStreamType);
 
   m_pTracks[FindTrackIndex(trackId)]->
     SetFixedSampleDuration(sampleDuration);
@@ -1242,72 +1294,84 @@
 
   return trackId;
 }
+#endif
 
 MP4TrackId MP4File::AddVideoTrack(
-    u_int32_t timeScale,
-    MP4Duration sampleDuration,
-    u_int16_t width,
-    u_int16_t height,
-    u_int8_t videoType)
+	u_int32_t timeScale, 
+	MP4Duration sampleDuration, 
+	u_int16_t width, 
+	u_int16_t height, 
+	u_int8_t videoType)
 {
-    MP4TrackId trackId = AddTrack(MP4_VIDEO_TRACK_TYPE, timeScale);
+	MP4TrackId trackId = AddTrack(MP4_VIDEO_TRACK_TYPE, timeScale);
 
-    AddTrackToOd(trackId);
+	AddTrackToOd(trackId);
 
-    SetTrackFloatProperty(trackId, "tkhd.width", width);
-    SetTrackFloatProperty(trackId, "tkhd.height", height);
+	SetTrackFloatProperty(trackId, "tkhd.width", width);
+	SetTrackFloatProperty(trackId, "tkhd.height", height);
 
-    InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "vmhd", 0);
+	InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "vmhd", 0);
 
-    AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4v");
+	AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4v");
 
-    // stsd is a unique beast in that it has a count of the number
-    // of child atoms that needs to be incremented after we add the mp4v atom
-    MP4Integer32Property* pStsdCountProperty;
-    FindIntegerProperty(
-        MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-        (MP4Property**)&pStsdCountProperty);
-    pStsdCountProperty->IncrementValue();
+	// stsd is a unique beast in that it has a count of the number 
+	// of child atoms that needs to be incremented after we add the mp4v atom
+	MP4Integer32Property* pStsdCountProperty;
+	FindIntegerProperty(
+		MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		(MP4Property**)&pStsdCountProperty);
+	pStsdCountProperty->IncrementValue();
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4v.width", width);
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4v.height", height);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4v.width", width);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4v.height", height);
 
-    SetTrackIntegerProperty(trackId,
-                "mdia.minf.stbl.stsd.mp4v.esds.ESID",
+	SetTrackIntegerProperty(trackId, 
+				"mdia.minf.stbl.stsd.mp4v.esds.ESID", 
 #if 0
-                // note - for a file, these values need to
-                // be 0 - wmay - 04/16/2003
-                trackId
+				// note - for a file, these values need to 
+				// be 0 - wmay - 04/16/2003
+				trackId
 #else
-                0
+				0
 #endif
-                );
+				);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.objectTypeId",
-        videoType);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.objectTypeId", 
+		videoType);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.streamType",
-        MP4VisualStreamType);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.streamType", 
+		MP4VisualStreamType);
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsz.sampleSize", sampleDuration);
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsz.sampleSize", sampleDuration);
 
-    m_pTracks[FindTrackIndex(trackId)]->
-        SetFixedSampleDuration(sampleDuration);
+	m_pTracks[FindTrackIndex(trackId)]->
+		SetFixedSampleDuration(sampleDuration);
 
-    return trackId;
+	return trackId;
 }
 
-MP4TrackId MP4File::AddEncVideoTrack(u_int32_t timeScale,
-                     MP4Duration sampleDuration,
-                     u_int16_t width,
-                     u_int16_t height,
-                     u_int8_t videoType)
+#ifdef ISMACRYP
+MP4TrackId MP4File::AddEncVideoTrack(u_int32_t timeScale, 
+				     MP4Duration sampleDuration, 
+				     u_int16_t width, 
+				     u_int16_t height, 
+				     ismacryp_session_id_t ismaCryptSId,
+				     u_int8_t videoType)
 {
+  ismacryp_scheme_t scheme_type;
+  ismacryp_schemeversion_t scheme_version;
+  u_int32_t original_fmt = 0;
+  u_int8_t key_ind_len = 0;
+  u_int8_t iv_len = 0;
+  bool selective_enc = FALSE;
+  char *kms_uri = NULL;
+  /**/
+
   MP4TrackId trackId = AddTrack(MP4_VIDEO_TRACK_TYPE, timeScale);
 
   AddTrackToOd(trackId);
@@ -1319,185 +1383,243 @@
 
   AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "encv");
 
-  // stsd is a unique beast in that it has a count of the number
+  // stsd is a unique beast in that it has a count of the number 
   // of child atoms that needs to be incremented after we add the encv atom
   MP4Integer32Property* pStsdCountProperty;
   FindIntegerProperty(
-              MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-              (MP4Property**)&pStsdCountProperty);
+		      MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		      (MP4Property**)&pStsdCountProperty);
   pStsdCountProperty->IncrementValue();
 
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.encv.width", width);
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.encv.height", height);
+
+  /* set all the ismacryp-specific values */
+  // original format is mp4v
+  original_fmt = ('m'<<24 | 'p'<<16 | '4'<<8 | 'v');
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsd.encv.width", width);
+			  "mdia.minf.stbl.stsd.encv.sinf.frma.data-format", 
+			  original_fmt);
+
+  if (ismacrypGetScheme(ismaCryptSId, &scheme_type) != 0) {
+    throw new MP4Error("can't get the ismacryp scheme type", "AddEncVideoTrack");
+  }
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsd.encv.height", height);
+			  "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_type", 
+			  scheme_type);
 
+  if (ismacrypGetSchemeVersion(ismaCryptSId, &scheme_version) != 0) {
+    throw new MP4Error("can't get the ismacryp scheme version", "AddEncVideoTrack");
+  }
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsd.encv.esds.ESID",
-#if 0
-              // note - for a file, these values need to
-              // be 0 - wmay - 04/16/2003
-              trackId
-#else
-              0
-#endif
-              );
+			  "mdia.minf.stbl.stsd.encv.sinf.schm.scheme_version", 
+			  scheme_version);
+  
+  if (ismacrypGetKMSUri(ismaCryptSId, &kms_uri) != 0) {
+    if (kms_uri != NULL) {
+      free(kms_uri);
+    }
+    throw new MP4Error("can't get the ismacryp KMS URI", "AddEncVideoTrack");
+  }
+  SetTrackStringProperty(trackId,
+			 "mdia.minf.stbl.stsd.encv.sinf.schi.iKMS.kms_URI", 
+			 kms_uri);
+  if (kms_uri != NULL) {
+    free(kms_uri);
+  }  
 
+  if (ismacrypGetSelectiveEncryption(ismaCryptSId, &selective_enc) != 0) {
+    throw new MP4Error("can't get the ismacryp selective encryption flag", "AddEncVideoTrack");
+  }
   SetTrackIntegerProperty(trackId,
-          "mdia.minf.stbl.stsd.encv.esds.decConfigDescr.objectTypeId",
-              videoType);
+			  "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.selective-encryption", 
+			  selective_enc);
 
+  if (ismacrypGetKeyIndicatorLength(ismaCryptSId, &key_ind_len) != 0) {
+    throw new MP4Error("can't get the ismacryp key indicator length", "AddEncVideoTrack");
+  }
   SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.encv.esds.decConfigDescr.streamType",
-              MP4VisualStreamType);
+			  "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.key-indicator-length", 
+			  key_ind_len);
 
+  if (ismacrypGetIVLength(ismaCryptSId, &iv_len) != 0) {
+    throw new MP4Error("can't get the ismacryp IV length", "AddEncVideoTrack");
+  }
   SetTrackIntegerProperty(trackId,
-              "mdia.minf.stbl.stsz.sampleSize", sampleDuration);
+			  "mdia.minf.stbl.stsd.encv.sinf.schi.iSFM.IV-length", 
+			  iv_len);
+  /* end ismacryp */
 
+
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsd.encv.esds.ESID", 
+#if 0
+			  // note - for a file, these values need to 
+			  // be 0 - wmay - 04/16/2003
+			  trackId
+#else
+			  0
+#endif
+			  );
+
+  SetTrackIntegerProperty(trackId, 
+		  "mdia.minf.stbl.stsd.encv.esds.decConfigDescr.objectTypeId", 
+			  videoType);
+
+  SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.encv.esds.decConfigDescr.streamType", 
+			  MP4VisualStreamType);
+
+  SetTrackIntegerProperty(trackId, 
+			  "mdia.minf.stbl.stsz.sampleSize", sampleDuration);
+
   m_pTracks[FindTrackIndex(trackId)]->
     SetFixedSampleDuration(sampleDuration);
 
   return trackId;
 }
+#endif
 
 MP4TrackId MP4File::AddHintTrack(MP4TrackId refTrackId)
 {
-    // validate reference track id
-    FindTrackIndex(refTrackId);
+	// validate reference track id
+	FindTrackIndex(refTrackId);
 
-    MP4TrackId trackId =
-        AddTrack(MP4_HINT_TRACK_TYPE, GetTrackTimeScale(refTrackId));
+	MP4TrackId trackId = 
+		AddTrack(MP4_HINT_TRACK_TYPE, GetTrackTimeScale(refTrackId));
 
-    InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "hmhd", 0);
+	InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "hmhd", 0);
 
-    AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "rtp ");
+	AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "rtp ");
 
-    // stsd is a unique beast in that it has a count of the number
-    // of child atoms that needs to be incremented after we add the rtp atom
-    MP4Integer32Property* pStsdCountProperty;
-    FindIntegerProperty(
-        MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
-        (MP4Property**)&pStsdCountProperty);
-    pStsdCountProperty->IncrementValue();
+	// stsd is a unique beast in that it has a count of the number 
+	// of child atoms that needs to be incremented after we add the rtp atom
+	MP4Integer32Property* pStsdCountProperty;
+	FindIntegerProperty(
+		MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+		(MP4Property**)&pStsdCountProperty);
+	pStsdCountProperty->IncrementValue();
 
-    SetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.rtp .tims.timeScale",
-        GetTrackTimeScale(trackId));
+	SetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.rtp .tims.timeScale", 
+		GetTrackTimeScale(trackId));
 
-    AddDescendantAtoms(MakeTrackName(trackId, NULL), "tref.hint");
+	AddDescendantAtoms(MakeTrackName(trackId, NULL), "tref.hint");
 
-    AddTrackReference(MakeTrackName(trackId, "tref.hint"), refTrackId);
+	AddTrackReference(MakeTrackName(trackId, "tref.hint"), refTrackId);
 
-    AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hnti.sdp ");
+	AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hnti.sdp ");
 
-    AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hinf");
+	AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.hinf");
 
-    return trackId;
+	return trackId;
 }
 
 void MP4File::DeleteTrack(MP4TrackId trackId)
 {
-    ProtectWriteOperation("MP4DeleteTrack");
+	ProtectWriteOperation("MP4DeleteTrack");
 
-    u_int32_t trakIndex = FindTrakAtomIndex(trackId);
-    u_int16_t trackIndex = FindTrackIndex(trackId);
-    MP4Track* pTrack = m_pTracks[trackIndex];
+	u_int32_t trakIndex = FindTrakAtomIndex(trackId);
+	u_int16_t trackIndex = FindTrackIndex(trackId);
+	MP4Track* pTrack = m_pTracks[trackIndex];
 
-    MP4Atom* pTrakAtom = pTrack->GetTrakAtom();
-    ASSERT(pTrakAtom);
+	MP4Atom* pTrakAtom = pTrack->GetTrakAtom();
+	ASSERT(pTrakAtom);
 
-    MP4Atom* pMoovAtom = FindAtom("moov");
-    ASSERT(pMoovAtom);
+	MP4Atom* pMoovAtom = FindAtom("moov");
+	ASSERT(pMoovAtom);
 
-    RemoveTrackFromIod(trackId);
-    RemoveTrackFromOd(trackId);
+	RemoveTrackFromIod(trackId);
+	RemoveTrackFromOd(trackId);
 
-    if (trackId == m_odTrackId) {
-        m_odTrackId = 0;
-    }
+	if (trackId == m_odTrackId) {
+		m_odTrackId = 0;
+	}
 
-    pMoovAtom->DeleteChildAtom(pTrakAtom);
+	pMoovAtom->DeleteChildAtom(pTrakAtom);
 
-    m_trakIds.Delete(trakIndex);
+	m_trakIds.Delete(trakIndex);
 
-    m_pTracks.Delete(trackIndex);
+	m_pTracks.Delete(trackIndex);
 
-    delete pTrack;
-    delete pTrakAtom;
+	delete pTrack;
+	delete pTrakAtom;
 }
 
 u_int32_t MP4File::GetNumberOfTracks(const char* type, u_int8_t subType)
 {
-    if (type == NULL) {
-        return m_pTracks.Size();
-    }
+	if (type == NULL) {
+		return m_pTracks.Size();
+	} 
 
-    u_int32_t typeSeen = 0;
-    const char* normType = MP4Track::NormalizeTrackType(type);
+	u_int32_t typeSeen = 0;
+	const char* normType = MP4Track::NormalizeTrackType(type);
 
-    for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
-        if (!strcmp(normType, m_pTracks[i]->GetType())) {
-            if (subType) {
-                if (normType == MP4_AUDIO_TRACK_TYPE) {
-                    if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
-                        continue;
-                    }
-                } else if (normType == MP4_VIDEO_TRACK_TYPE) {
-                    if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
-                        continue;
-                    }
-                }
-                // else unknown subtype, ignore it
-            }
-            typeSeen++;
-        }
-    }
-    return typeSeen;
-}
+	for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
+		if (!strcmp(normType, m_pTracks[i]->GetType())) {
+			if (subType) {
+				if (normType == MP4_AUDIO_TRACK_TYPE) {
+					if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+					if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
+						continue;
+					}
+				} 
+				// else unknown subtype, ignore it
+			}
+			typeSeen++;
+		}
+	}
+	return typeSeen;
+}
 
 MP4TrackId MP4File::AllocTrackId()
 {
-    MP4TrackId trackId =
-        GetIntegerProperty("moov.mvhd.nextTrackId");
+	MP4TrackId trackId = 
+		GetIntegerProperty("moov.mvhd.nextTrackId");
 
-    if (trackId <= 0xFFFF) {
-        // check that nextTrackid is correct
-        try {
-            FindTrackIndex(trackId);
-            // ERROR, this trackId is in use
-        }
-        catch (MP4Error* e) {
-            // OK, this trackId is not in use, proceed
-            delete e;
-            SetIntegerProperty("moov.mvhd.nextTrackId", trackId + 1);
-            return trackId;
-        }
-    }
+	if (trackId <= 0xFFFF) {
+		// check that nextTrackid is correct
+		try {
+			FindTrackIndex(trackId);
+			// ERROR, this trackId is in use
+		}
+		catch (MP4Error* e) {
+			// OK, this trackId is not in use, proceed
+			delete e;
+			SetIntegerProperty("moov.mvhd.nextTrackId", trackId + 1);
+			return trackId;
+		}
+	}
 
-    // we need to search for a track id
-    for (trackId = 1; trackId <= 0xFFFF; trackId++) {
-        try {
-            FindTrackIndex(trackId);
-            // KEEP LOOKING, this trackId is in use
-        }
-        catch (MP4Error* e) {
-            // OK, this trackId is not in use, proceed
-            delete e;
-            return trackId;
-        }
-    }
+	// we need to search for a track id
+	for (trackId = 1; trackId <= 0xFFFF; trackId++) {
+		try {
+			FindTrackIndex(trackId);
+			// KEEP LOOKING, this trackId is in use
+		}
+		catch (MP4Error* e) {
+			// OK, this trackId is not in use, proceed
+			delete e;
+			return trackId;
+		}
+	}
 
-    // extreme case where mp4 file has 2^16 tracks in it
-    throw new MP4Error("too many existing tracks", "AddTrack");
-    return MP4_INVALID_TRACK_ID;        // to keep MSVC happy
+	// extreme case where mp4 file has 2^16 tracks in it
+	throw new MP4Error("too many existing tracks", "AddTrack");
+	return MP4_INVALID_TRACK_ID;		// to keep MSVC happy
 }
 
-MP4TrackId MP4File::FindTrackId(u_int16_t trackIndex,
-                const char* type, u_int8_t subType)
+MP4TrackId MP4File::FindTrackId(u_int16_t trackIndex, 
+				const char* type, u_int8_t subType)
 {
   if (type == NULL) {
     return m_pTracks[trackIndex]->GetId();
-  }
+  } 
 
   u_int32_t typeSeen = 0;
   const char* normType = MP4Track::NormalizeTrackType(type);
@@ -1505,20 +1627,20 @@
   for (u_int32_t i = 0; i < m_pTracks.Size(); i++) {
     if (!strcmp(normType, m_pTracks[i]->GetType())) {
       if (subType) {
-    if (normType == MP4_AUDIO_TRACK_TYPE) {
-      if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
-        continue;
+	if (normType == MP4_AUDIO_TRACK_TYPE) {
+	  if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
+	    continue;
+	  }
+	} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+	  if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
+	    continue;
+	  }
+	} 
+	// else unknown subtype, ignore it
       }
-    } else if (normType == MP4_VIDEO_TRACK_TYPE) {
-      if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
-        continue;
-      }
-    }
-    // else unknown subtype, ignore it
-      }
 
       if (trackIndex == typeSeen) {
-    return m_pTracks[i]->GetId();
+	return m_pTracks[i]->GetId();
       }
 
       typeSeen++;
@@ -1525,177 +1647,177 @@
     }
   }
 
-  throw new MP4Error("Track index doesn't exist - track %d type %s",
-             "FindTrackId",
-             trackIndex, type);
+  throw new MP4Error("Track index doesn't exist - track %d type %s", 
+		     "FindTrackId", 
+		     trackIndex, type); 
   return MP4_INVALID_TRACK_ID; // satisfy MS compiler
 }
 
 u_int16_t MP4File::FindTrackIndex(MP4TrackId trackId)
 {
-    for (u_int32_t i = 0; i < m_pTracks.Size() && i <= 0xFFFF; i++) {
-        if (m_pTracks[i]->GetId() == trackId) {
-            return (u_int16_t)i;
-        }
-    }
-
-    throw new MP4Error("Track id %d doesn't exist", "FindTrackIndex", trackId);
-    return (u_int16_t)-1; // satisfy MS compiler
+	for (u_int32_t i = 0; i < m_pTracks.Size() && i <= 0xFFFF; i++) {
+		if (m_pTracks[i]->GetId() == trackId) {
+			return (u_int16_t)i;
+		}
+	}
+	
+	throw new MP4Error("Track id %d doesn't exist", "FindTrackIndex", trackId); 
+	return (u_int16_t)-1; // satisfy MS compiler
 }
 
 u_int16_t MP4File::FindTrakAtomIndex(MP4TrackId trackId)
 {
-    if (trackId) {
-        for (u_int32_t i = 0; i < m_trakIds.Size(); i++) {
-            if (m_trakIds[i] == trackId) {
-                return i;
-            }
-        }
-    }
+	if (trackId) {
+		for (u_int32_t i = 0; i < m_trakIds.Size(); i++) {
+			if (m_trakIds[i] == trackId) {
+				return i;
+			}
+		}
+	}
 
-    throw new MP4Error("Track id %d doesn't exist", "FindTrakAtomIndex",
-               trackId);
-    return (u_int16_t)-1; // satisfy MS compiler
+	throw new MP4Error("Track id %d doesn't exist", "FindTrakAtomIndex",
+			   trackId); 
+	return (u_int16_t)-1; // satisfy MS compiler
 }
 
 u_int32_t MP4File::GetSampleSize(MP4TrackId trackId, MP4SampleId sampleId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetSampleSize(sampleId);
+	return m_pTracks[FindTrackIndex(trackId)]->GetSampleSize(sampleId);
 }
 
 u_int32_t MP4File::GetTrackMaxSampleSize(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetMaxSampleSize();
+	return m_pTracks[FindTrackIndex(trackId)]->GetMaxSampleSize();
 }
 
-MP4SampleId MP4File::GetSampleIdFromTime(MP4TrackId trackId,
-    MP4Timestamp when, bool wantSyncSample)
+MP4SampleId MP4File::GetSampleIdFromTime(MP4TrackId trackId, 
+	MP4Timestamp when, bool wantSyncSample)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->
-        GetSampleIdFromTime(when, wantSyncSample);
+	return m_pTracks[FindTrackIndex(trackId)]->
+		GetSampleIdFromTime(when, wantSyncSample);
 }
 
 MP4Timestamp MP4File::GetSampleTime(
-    MP4TrackId trackId, MP4SampleId sampleId)
+	MP4TrackId trackId, MP4SampleId sampleId)
 {
-    MP4Timestamp timestamp;
-    m_pTracks[FindTrackIndex(trackId)]->
-        GetSampleTimes(sampleId, &timestamp, NULL);
-    return timestamp;
+	MP4Timestamp timestamp;
+	m_pTracks[FindTrackIndex(trackId)]->
+		GetSampleTimes(sampleId, &timestamp, NULL);
+	return timestamp;
 }
 
 MP4Duration MP4File::GetSampleDuration(
-    MP4TrackId trackId, MP4SampleId sampleId)
+	MP4TrackId trackId, MP4SampleId sampleId)
 {
-    MP4Duration duration;
-    m_pTracks[FindTrackIndex(trackId)]->
-        GetSampleTimes(sampleId, NULL, &duration);
-    return duration;
+	MP4Duration duration;
+	m_pTracks[FindTrackIndex(trackId)]->
+		GetSampleTimes(sampleId, NULL, &duration);
+	return duration; 
 }
 
 MP4Duration MP4File::GetSampleRenderingOffset(
-    MP4TrackId trackId, MP4SampleId sampleId)
+	MP4TrackId trackId, MP4SampleId sampleId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->
-        GetSampleRenderingOffset(sampleId);
+	return m_pTracks[FindTrackIndex(trackId)]->
+		GetSampleRenderingOffset(sampleId);
 }
 
 bool MP4File::GetSampleSync(MP4TrackId trackId, MP4SampleId sampleId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->IsSyncSample(sampleId);
+	return m_pTracks[FindTrackIndex(trackId)]->IsSyncSample(sampleId);
 }
 
 void MP4File::ReadSample(MP4TrackId trackId, MP4SampleId sampleId,
-        u_int8_t** ppBytes, u_int32_t* pNumBytes,
-        MP4Timestamp* pStartTime, MP4Duration* pDuration,
-        MP4Duration* pRenderingOffset, bool* pIsSyncSample)
+		u_int8_t** ppBytes, u_int32_t* pNumBytes, 
+		MP4Timestamp* pStartTime, MP4Duration* pDuration,
+		MP4Duration* pRenderingOffset, bool* pIsSyncSample)
 {
-    m_pTracks[FindTrackIndex(trackId)]->
-        ReadSample(sampleId, ppBytes, pNumBytes,
-            pStartTime, pDuration, pRenderingOffset, pIsSyncSample);
+	m_pTracks[FindTrackIndex(trackId)]->
+		ReadSample(sampleId, ppBytes, pNumBytes, 
+			pStartTime, pDuration, pRenderingOffset, pIsSyncSample);
 }
 
 void MP4File::WriteSample(MP4TrackId trackId,
-        const u_int8_t* pBytes, u_int32_t numBytes,
-        MP4Duration duration, MP4Duration renderingOffset, bool isSyncSample)
+		const u_int8_t* pBytes, u_int32_t numBytes,
+		MP4Duration duration, MP4Duration renderingOffset, bool isSyncSample)
 {
-    ProtectWriteOperation("MP4WriteSample");
+	ProtectWriteOperation("MP4WriteSample");
 
-    m_pTracks[FindTrackIndex(trackId)]->
-        WriteSample(pBytes, numBytes, duration, renderingOffset, isSyncSample);
+	m_pTracks[FindTrackIndex(trackId)]->
+		WriteSample(pBytes, numBytes, duration, renderingOffset, isSyncSample);
 
-    m_pModificationProperty->SetValue(MP4GetAbsTimestamp());
+	m_pModificationProperty->SetValue(MP4GetAbsTimestamp());
 }
 
-void MP4File::SetSampleRenderingOffset(MP4TrackId trackId,
-    MP4SampleId sampleId, MP4Duration renderingOffset)
+void MP4File::SetSampleRenderingOffset(MP4TrackId trackId, 
+	MP4SampleId sampleId, MP4Duration renderingOffset)
 {
-    ProtectWriteOperation("MP4SetSampleRenderingOffset");
+	ProtectWriteOperation("MP4SetSampleRenderingOffset");
 
-    m_pTracks[FindTrackIndex(trackId)]->
-        SetSampleRenderingOffset(sampleId, renderingOffset);
+	m_pTracks[FindTrackIndex(trackId)]->
+		SetSampleRenderingOffset(sampleId, renderingOffset);
 
-    m_pModificationProperty->SetValue(MP4GetAbsTimestamp());
+	m_pModificationProperty->SetValue(MP4GetAbsTimestamp());
 }
 
 char* MP4File::MakeTrackName(MP4TrackId trackId, const char* name)
 {
-    u_int16_t trakIndex = FindTrakAtomIndex(trackId);
+	u_int16_t trakIndex = FindTrakAtomIndex(trackId);
 
-    static char trakName[1024];
-    if (name == NULL || name[0] == '\0') {
-        snprintf(trakName, sizeof(trakName),
-            "moov.trak[%u]", trakIndex);
-    } else {
-        snprintf(trakName, sizeof(trakName),
-            "moov.trak[%u].%s", trakIndex, name);
-    }
-    return trakName;
+	static char trakName[1024];
+	if (name == NULL || name[0] == '\0') {
+		snprintf(trakName, sizeof(trakName), 
+			"moov.trak[%u]", trakIndex);
+	} else {
+		snprintf(trakName, sizeof(trakName), 
+			"moov.trak[%u].%s", trakIndex, name);
+	}
+	return trakName;
 }
 
 u_int64_t MP4File::GetTrackIntegerProperty(MP4TrackId trackId, const char* name)
 {
-    return GetIntegerProperty(MakeTrackName(trackId, name));
+	return GetIntegerProperty(MakeTrackName(trackId, name));
 }
 
-void MP4File::SetTrackIntegerProperty(MP4TrackId trackId, const char* name,
-    int64_t value)
+void MP4File::SetTrackIntegerProperty(MP4TrackId trackId, const char* name, 
+	int64_t value)
 {
-    SetIntegerProperty(MakeTrackName(trackId, name), value);
+	SetIntegerProperty(MakeTrackName(trackId, name), value);
 }
 
 float MP4File::GetTrackFloatProperty(MP4TrackId trackId, const char* name)
 {
-    return GetFloatProperty(MakeTrackName(trackId, name));
+	return GetFloatProperty(MakeTrackName(trackId, name));
 }
 
-void MP4File::SetTrackFloatProperty(MP4TrackId trackId, const char* name,
-    float value)
+void MP4File::SetTrackFloatProperty(MP4TrackId trackId, const char* name, 
+	float value)
 {
-    SetFloatProperty(MakeTrackName(trackId, name), value);
+	SetFloatProperty(MakeTrackName(trackId, name), value);
 }
 
 const char* MP4File::GetTrackStringProperty(MP4TrackId trackId, const char* name)
 {
-    return GetStringProperty(MakeTrackName(trackId, name));
+	return GetStringProperty(MakeTrackName(trackId, name));
 }
 
 void MP4File::SetTrackStringProperty(MP4TrackId trackId, const char* name,
-    const char* value)
+	const char* value)
 {
-    SetStringProperty(MakeTrackName(trackId, name), value);
+	SetStringProperty(MakeTrackName(trackId, name), value);
 }
 
-void MP4File::GetTrackBytesProperty(MP4TrackId trackId, const char* name,
-    u_int8_t** ppValue, u_int32_t* pValueSize)
+void MP4File::GetTrackBytesProperty(MP4TrackId trackId, const char* name, 
+	u_int8_t** ppValue, u_int32_t* pValueSize)
 {
-    GetBytesProperty(MakeTrackName(trackId, name), ppValue, pValueSize);
+	GetBytesProperty(MakeTrackName(trackId, name), ppValue, pValueSize);
 }
 
-void MP4File::SetTrackBytesProperty(MP4TrackId trackId, const char* name,
-    const u_int8_t* pValue, u_int32_t valueSize)
+void MP4File::SetTrackBytesProperty(MP4TrackId trackId, const char* name, 
+	const u_int8_t* pValue, u_int32_t valueSize)
 {
-    SetBytesProperty(MakeTrackName(trackId, name), pValue, valueSize);
+	SetBytesProperty(MakeTrackName(trackId, name), pValue, valueSize);
 }
 
 
@@ -1703,107 +1825,107 @@
 
 MP4Duration MP4File::GetDuration()
 {
-    return m_pDurationProperty->GetValue();
+	return m_pDurationProperty->GetValue();
 }
 
 void MP4File::SetDuration(MP4Duration value)
 {
-    m_pDurationProperty->SetValue(value);
+	m_pDurationProperty->SetValue(value);
 }
 
 u_int32_t MP4File::GetTimeScale()
 {
-    return m_pTimeScaleProperty->GetValue();
+	return m_pTimeScaleProperty->GetValue();
 }
 
 void MP4File::SetTimeScale(u_int32_t value)
 {
-    if (value == 0) {
-        throw new MP4Error("invalid value", "SetTimeScale");
-    }
-    m_pTimeScaleProperty->SetValue(value);
+	if (value == 0) {
+		throw new MP4Error("invalid value", "SetTimeScale");
+	}
+	m_pTimeScaleProperty->SetValue(value);
 }
 
 u_int8_t MP4File::GetODProfileLevel()
 {
-    return GetIntegerProperty("moov.iods.ODProfileLevelId");
+	return GetIntegerProperty("moov.iods.ODProfileLevelId");
 }
 
 void MP4File::SetODProfileLevel(u_int8_t value)
 {
-    SetIntegerProperty("moov.iods.ODProfileLevelId", value);
+	SetIntegerProperty("moov.iods.ODProfileLevelId", value);
 }
-
+ 
 u_int8_t MP4File::GetSceneProfileLevel()
 {
-    return GetIntegerProperty("moov.iods.sceneProfileLevelId");
+	return GetIntegerProperty("moov.iods.sceneProfileLevelId");
 }
 
 void MP4File::SetSceneProfileLevel(u_int8_t value)
 {
-    SetIntegerProperty("moov.iods.sceneProfileLevelId", value);
+	SetIntegerProperty("moov.iods.sceneProfileLevelId", value);
 }
-
+ 
 u_int8_t MP4File::GetVideoProfileLevel()
 {
-    return GetIntegerProperty("moov.iods.visualProfileLevelId");
+	return GetIntegerProperty("moov.iods.visualProfileLevelId");
 }
 
 void MP4File::SetVideoProfileLevel(u_int8_t value)
 {
-    SetIntegerProperty("moov.iods.visualProfileLevelId", value);
+	SetIntegerProperty("moov.iods.visualProfileLevelId", value);
 }
-
+ 
 u_int8_t MP4File::GetAudioProfileLevel()
 {
-    return GetIntegerProperty("moov.iods.audioProfileLevelId");
+	return GetIntegerProperty("moov.iods.audioProfileLevelId");
 }
 
 void MP4File::SetAudioProfileLevel(u_int8_t value)
 {
-    SetIntegerProperty("moov.iods.audioProfileLevelId", value);
+	SetIntegerProperty("moov.iods.audioProfileLevelId", value);
 }
-
+ 
 u_int8_t MP4File::GetGraphicsProfileLevel()
 {
-    return GetIntegerProperty("moov.iods.graphicsProfileLevelId");
+	return GetIntegerProperty("moov.iods.graphicsProfileLevelId");
 }
 
 void MP4File::SetGraphicsProfileLevel(u_int8_t value)
 {
-    SetIntegerProperty("moov.iods.graphicsProfileLevelId", value);
+	SetIntegerProperty("moov.iods.graphicsProfileLevelId", value);
 }
-
+ 
 const char* MP4File::GetSessionSdp()
 {
-    return GetStringProperty("moov.udta.hnti.rtp .sdpText");
+	return GetStringProperty("moov.udta.hnti.rtp .sdpText");
 }
 
 void MP4File::SetSessionSdp(const char* sdpString)
 {
-    AddDescendantAtoms("moov", "udta.hnti.rtp ");
+	AddDescendantAtoms("moov", "udta.hnti.rtp ");
 
-    SetStringProperty("moov.udta.hnti.rtp .sdpText", sdpString);
+	SetStringProperty("moov.udta.hnti.rtp .sdpText", sdpString);
 }
 
 void MP4File::AppendSessionSdp(const char* sdpFragment)
 {
-    const char* oldSdpString = NULL;
-    try {
-        oldSdpString = GetSessionSdp();
-    }
-    catch (MP4Error* e) {
-        delete e;
-        SetSessionSdp(sdpFragment);
-        return;
-    }
+	const char* oldSdpString = NULL;
+	try {
+		oldSdpString = GetSessionSdp();
+	}
+	catch (MP4Error* e) {
+		delete e;
+		SetSessionSdp(sdpFragment);
+		return;
+	}
 
-    char* newSdpString =
-        (char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1);
-    strcpy(newSdpString, oldSdpString);
-    strcat(newSdpString, sdpFragment);
-    SetSessionSdp(newSdpString);
-    MP4Free(newSdpString);
+	char* newSdpString =
+		(char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1);
+	strcpy(newSdpString, oldSdpString);
+	strcat(newSdpString, sdpFragment);
+	SetSessionSdp(newSdpString);
+	MP4Free(newSdpString);
 }
 
 
@@ -1811,33 +1933,33 @@
 
 MP4SampleId MP4File::GetTrackNumberOfSamples(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetNumberOfSamples();
+	return m_pTracks[FindTrackIndex(trackId)]->GetNumberOfSamples();
 }
 
 const char* MP4File::GetTrackType(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetType();
+	return m_pTracks[FindTrackIndex(trackId)]->GetType();
 }
 
 u_int32_t MP4File::GetTrackTimeScale(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetTimeScale();
+	return m_pTracks[FindTrackIndex(trackId)]->GetTimeScale();
 }
 
 void MP4File::SetTrackTimeScale(MP4TrackId trackId, u_int32_t value)
 {
-    if (value == 0) {
-        throw new MP4Error("invalid value", "SetTrackTimeScale");
-    }
-    SetTrackIntegerProperty(trackId, "mdia.mdhd.timeScale", value);
+	if (value == 0) {
+		throw new MP4Error("invalid value", "SetTrackTimeScale");
+	}
+	SetTrackIntegerProperty(trackId, "mdia.mdhd.timeScale", value);
 }
 
 MP4Duration MP4File::GetTrackDuration(MP4TrackId trackId)
 {
-    return GetTrackIntegerProperty(trackId, "mdia.mdhd.duration");
+	return GetTrackIntegerProperty(trackId, "mdia.mdhd.duration");
 }
 
-// now GetTrackEsdsObjectTypeId
+// now GetTrackEsdsObjectTypeId 
 u_int8_t MP4File::GetTrackAudioType(MP4TrackId trackId)
 {
         return GetTrackIntegerProperty(trackId,
@@ -1846,613 +1968,613 @@
 
 u_int8_t MP4File::GetTrackEsdsObjectTypeId(MP4TrackId trackId)
 {
-    // changed mp4a to * to handle enca case
-    return GetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeId");
+	// changed mp4a to * to handle enca case
+	return GetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.*.esds.decConfigDescr.objectTypeId");
 }
 
 u_int8_t MP4File::GetTrackAudioMpeg4Type(MP4TrackId trackId)
 {
-    // verify that track is an MPEG-4 audio track
-    if (GetTrackEsdsObjectTypeId(trackId) != MP4_MPEG4_AUDIO_TYPE) {
-        return MP4_MPEG4_INVALID_AUDIO_TYPE;
-    }
+	// verify that track is an MPEG-4 audio track 
+	if (GetTrackEsdsObjectTypeId(trackId) != MP4_MPEG4_AUDIO_TYPE) {
+		return MP4_MPEG4_INVALID_AUDIO_TYPE;
+	}
 
-    u_int8_t* pEsConfig = NULL;
-    u_int32_t esConfigSize;
+	u_int8_t* pEsConfig = NULL;
+	u_int32_t esConfigSize;
 
-    // The Mpeg4 audio type (AAC, CELP, HXVC, ...)
-    // is the first 5 bits of the ES configuration
+	// The Mpeg4 audio type (AAC, CELP, HXVC, ...)
+	// is the first 5 bits of the ES configuration
 
-    GetTrackESConfiguration(trackId, &pEsConfig, &esConfigSize);
+	GetTrackESConfiguration(trackId, &pEsConfig, &esConfigSize);
 
-    if (esConfigSize < 1) {
-        return MP4_MPEG4_INVALID_AUDIO_TYPE;
-    }
+	if (esConfigSize < 1) {
+		return MP4_MPEG4_INVALID_AUDIO_TYPE;
+	}
 
-    u_int8_t mpeg4Type = (pEsConfig[0] >> 3);
+	u_int8_t mpeg4Type = (pEsConfig[0] >> 3);
 
-    free(pEsConfig);
+	free(pEsConfig);
 
-    return mpeg4Type;
+	return mpeg4Type;
 }
 
 // replaced with GetTrackEsdsObjectTypeId
 u_int8_t MP4File::GetTrackVideoType(MP4TrackId trackId)
 {
-    return GetTrackIntegerProperty(trackId,
-        "mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.objectTypeId");
+	return GetTrackIntegerProperty(trackId, 
+		"mdia.minf.stbl.stsd.mp4v.esds.decConfigDescr.objectTypeId");
 }
 
 MP4Duration MP4File::GetTrackFixedSampleDuration(MP4TrackId trackId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetFixedSampleDuration();
+	return m_pTracks[FindTrackIndex(trackId)]->GetFixedSampleDuration();
 }
 
 float MP4File::GetTrackVideoFrameRate(MP4TrackId trackId)
 {
-    MP4SampleId numSamples =
-        GetTrackNumberOfSamples(trackId);
-    u_int64_t
-        msDuration =
-        ConvertFromTrackDuration(trackId,
-            GetTrackDuration(trackId), MP4_MSECS_TIME_SCALE);
+	MP4SampleId numSamples =
+		GetTrackNumberOfSamples(trackId);
+	u_int64_t 
+		msDuration =
+		ConvertFromTrackDuration(trackId, 
+			GetTrackDuration(trackId), MP4_MSECS_TIME_SCALE);
 
-    if (msDuration == 0) {
-        return 0.0;
-    }
+	if (msDuration == 0) {
+		return 0.0;
+	}
 
-    return ((double)numSamples / UINT64_TO_DOUBLE(msDuration)) * MP4_MSECS_TIME_SCALE;
+	return ((double)numSamples / UINT64_TO_DOUBLE(msDuration)) * MP4_MSECS_TIME_SCALE;
 }
 
-void MP4File::GetTrackESConfiguration(MP4TrackId trackId,
-    u_int8_t** ppConfig, u_int32_t* pConfigSize)
+void MP4File::GetTrackESConfiguration(MP4TrackId trackId, 
+	u_int8_t** ppConfig, u_int32_t* pConfigSize)
 {
-    GetTrackBytesProperty(trackId,
-        "mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo[0].info",
-        ppConfig, pConfigSize);
+	GetTrackBytesProperty(trackId, 
+		"mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo[0].info",
+		ppConfig, pConfigSize);
 }
 
-void MP4File::SetTrackESConfiguration(MP4TrackId trackId,
-    const u_int8_t* pConfig, u_int32_t configSize)
+void MP4File::SetTrackESConfiguration(MP4TrackId trackId, 
+	const u_int8_t* pConfig, u_int32_t configSize)
 {
-    // get a handle on the track decoder config descriptor
-    MP4DescriptorProperty* pConfigDescrProperty = NULL;
-    FindProperty(MakeTrackName(trackId,
-        "mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo"),
-        (MP4Property**)&pConfigDescrProperty);
+	// get a handle on the track decoder config descriptor 
+	MP4DescriptorProperty* pConfigDescrProperty = NULL;
+	FindProperty(MakeTrackName(trackId, 
+		"mdia.minf.stbl.stsd.*[0].esds.decConfigDescr.decSpecificInfo"),
+		(MP4Property**)&pConfigDescrProperty);
 
-    if (pConfigDescrProperty == NULL) {
-        // probably trackId refers to a hint track
-        throw new MP4Error("no such property", "MP4SetTrackESConfiguration");
-    }
+	if (pConfigDescrProperty == NULL) {
+		// probably trackId refers to a hint track
+		throw new MP4Error("no such property", "MP4SetTrackESConfiguration");
+	}
 
-    // lookup the property to store the configuration
-    MP4BytesProperty* pInfoProperty = NULL;
-    pConfigDescrProperty->FindProperty("decSpecificInfo[0].info",
-        (MP4Property**)&pInfoProperty);
+	// lookup the property to store the configuration
+	MP4BytesProperty* pInfoProperty = NULL;
+	pConfigDescrProperty->FindProperty("decSpecificInfo[0].info",
+		(MP4Property**)&pInfoProperty);
 
-    // configuration being set for the first time
-    if (pInfoProperty == NULL) {
-        // need to create a new descriptor to hold it
-        MP4Descriptor* pConfigDescr =
-            pConfigDescrProperty->AddDescriptor(MP4DecSpecificDescrTag);
-        pConfigDescr->Generate();
+	// configuration being set for the first time
+	if (pInfoProperty == NULL) {
+		// need to create a new descriptor to hold it
+		MP4Descriptor* pConfigDescr =
+			pConfigDescrProperty->AddDescriptor(MP4DecSpecificDescrTag);
+		pConfigDescr->Generate();
 
-        pConfigDescrProperty->FindProperty(
-            "decSpecificInfo[0].info",
-            (MP4Property**)&pInfoProperty);
-        ASSERT(pInfoProperty);
-    }
+		pConfigDescrProperty->FindProperty(
+			"decSpecificInfo[0].info",
+			(MP4Property**)&pInfoProperty);
+		ASSERT(pInfoProperty);
+	}
 
-    // set the value
-    pInfoProperty->SetValue(pConfig, configSize);
+	// set the value
+	pInfoProperty->SetValue(pConfig, configSize);
 }
 
 const char* MP4File::GetHintTrackSdp(MP4TrackId hintTrackId)
 {
-    return GetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText");
+	return GetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText");
 }
 
 void MP4File::SetHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4SetHintTrackSdp");
-    }
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4SetHintTrackSdp");
+	}
 
-    AddDescendantAtoms(
-        MakeTrackName(hintTrackId, NULL), "udta.hnti.sdp ");
+	AddDescendantAtoms(
+		MakeTrackName(hintTrackId, NULL), "udta.hnti.sdp ");
 
-    SetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText", sdpString);
+	SetTrackStringProperty(hintTrackId, "udta.hnti.sdp .sdpText", sdpString);
 }
 
-void MP4File::AppendHintTrackSdp(MP4TrackId hintTrackId,
-    const char* sdpFragment)
+void MP4File::AppendHintTrackSdp(MP4TrackId hintTrackId, 
+	const char* sdpFragment)
 {
-    const char* oldSdpString = NULL;
-    try {
-        oldSdpString = GetHintTrackSdp(hintTrackId);
-    }
-    catch (MP4Error* e) {
-        delete e;
-        SetHintTrackSdp(hintTrackId, sdpFragment);
-        return;
-    }
+	const char* oldSdpString = NULL;
+	try {
+		oldSdpString = GetHintTrackSdp(hintTrackId);
+	}
+	catch (MP4Error* e) {
+		delete e;
+		SetHintTrackSdp(hintTrackId, sdpFragment);
+		return;
+	}
 
-    char* newSdpString =
-        (char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1);
-    strcpy(newSdpString, oldSdpString);
-    strcat(newSdpString, sdpFragment);
-    SetHintTrackSdp(hintTrackId, newSdpString);
-    MP4Free(newSdpString);
+	char* newSdpString =
+		(char*)MP4Malloc(strlen(oldSdpString) + strlen(sdpFragment) + 1);
+	strcpy(newSdpString, oldSdpString);
+	strcat(newSdpString, sdpFragment);
+	SetHintTrackSdp(hintTrackId, newSdpString);
+	MP4Free(newSdpString);
 }
 
 void MP4File::GetHintTrackRtpPayload(
-    MP4TrackId hintTrackId,
-    char** ppPayloadName,
-    u_int8_t* pPayloadNumber,
-    u_int16_t* pMaxPayloadSize,
-    char **ppEncodingParams)
+	MP4TrackId hintTrackId,
+	char** ppPayloadName,
+	u_int8_t* pPayloadNumber,
+	u_int16_t* pMaxPayloadSize,
+	char **ppEncodingParams)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetHintTrackRtpPayload");
-    }
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetHintTrackRtpPayload");
+	}
 
-    ((MP4RtpHintTrack*)pTrack)->GetPayload(
-        ppPayloadName, pPayloadNumber, pMaxPayloadSize, ppEncodingParams);
+	((MP4RtpHintTrack*)pTrack)->GetPayload(
+		ppPayloadName, pPayloadNumber, pMaxPayloadSize, ppEncodingParams);
 }
 
 void MP4File::SetHintTrackRtpPayload(MP4TrackId hintTrackId,
-    const char* payloadName, u_int8_t* pPayloadNumber, u_int16_t maxPayloadSize,
-                     const char *encoding_params,
-                     bool include_rtp_map,
-                     bool include_mpeg4_esid)
+	const char* payloadName, u_int8_t* pPayloadNumber, u_int16_t maxPayloadSize,
+				     const char *encoding_params,
+				     bool include_rtp_map,
+				     bool include_mpeg4_esid)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4SetHintTrackRtpPayload");
-    }
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4SetHintTrackRtpPayload");
+	}
 
-    u_int8_t payloadNumber;
-    if (pPayloadNumber && *pPayloadNumber != MP4_SET_DYNAMIC_PAYLOAD) {
-        payloadNumber = *pPayloadNumber;
-    } else {
-        payloadNumber = AllocRtpPayloadNumber();
-        if (pPayloadNumber) {
-            *pPayloadNumber = payloadNumber;
-        }
-    }
+	u_int8_t payloadNumber;
+	if (pPayloadNumber && *pPayloadNumber != MP4_SET_DYNAMIC_PAYLOAD) {
+		payloadNumber = *pPayloadNumber;
+	} else {
+		payloadNumber = AllocRtpPayloadNumber();
+		if (pPayloadNumber) {
+			*pPayloadNumber = payloadNumber;
+		}
+	}
 
-    ((MP4RtpHintTrack*)pTrack)->SetPayload(
-        payloadName, payloadNumber, maxPayloadSize, encoding_params,
-        include_rtp_map, include_mpeg4_esid);
+	((MP4RtpHintTrack*)pTrack)->SetPayload(
+		payloadName, payloadNumber, maxPayloadSize, encoding_params,
+		include_rtp_map, include_mpeg4_esid);
 }
 
 u_int8_t MP4File::AllocRtpPayloadNumber()
 {
-    MP4Integer32Array usedPayloads;
-    u_int32_t i;
+	MP4Integer32Array usedPayloads;
+	u_int32_t i;
 
-    // collect rtp payload numbers in use by existing tracks
-    for (i = 0; i < m_pTracks.Size(); i++) {
-        MP4Atom* pTrakAtom = m_pTracks[i]->GetTrakAtom();
+	// collect rtp payload numbers in use by existing tracks
+	for (i = 0; i < m_pTracks.Size(); i++) {
+		MP4Atom* pTrakAtom = m_pTracks[i]->GetTrakAtom();
 
-        MP4Integer32Property* pPayloadProperty = NULL;
-        pTrakAtom->FindProperty("trak.udta.hinf.payt.payloadNumber",
-            (MP4Property**)&pPayloadProperty);
+		MP4Integer32Property* pPayloadProperty = NULL;
+		pTrakAtom->FindProperty("trak.udta.hinf.payt.payloadNumber",
+			(MP4Property**)&pPayloadProperty);
 
-        if (pPayloadProperty) {
-            usedPayloads.Add(pPayloadProperty->GetValue());
-        }
-    }
+		if (pPayloadProperty) {
+			usedPayloads.Add(pPayloadProperty->GetValue());
+		}
+	}
 
-    // search dynamic payload range for an available slot
-    u_int8_t payload;
-    for (payload = 96; payload < 128; payload++) {
-        for (i = 0; i < usedPayloads.Size(); i++) {
-            if (payload == usedPayloads[i]) {
-                break;
-            }
-        }
-        if (i == usedPayloads.Size()) {
-            break;
-        }
-    }
+	// search dynamic payload range for an available slot
+	u_int8_t payload;
+	for (payload = 96; payload < 128; payload++) {
+		for (i = 0; i < usedPayloads.Size(); i++) {
+			if (payload == usedPayloads[i]) {
+				break;
+			}
+		}
+		if (i == usedPayloads.Size()) {
+			break;
+		}
+	}
 
-    if (payload >= 128) {
-        throw new MP4Error("no more available rtp payload numbers",
-            "AllocRtpPayloadNumber");
-    }
+	if (payload >= 128) {
+		throw new MP4Error("no more available rtp payload numbers",
+			"AllocRtpPayloadNumber");
+	}
 
-    return payload;
+	return payload;
 }
 
 MP4TrackId MP4File::GetHintTrackReferenceTrackId(
-    MP4TrackId hintTrackId)
+	MP4TrackId hintTrackId)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetHintTrackReferenceTrackId");
-    }
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetHintTrackReferenceTrackId");
+	}
 
-    MP4Track* pRefTrack = ((MP4RtpHintTrack*)pTrack)->GetRefTrack();
+	MP4Track* pRefTrack = ((MP4RtpHintTrack*)pTrack)->GetRefTrack();
 
-    if (pRefTrack == NULL) {
-        return MP4_INVALID_TRACK_ID;
-    }
-    return pRefTrack->GetId();
+	if (pRefTrack == NULL) {
+		return MP4_INVALID_TRACK_ID;
+	}
+	return pRefTrack->GetId();
 }
 
 void MP4File::ReadRtpHint(
-    MP4TrackId hintTrackId,
-    MP4SampleId hintSampleId,
-    u_int16_t* pNumPackets)
+	MP4TrackId hintTrackId,
+	MP4SampleId hintSampleId,
+	u_int16_t* pNumPackets)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track", "MP4ReadRtpHint");
-    }
-    ((MP4RtpHintTrack*)pTrack)->
-        ReadHint(hintSampleId, pNumPackets);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", "MP4ReadRtpHint");
+	}
+	((MP4RtpHintTrack*)pTrack)->
+		ReadHint(hintSampleId, pNumPackets);
 }
 
 u_int16_t MP4File::GetRtpHintNumberOfPackets(
-    MP4TrackId hintTrackId)
+	MP4TrackId hintTrackId)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetRtpHintNumberOfPackets");
-    }
-    return ((MP4RtpHintTrack*)pTrack)->GetHintNumberOfPackets();
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetRtpHintNumberOfPackets");
+	}
+	return ((MP4RtpHintTrack*)pTrack)->GetHintNumberOfPackets();
 }
 
 int8_t MP4File::GetRtpPacketBFrame(
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex)
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetRtpHintBFrame");
-    }
-    return ((MP4RtpHintTrack*)pTrack)->GetPacketBFrame(packetIndex);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetRtpHintBFrame");
+	}
+	return ((MP4RtpHintTrack*)pTrack)->GetPacketBFrame(packetIndex);
 }
 
 int32_t MP4File::GetRtpPacketTransmitOffset(
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex)
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetRtpPacketTransmitOffset");
-    }
-    return ((MP4RtpHintTrack*)pTrack)->GetPacketTransmitOffset(packetIndex);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetRtpPacketTransmitOffset");
+	}
+	return ((MP4RtpHintTrack*)pTrack)->GetPacketTransmitOffset(packetIndex);
 }
 
 void MP4File::ReadRtpPacket(
-    MP4TrackId hintTrackId,
-    u_int16_t packetIndex,
-    u_int8_t** ppBytes,
-    u_int32_t* pNumBytes,
-    u_int32_t ssrc,
-    bool includeHeader,
-    bool includePayload)
+	MP4TrackId hintTrackId,
+	u_int16_t packetIndex,
+	u_int8_t** ppBytes, 
+	u_int32_t* pNumBytes,
+	u_int32_t ssrc,
+	bool includeHeader,
+	bool includePayload)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track", "MP4ReadPacket");
-    }
-    ((MP4RtpHintTrack*)pTrack)->ReadPacket(
-        packetIndex, ppBytes, pNumBytes,
-        ssrc, includeHeader, includePayload);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", "MP4ReadPacket");
+	}
+	((MP4RtpHintTrack*)pTrack)->ReadPacket(
+		packetIndex, ppBytes, pNumBytes,
+		ssrc, includeHeader, includePayload);
 }
 
 MP4Timestamp MP4File::GetRtpTimestampStart(
-    MP4TrackId hintTrackId)
+	MP4TrackId hintTrackId)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4GetRtpTimestampStart");
-    }
-    return ((MP4RtpHintTrack*)pTrack)->GetRtpTimestampStart();
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4GetRtpTimestampStart");
+	}
+	return ((MP4RtpHintTrack*)pTrack)->GetRtpTimestampStart();
 }
 
 void MP4File::SetRtpTimestampStart(
-    MP4TrackId hintTrackId,
-    MP4Timestamp rtpStart)
+	MP4TrackId hintTrackId,
+	MP4Timestamp rtpStart)
 {
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4SetRtpTimestampStart");
-    }
-    ((MP4RtpHintTrack*)pTrack)->SetRtpTimestampStart(rtpStart);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4SetRtpTimestampStart");
+	}
+	((MP4RtpHintTrack*)pTrack)->SetRtpTimestampStart(rtpStart);
 }
 
-void MP4File::AddRtpHint(MP4TrackId hintTrackId,
-    bool isBframe, u_int32_t timestampOffset)
+void MP4File::AddRtpHint(MP4TrackId hintTrackId, 
+	bool isBframe, u_int32_t timestampOffset)
 {
-    ProtectWriteOperation("MP4AddRtpHint");
+	ProtectWriteOperation("MP4AddRtpHint");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track", "MP4AddRtpHint");
-    }
-    ((MP4RtpHintTrack*)pTrack)->AddHint(isBframe, timestampOffset);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", "MP4AddRtpHint");
+	}
+	((MP4RtpHintTrack*)pTrack)->AddHint(isBframe, timestampOffset);
 }
 
 void MP4File::AddRtpPacket(
-    MP4TrackId hintTrackId, bool setMbit, int32_t transmitOffset)
+	MP4TrackId hintTrackId, bool setMbit, int32_t transmitOffset)
 {
-    ProtectWriteOperation("MP4AddRtpPacket");
+	ProtectWriteOperation("MP4AddRtpPacket");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track", "MP4AddRtpPacket");
-    }
-    ((MP4RtpHintTrack*)pTrack)->AddPacket(setMbit, transmitOffset);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", "MP4AddRtpPacket");
+	}
+	((MP4RtpHintTrack*)pTrack)->AddPacket(setMbit, transmitOffset);
 }
 
-void MP4File::AddRtpImmediateData(MP4TrackId hintTrackId,
-    const u_int8_t* pBytes, u_int32_t numBytes)
+void MP4File::AddRtpImmediateData(MP4TrackId hintTrackId, 
+	const u_int8_t* pBytes, u_int32_t numBytes)
 {
-    ProtectWriteOperation("MP4AddRtpImmediateData");
+	ProtectWriteOperation("MP4AddRtpImmediateData");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4AddRtpImmediateData");
-    }
-    ((MP4RtpHintTrack*)pTrack)->AddImmediateData(pBytes, numBytes);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4AddRtpImmediateData");
+	}
+	((MP4RtpHintTrack*)pTrack)->AddImmediateData(pBytes, numBytes);
 }
 
-void MP4File::AddRtpSampleData(MP4TrackId hintTrackId,
-    MP4SampleId sampleId, u_int32_t dataOffset, u_int32_t dataLength)
+void MP4File::AddRtpSampleData(MP4TrackId hintTrackId, 
+	MP4SampleId sampleId, u_int32_t dataOffset, u_int32_t dataLength)
 {
-    ProtectWriteOperation("MP4AddRtpSampleData");
+	ProtectWriteOperation("MP4AddRtpSampleData");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4AddRtpSampleData");
-    }
-    ((MP4RtpHintTrack*)pTrack)->AddSampleData(
-        sampleId, dataOffset, dataLength);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4AddRtpSampleData");
+	}
+	((MP4RtpHintTrack*)pTrack)->AddSampleData(
+		sampleId, dataOffset, dataLength);
 }
 
 void MP4File::AddRtpESConfigurationPacket(MP4TrackId hintTrackId)
 {
-    ProtectWriteOperation("MP4AddRtpESConfigurationPacket");
+	ProtectWriteOperation("MP4AddRtpESConfigurationPacket");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4AddRtpESConfigurationPacket");
-    }
-    ((MP4RtpHintTrack*)pTrack)->AddESConfigurationPacket();
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4AddRtpESConfigurationPacket");
+	}
+	((MP4RtpHintTrack*)pTrack)->AddESConfigurationPacket();
 }
 
 void MP4File::WriteRtpHint(MP4TrackId hintTrackId,
-    MP4Duration duration, bool isSyncSample)
+	MP4Duration duration, bool isSyncSample)
 {
-    ProtectWriteOperation("MP4WriteRtpHint");
+	ProtectWriteOperation("MP4WriteRtpHint");
 
-    MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
+	MP4Track* pTrack = m_pTracks[FindTrackIndex(hintTrackId)];
 
-    if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
-        throw new MP4Error("track is not a hint track",
-            "MP4WriteRtpHint");
-    }
-    ((MP4RtpHintTrack*)pTrack)->WriteHint(duration, isSyncSample);
+	if (strcmp(pTrack->GetType(), MP4_HINT_TRACK_TYPE)) {
+		throw new MP4Error("track is not a hint track", 
+			"MP4WriteRtpHint");
+	}
+	((MP4RtpHintTrack*)pTrack)->WriteHint(duration, isSyncSample);
 }
 
 u_int64_t MP4File::ConvertFromMovieDuration(
-    MP4Duration duration,
-    u_int32_t timeScale)
+	MP4Duration duration,
+	u_int32_t timeScale)
 {
-    return MP4ConvertTime((u_int64_t)duration,
-        GetTimeScale(), timeScale);
+	return MP4ConvertTime((u_int64_t)duration, 
+		GetTimeScale(), timeScale);
 }
 
 u_int64_t MP4File::ConvertFromTrackTimestamp(
-    MP4TrackId trackId,
-    MP4Timestamp timeStamp,
-    u_int32_t timeScale)
+	MP4TrackId trackId, 
+	MP4Timestamp timeStamp,
+	u_int32_t timeScale)
 {
-    return MP4ConvertTime(timeStamp,
-        GetTrackTimeScale(trackId), timeScale);
+	return MP4ConvertTime(timeStamp, 
+		GetTrackTimeScale(trackId), timeScale);
 }
 
 MP4Timestamp MP4File::ConvertToTrackTimestamp(
-    MP4TrackId trackId,
-    u_int64_t timeStamp,
-    u_int32_t timeScale)
+	MP4TrackId trackId, 
+	u_int64_t timeStamp,
+	u_int32_t timeScale)
 {
-    return (MP4Timestamp)MP4ConvertTime(timeStamp,
-        timeScale, GetTrackTimeScale(trackId));
+	return (MP4Timestamp)MP4ConvertTime(timeStamp, 
+		timeScale, GetTrackTimeScale(trackId));
 }
 
 u_int64_t MP4File::ConvertFromTrackDuration(
-    MP4TrackId trackId,
-    MP4Duration duration,
-    u_int32_t timeScale)
+	MP4TrackId trackId, 
+	MP4Duration duration,
+	u_int32_t timeScale)
 {
-    return MP4ConvertTime((u_int64_t)duration,
-        GetTrackTimeScale(trackId), timeScale);
+	return MP4ConvertTime((u_int64_t)duration, 
+		GetTrackTimeScale(trackId), timeScale);
 }
 
 MP4Duration MP4File::ConvertToTrackDuration(
-    MP4TrackId trackId,
-    u_int64_t duration,
-    u_int32_t timeScale)
+	MP4TrackId trackId, 
+	u_int64_t duration,
+	u_int32_t timeScale)
 {
-    return (MP4Duration)MP4ConvertTime(duration,
-        timeScale, GetTrackTimeScale(trackId));
+	return (MP4Duration)MP4ConvertTime(duration, 
+		timeScale, GetTrackTimeScale(trackId));
 }
 
 u_int8_t MP4File::ConvertTrackTypeToStreamType(const char* trackType)
 {
-    u_int8_t streamType;
+	u_int8_t streamType;
 
-    if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) {
-        streamType = MP4ObjectDescriptionStreamType;
-    } else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) {
-        streamType = MP4SceneDescriptionStreamType;
-    } else if (!strcmp(trackType, MP4_CLOCK_TRACK_TYPE)) {
-        streamType = MP4ClockReferenceStreamType;
-    } else if (!strcmp(trackType, MP4_MPEG7_TRACK_TYPE)) {
-        streamType = MP4Mpeg7StreamType;
-    } else if (!strcmp(trackType, MP4_OCI_TRACK_TYPE)) {
-        streamType = MP4OCIStreamType;
-    } else if (!strcmp(trackType, MP4_IPMP_TRACK_TYPE)) {
-        streamType = MP4IPMPStreamType;
-    } else if (!strcmp(trackType, MP4_MPEGJ_TRACK_TYPE)) {
-        streamType = MP4MPEGJStreamType;
-    } else {
-        streamType = MP4UserPrivateStreamType;
-    }
+	if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) {
+		streamType = MP4ObjectDescriptionStreamType;
+	} else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) {
+		streamType = MP4SceneDescriptionStreamType;
+	} else if (!strcmp(trackType, MP4_CLOCK_TRACK_TYPE)) {
+		streamType = MP4ClockReferenceStreamType;
+	} else if (!strcmp(trackType, MP4_MPEG7_TRACK_TYPE)) {
+		streamType = MP4Mpeg7StreamType;
+	} else if (!strcmp(trackType, MP4_OCI_TRACK_TYPE)) {
+		streamType = MP4OCIStreamType;
+	} else if (!strcmp(trackType, MP4_IPMP_TRACK_TYPE)) {
+		streamType = MP4IPMPStreamType;
+	} else if (!strcmp(trackType, MP4_MPEGJ_TRACK_TYPE)) {
+		streamType = MP4MPEGJStreamType;
+	} else {
+		streamType = MP4UserPrivateStreamType;
+	}
 
-    return streamType;
+	return streamType;
 }
 
 // edit list
 
 char* MP4File::MakeTrackEditName(
-    MP4TrackId trackId,
-    MP4EditId editId,
-    const char* name)
+	MP4TrackId trackId,
+	MP4EditId editId,
+	const char* name)
 {
-    char* trakName = MakeTrackName(trackId, NULL);
+	char* trakName = MakeTrackName(trackId, NULL);
 
-    static char editName[1024];
-    snprintf(editName, sizeof(editName),
-        "%s.edts.elst.entries[%u].%s",
-        trakName, editId - 1, name);
-    return editName;
+	static char editName[1024];
+	snprintf(editName, sizeof(editName), 
+		"%s.edts.elst.entries[%u].%s", 
+		trakName, editId - 1, name);
+	return editName;
 }
 
 MP4EditId MP4File::AddTrackEdit(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    ProtectWriteOperation("AddTrackEdit");
-    return m_pTracks[FindTrackIndex(trackId)]->AddEdit(editId);
+	ProtectWriteOperation("AddTrackEdit");
+	return m_pTracks[FindTrackIndex(trackId)]->AddEdit(editId);
 }
 
 void MP4File::DeleteTrackEdit(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    ProtectWriteOperation("DeleteTrackEdit");
-    m_pTracks[FindTrackIndex(trackId)]->DeleteEdit(editId);
+	ProtectWriteOperation("DeleteTrackEdit");
+	m_pTracks[FindTrackIndex(trackId)]->DeleteEdit(editId);
 }
 
 u_int32_t MP4File::GetTrackNumberOfEdits(
-    MP4TrackId trackId)
+	MP4TrackId trackId)
 {
-    return GetTrackIntegerProperty(trackId, "edts.elst.entryCount");
+	return GetTrackIntegerProperty(trackId, "edts.elst.entryCount");
 }
 
 MP4Duration MP4File::GetTrackEditTotalDuration(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetEditTotalDuration(editId);
+	return m_pTracks[FindTrackIndex(trackId)]->GetEditTotalDuration(editId);
 }
 
 MP4Timestamp MP4File::GetTrackEditStart(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetEditStart(editId);
+	return m_pTracks[FindTrackIndex(trackId)]->GetEditStart(editId);
 }
 
 MP4Timestamp MP4File::GetTrackEditMediaStart(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    return GetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "mediaTime"));
+	return GetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "mediaTime"));
 }
 
 void MP4File::SetTrackEditMediaStart(
-    MP4TrackId trackId,
-    MP4EditId editId,
-    MP4Timestamp startTime)
+	MP4TrackId trackId,
+	MP4EditId editId,
+	MP4Timestamp startTime)
 {
-    SetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "mediaTime"),
-        startTime);
+	SetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "mediaTime"),
+		startTime);
 }
 
 MP4Duration MP4File::GetTrackEditDuration(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    return GetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "segmentDuration"));
+	return GetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "segmentDuration"));
 }
 
 void MP4File::SetTrackEditDuration(
-    MP4TrackId trackId,
-    MP4EditId editId,
-    MP4Duration duration)
+	MP4TrackId trackId,
+	MP4EditId editId,
+	MP4Duration duration)
 {
-    SetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "segmentDuration"),
-        duration);
+	SetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "segmentDuration"),
+		duration);
 }
 
 bool MP4File::GetTrackEditDwell(
-    MP4TrackId trackId,
-    MP4EditId editId)
+	MP4TrackId trackId,
+	MP4EditId editId)
 {
-    return (GetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "mediaRate")) == 0);
+	return (GetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "mediaRate")) == 0);
 }
 
 void MP4File::SetTrackEditDwell(
-    MP4TrackId trackId,
-    MP4EditId editId,
-    bool dwell)
+	MP4TrackId trackId,
+	MP4EditId editId,
+	bool dwell)
 {
-    SetIntegerProperty(
-        MakeTrackEditName(trackId, editId, "mediaRate"),
-        (dwell ? 0 : 1));
+	SetIntegerProperty(
+		MakeTrackEditName(trackId, editId, "mediaRate"),
+		(dwell ? 0 : 1));
 }
 
 MP4SampleId MP4File::GetSampleIdFromEditTime(
-    MP4TrackId trackId,
-    MP4Timestamp when,
-    MP4Timestamp* pStartTime,
-    MP4Duration* pDuration)
+	MP4TrackId trackId,
+	MP4Timestamp when,
+	MP4Timestamp* pStartTime,
+	MP4Duration* pDuration)
 {
-    return m_pTracks[FindTrackIndex(trackId)]->GetSampleIdFromEditTime(
-        when, pStartTime, pDuration);
+	return m_pTracks[FindTrackIndex(trackId)]->GetSampleIdFromEditTime(
+		when, pStartTime, pDuration);
 }
 
--- a/common/mp4v2/mp4file.h
+++ b/common/mp4v2/mp4file.h
@@ -32,18 +32,6 @@
 class MP4Descriptor;
 class MP4DescriptorProperty;
 
-
-#ifdef USE_FILE_CALLBACKS
-typedef u_int32_t (*MP4OpenCallback)(const char *pName, const char *mode, void *userData);
-typedef void (*MP4CloseCallback)(void *userData);
-typedef u_int32_t (*MP4ReadCallback)(void *pBuffer, unsigned int nBytesToRead, void *userData);
-typedef u_int32_t (*MP4WriteCallback)(void *pBuffer, unsigned int nBytesToWrite, void *userData);
-typedef int32_t (*MP4SetposCallback)(u_int32_t pos, void *userData);
-typedef int64_t (*MP4GetposCallback)(void *userData);
-typedef int64_t (*MP4FilesizeCallback)(void *userData);
-#endif
-
-
 class MP4File {
 public: /* equivalent to MP4 library API */
 	MP4File(u_int32_t verbosity = 0);
@@ -51,7 +39,7 @@
 
 	/* file operations */
 	void Read(const char* fileName);
-	void Create(const char* fileName, bool use64bits);
+	void Create(const char* fileName, u_int32_t flags);
 	void Modify(const char* fileName);
 	void Optimize(const char* orgFileName, 
 		const char* newFileName = NULL);
@@ -67,9 +55,7 @@
 		m_verbosity = verbosity;
 	}
 
-	bool Use64Bits() {
-		return m_use64bits;
-	}
+	bool Use64Bits(const char *atomName);
 
 	/* file properties */
 
@@ -206,10 +192,13 @@
 		MP4Duration sampleDuration,
 		u_int8_t audioType);
 
+#ifdef ISMACRYP
 	MP4TrackId AddEncAudioTrack( // ismacrypt
 		u_int32_t timeScale, 
 		MP4Duration sampleDuration,
-		u_int8_t audioType);
+		u_int8_t audioType,
+		ismacryp_session_id_t ismaCryptSId);
+#endif
 
 	MP4TrackId AddVideoTrack(
 		u_int32_t timeScale, 
@@ -217,13 +206,16 @@
 		u_int16_t width, 
 		u_int16_t height, 
 		u_int8_t videoType);
-	
+
+#ifdef ISMACRYP	
 	MP4TrackId AddEncVideoTrack( // ismacrypt
 		u_int32_t timeScale, 
 		MP4Duration sampleDuration,
 		u_int16_t width, 
 		u_int16_t height, 
+		ismacryp_session_id_t ismaCryptSId,
 		u_int8_t videoType);
+#endif
 
 	MP4TrackId AddHintTrack(MP4TrackId refTrackId);
 
@@ -441,46 +433,49 @@
 		MP4Timestamp* pStartTime = NULL,
 		MP4Duration* pDuration = NULL);
 
-    /* iTunes metadata handling */
-    bool CreateMetadataAtom(const char* name);
-    bool MetadataDelete();
-
-    /* set metadata */
-    bool SetMetadataName(const char* value);
-    bool SetMetadataWriter(const char* value);
-    bool SetMetadataAlbum(const char* value);
-    bool SetMetadataArtist(const char* value);
-    bool SetMetadataTool(const char* value);
-    bool SetMetadataComment(const char* value);
-    bool SetMetadataYear(const char* value);
-    bool SetMetadataTrack(u_int16_t track, u_int16_t totalTracks);
-    bool SetMetadataDisk(u_int16_t disk, u_int16_t totalDisks);
-    bool SetMetadataGenre(const char* genreIndex);
-    bool SetMetadataTempo(u_int16_t tempo);
-    bool SetMetadataCompilation(u_int8_t compilation);
-    bool SetMetadataCoverArt(u_int8_t *coverArt, u_int32_t size);
-    bool SetMetadataFreeForm(char *name, u_int8_t* pValue, u_int32_t valueSize);
-
-    /* get metadata */
-    bool GetMetadataByIndex(u_int32_t index,
-        const char** ppName,
-        u_int8_t** ppValue, u_int32_t* pValueSize);
-    bool GetMetadataName(char** value);
-    bool GetMetadataWriter(char** value);
-    bool GetMetadataAlbum(char** value);
-    bool GetMetadataArtist(char** value);
-    bool GetMetadataTool(char** value);
-    bool GetMetadataComment(char** value);
-    bool GetMetadataYear(char** value);
-    bool GetMetadataTrack(u_int16_t* track, u_int16_t* totalTracks);
-    bool GetMetadataDisk(u_int16_t* disk, u_int16_t* totalDisks);
-    bool GetMetadataGenre(char** genre);
-    bool GetMetadataTempo(u_int16_t* tempo);
-    bool GetMetadataCompilation(u_int8_t* compilation);
-    bool GetMetadataCoverArt(u_int8_t **coverArt, u_int32_t* size);
-    bool GetMetadataFreeForm(char *name, u_int8_t** pValue, u_int32_t* valueSize);
-
-
+	/* iTunes metadata handling */
+	bool CreateMetadataAtom(const char* name);
+	bool MetadataDelete(void);
+	
+	/* set metadata */
+	bool SetMetadataName(const char* value);
+	bool SetMetadataWriter(const char* value);
+	bool SetMetadataAlbum(const char* value);
+	bool SetMetadataArtist(const char* value);
+	bool SetMetadataTool(const char* value);
+	bool SetMetadataComment(const char* value);
+	bool SetMetadataYear(const char* value);
+	bool SetMetadataTrack(u_int16_t track, u_int16_t totalTracks);
+	bool SetMetadataDisk(u_int16_t disk, u_int16_t totalDisks);
+	bool SetMetadataGenre(const char *value);
+	bool SetMetadataTempo(u_int16_t tempo);
+	bool SetMetadataCompilation(u_int8_t compilation);
+	bool SetMetadataCoverArt(u_int8_t *coverArt, u_int32_t size);
+	bool SetMetadataFreeForm(char *name, 
+				 u_int8_t* pValue, 
+				 u_int32_t valueSize);
+ 
+	/* get metadata */
+	bool GetMetadataByIndex(u_int32_t index,
+				const char** ppName,
+				u_int8_t** ppValue, 
+				u_int32_t* pValueSize);
+	bool GetMetadataName(char** value);
+	bool GetMetadataWriter(char** value);
+	bool GetMetadataAlbum(char** value);
+	bool GetMetadataArtist(char** value);
+	bool GetMetadataTool(char** value);
+	bool GetMetadataComment(char** value);
+	bool GetMetadataYear(char** value);
+	bool GetMetadataTrack(u_int16_t* track, u_int16_t* totalTracks);
+	bool GetMetadataDisk(u_int16_t* disk, u_int16_t* totalDisks);
+	bool GetMetadataGenre(char **value);
+	bool GetMetadataTempo(u_int16_t* tempo);
+	bool GetMetadataCompilation(u_int8_t* compilation);
+	bool GetMetadataCoverArt(u_int8_t **coverArt, u_int32_t* size);
+	bool GetMetadataFreeForm(char *name, 
+				 u_int8_t** pValue, 
+				 u_int32_t* valueSize);
 	/* end of MP4 API */
 
 	/* "protected" interface to be used only by friends in library */
@@ -570,18 +565,6 @@
 		MP4Atom* pAncestorAtom,
 		const char* childName);
 
-#ifdef USE_FILE_CALLBACKS
-    MP4OpenCallback m_MP4fopen;
-    MP4CloseCallback m_MP4fclose;
-    MP4ReadCallback m_MP4fread;
-    MP4WriteCallback m_MP4fwrite;
-    MP4SetposCallback m_MP4fsetpos;
-    MP4GetposCallback m_MP4fgetpos;
-    MP4FilesizeCallback m_MP4filesize;
-
-    void *m_userData;
-#endif
-
 protected:
 	void Open(const char* fmode);
 	void ReadFromFile();
@@ -686,7 +669,7 @@
 	MP4TrackId		m_odTrackId;
 	u_int32_t		m_verbosity;
 	char			m_mode;
-	bool			m_use64bits;
+	u_int32_t               m_createFlags;
 	bool			m_useIsma;
 
 	// cached properties
@@ -704,16 +687,6 @@
 	u_int8_t	m_bufReadBits;
 	u_int8_t	m_numWriteBits;
 	u_int8_t	m_bufWriteBits;
-
-#ifdef USE_FILE_CALLBACKS
-    static u_int32_t MP4fopen_cb(const char *pName, const char *mode, void *userData);
-    static void MP4fclose_cb(void *userData);
-    static u_int32_t MP4fread_cb(void *pBuffer, unsigned int nBytesToRead, void *userData);
-    static u_int32_t MP4fwrite_cb(void *pBuffer, unsigned int nBytesToWrite, void *userData);
-    static int32_t MP4fsetpos_cb(u_int32_t pos, void *userData);
-    static int64_t MP4fgetpos_cb(void *userData);
-    static int64_t MP4filesize_cb(void *userData);
-#endif
 };
 
 #endif /* __MP4_FILE_INCLUDED__ */
--- a/common/mp4v2/mp4file_io.cpp
+++ b/common/mp4v2/mp4file_io.cpp
@@ -34,25 +34,16 @@
 u_int64_t MP4File::GetPosition(FILE* pFile)
 {
 	if (m_memoryBuffer == NULL) {
-#ifndef USE_FILE_CALLBACKS
-		fpos_t fpos;
 		if (pFile == NULL) {
 			ASSERT(m_pFile);
 			pFile = m_pFile;
 		}
 
+		fpos_t fpos;
 		if (fgetpos(pFile, &fpos) < 0) {
 			throw new MP4Error(errno, "MP4GetPosition");
 		}
 		return FPOS_TO_UINT64(fpos);
-#else
-
-        u_int64_t pos;
-		if ((pos = m_MP4fgetpos(m_userData)) < 0) {
-			throw new MP4Error(errno, "MP4GetPosition");
-		}
-		return (u_int64_t)pos;
-#endif
 	} else {
 		return m_memoryBufferPosition;
 	}
@@ -61,7 +52,6 @@
 void MP4File::SetPosition(u_int64_t pos, FILE* pFile)
 {
 	if (m_memoryBuffer == NULL) {
-#ifndef USE_FILE_CALLBACKS
 		if (pFile == NULL) {
 			ASSERT(m_pFile);
 			pFile = m_pFile;
@@ -72,11 +62,6 @@
 		if (fsetpos(pFile, &fpos) < 0) {
 			throw new MP4Error(errno, "MP4SetPosition");
 		}
-#else
-		if (m_MP4fsetpos(pos, m_userData) < 0) {
-			throw new MP4Error(errno, "MP4SetPosition");
-		}
-#endif
 	} else {
 		if (pos >= m_memoryBufferSize) {
 		  //		  abort();
@@ -109,15 +94,12 @@
 	ASSERT(pBytes);
 	WARNING(m_numReadBits > 0);
 
-#ifndef USE_FILE_CALLBACKS
 	if (pFile == NULL) {
 		pFile = m_pFile;
 	}
 	ASSERT(pFile);
-#endif
 
 	if (m_memoryBuffer == NULL) {
-#ifndef USE_FILE_CALLBACKS
 		if (fread(pBytes, 1, numBytes, pFile) != numBytes) {
 			if (feof(pFile)) {
 				throw new MP4Error(
@@ -124,10 +106,6 @@
 					"not enough bytes, reached end-of-file",
 					"MP4ReadBytes");
 			} else {
-#else
-		if (m_MP4fread(pBytes, numBytes, m_userData) != numBytes) {
-            {
-#endif
 				throw new MP4Error(errno, "MP4ReadBytes");
 			}
 		}
@@ -194,7 +172,6 @@
 	}
 
 	if (m_memoryBuffer == NULL) {
-#ifndef USE_FILE_CALLBACKS
 		if (pFile == NULL) {
 			ASSERT(m_pFile);
 			pFile = m_pFile;
@@ -201,9 +178,6 @@
 		}
 
 		u_int32_t rc = fwrite(pBytes, 1, numBytes, pFile);
-#else
-		u_int32_t rc = m_MP4fwrite(pBytes, numBytes, m_userData);
-#endif
 		if (rc != numBytes) {
 			throw new MP4Error(errno, "MP4WriteBytes");
 		}
@@ -587,69 +561,3 @@
 	} while (i > 0);
 }
 
-#ifdef USE_FILE_CALLBACKS
-u_int32_t MP4File::MP4fopen_cb(const char *pName,
-                               const char *mode, void *userData)
-{
-    MP4File *myFile = (MP4File*)userData;
-
-    myFile->m_pFile = fopen(pName, mode);
-    if (myFile->m_pFile == NULL)
-        return 0;
-
-    return 1;
-}
-
-void MP4File::MP4fclose_cb(void *userData)
-{
-    MP4File *myFile = (MP4File*)userData;
-
-    fclose(myFile->m_pFile);
-    myFile->m_pFile = NULL;
-}
-
-u_int32_t MP4File::MP4fread_cb(void *pBuffer, unsigned int nBytesToRead,
-                               void *userData)
-{
-    MP4File *myFile = (MP4File*)userData;
-
-    return fread(pBuffer, 1, nBytesToRead, myFile->m_pFile);
-}
-
-u_int32_t MP4File::MP4fwrite_cb(void *pBuffer, unsigned int nBytesToWrite,
-                                void *userData)
-{
-    MP4File *myFile = (MP4File*)userData;
-
-    return fwrite(pBuffer, 1, nBytesToWrite, myFile->m_pFile);
-}
-
-int64_t MP4File::MP4fgetpos_cb(void *userData)
-{
-    fpos_t fpos;
-    MP4File *myFile = (MP4File*)userData;
-
-    if (fgetpos(myFile->m_pFile, &fpos) < 0)
-        return -1;
-    return FPOS_TO_UINT64(fpos);
-}
-
-int32_t MP4File::MP4fsetpos_cb(u_int32_t pos, void *userData)
-{
-    fpos_t fpos;
-    MP4File *myFile = (MP4File*)userData;
-
-    VAR_TO_FPOS(fpos, pos);
-    return fsetpos(myFile->m_pFile, &fpos);
-}
-
-int64_t MP4File::MP4filesize_cb(void *userData)
-{
-    struct stat s;
-    MP4File *myFile = (MP4File*)userData;
-
-    if (fstat(fileno(myFile->m_pFile), &s) < 0)
-        return -1;
-    return s.st_size;
-}
-#endif
--- a/common/mp4v2/mp4info.cpp
+++ b/common/mp4v2/mp4info.cpp
@@ -27,6 +27,7 @@
 	MP4TrackId trackId)
 {
 	static const char* mpeg4AudioNames[] = {
+#if 0
 		"MPEG-4 Main @ L1",
 		"MPEG-4 Main @ L2",
 		"MPEG-4 Main @ L3",
@@ -40,9 +41,39 @@
 		"MPEG-4 Synthesis @ L1",
 		"MPEG-4 Synthesis @ L2",
 		"MPEG-4 Synthesis @ L3",
+#else
+		"MPEG-4 AAC main",
+		"MPEG-4 AAC LC", 
+		"MPEG-4 AAC SSR",
+		"MPEG-4 AAC LTP",
+		NULL,
+		"MPEG-4 AAC Scalable",
+		"MPEG-4 TwinVQ",
+		"MPEG-4 CELP",
+		"MPEG-4 HVXC",
+		NULL, NULL,
+		"MPEG-4 TTSI",
+		"MPEG-4 Main Synthetic",
+		"MPEG-4 Wavetable Syn",
+		"MPEG-4 General MIDI",
+		"MPEG-4 Algo Syn and Audio FX",
+		"MPEG-4 ER AAC LC",
+		NULL,
+		"MPEG-4 ER AAC LTP",
+		"MPEG-4 ER AAC Scalable",
+		"MPEG-4 ER TwinVQ",
+		"MPEG-4 ER BSAC",
+		"MPEG-4 ER ACC LD",
+		"MPEG-4 ER CELP",
+		"MPEG-4 ER HVXC",
+		"MPEG-4 ER HILN",
+		"MPEG-4 ER Parametric",
+#endif
 	};
+#if 0
 	static u_int8_t numMpeg4AudioTypes = 
 		sizeof(mpeg4AudioNames) / sizeof(char*);
+#endif
 
 	static u_int8_t mpegAudioTypes[] = {
 		MP4_MPEG2_AAC_MAIN_AUDIO_TYPE,	// 0x66
@@ -78,12 +109,31 @@
 	const char* typeName = "Unknown";
 
 	if (type == MP4_MPEG4_AUDIO_TYPE) {
+	  u_int8_t* pAacConfig = NULL;
+	  u_int32_t aacConfigLength;
+
+	  MP4GetTrackESConfiguration(mp4File, 
+				     trackId,
+				     &pAacConfig,
+				     &aacConfigLength);
+
+	  if (pAacConfig != NULL && aacConfigLength >= 2) {
+	    type = (pAacConfig[0] >> 3) & 0x1f;
+	    if (type == 0 || type == 5 || type == 10 || type == 11 ||
+		type == 18 || type >= 28) {
+	      typeName = "MPEG-4";
+	    } else {
+	      typeName = mpeg4AudioNames[type - 1];
+	    }
+	    free(pAacConfig);
+#if 0
 		type = MP4GetAudioProfileLevel(mp4File);
-		if (type > 0 && type <= numMpeg4AudioTypes) {
+		if (type > 0 && type <= numMpeg4AudioTypes) 
 			typeName = mpeg4AudioNames[type - 1];
-		} else {
-			typeName = "MPEG-4";
-		}
+#endif
+	  } else {
+	    typeName = "MPEG-4";
+	  }
 	} else {
 		for (u_int8_t i = 0; i < numMpegAudioTypes; i++) {
 			if (type == mpegAudioTypes[i]) {
@@ -112,7 +162,7 @@
 	sprintf(sInfo,	
 		"%u\taudio\t%s, %.3f secs, %u kbps, %u Hz\n", 
 		trackId, 
-		typeName,
+		typeName, 
 		msDuration / 1000.0, 
 		(avgBitRate + 500) / 1000, 
 		timeScale);
@@ -119,30 +169,85 @@
 
 	return sInfo;
 }
+static struct {
+  uint8_t profile;
+  const char *name;
+} VisualProfileToName[] = {
+  { MPEG4_SP_L1, "MPEG-4 Simple @ L1"},
+  { MPEG4_SP_L2, "MPEG-4 Simple @ L2" },
+  { MPEG4_SP_L3, "MPEG-4 Simple @ L3" },
+  { MPEG4_SP_L0, "MPEG-4 Simple @ L0" },
+  { MPEG4_SSP_L1, "MPEG-4 Simple Scalable @ L1"},
+  { MPEG4_SSP_L2, "MPEG-4 Simple Scalable @ L2" },
+  { MPEG4_CP_L1, "MPEG-4 Core @ L1"},
+  { MPEG4_CP_L2, "MPEG-4 Core @ L2"},
+  { MPEG4_MP_L2, "MPEG-4 Main @ L2"},
+  { MPEG4_MP_L3, "MPEG-4 Main @ L3"},
+  { MPEG4_MP_L4, "MPEG-4 Main @ L4"},
+  { MPEG4_NBP_L2, "MPEG-4 N-bit @ L2"},
+  { MPEG4_STP_L1, "MPEG-4  Scalable Texture @ L1"},
+  { MPEG4_SFAP_L1, "MPEG-4 Simple Face Anim @ L1"},
+  { MPEG4_SFAP_L2, "MPEG-4  Simple Face Anim @ L2"},
+  { MPEG4_SFBAP_L1, "MPEG-4  Simple FBA @ L1"},
+  { MPEG4_SFBAP_L2, "MPEG-4 Simple FBA @ L2"},
+  { MPEG4_BATP_L1, "MPEG-4 Basic Anim Text @ L1"},
+  { MPEG4_BATP_L2, "MPEG-4 Basic Anim Text @ L2"},
+  { MPEG4_HP_L1, "MPEG-4 Hybrid @ L1"},
+  { MPEG4_HP_L2, "MPEG-4 Hybrid @ L2"},
+  { MPEG4_ARTSP_L1, "MPEG-4 Adv RT Simple @ L1"},
+  { MPEG4_ARTSP_L2, "MPEG-4 Adv RT Simple @ L2"},
+  { MPEG4_ARTSP_L3, "MPEG-4 Adv RT Simple @ L3"},
+  { MPEG4_ARTSP_L4, "MPEG-4 Adv RT Simple @ L4"},
+  { MPEG4_CSP_L1, "MPEG-4 Core Scalable @ L1"},
+  { MPEG4_CSP_L2, "MPEG-4 Core Scalable @ L2"},
+  { MPEG4_CSP_L3, "MPEG-4 Core Scalable @ L3"},
+  { MPEG4_ACEP_L1, "MPEG-4 Adv Coding Efficieny @ L1"},
+  { MPEG4_ACEP_L2, "MPEG-4 Adv Coding Efficieny @ L2"},
+  { MPEG4_ACEP_L3, "MPEG-4 Adv Coding Efficieny @ L3"},
+  { MPEG4_ACEP_L4, "MPEG-4 Adv Coding Efficieny @ L4"},
+  { MPEG4_ACP_L1, "MPEG-4 Adv Core Profile @ L1"},
+  { MPEG4_ACP_L2, "MPEG-4 Adv Core Profile @ L2"},
+  { MPEG4_AST_L1, "MPEG-4 Adv Scalable Texture @ L1"},
+  { MPEG4_AST_L2, "MPEG-4 Adv Scalable Texture @ L2"},
+  { MPEG4_AST_L3, "MPEG-4 Adv Scalable Texture @ L3"},
+  { MPEG4_S_STUDIO_P_L1, "MPEG-4 Simple Studio @ L1"},
+  { MPEG4_S_STUDIO_P_L2, "MPEG-4 Simple Studio @ L2"},
+  { MPEG4_S_STUDIO_P_L3, "MPEG-4 Simple Studio @ L3"},
+  { MPEG4_S_STUDIO_P_L4, "MPEG-4 Simple Studio @ L4"},
+  { MPEG4_C_STUDIO_P_L1, "MPEG-4 Core Studio @ L1"},
+  { MPEG4_C_STUDIO_P_L2, "MPEG-4 Core Studio @ L2"},
+  { MPEG4_C_STUDIO_P_L3, "MPEG-4 Core Studio @ L3"},
+  { MPEG4_C_STUDIO_P_L4, "MPEG-4 Core Studio @ L4"},
+  { MPEG4_ASP_L0, "MPEG-4 Adv Simple@L0"},
+  { MPEG4_ASP_L1, "MPEG-4 Adv Simple@L1"},
+  { MPEG4_ASP_L2, "MPEG-4 Adv Simple@L2"},
+  { MPEG4_ASP_L3, "MPEG-4 Adv Simple@L3"},
+  { MPEG4_ASP_L4, "MPEG-4 Adv Simple@L4"},
+  { MPEG4_ASP_L5, "MPEG-4 Adv Simple@L5"},
+  { MPEG4_ASP_L3B, "MPEG-4 Adv Simple@L3b"},
+  { MPEG4_FGSP_L0, "MPEG-4 FGS @ L0" },
+  { MPEG4_FGSP_L1, "MPEG-4 FGS @ L1" },
+  { MPEG4_FGSP_L2, "MPEG-4 FGS @ L2" },
+  { MPEG4_FGSP_L3, "MPEG-4 FGS @ L3" },
+  { MPEG4_FGSP_L4, "MPEG-4 FGS @ L4" },
+  { MPEG4_FGSP_L5, "MPEG-4 FGS @ L5" }
+};
 
+static const char *Mpeg4VisualProfileName (uint8_t visual_profile)
+{
+  size_t size = sizeof(VisualProfileToName) / sizeof(*VisualProfileToName);
+
+  for (size_t ix = 0; ix < size; ix++) {
+    if (visual_profile == VisualProfileToName[ix].profile) {
+      return (VisualProfileToName[ix].name);
+    }
+  }
+  return ("MPEG-4");
+}
 static char* PrintVideoInfo(
 	MP4FileHandle mp4File, 
 	MP4TrackId trackId)
 {
-	static const char* mpeg4VideoNames[] = {
-		"MPEG-4 Simple @ L3",
-		"MPEG-4 Simple @ L2",
-		"MPEG-4 Simple @ L1",
-		"MPEG-4 Simple Scalable @ L2",
-		"MPEG-4 Simple Scalable @ L1",
-		"MPEG-4 Core @ L2",
-		"MPEG-4 Core @ L1",
-		"MPEG-4 Main @ L4",
-		"MPEG-4 Main @ L3",
-		"MPEG-4 Main @ L2",
-		"MPEG-4 Main @ L1",
-		"MPEG-4 N-Bit @ L2",
-		"MPEG-4 Hybrid @ L2",
-		"MPEG-4 Hybrid @ L1",
-		"MPEG-4 Hybrid @ L1",
-	};
-	static u_int8_t numMpeg4VideoTypes = 
-		sizeof(mpeg4VideoNames) / sizeof(char*);
 
 	static u_int8_t mpegVideoTypes[] = {
 		MP4_MPEG2_SIMPLE_VIDEO_TYPE,	// 0x60
@@ -181,11 +286,7 @@
 
 	if (type == MP4_MPEG4_VIDEO_TYPE) {
 		type = MP4GetVideoProfileLevel(mp4File);
-		if (type > 0 && type <= numMpeg4VideoTypes) {
-			typeName = mpeg4VideoNames[type - 1];
-		} else {
-			typeName = "MPEG-4";
-		}
+		typeName = Mpeg4VisualProfileName(type);
 	} else {
 		for (u_int8_t i = 0; i < numMpegVideoTypes; i++) {
 			if (type == mpegVideoTypes[i]) {
--- a/common/mp4v2/mp4meta.cpp
+++ b/common/mp4v2/mp4meta.cpp
@@ -102,7 +102,7 @@
         return false;
 
     /* some fields need special flags set */
-    if (name[0] == '�')
+    if ((uint8_t)name[0] == 0251)
     {
         pMetaAtom->SetFlags(0x1);
     } else if ((memcmp(name, "cpil", 4) == 0) || (memcmp(name, "tmpo", 4) == 0)) {
@@ -574,7 +574,8 @@
 
 int GenreToString(char** GenreStr, const int genre)
 {
-    if (genre > 0 && genre <= sizeof(ID3v1GenreList)/sizeof(*ID3v1GenreList))
+  if (genre > 0 && 
+      genre <= (int)(sizeof(ID3v1GenreList)/sizeof(*ID3v1GenreList)))
     {
         *GenreStr = (char*)malloc((strlen(ID3v1GenreList[genre-1])+1)*sizeof(char));
         memset(*GenreStr, 0, (strlen(ID3v1GenreList[genre-1])+1)*sizeof(char));
@@ -589,7 +590,7 @@
 
 int StringToGenre(const char* GenreStr)
 {
-    int i;
+    unsigned int i;
 
     for (i = 0; i < sizeof(ID3v1GenreList)/sizeof(*ID3v1GenreList); i++)
     {
@@ -830,7 +831,6 @@
     MP4BytesProperty *pMetadataProperty = NULL;
     char s[256];
     int i = 0;
-    bool nameExists = false;
 
     while (1)
     {
--- a/common/mp4v2/mp4property.cpp
+++ b/common/mp4v2/mp4property.cpp
@@ -195,11 +195,7 @@
 	}
 	Indent(pFile, indent);
 	fprintf(pFile, 
-#ifdef _WIN32
-		"%s = "LLU" (0x%016I64x)\n", 
-#else
-		"%s = "LLU" (0x%016llx)\n", 
-#endif
+		"%s = "U64" (0x%016"X64F")\n", 
 		m_name, m_values[index], m_values[index]);
 }
 
@@ -234,11 +230,7 @@
 		hexWidth++;
 	}
 	fprintf(pFile, 
-#ifdef _WIN32
-		"%s = "LLU" (0x%0*I64x) <%u bits>\n", 
-#else
-		"%s = "LLU" (0x%0*llx) <%u bits>\n", 
-#endif
+		"%s = "U64" (0x%0*"X64F") <%u bits>\n", 
 		m_name, m_values[index], (int)hexWidth, m_values[index], m_numBits);
 }
 
--- a/common/mp4v2/mp4track.cpp
+++ b/common/mp4v2/mp4track.cpp
@@ -247,7 +247,7 @@
 	*pNumBytes = sampleSize;
 
 	VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(),
-		printf("ReadSample: track %u id %u offset 0x"LLX" size %u (0x%x)\n",
+		printf("ReadSample: track %u id %u offset 0x"X64" size %u (0x%x)\n",
 			m_trackId, sampleId, fileOffset, *pNumBytes, *pNumBytes));
 
 	bool bufferMalloc = false;
@@ -265,7 +265,7 @@
 			GetSampleTimes(sampleId, pStartTime, pDuration);
 
 			VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(),
-				printf("ReadSample:  start "LLU" duration "LLD"\n",
+				printf("ReadSample:  start "U64" duration "D64"\n",
 					(pStartTime ? *pStartTime : 0), 
 					(pDuration ? *pDuration : 0)));
 		}
@@ -273,7 +273,7 @@
 			*pRenderingOffset = GetSampleRenderingOffset(sampleId);
 
 			VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(),
-				printf("ReadSample:  renderingOffset "LLD"\n",
+				printf("ReadSample:  renderingOffset "D64"\n",
 					*pRenderingOffset));
 		}
 		if (pIsSyncSample) {
@@ -355,7 +355,7 @@
 	}
 
 	VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(),
-		printf("duration "LLU"\n", duration));
+		printf("duration "U64"\n", duration));
 
 	// append sample bytes to chunk buffer
 	m_pChunkBuffer = (u_int8_t*)MP4Realloc(m_pChunkBuffer, 
@@ -396,7 +396,7 @@
 	m_pFile->WriteBytes(m_pChunkBuffer, m_chunkBufferSize);
 
 	VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(),
-		printf("WriteChunk: track %u offset 0x"LLX" size %u (0x%x) numSamples %u\n",
+		printf("WriteChunk: track %u offset 0x"X64" size %u (0x%x) numSamples %u\n",
 			m_trackId, chunkOffset, m_chunkBufferSize, 
 			m_chunkBufferSize, m_chunkSamples));
 
@@ -673,7 +673,6 @@
 	if (pUrlAtom->GetFlags() & 1) {
 		pFile = NULL;	// self-contained
 	} else {
-#ifndef USE_FILE_CALLBACKS
 		MP4StringProperty* pLocationProperty = NULL;
 		pUrlAtom->FindProperty(
 			"*.location", 
@@ -701,17 +700,10 @@
 				}
 			}
 		} 
-#else
-        throw new MP4Error(errno, "Function not supported when using callbacks", "GetSampleFile");
-#endif
 	}
 
 	if (m_lastSampleFile) {
-#ifndef USE_FILE_CALLBACKS
 		fclose(m_lastSampleFile);
-#else
-        throw new MP4Error(errno, "Function not supported when using callbacks", "GetSampleFile");
-#endif
 	}
 
 	// cache the answer
@@ -1309,7 +1301,7 @@
 	*ppChunk = (u_int8_t*)MP4Malloc(*pChunkSize);
 
 	VERBOSE_READ_SAMPLE(m_pFile->GetVerbosity(),
-		printf("ReadChunk: track %u id %u offset 0x"LLX" size %u (0x%x)\n",
+		printf("ReadChunk: track %u id %u offset 0x"X64" size %u (0x%x)\n",
 			m_trackId, chunkId, chunkOffset, *pChunkSize, *pChunkSize));
 
 	u_int64_t oldPos = m_pFile->GetPosition(); // only used in mode == 'w'
@@ -1343,7 +1335,7 @@
 	m_pChunkOffsetProperty->SetValue(chunkOffset, chunkId - 1);
 
 	VERBOSE_WRITE_SAMPLE(m_pFile->GetVerbosity(),
-		printf("RewriteChunk: track %u id %u offset 0x"LLX" size %u (0x%x)\n",
+		printf("RewriteChunk: track %u id %u offset 0x"X64" size %u (0x%x)\n",
 			m_trackId, chunkId, chunkOffset, chunkSize, chunkSize)); 
 }
 
--- a/common/mp4v2/mpeg4ip.h
+++ b/common/mp4v2/mpeg4ip.h
@@ -3,20 +3,20 @@
  * License Version 1.1 (the "License"); you may not use this file
  * except in compliance with the License. You may obtain a copy of
  * the License at http://www.mozilla.org/MPL/
- *
+ * 
  * Software distributed under the License is distributed on an "AS
  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * rights and limitations under the License.
- *
+ * 
  * The Original Code is MPEG4IP.
- *
+ * 
  * The Initial Developer of the Original Code is Cisco Systems Inc.
  * Portions created by Cisco Systems Inc. are
  * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
- *
- * Contributor(s):
- *      Dave Mackie     dmackie@cisco.com
+ * 
+ * Contributor(s): 
+ *		Dave Mackie		dmackie@cisco.com
  */
 
 #ifndef __MPEG4IP_INCLUDED__
@@ -24,12 +24,307 @@
 
 /* project wide applicable stuff here */
 
+
+#ifdef WIN32
+#define HAVE_IN_PORT_T
+#define HAVE_SOCKLEN_T
+#include <win32_ver.h>
+#define NEED_SDL_VIDEO_IN_MAIN_THREAD
+#else
+#undef PACKAGE
+#undef VERSION
+#include <mpeg4ip_config.h>
+#endif
+
+
+
+
+#ifdef WIN32
+
+#define _WIN32_WINNT 0x0400
+#define _WINSOCKAPI_
+#include <windows.h>
+#include <winsock2.h>
 #include <stdio.h>
-#include <systems.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <limits.h>
 
+typedef unsigned __int64 uint64_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int64 u_int64_t;
+typedef unsigned __int32 u_int32_t;
+typedef unsigned __int16 u_int16_t;
+typedef unsigned __int8 u_int8_t;
+typedef __int64 int64_t;
+typedef __int32 int32_t;
+typedef __int16 int16_t;
+typedef __int8  int8_t;
+typedef unsigned short in_port_t;
+typedef int socklen_t;
+typedef int ssize_t;
+#define snprintf _snprintf
+#define strncasecmp _strnicmp
+#define strcasecmp _stricmp
+
+#include <io.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#define write _write
+#define lseek _lseek
+#define close _close
+#define open _open
+#define access _access
+#define vsnprintf _vsnprintf
+#define F_OK 0
+#define OPEN_RDWR (_O_RDWR | _O_BINARY)
+#define OPEN_CREAT (_O_CREAT | _O_BINARY)
+#define OPEN_RDONLY (_O_RDONLY | _O_BINARY)
+#define srandom srand
+#define random rand
+
+#define IOSBINARY ios::binary
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int gettimeofday(struct timeval *t, void *);
+#ifdef __cplusplus
+}
+#endif
+
+#define PATH_MAX MAX_PATH
+#define MAX_UINT64 -1
+#define D64F "I64d"
+#define U64F  "I64u"
+#define X64F "I64x"
+#define M_64 1000i64
+#define C_64 100i64
+#define I_64 1i64
+
+#define LOG_EMERG 0
+#define LOG_ALERT 1
+#define LOG_CRIT 2
+#define LOG_ERR 3
+#define LOG_WARNING 4
+#define LOG_NOTICE 5
+#define LOG_INFO 6
+#define LOG_DEBUG 7
+
+#if     !__STDC__ && _INTEGRAL_MAX_BITS >= 64
+#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(_FPOSOFF(fpos))
+#else
+#define VAR_TO_FPOS(fpos, var) (fpos).lopart = ((var) & UINT_MAX); (fpos).hipart = ((var) >> 32)
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((uint64_t)((fpos).hipart ) << 32 | (fpos).lopart)
+#endif
+
+#define __STRING(expr) #expr
+
+#define FOPEN_READ_BINARY "rb"
+#define FOPEN_WRITE_BINARY "wb"
+
+#define UINT64_TO_DOUBLE(a) ((double)((int64_t)(a)))
+#else /* UNIX */
+/*****************************************************************************
+ *   UNIX LIKE DEFINES BELOW THIS POINT
+ *****************************************************************************/
+#ifdef sun
+#include <sys/feature_tests.h>
+#endif
+
+#ifndef _FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 64
+#else
+#ifndef sun
+#if _FILE_OFFSET_BITS < 64
+ #error File offset bits is already set to non-64 value
+#endif
+#endif
+#endif
+
+#ifndef _LARGEFILE_SOURCE
+#define _LARGEFILE_SOURCE
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+#error "Don't have stdint.h or inttypes.h - no way to get uint8_t"
+#endif
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <syslog.h>
+#include <string.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <sys/stat.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+#include <sys/param.h>
+
+#define OPEN_RDWR O_RDWR
+#define OPEN_CREAT O_CREAT 
+#define OPEN_RDONLY O_RDONLY
+
+#define closesocket close
+#define IOSBINARY ios::bin
+
+#if SIZEOF_LONG == 8
+#define MAX_UINT64 -1LU
+#define D64F "ld"
+#define U64F  "lu"
+#define X64F "lx"
+
+#define MM_64 1000000LU
+#define M_64 1000LU
+#define C_64 100LU
+#define I_64 1LU
+#else
+#define MAX_UINT64 -1LLU
+#define D64F "lld"
+#define U64F  "llu"
+#define X64F "llx"
+
+#define MM_64 1000000LLU
+#define M_64 1000LLU
+#define C_64 100LLU
+#define I_64 1LLU
+#endif
+
+#ifdef HAVE_FPOS_T_POS
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((fpos).__pos)
+#define VAR_TO_FPOS(fpos, var) (fpos).__pos = (var)
+#else
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
+#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
+#endif
+
+#define FOPEN_READ_BINARY "r"
+#define FOPEN_WRITE_BINARY "w"
+#define UINT64_TO_DOUBLE(a) ((double)(a))
+#endif /* define unix */
+
+/*****************************************************************************
+ *             Generic type includes used in the whole package               *
+ *****************************************************************************/
+#define D64  "%"D64F
+#define U64  "%"U64F
+#define X64 "%"X64F
+
+#include <stdarg.h>
+typedef void (*error_msg_func_t)(int loglevel,
+				 const char *lib,
+				 const char *fmt,
+				 va_list ap);
+typedef void (*lib_message_func_t)(int loglevel,
+				   const char *lib,
+				   const char *fmt,
+				   ...);
+#ifndef HAVE_IN_PORT_T
+typedef uint16_t in_port_t;
+#endif
+
+#ifndef HAVE_SOCKLEN_T
+typedef unsigned int socklen_t;
+#endif
+
+#ifdef sun
+#include <limits.h>
+#define u_int8_t uint8_t
+#define u_int16_t uint16_t
+#define u_int32_t uint32_t
+#define u_int64_t uint64_t
+#define __STRING(expr) #expr
+#endif
+
+#ifndef HAVE_STRSEP
+#ifdef __cplusplus
+extern "C" {
+#endif
+char *strsep(char **strp, const char *delim); 
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE (-1)
+#endif
+
+#define MALLOC_STRUCTURE(a) ((a *)malloc(sizeof(a)))
+
+#define CHECK_AND_FREE(a) if ((a) != NULL) { free((void *)(a)); (a) = NULL;}
+
+#define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name))))
+
+#define ADV_SPACE(a) {while (isspace(*(a)) && (*(a) != '\0'))(a)++;}
+
+#ifndef HAVE_GTK
+typedef char gchar;
+typedef unsigned char guchar;
+
+typedef int gint;
+typedef unsigned int guint;
+
+typedef long glong;
+typedef unsigned long gulong;
+
+typedef double gdouble;
+
+typedef int gboolean;
+
+typedef int16_t gint16;
+typedef uint16_t guint16;
+
+typedef int32_t gint32;
+typedef uint32_t guint32;
+
+typedef int64_t gint64;
+typedef uint64_t guint64;
+
+typedef uint8_t  guint8;
+typedef int8_t gint8;
+
+#endif
+
 #ifndef FALSE
 #define FALSE 0
 #endif
+
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -38,13 +333,6 @@
 #ifndef bool
 typedef unsigned char bool;
 #endif
-#endif
-
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
 
 #ifndef ROUND
--- a/common/mp4v2/need_for_win32.c
+++ b/common/mp4v2/need_for_win32.c
@@ -1,4 +1,4 @@
-#include "systems.h"
+#include "mpeg4ip.h"
 #include <sys/timeb.h>
 
 int gettimeofday (struct timeval *t, void *foo)
--- a/common/mp4v2/rtphint.cpp
+++ b/common/mp4v2/rtphint.cpp
@@ -313,6 +313,9 @@
 	u_int16_t* pMaxPayloadSize,
 	char **ppEncodingParams)
 {
+  const char* pRtpMap;
+  char* pSlash;
+  u_int32_t length;
 	InitPayload();
 
 	if (ppPayloadName || ppEncodingParams) {
@@ -321,10 +324,9 @@
 	  if (ppEncodingParams)
 	    *ppEncodingParams = NULL;
 		if (m_pRtpMapProperty) {
-			const char* pRtpMap = m_pRtpMapProperty->GetValue();
-			char* pSlash = strchr(pRtpMap, '/');
+			pRtpMap = m_pRtpMapProperty->GetValue();
+			pSlash = strchr(pRtpMap, '/');
 
-			u_int32_t length;
 			if (pSlash) {
 				length = pSlash - pRtpMap;
 			} else {
@@ -336,6 +338,7 @@
 			  strncpy(*ppPayloadName, pRtpMap, length); 
 			}
 			if (pSlash && ppEncodingParams) {
+			  pSlash++;
 			  pSlash = strchr(pSlash, '/');
 			  if (pSlash != NULL) {
 			    pSlash++;
@@ -1183,6 +1186,7 @@
 	((MP4Integer16Property*)m_pProperties[2])->SetValue(dataLength);
 	((MP4Integer32Property*)m_pProperties[3])->SetValue(sampleId);
 	((MP4Integer32Property*)m_pProperties[4])->SetValue(0); 
+	CHECK_AND_FREE(m_pRefData);
 	m_pRefData = pData;
 }
 
--- a/common/mp4v2/rtphint.h
+++ b/common/mp4v2/rtphint.h
@@ -78,6 +78,10 @@
 public:
 	MP4RtpSampleData(MP4RtpPacket* pPacket);
 
+	~MP4RtpSampleData(void) {
+	  CHECK_AND_FREE(m_pRefData);
+	};
+
 	void SetEmbeddedImmediate(
 		MP4SampleId sampleId, 
 		u_int8_t* pData, u_int16_t dataLength);
--- a/common/mp4v2/systems.h
+++ /dev/null
@@ -1,312 +1,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- * 
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- * 
- * The Original Code is MPEG4IP.
- * 
- * The Initial Developer of the Original Code is Cisco Systems Inc.
- * Portions created by Cisco Systems Inc. are
- * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
- * 
- * Contributor(s): 
- *		Dave Mackie		dmackie@cisco.com
- *		Bill May		wmay@cisco.com
- */
-
-#ifndef __SYSTEMS_H__
-#define __SYSTEMS_H__
-
-#ifdef WIN32
-#define HAVE_IN_PORT_T
-#define HAVE_SOCKLEN_T
-#include <win32_ver.h>
-#define NEED_SDL_VIDEO_IN_MAIN_THREAD
-#else
-#undef PACKAGE
-#undef VERSION
-#include <config.h>
-#endif
-
-
-
-
-#ifdef WIN32
-
-#define _WIN32_WINNT 0x0400
-#define _WINSOCKAPI_
-#include <windows.h>
-#include <winsock2.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <time.h>
-#include <limits.h>
-
-typedef unsigned __int64 uint64_t;
-typedef unsigned __int32 uint32_t;
-typedef unsigned __int16 uint16_t;
-typedef unsigned __int8 uint8_t;
-typedef unsigned __int64 u_int64_t;
-typedef unsigned __int32 u_int32_t;
-typedef unsigned __int16 u_int16_t;
-typedef unsigned __int8 u_int8_t;
-typedef __int64 int64_t;
-typedef __int32 int32_t;
-typedef __int16 int16_t;
-typedef __int8  int8_t;
-typedef unsigned short in_port_t;
-typedef int socklen_t;
-typedef int ssize_t;
-#define snprintf _snprintf
-#define strncasecmp _strnicmp
-#define strcasecmp _stricmp
-
-#include <io.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#define write _write
-#define lseek _lseek
-#define close _close
-#define open _open
-#define access _access
-#define vsnprintf _vsnprintf
-#define F_OK 0
-#define OPEN_RDWR (_O_RDWR | _O_BINARY)
-#define OPEN_CREAT (_O_CREAT | _O_BINARY)
-#define OPEN_RDONLY (_O_RDONLY | _O_BINARY)
-#define srandom srand
-#define random rand
-
-#define IOSBINARY ios::binary
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-int gettimeofday(struct timeval *t, void *);
-#ifdef __cplusplus
-}
-#endif
-
-#define PATH_MAX MAX_PATH
-#define MAX_UINT64 -1
-#define LLD "%I64d"
-#define LLU "%I64u"
-#define LLX "%I64x"
-#define LLX16 "%016I64x"
-#define M_LLU 1000i64
-#define C_LLU 100i64
-#define I_LLU 1i64
-
-#define LOG_EMERG 0
-#define LOG_ALERT 1
-#define LOG_CRIT 2
-#define LOG_ERR 3
-#define LOG_WARNING 4
-#define LOG_NOTICE 5
-#define LOG_INFO 6
-#define LOG_DEBUG 7
-
-#if     !__STDC__ && _INTEGRAL_MAX_BITS >= 64
-#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
-#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(_FPOSOFF(fpos))
-#else
-#define VAR_TO_FPOS(fpos, var) (fpos).lopart = ((var) & UINT_MAX); (fpos).hipart = ((var) >> 32)
-#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((uint64_t)((fpos).hipart ) << 32 | (fpos).lopart)
-#endif
-
-#define __STRING(expr) #expr
-
-#define FOPEN_READ_BINARY "rb"
-#define FOPEN_WRITE_BINARY "wb"
-
-#define UINT64_TO_DOUBLE(a) ((double)((int64_t)(a)))
-#else /* UNIX */
-/*****************************************************************************
- *   UNIX LIKE DEFINES BELOW THIS POINT
- *****************************************************************************/
-#ifdef sun
-#include <sys/feature_tests.h>
-#endif
-
-#ifndef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#else
-#if _FILE_OFFSET_BITS < 64
-#error File offset bits is already set to non-64 value
-#endif
-#endif
-
-#ifndef _LARGEFILE_SOURCE
-#define _LARGEFILE_SOURCE
-#endif
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#else
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#error "Don't have stdint.h or inttypes.h - no way to get uint8_t"
-#endif
-#endif
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <syslog.h>
-#include <string.h>
-#include <ctype.h>
-#include <netdb.h>
-#include <sys/stat.h>
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-#include <sys/param.h>
-
-#define OPEN_RDWR O_RDWR
-#define OPEN_CREAT O_CREAT 
-#define OPEN_RDONLY O_RDONLY
-
-#define closesocket close
-#define IOSBINARY ios::bin
-#define MAX_UINT64 -1LLU
-#define LLD "%lld"
-#define LLU "%llu"
-#define LLX "%llx"
-#define LLX16 "%016llx"
-#define M_LLU 1000LLU
-#define C_LLU 100LLU
-#define I_LLU 1LLU
-#ifdef HAVE_FPOS_T_POS
-#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((fpos).__pos)
-#define VAR_TO_FPOS(fpos, var) (fpos).__pos = (var)
-#else
-#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
-#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
-#endif
-
-#define FOPEN_READ_BINARY "r"
-#define FOPEN_WRITE_BINARY "w"
-#define UINT64_TO_DOUBLE(a) ((double)(a))
-#endif /* define unix */
-
-/*****************************************************************************
- *             Generic type includes used in the whole package               *
- *****************************************************************************/
-#include <stdarg.h>
-typedef void (*error_msg_func_t)(int loglevel,
-				 const char *lib,
-				 const char *fmt,
-				 va_list ap);
-typedef void (*lib_message_func_t)(int loglevel,
-				   const char *lib,
-				   const char *fmt,
-				   ...);
-#ifndef HAVE_IN_PORT_T
-typedef uint16_t in_port_t;
-#endif
-
-#ifndef HAVE_SOCKLEN_T
-typedef unsigned int socklen_t;
-#endif
-
-#ifdef sun
-#include <limits.h>
-#define u_int8_t uint8_t
-#define u_int16_t uint16_t
-#define u_int32_t uint32_t
-#define u_int64_t uint64_t
-#define __STRING(expr) #expr
-#endif
-
-#ifndef HAVE_STRSEP
-#ifdef __cplusplus
-extern "C" {
-#endif
-char *strsep(char **strp, const char *delim); 
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef INADDR_NONE
-#define INADDR_NONE (-1)
-#endif
-
-#define MALLOC_STRUCTURE(a) ((a *)malloc(sizeof(a)))
-
-#define CHECK_AND_FREE(a) if ((a) != NULL) { free((void *)(a)); (a) = NULL;}
-
-#define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name))))
-
-#ifndef HAVE_GLIB_H
-typedef char gchar;
-typedef unsigned char guchar;
-
-typedef int gint;
-typedef unsigned int guint;
-
-typedef long glong;
-typedef unsigned long gulong;
-
-typedef double gdouble;
-
-typedef int gboolean;
-
-typedef int16_t gint16;
-typedef uint16_t guint16;
-
-typedef int32_t gint32;
-typedef uint32_t guint32;
-
-typedef int64_t gint64;
-typedef uint64_t guint64;
-
-typedef uint8_t  guint8;
-typedef int8_t gint8;
-
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#endif /* __SYSTEMS_H__ */
-
-
-
-
--- a/common/mp4v2/win32_ver.h
+++ b/common/mp4v2/win32_ver.h
@@ -1,2 +1,2 @@
 #define PACKAGE "mpeg4ip"
-#define VERSION "0.9.8.6"
+#define VERSION "1.0"
--- a/plugins/in_mp4/aac2mp4.cpp
+++ b/plugins/in_mp4/aac2mp4.cpp
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: aac2mp4.cpp,v 1.2 2003/07/29 08:20:14 menno Exp $
+** $Id: aac2mp4.cpp,v 1.3 2004/03/30 08:16:09 menno Exp $
 **/
 
 #include <mpeg4ip.h>
@@ -40,7 +40,7 @@
     const char *type;
     MP4TrackId createdTrackId = MP4_INVALID_TRACK_ID;
 
-    mp4File = MP4Create(mp4FileName, 0, 0, 0);
+    mp4File = MP4Create(mp4FileName, 0, 0);
     if (mp4File)
     {
         MP4SetTimeScale(mp4File, Mp4TimeScale);