Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_1.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Video uses dynamic payload type
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=video 4000 RTP/AVP 100
+a=rtpmap:100 myvideo/80000
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=video 0 RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and video", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/120_sdp_with_video_dynamic_2.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# In this case the video codec uses dynamic payload type
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=video 4000 RTP/AVP 100
+a=rtpmap:100 myvideo/96000
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=video 0 RTP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and video", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_1.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Video uses static payload type which will cause failure
+# when session.c looks-up the codec in codec manager
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=video 4000 RTP/AVP 54
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=video 0 RTP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and video", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/121_sdp_with_video_static_2.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Video uses static payload type which will cause failure
+# when session.c looks-up the codec in codec manager
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=video 4000 RTP/AVP 54
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=video 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and video", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_1.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=xapplicationx 4000 RTP/AVP 100
+a=rtpmap:100 myapp/80000
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=xapplicationx 0 RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/122_sdp_with_unknown_dynamic_2.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=xapplicationx 4000 RTP/AVP 100
+a=rtpmap:100 myapp/80000
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=xapplicationx 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_1.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# The unknown media uses static payload type
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=xapplicationx 4000 RTP/AVP 54
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=xapplicationx 0 RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/123_sdp_with_unknown_static_2.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# The unknown media uses static payload type
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=xapplicationx 4000 RTP/AVP 54
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=xapplicationx 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/124_sdp_with_unknown_static_unknown_transport.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/124_sdp_with_unknown_static_unknown_transport.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/124_sdp_with_unknown_static_unknown_transport.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=xapplicationx 4000 XRTPX/XAVPX 54
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=xapplicationx 0 XRTPX/XAVPX "
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown and with unknown transport", 
+			   pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_0.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_0.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_0.py	(revision 2081)
@@ -0,0 +1,30 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple good m=audio lines! The current algorithm in pjsua-lib will
+# select the last audio (which should be okay, as we're entitled to
+# select any of them)
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=audio 4000 RTP/AVP 0
+m=audio 3000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/AVP[\\s\\S]+m=audio 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mutiple good m=audio lines", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_1.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple m=audio, one of them is bad
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+m=audio 4000 UNKNOWN 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+m=audio 0 UNKNOWN"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Audio and bad audio", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_2.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple m=audio, one of them is bad
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 UNKNOWN 0
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 UNKNOWN[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Audio and bad audio", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_3.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_3.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_3.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple m=audio, one of them has dynamic PT codec that we don't support
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 100
+a=rtpmap:100 someunknowncodec/8000
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/AVP[\s\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Multiple audio lines", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_4.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_4.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/125_sdp_with_multi_audio_4.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple m=audio, one of them has static PT codec that we don't support
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 80
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/AVP[\s\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Multiple audio lines", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py	(revision 2080)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/151_err_sdp_video.py	(revision 2081)
@@ -15,6 +15,5 @@
 pjsua_args = "--null-audio --auto-answer 200"
 extra_headers = ""
-include = ["Content-Type: application/sdp",	# response must include SDP
-	   "m=audio"]
+include = []
 exclude = []
 
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py	(revision 2080)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/153_err_sdp_unsupported_codec.py	(revision 2081)
@@ -16,6 +16,5 @@
 pjsua_args = "--null-audio --auto-answer 200"
 extra_headers = ""
-include = ["Content-Type: application/sdp",	# response must include SDP
-	   "m=audio"]
+include = []
 exclude = []
 
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py	(revision 2080)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/158_err_sdp_bad_transport_type.py	(revision 2081)
@@ -21,5 +21,5 @@
 include = []
 exclude = []
-sendto_cfg = sip.SendtoCfg("Unsupported transport type", pjsua_args, sdp, 406, 
+sendto_cfg = sip.SendtoCfg("Unsupported transport type", pjsua_args, sdp, 488, 
 			   extra_headers=extra_headers,
 			   resp_inc=include, resp_exc=exclude) 
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_1.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+m=xapplicationx 4000 RTP/AVP 100
+a=rtpmap:100 myapp/80000
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 1 --srtp-secure 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+a=crypto[\\s\\S]+m=xapplicationx 0 RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("SRTP audio and unknown media", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_media_2.py	(revision 2081)
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=xapplicationx 4000 RTP/AVP 100
+a=rtpmap:100 myapp/80000
+m=audio 5000 RTP/AVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 1 --srtp-secure 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=xapplicationx 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+a=crypto"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Unknown media and SRTP audio", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_1.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_1.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_1.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+m=audio 4000 UNKNOWN 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 1 --srtp-secure 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+a=crypto[\\s\\S]+m=audio 0 UNKNOWN"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("SRTP audio and unknown media", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_2.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_2.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/320_srtp_with_unknown_transport_2.py	(revision 2081)
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 UNKNOWN 0
+m=audio 5000 RTP/AVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 1 --srtp-secure 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 UNKNOWN[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP[\\s\\S]+a=crypto"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("SRTP audio and unknown media", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/330_srtp_prefer_rtp_savp.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/330_srtp_prefer_rtp_savp.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/330_srtp_prefer_rtp_savp.py	(revision 2081)
@@ -0,0 +1,30 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# When SRTP is enabled in pjsua, it should prefer to use
+# RTP/SAVP media line if there are multiple m=audio lines
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0
+a=rtpmap:0 pcmu/8000
+m=audio 5000 RTP/SAVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 1 --srtp-secure 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/AVP[\\s\\S]+a=rtpmap:0[\\s\\S]+m=audio [1-9]+[0-9]* RTP/SAVP[\\s\\S]+a=crypto"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Prefer RTP/SAVP", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/331_srtp_prefer_rtp_avp.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/331_srtp_prefer_rtp_avp.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/331_srtp_prefer_rtp_avp.py	(revision 2081)
@@ -0,0 +1,29 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# When SRTP is NOT enabled in pjsua, it should prefer to use
+# RTP/AVP media line if there are multiple m=audio lines
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/SAVP 0
+a=crypto:1 aes_cm_128_hmac_sha1_80 inline:WnD7c1ksDGs+dIefCEo8omPg4uO8DYIinNGL5yxQ
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200 --use-srtp 0"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/SAVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = ["a=crypto"]
+
+sendto_cfg = sip.SendtoCfg("Prefer RTP/SAVP", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
Index: /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/999_asterisk_err.py
===================================================================
--- /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/999_asterisk_err.py	(revision 2081)
+++ /pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-sendto/999_asterisk_err.py	(revision 2081)
@@ -0,0 +1,45 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2008-June/003426.html:
+#
+# Report in pjsip mailing list on 27/6/2008 that this message will
+# cause pjsip to respond with 500 and then second request will cause
+# segfault.
+complete_msg = \
+"""INVITE sip:5001@192.168.1.200:5060;transport=UDP SIP/2.0
+Via: SIP/2.0/UDP 192.168.1.11:5060;branch=z9hG4bK74a60ee5;rport
+From: \"A user\" <sip:66660000@192.168.1.11>;tag=as2858a32c
+To: <sip:5001@192.168.1.200:5060;transport=UDP>
+Contact: <sip:66660000@192.168.1.11>
+Call-ID: 0bc7612c665e875a4a46411442b930a6@192.168.1.11
+CSeq: 102 INVITE
+User-Agent: Asterisk PBX
+Max-Forwards: 70
+Date: Fri, 27 Jun 2008 08:46:47 GMT
+Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
+Supported: replaces
+Content-Type: application/sdp
+Content-Length: 285
+
+v=0
+o=root 4236 4236 IN IP4 192.168.1.11
+s=session
+c=IN IP4 192.168.1.11
+t=0 0
+m=audio 14390 RTP/AVP 0 3 8 101
+a=rtpmap:0 PCMU/8000
+a=rtpmap:3 GSM/8000
+a=rtpmap:8 PCMA/8000
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-16
+a=silenceSupp:off - - - -
+a=ptime:20
+a=sendrecv
+"""
+
+
+sendto_cfg = sip.SendtoCfg( "Asterisk 500", "--null-audio --auto-answer 200", 
+			    "", 200, complete_msg=complete_msg)
+
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 2080)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 2081)
@@ -977,7 +977,7 @@
     /* Reject offer if we couldn't find a good m=audio line in offer */
     if (call->audio_idx < 0) {
-	if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE;
+	if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE;
 	pjsua_media_channel_deinit(call_id);
-	return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE);
+	return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE_HERE);
     }
 
