From 589da4b29c3e27c3d8b3e263710bac341be5ab4e Mon Sep 17 00:00:00 2001
From: smorlat <smorlat@3f6dc0c8-ddfe-455d-9043-3cd528dc4637>
Date: Mon, 31 Aug 2009 14:45:48 +0000
Subject: [PATCH] compilation with video works on mac

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@613 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
---
 linphone/mediastreamer2/autogen.sh               |  3 ++-
 linphone/mediastreamer2/configure.ac             |  3 ++-
 linphone/mediastreamer2/src/Makefile.am          |  4 +++-
 linphone/mediastreamer2/src/aqsnd.c              | 10 ++--------
 linphone/mediastreamer2/src/ice.c                |  2 +-
 linphone/mediastreamer2/src/mscommon.c           |  3 ---
 linphone/mediastreamer2/src/{msv4m.c => msv4m.m} | 16 +++++++++-------
 linphone/oRTP/autogen.sh                         | 16 ++++++++++++++--
 8 files changed, 33 insertions(+), 24 deletions(-)
 rename linphone/mediastreamer2/src/{msv4m.c => msv4m.m} (98%)

diff --git a/linphone/mediastreamer2/autogen.sh b/linphone/mediastreamer2/autogen.sh
index 4268f67363..50299b9364 100755
--- a/linphone/mediastreamer2/autogen.sh
+++ b/linphone/mediastreamer2/autogen.sh
@@ -23,7 +23,8 @@ fi
 echo "Generating build scripts in mediastreamer..."
 set -x
 $LIBTOOLIZE --copy --force
-autoheader
 $ACLOCAL  $ACLOCAL_ARGS
+autoheader
 $AUTOMAKE --force-missing --add-missing --copy
 autoconf
+
diff --git a/linphone/mediastreamer2/configure.ac b/linphone/mediastreamer2/configure.ac
index 264269c1b4..42174faed3 100644
--- a/linphone/mediastreamer2/configure.ac
+++ b/linphone/mediastreamer2/configure.ac
@@ -83,6 +83,7 @@ AC_ARG_ENABLE(debug,
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_CXX
+AC_PROG_OBJC
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 AC_ENABLE_SHARED(yes)
@@ -342,7 +343,7 @@ AC_ARG_ENABLE(macaqsnd,
         yes) macaqsnd=true ;;
         no)  macaqsnd=false ;;
         *) AC_MSG_ERROR(bad value ${enableval} for --enable-macaqsnd) ;;
-      esac],[macaqsnd=yes])
+      esac],[macaqsnd=true])
 
 if test "$macosx_found" != "yes" ; then
 	macaqsnd=false
diff --git a/linphone/mediastreamer2/src/Makefile.am b/linphone/mediastreamer2/src/Makefile.am
index 8c1d0070a5..c85f158464 100644
--- a/linphone/mediastreamer2/src/Makefile.am
+++ b/linphone/mediastreamer2/src/Makefile.am
@@ -92,7 +92,7 @@ endif
 if BUILD_VIDEO
 
 if BUILD_MACOSX
-libmediastreamer_la_SOURCES+=msv4m.c
+libmediastreamer_la_SOURCES+=msv4m.m
 endif
 
 if BUILD_V4L
@@ -178,6 +178,8 @@ if BUILD_VIDEO
 AM_CFLAGS+=$(VIDEO_CFLAGS)
 endif
 
+AM_OBJCFLAGS=$(AM_CFLAGS)
+
 imgdir=$(datadir)/images/
 
 img_DATA=nowebcamCIF.jpg
diff --git a/linphone/mediastreamer2/src/aqsnd.c b/linphone/mediastreamer2/src/aqsnd.c
index 559a6c5b49..e2325c4ea4 100644
--- a/linphone/mediastreamer2/src/aqsnd.c
+++ b/linphone/mediastreamer2/src/aqsnd.c
@@ -240,18 +240,15 @@ void setupRead(MSSndCard *card) {
 
 static void aq_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent)
 {
-	AQData *d=(AQData*)card->data;
 }
 
 static int aq_get_level(MSSndCard *card, MSSndCardMixerElem e)
 {
-	AQData *d=(AQData*)card->data;
 	return 0;
 }
 
 static void aq_set_source(MSSndCard *card, MSSndCardCapture source)
 {
-	AQData *d=(AQData*)card->data;
 }
 
 static void aq_init(MSSndCard *card){
@@ -298,8 +295,6 @@ MSSndCardDesc aq_card_desc={
 
 static MSSndCard *aq_duplicate(MSSndCard *obj){
 	MSSndCard *card=ms_snd_card_new(&aq_card_desc);
-	AQData *dcard=(AQData*)card->data;
-	AQData *dobj=(AQData*)obj->data;
 	card->name=ms_strdup(obj->name);
 	return card;
 }
@@ -450,7 +445,6 @@ static void aq_stop_r(MSSndCard *card){
 static void aq_start_w(MSSndCard *card){
 	ms_debug("aq_start_w");
 	AQData *d=(AQData*)card->data;
-	int i;
 	if(d->write_started == FALSE) {
 		OSStatus aqresult;
 		d->writeBufferByteSize = kSecondsPerBuffer * d->rate * (d->bits / 8);		
@@ -582,7 +576,7 @@ static int set_rate(MSFilter *f, void *arg){
 	d->rate=*((int*)arg);
 	return 0;
 }
-
+/*
 static int set_nchannels(MSFilter *f, void *arg){
 	ms_debug("set_nchannels %d", *((int*)arg));
 	MSSndCard *card=(MSSndCard*)f->data;
@@ -590,7 +584,7 @@ static int set_nchannels(MSFilter *f, void *arg){
 	d->stereo=(*((int*)arg)==2);
 	return 0;
 }
-
+*/
 static MSFilterMethod aq_methods[]={
 	{	MS_FILTER_SET_SAMPLE_RATE	, set_rate	},
 /* not support yet
diff --git a/linphone/mediastreamer2/src/ice.c b/linphone/mediastreamer2/src/ice.c
index 1b76cdad6d..253ffa0364 100644
--- a/linphone/mediastreamer2/src/ice.c
+++ b/linphone/mediastreamer2/src/ice.c
@@ -256,7 +256,7 @@ static int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList
 			}
 			else if (cand_pair!=NULL)
 			{
-				struct CandidatePair *cand_pair2;
+				struct CandidatePair *cand_pair2=NULL;
 				int pos2;
 				for (pos2=0;pos2<pos && remote_candidates[pos2].remote_candidate.conn_addr[0]!='\0';pos2++)
 				{
diff --git a/linphone/mediastreamer2/src/mscommon.c b/linphone/mediastreamer2/src/mscommon.c
index 52a3ddf920..6ee697d81b 100644
--- a/linphone/mediastreamer2/src/mscommon.c
+++ b/linphone/mediastreamer2/src/mscommon.c
@@ -513,9 +513,6 @@ static MSWebCamDesc * ms_web_cam_descs[]={
 void ms_init(){
 	int i;
 	MSSndCardManager *cm;
-#ifdef __APPLE__
-	NSApplicationLoad();
-#endif
 
 #if !defined(_WIN32_WCE)
 	if (getenv("MEDIASTREAMER_DEBUG")!=NULL){
diff --git a/linphone/mediastreamer2/src/msv4m.c b/linphone/mediastreamer2/src/msv4m.m
similarity index 98%
rename from linphone/mediastreamer2/src/msv4m.c
rename to linphone/mediastreamer2/src/msv4m.m
index 5299732d82..de52a465fd 100644
--- a/linphone/mediastreamer2/src/msv4m.c
+++ b/linphone/mediastreamer2/src/msv4m.m
@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "mediastreamer2/msvideo.h"
 #include "mediastreamer2/msticker.h"
 #include "mediastreamer2/msv4l.h"
-//#include "nowebcam.h"
+#include "nowebcam.h"
 #include "mediastreamer2/mswebcam.h"
 
 // build for carbon
@@ -41,11 +41,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #if __APPLE_CC__
   #include <Carbon/Carbon.h>
   #include <QuicKTime/QuickTime.h>
+  #include <AppKit/AppKit.h>
 #else
   #include <ConditionalMacros.h>
   #include <QuickTimeComponents.h>
   #include <TextUtils.h>
-
+  #include <AppKit/AppKit.h>
   #include <stdio.h>
 #endif
 
@@ -215,7 +216,7 @@ static int v4m_close(v4mState *s)
   s->seqgrab=NULL;
   if (s->decomseq)
     CDSequenceEnd(s->decomseq);
-  s->decomseq=NULL;
+  s->decomseq=0;
   if (s->pgworld!=NULL)
     DisposeGWorld(s->pgworld);
   s->pgworld=NULL;
@@ -227,7 +228,7 @@ unsigned char *stdToPascalString(char *buffer, char * str) {
 
 		memcpy(buffer + 1, str, strlen(str));
 
-		return buffer;
+		return (unsigned char*)buffer;
 	} else {
 		return NULL;
 	}
@@ -601,8 +602,8 @@ MSWebCamDesc ms_v4m_cam_desc={
 
 char * genDeviceName(unsigned char * device,short inputIndex, unsigned char * input) 
 {
-	char buffer[32];
-	sprintf(buffer, "%s:%d:%s", device,inputIndex,input);
+	static char buffer[32];
+	snprintf(buffer,sizeof(buffer), "%s:%d:%s", device,inputIndex,input);
         return buffer;
 }
 
@@ -613,7 +614,7 @@ static char* pas2cstr(const char *pstr)
 {
     char *cstr = ms_malloc(pstr[0] + 1);
     memcpy(cstr, pstr+1, pstr[0]);
-    cstr[pstr[0]] = 0;
+    cstr[(int)pstr[0]] = 0;
     
     return cstr;
     
@@ -627,6 +628,7 @@ static void ms_v4m_detect(MSWebCamManager *obj){
         SGChannel _SGChanVideo;
 
         SeqGrabComponent _seqGrab;
+	NSApplicationLoad();
         
         if (_SGChanVideo) {
 		SGDisposeChannel(_seqGrab, _SGChanVideo);
diff --git a/linphone/oRTP/autogen.sh b/linphone/oRTP/autogen.sh
index 203deb2622..83085a0284 100755
--- a/linphone/oRTP/autogen.sh
+++ b/linphone/oRTP/autogen.sh
@@ -9,10 +9,22 @@ else
 	AUTOMAKE=automake-${AM_VERSION}
 fi
 
+if test -f /opt/local/bin/glibtoolize ; then
+        # darwin
+        LIBTOOLIZE=/opt/local/bin/glibtoolize
+else
+        LIBTOOLIZE=libtoolize
+fi
+if test -d /opt/local/share/aclocal ; then
+        ACLOCAL_ARGS="-I /opt/local/share/aclocal"
+fi
+
+
 set -x
 rm -rf config.cache autom4te.cache
-$ACLOCAL
+$LIBTOOLIZE --copy --force
+$ACLOCAL $ACLOCAL_ARGS
 autoheader
 $AUTOMAKE --add-missing --copy
-libtoolize --copy --force
 autoconf
+
-- 
GitLab