# Patch to fix build error and warnings:
#   error: redefinition of strcasestr function from string.h
#   warning: deprecated conversion of string constants to char*
#   warning: using '==' for comparison between C strings
#   warning: using '%llu' for type uint64_t on 64 bits systems
# Copyright (C) 2012 Georgi D. Sotirov <gdsotirov@dir.bg>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# $Id: faac-1.28-build.diff,v 1.2 2012/09/01 17:08:35 gsotirov Exp $
#

diff -urNad faac-1.28-orig/common/mp4v2/atom_avcC.cpp faac-1.28/common/mp4v2/atom_avcC.cpp
--- faac-1.28-orig/common/mp4v2/atom_avcC.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/atom_avcC.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -29,7 +29,7 @@
 class SizeTableProperty : public MP4TableProperty 
 {
  public:
-  SizeTableProperty(char *name, MP4IntegerProperty *pCountProperty) :
+  SizeTableProperty(const char *name, MP4IntegerProperty *pCountProperty) :
     MP4TableProperty(name, pCountProperty) {};
  protected:
   void ReadEntry(MP4File *pFile, u_int32_t index) {
diff -urNad faac-1.28-orig/common/mp4v2/atom_ohdr.cpp faac-1.28/common/mp4v2/atom_ohdr.cpp
--- faac-1.28-orig/common/mp4v2/atom_ohdr.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/atom_ohdr.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -21,7 +21,7 @@
       \param useCountedFormat    counted format flag.
       \param useUnicode          unicode flag.
   */
-	OhdrMP4StringProperty(char* name, bool useCountedFormat = false,
+	OhdrMP4StringProperty(const char* name, bool useCountedFormat = false,
     bool useUnicode = false): MP4StringProperty(name, useCountedFormat,
     useUnicode) {
   }
diff -urNad faac-1.28-orig/common/mp4v2/atom_stz2.cpp faac-1.28/common/mp4v2/atom_stz2.cpp
--- faac-1.28-orig/common/mp4v2/atom_stz2.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/atom_stz2.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -30,7 +30,7 @@
 class MP4HalfSizeTableProperty : public MP4TableProperty
 {
 public:
-  MP4HalfSizeTableProperty(char *name, MP4IntegerProperty *pCountProperty) :
+  MP4HalfSizeTableProperty(const char *name, MP4IntegerProperty *pCountProperty) :
     MP4TableProperty(name, pCountProperty) {};
 
   // The count is half the actual size
diff -urNad faac-1.28-orig/common/mp4v2/mp4atom.cpp faac-1.28/common/mp4v2/mp4atom.cpp
--- faac-1.28-orig/common/mp4v2/mp4atom.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4atom.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -806,7 +806,7 @@
 	AddProperty(new MP4Integer24Property("flags"));
 }
 
-void MP4Atom::AddReserved(char* name, u_int32_t size) 
+void MP4Atom::AddReserved(const char* name, u_int32_t size) 
 {
 	MP4BytesProperty* pReserved = new MP4BytesProperty(name, size); 
 	pReserved->SetReadOnly();
diff -urNad faac-1.28-orig/common/mp4v2/mp4atom.h faac-1.28/common/mp4v2/mp4atom.h
--- faac-1.28-orig/common/mp4v2/mp4atom.h	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4atom.h	2012-09-01 19:49:19.000000000 +0300
@@ -204,7 +204,7 @@
 
 	void AddVersionAndFlags();
 
-	void AddReserved(char* name, u_int32_t size);
+	void AddReserved(const char* name, u_int32_t size);
 
 	void ExpectChildAtom(const char* name, 
 		bool mandatory, bool onlyOne = true);
diff -urNad faac-1.28-orig/common/mp4v2/mp4file.cpp faac-1.28/common/mp4v2/mp4file.cpp
--- faac-1.28-orig/common/mp4v2/mp4file.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4file.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -718,7 +718,7 @@
 	}
 }
 
-void MP4File::ProtectWriteOperation(char* where)
+void MP4File::ProtectWriteOperation(const char* where)
 {
 	if (m_mode == 'r') {
 		throw new MP4Error("operation not permitted in read mode", where);
@@ -1274,7 +1274,7 @@
 }
 
 // NULL terminated list of brands which require the IODS atom
-char *brandsWithIods[] = { "mp42",
+const char *brandsWithIods[] = { "mp42",
                            "isom",
                            NULL};
 
@@ -2211,11 +2211,11 @@
 	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 (!strcmp(normType, MP4_AUDIO_TRACK_TYPE)) {
 					if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
 						continue;
 					}
-				} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+				} else if (!strcmp(normType,MP4_VIDEO_TRACK_TYPE)) {
 					if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
 						continue;
 					}
@@ -2278,11 +2278,11 @@
   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 (!strcmp(normType,MP4_AUDIO_TRACK_TYPE)) {
 	  if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
 	    continue;
 	  }
-	} else if (normType == MP4_VIDEO_TRACK_TYPE) {
+	} else if (!strcmp(normType,MP4_VIDEO_TRACK_TYPE)) {
 	  if (subType != GetTrackEsdsObjectTypeId(m_pTracks[i]->GetId())) {
 	    continue;
 	  }
diff -urNad faac-1.28-orig/common/mp4v2/mp4file.h faac-1.28/common/mp4v2/mp4file.h
--- faac-1.28-orig/common/mp4v2/mp4file.h	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4file.h	2012-09-01 19:49:19.000000000 +0300
@@ -700,7 +700,7 @@
 	const char* TempFileName();
 	void Rename(const char* existingFileName, const char* newFileName);
 
-	void ProtectWriteOperation(char* where);
+	void ProtectWriteOperation(const char* where);
 
 	void FindIntegerProperty(const char* name, 
 		MP4Property** ppProperty, u_int32_t* pIndex = NULL);
diff -urNad faac-1.28-orig/common/mp4v2/mp4property.cpp faac-1.28/common/mp4v2/mp4property.cpp
--- faac-1.28-orig/common/mp4v2/mp4property.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4property.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -313,7 +313,7 @@
 
 // MP4StringProperty
 
-MP4StringProperty::MP4StringProperty(char* name, 
+MP4StringProperty::MP4StringProperty(const char* name, 
 	bool useCountedFormat, bool useUnicode)
 	: MP4Property(name)
 {
@@ -420,7 +420,7 @@
 
 // MP4BytesProperty
 
-MP4BytesProperty::MP4BytesProperty(char* name, u_int32_t valueSize,
+MP4BytesProperty::MP4BytesProperty(const char* name, u_int32_t valueSize,
                                    u_int32_t defaultValueSize)
 	: MP4Property(name)
 {
@@ -549,7 +549,7 @@
 
 // MP4TableProperty
 
-MP4TableProperty::MP4TableProperty(char* name, MP4IntegerProperty* pCountProperty)
+MP4TableProperty::MP4TableProperty(const char* name, MP4IntegerProperty* pCountProperty)
 	: MP4Property(name) 
 {
 	m_pCountProperty = pCountProperty;
@@ -725,7 +725,7 @@
 
 // MP4DescriptorProperty
   
-MP4DescriptorProperty::MP4DescriptorProperty(char* name, 
+MP4DescriptorProperty::MP4DescriptorProperty(const char* name, 
 	u_int8_t tagsStart, u_int8_t tagsEnd, bool mandatory, bool onlyOne)
 	: MP4Property(name) 
 { 
diff -urNad faac-1.28-orig/common/mp4v2/mp4property.h faac-1.28/common/mp4v2/mp4property.h
--- faac-1.28-orig/common/mp4v2/mp4property.h	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4property.h	2012-09-01 19:49:19.000000000 +0300
@@ -100,7 +100,7 @@
 
 class MP4IntegerProperty : public MP4Property {
 protected:
-	MP4IntegerProperty(char* name)
+	MP4IntegerProperty(const char* name)
 		: MP4Property(name) { };
 
 public:
@@ -118,7 +118,7 @@
 #define MP4INTEGER_PROPERTY_DECL2(isize, xsize) \
 	class MP4Integer##xsize##Property : public MP4IntegerProperty { \
 	public: \
-		MP4Integer##xsize##Property(char* name) \
+		MP4Integer##xsize##Property(const char* name) \
 			: MP4IntegerProperty(name) { \
 			SetCount(1); \
 			m_values[0] = 0; \
@@ -188,7 +188,7 @@
 
 class MP4BitfieldProperty : public MP4Integer64Property {
 public:
-	MP4BitfieldProperty(char* name, u_int8_t numBits)
+	MP4BitfieldProperty(const char* name, u_int8_t numBits)
 		: MP4Integer64Property(name) {
 		ASSERT(numBits != 0);
 		ASSERT(numBits <= 64);
@@ -213,7 +213,7 @@
 
 class MP4Float32Property : public MP4Property {
 public:
-	MP4Float32Property(char* name)
+	MP4Float32Property(const char* name)
 		: MP4Property(name) {
 		m_useFixed16Format = false;
 		m_useFixed32Format = false;
@@ -280,7 +280,7 @@
 
 class MP4StringProperty : public MP4Property {
 public:
-	MP4StringProperty(char* name, 
+	MP4StringProperty(const char* name, 
 	  bool useCountedFormat = false, bool useUnicode = false);
 
 	~MP4StringProperty();
@@ -355,7 +355,7 @@
 
 class MP4BytesProperty : public MP4Property {
 public:
-	MP4BytesProperty(char* name, u_int32_t valueSize = 0,
+	MP4BytesProperty(const char* name, u_int32_t valueSize = 0,
                          u_int32_t defaultValueSize = 0);
 
 	~MP4BytesProperty();
@@ -419,7 +419,7 @@
 
 class MP4TableProperty : public MP4Property {
 public:
-	MP4TableProperty(char* name, MP4IntegerProperty* pCountProperty);
+	MP4TableProperty(const char* name, MP4IntegerProperty* pCountProperty);
 
 	~MP4TableProperty();
 
@@ -469,7 +469,7 @@
 
 class MP4DescriptorProperty : public MP4Property {
 public:
-	MP4DescriptorProperty(char* name = NULL, 
+	MP4DescriptorProperty(const char* name = NULL, 
 	  u_int8_t tagsStart = 0, u_int8_t tagsEnd = 0,
 	  bool mandatory = false, bool onlyOne = false);
 
@@ -531,7 +531,7 @@
 
 class MP4QosQualifierProperty : public MP4DescriptorProperty {
 public:
-	MP4QosQualifierProperty(char* name = NULL, 
+	MP4QosQualifierProperty(const char* name = NULL, 
 	  u_int8_t tagsStart = 0, u_int8_t tagsEnd = 0,
 	  bool mandatory = false, bool onlyOne = false) :
 	MP4DescriptorProperty(name, tagsStart, tagsEnd, mandatory, onlyOne) { }
diff -urNad faac-1.28-orig/common/mp4v2/mp4track.cpp faac-1.28/common/mp4v2/mp4track.cpp
--- faac-1.28-orig/common/mp4v2/mp4track.cpp	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4track.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -1360,7 +1360,7 @@
   }
 }
 
-MP4Atom* MP4Track::AddAtom(char* parentName, char* childName)
+MP4Atom* MP4Track::AddAtom(const char* parentName, const char* childName)
 {
 	MP4Atom* pChildAtom = MP4Atom::CreateAtom(childName);
 
diff -urNad faac-1.28-orig/common/mp4v2/mp4track.h faac-1.28/common/mp4v2/mp4track.h
--- faac-1.28-orig/common/mp4v2/mp4track.h	2009-01-25 03:14:34.000000000 +0200
+++ faac-1.28/common/mp4v2/mp4track.h	2012-09-01 19:49:19.000000000 +0300
@@ -168,7 +168,7 @@
 	void UpdateSyncSamples(MP4SampleId sampleId, 
 		bool isSyncSample);
 
-	MP4Atom* AddAtom(char* parentName, char* childName);
+	MP4Atom* AddAtom(const char* parentName, const char* childName);
 
 	void UpdateDurations(MP4Duration duration);
 	MP4Duration ToMovieDuration(MP4Duration trackDuration);
diff -urNad faac-1.28-orig/common/mp4v2/mpeg4ip.h faac-1.28/common/mp4v2/mpeg4ip.h
--- faac-1.28-orig/common/mp4v2/mpeg4ip.h	2009-01-27 00:42:35.000000000 +0200
+++ faac-1.28/common/mp4v2/mpeg4ip.h	2012-09-01 19:50:55.000000000 +0300
@@ -120,14 +120,6 @@
 #endif
 #include <sys/param.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-char *strcasestr(const char *haystack, const char *needle);
-#ifdef __cplusplus
-}
-#endif
-
 #define OPEN_RDWR O_RDWR
 #define OPEN_CREAT O_CREAT 
 #define OPEN_RDONLY O_RDONLY
@@ -135,7 +127,7 @@
 #define closesocket close
 #define IOSBINARY ios::bin
 
-#if SIZEOF_LONG == 8
+#if __WORDSIZE == 64
 #define MAX_UINT64 -1LU
 #define D64F "ld"
 #define U64F  "lu"
diff -urNad faac-1.28-orig/common/mp4v2/ocidescriptors.cpp faac-1.28/common/mp4v2/ocidescriptors.cpp
--- faac-1.28-orig/common/mp4v2/ocidescriptors.cpp	2004-07-27 11:28:24.000000000 +0300
+++ faac-1.28/common/mp4v2/ocidescriptors.cpp	2012-09-01 19:49:19.000000000 +0300
@@ -171,7 +171,7 @@
 
 class MP4CreatorTableProperty : public MP4TableProperty {
 public:
-	MP4CreatorTableProperty(char* name, MP4Integer8Property* pCountProperty) :
+	MP4CreatorTableProperty(const char* name, MP4Integer8Property* pCountProperty) :
 		MP4TableProperty(name, pCountProperty) {
 	};
 protected:
