From 1dc662bf495b150fa456d31b5f18e16d43969b4f Mon Sep 17 00:00:00 2001
From: Jehan Monnier <jehan.monnier@linphone.org>
Date: Wed, 21 Jul 2010 14:25:17 +0200
Subject: [PATCH] init mediastream after call is accepted in case of iPhone
 build. If mediastream is init to early, linphone issues a SIGPIPE in case of
 incoming call while in background. fixed error are: 	Error receiving RTP
 packet: Socket is not connected. 	Error receiving RTCP packet: Socket is
 not connected. 	linphone process event get a message 15 
 CALL_ACK 	Error receiving RTP packet: Socket is not connected. 	Error
 receiving RTCP packet: Socket is not connected. 	Audio MSTicker: We are
 late of 51 miliseconds. 	synchronizing timestamp, diff=1520 	Error
 sending rtp packet: Broken pipe ; socket=16 	Error sending rtp packet:
 Broken pipe ; socket=16 	Error sending rtp packet: Broken pipe ;
 socket=16 	Error receiving RTP packet: Socket is not connected. 	Error
 receiving RTCP packet: Socket is not connected.

---
 coreapi/callbacks.c    | 2 ++
 coreapi/linphonecore.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c
index 6833fba82c..c94388a9c7 100644
--- a/coreapi/callbacks.c
+++ b/coreapi/callbacks.c
@@ -105,7 +105,9 @@ static void call_received(SalOp *h){
 	}
 	linphone_call_set_state(call,LCStateRinging);
 	sal_call_notify_ringing(h);
+#if !(__IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
 	linphone_core_init_media_streams(lc,lc->call);
+#endif
 	if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,tmp);
 	ms_free(barmesg);
 	ms_free(tmp);
diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index 121b329243..55b9a75532 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -2515,7 +2515,9 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url)
 	contact=get_fixed_contact(lc,call,cfg);
 	if (contact)
 		sal_op_set_contact(call->op,contact);
-	
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
+	linphone_core_init_media_streams(lc,call);
+#endif
 	sal_call_accept(call->op);
 	lc->vtable.display_status(lc,_("Connected."));
 	gstate_new_state(lc, GSTATE_CALL_IN_CONNECTED, NULL);
-- 
GitLab