Index: /pjproject/trunk/pjlib/include/pj/log.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/log.h	(revision 319)
+++ /pjproject/trunk/pjlib/include/pj/log.h	(revision 320)
@@ -229,4 +229,19 @@
 #  define pj_log_set_decor(decor)
 
+/**
+ * Get current maximum log verbositylevel.
+ *
+ * @return	    Current log maximum level.
+ */
+#  define pj_log_get_level()	0
+
+/**
+ * Get current log decoration flag.
+ *
+ * @return	    Log decoration flag.
+ */
+#  define pj_log_get_decor()	0
+
+
 #endif	/* #if PJ_LOG_MAX_LEVEL >= 1 */
 
Index: /pjproject/trunk/pjmedia/build/Makefile
===================================================================
--- /pjproject/trunk/pjmedia/build/Makefile	(revision 319)
+++ /pjproject/trunk/pjmedia/build/Makefile	(revision 320)
@@ -1,2 +1,18 @@
+
+# Before we include local os-mak, set default sound framework to use
+# PortAudio.
+export SOUND_OBJS = $(PORTAUDIO_OBJS)
+
+# Also set default codec files to be included
+# If these codecs are to be excluded, then the appropriate PJMEDIA_HAS_XXX_CODEC macros 
+# MUST be set too in pj/config_site.h, to inform applications about the codec 
+# availability.
+#
+# E.g., to exclude Speex, we need to exclude SPEEX_OBJS from CODEC_OBJS, AND specify
+#       "#define PJMEDIA_HAS_SPEEX_CODEC 0" in pj/config_site.h.
+#
+export CODEC_OBJS = $(GSM_OBJS) $(SPEEX_OBJS)
+
+
 include ../../build/common.mak
 
@@ -8,4 +24,24 @@
 export PJMEDIA_LIB:=../lib/libpjmedia-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME)$(LIBEXT)
 export PJMEDIA_CODEC_LIB:=../lib/libpjmedia-codec-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME)$(LIBEXT)
+
+###############################################################################
+# Sound frameworks
+# These are activated by setting SOUND_OBJS var, e.g.:
+#  export SOUND_OBJS = $(PORTAUDIO_OBJS), or
+#  export SOUND_OBJS = $(NULLSOUND_OBJS)
+#
+PA_DIR:=portaudio
+PORTAUDIO_OBJS := pasound.o \
+		  $(PA_DIR)/pa_allocation.o \
+		  $(PA_DIR)/pa_converters.o \
+		  $(PA_DIR)/pa_cpuload.o \
+		  $(PA_DIR)/pa_dither.o \
+		  $(PA_DIR)/pa_front.o \
+		  $(PA_DIR)/pa_process.o \
+		  $(PA_DIR)/pa_skeleton.o \
+		  $(PA_DIR)/pa_stream.o \
+		  $(PA_DIR)/pa_trace.o
+
+NULLSOUND_OBJS := nullsound.o
 
 ###############################################################################
@@ -27,20 +63,10 @@
 # Defines for building PJMEDIA library
 #
-PA_DIR:=portaudio
 export PJMEDIA_SRCDIR = ../src/pjmedia
 export PJMEDIA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
 			codec.o conference.o endpoint.o errno.o file_port.o \
-			g711.o jbuf.o pasound.o port.o resample.o rtcp.o \
+			g711.o jbuf.o null_port.o pasound.o port.o resample.o rtcp.o \
 			rtp.o sdp.o sdp_cmp.o sdp_neg.o session.o silencedet.o \
-			stream.o \
-		      	$(PA_DIR)/pa_allocation.o \
-			$(PA_DIR)/pa_converters.o \
-			$(PA_DIR)/pa_cpuload.o \
-			$(PA_DIR)/pa_dither.o \
-			$(PA_DIR)/pa_front.o \
-			$(PA_DIR)/pa_process.o \
-			$(PA_DIR)/pa_skeleton.o \
-			$(PA_DIR)/pa_stream.o \
-			$(PA_DIR)/pa_trace.o
+			stream.o $(SOUND_OBJS)
 
 export PJMEDIA_CFLAGS += $(_CFLAGS)
@@ -50,5 +76,6 @@
 # Defines for building PJMEDIA-Codec library
 #
-GSM_OBJS := 	gsm/add.o gsm/code.o gsm/decode.o \
+GSM_OBJS := 	gsm.o \
+		gsm/add.o gsm/code.o gsm/decode.o \
 		gsm/gsm_create.o gsm/gsm_decode.o gsm/gsm_destroy.o \
 		gsm/gsm_encode.o gsm/gsm_explode.o gsm/gsm_implode.o \
@@ -58,5 +85,6 @@
 GSM_CFLAGS :=
 
-SPEEX_OBJS :=	speex/bits.o speex/cb_search.o speex/exc_10_16_table.o  \
+SPEEX_OBJS :=	speex_codec.o \
+		speex/bits.o speex/cb_search.o speex/exc_10_16_table.o  \
 		speex/exc_10_32_table.o speex/exc_20_32_table.o speex/exc_5_256_table.o \
 		speex/exc_5_64_table.o speex/exc_8_128_table.o speex/filters.o \
@@ -72,6 +100,5 @@
 export PJMEDIA_CODEC_SRCDIR = ../src/pjmedia-codec
 export PJMEDIA_CODEC_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
-			gsm.o speex_codec.o pjmedia-codec-lib.o \
-			$(GSM_OBJS) $(SPEEX_OBJS)
+			$(CODEC_OBJS)
 export PJMEDIA_CODEC_CFLAGS += $(_CFLAGS) $(GSM_CFLAGS) $(SPEEX_CFLAGS)
 
@@ -135,5 +162,7 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJMEDIA_CODEC app=pjmedia-codec $@
 	@if test "$@" == "depend"; then \
-	  echo '$(PJMEDIA_TEST_EXE): $(PJMEDIA_LIB)' >> .pjmedia-test-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
+	  echo '$(PJMEDIA_LIB): .pjmedia-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend' >> .pjmedia-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
+	  echo '$(PJMEDIA_CODEC_LIB): .pjmedia-codec-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend' >> .pjmedia-codec-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
+	  echo '$(PJMEDIA_TEST_EXE): $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB)' >> .pjmedia-test-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
 	fi
 
Index: /pjproject/trunk/pjmedia/build/os-win32.mak
===================================================================
--- /pjproject/trunk/pjmedia/build/os-win32.mak	(revision 319)
+++ /pjproject/trunk/pjmedia/build/os-win32.mak	(revision 320)
@@ -12,2 +12,13 @@
 
 export OS_CFLAGS += -DPA_NO_ASIO -DPA_NO_DS
+
+# Example:
+#  to activate Null sound, uncomment this line below.
+#export SOUND_OBJS = $(NULLSOUND_OBJS)
+
+# Example:
+#  to include only GSM and exclude Speex codec, uncomment the "export" line below.
+#  Note that you'll need to put "#define PJMEDIA_HAS_SPEEX_CODEC 0" in
+#  <pj/config_site.h>
+#export CODEC_OBJS = $(GSM_OBJS)
+
Index: /pjproject/trunk/pjmedia/build/pjmedia.dsp
===================================================================
--- /pjproject/trunk/pjmedia/build/pjmedia.dsp	(revision 319)
+++ /pjproject/trunk/pjmedia/build/pjmedia.dsp	(revision 320)
@@ -42,5 +42,5 @@
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /GX /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "NDEBUG" /D "PA_NO_ASIO" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FD /c
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "NDEBUG" /D "PA_NO_ASIO" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c
 # SUBTRACT CPP /YX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -126,5 +126,4 @@
 
 SOURCE=..\src\pjmedia\nullsound.c
-# PROP Exclude_From_Build 1
 # End Source File
 # Begin Source File
Index: /pjproject/trunk/pjmedia/build/pjmedia_codec.dsp
===================================================================
--- /pjproject/trunk/pjmedia/build/pjmedia_codec.dsp	(revision 319)
+++ /pjproject/trunk/pjmedia/build/pjmedia_codec.dsp	(revision 320)
@@ -92,8 +92,4 @@
 # Begin Source File
 
-SOURCE="..\src\pjmedia-codec\pjmedia-codec-lib.c"
-# End Source File
-# Begin Source File
-
 SOURCE="..\src\pjmedia-codec\speex_codec.c"
 # End Source File
Index: /pjproject/trunk/pjmedia/include/pjmedia-codec.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec.h	(revision 320)
@@ -17,6 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJMEDIA_CODEC1_H__
-#define __PJMEDIA_CODEC1_H__
+#ifndef __PJMEDIA_CODEC_PJMEDIA_CODEC_H__
+#define __PJMEDIA_CODEC_PJMEDIA_CODEC_H__
 
 #include <pjmedia-codec/gsm.h>
@@ -24,32 +24,4 @@
 
 
-PJ_BEGIN_DECL
+#endif	/* __PJMEDIA_CODEC_PJMEDIA_CODEC_H__ */
 
-
-/**
- * Initialize pjmedia-codec library, and register all codec factories
- * in this library. If application wants to controll the order of
- * the codec, it MUST NOT call this function, but instead register
- * each codec individually.
- *
- * @param endpt	    The pjmedia endpoint.
- *
- * @return	    PJ_SUCCESS on success.
- */
-PJ_DECL(pj_status_t) pjmedia_codec_init(pjmedia_endpt *endpt);
-
-
-/**
- * Deinitialize pjmedia-codec library, and unregister all codec factories
- * in this library.
- *
- * @return	    PJ_SUCCESS on success.
- */
-PJ_DECL(pj_status_t) pjmedia_codec_deinit(void);
-
-
-PJ_END_DECL
-
-
-#endif	/* __PJMEDIA_CODEC_H__ */
-
Index: /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec/config.h	(revision 320)
@@ -23,17 +23,17 @@
 
 
-/*
- * Include GSM codec?
+/**
+ * Unless specified otherwise, GSM codec is included by default.
  */
-#ifndef PJMEDIA_CODEC_HAS_GSM
-#   define PJMEDIA_CODEC_HAS_GSM    1
+#ifndef PJMEDIA_HAS_GSM_CODEC
+#   define PJMEDIA_HAS_GSM_CODEC    1
 #endif
 
 
-/*
- * Include Speex codec?
+/**
+ * Unless specified otherwise, Speex codec is included by default.
  */
-#ifndef PJMEDIA_CODEC_HAS_SPEEX
-#   define PJMEDIA_CODEC_HAS_SPEEX    1
+#ifndef PJMEDIA_HAS_SPEEX_CODEC
+#   define PJMEDIA_HAS_SPEEX_CODEC    1
 #endif
 
Index: /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia-codec/types.h	(revision 320)
@@ -20,5 +20,5 @@
 #define __PJMEDIA_CODEC_TYPES_H__
 
-#include <pjmedia/types.h>
+#include <pjmedia-codec/config.h>
 
 
Index: /pjproject/trunk/pjmedia/include/pjmedia/config.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 320)
@@ -17,7 +17,34 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJMED_CONFIG_H__
-#define __PJMED_CONFIG_H__
+#ifndef __PJMEDIA_CONFIG_H__
+#define __PJMEDIA_CONFIG_H__
+
+#include <pj/config.h>
+
+/**
+ * Unless specified otherwise, PortAudio is enabled by default.
+ */
+#ifndef PJMEDIA_HAS_PORTAUDIO_SOUND
+#   define PJMEDIA_HAS_PORTAUDIO_SOUND	    1
+#endif
 
 
-#endif	/* __PJMED_CONFIG_H__ */
+/**
+ * Unless specified otherwise, Null sound is disabled.
+ * This option is mutually exclusive with PortAudio sound, or otherwise
+ * duplicate symbols error will occur.
+ */
+#ifndef PJMEDIA_HAS_NULL_SOUND
+#   define PJMEDIA_HAS_NULL_SOUND	    0
+#endif
+
+
+/**
+ * Unless specified otherwise, G711 codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_G711_CODEC
+#   define PJMEDIA_HAS_G711_CODEC	    1
+#endif
+
+
+#endif	/* __PJMEDIA_CONFIG_H__ */
Index: /pjproject/trunk/pjmedia/include/pjmedia/sound.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/sound.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia/sound.h	(revision 320)
@@ -25,5 +25,5 @@
  * @brief Sound player and recorder device framework.
  */
-
+#include <pjmedia/types.h>
 #include <pj/pool.h>
 
Index: /pjproject/trunk/pjmedia/include/pjmedia/types.h
===================================================================
--- /pjproject/trunk/pjmedia/include/pjmedia/types.h	(revision 319)
+++ /pjproject/trunk/pjmedia/include/pjmedia/types.h	(revision 320)
@@ -20,7 +20,6 @@
 #define __PJMEDIA_TYPES_H__
 
-#include <pj/types.h>
+#include <pjmedia/config.h>
 #include <pj/sock.h>
-
 
 /** 
Index: /pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c	(revision 319)
+++ /pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c	(revision 320)
@@ -27,4 +27,10 @@
 #include <pj/os.h>
 #include "gsm/gsm.h"
+
+/*
+ * Only build this file if PJMEDIA_HAS_GSM_CODEC != 0
+ */
+#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC != 0
+
 
 /* Prototypes for GSM factory */
@@ -474,2 +480,6 @@
     return PJ_SUCCESS;
 }
+
+
+#endif	/* PJMEDIA_HAS_GSM_CODEC */
+
Index: project/trunk/pjmedia/src/pjmedia-codec/pjmedia-codec-lib.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-codec/pjmedia-codec-lib.c	(revision 319)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/* $Id$ */
-/* 
- * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-#include <pjmedia-codec.h>
-
-/* Include factories: */
-#include <pjmedia-codec/config.h>
-#include <pjmedia-codec/gsm.h>
-#include <pjmedia-codec/speex.h>
-
-
-static pjmedia_endpt *the_endpt;
-static struct codec_list
-{
-    pj_status_t (*init)(pjmedia_endpt*);
-    pj_status_t (*deinit)(void);
-} codec_list[] = 
-{
-
-#if PJMEDIA_CODEC_HAS_GSM
-    { &pjmedia_codec_gsm_init, &pjmedia_codec_gsm_deinit},
-#endif
-
-#if PJMEDIA_CODEC_HAS_SPEEX
-    { &pjmedia_codec_speex_init_default, &pjmedia_codec_speex_deinit},
-#endif
-
-    { NULL, NULL }
-};
-
-/*
- * Initialize pjmedia-codec library, and register all codec factories
- * in this library.
- */
-PJ_DEF(pj_status_t) pjmedia_codec_init(pjmedia_endpt *endpt)
-{
-    pj_status_t status;
-    unsigned i;
-
-    the_endpt = endpt;
-
-    for (i=0; codec_list[i].init; ++i) {
-	status = (*codec_list[i].init)(the_endpt);
-	if (status != PJ_SUCCESS)
-	    return status;
-    }
-    return PJ_SUCCESS;
-}
-
-
-/*
- * Deinitialize pjmedia-codec library, and unregister all codec factories
- * in this library.
- */
-PJ_DEF(pj_status_t) pjmedia_codec_deinit(void)
-{
-    pj_status_t status;
-    unsigned i;
-
-    for (i=0; codec_list[i].init; ++i) {
-	status = (*codec_list[i].deinit)();
-	if (status != PJ_SUCCESS)
-	    return status;
-    }
-
-    return PJ_SUCCESS;
-}
-
-
-
-
Index: /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c	(revision 319)
+++ /pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c	(revision 320)
@@ -29,4 +29,10 @@
 #include <pj/string.h>
 #include <pj/os.h>
+
+/*
+ * Only build this file if PJMEDIA_HAS_SPEEX_CODEC != 0
+ */
+#if defined(PJMEDIA_HAS_SPEEX_CODEC) && PJMEDIA_HAS_SPEEX_CODEC!=0
+
 
 #define THIS_FILE   "speex_codec.c"
@@ -778,2 +784,5 @@
     return PJ_SUCCESS;
 }
+
+
+#endif	/* PJMEDIA_HAS_SPEEX_CODEC */
Index: /pjproject/trunk/pjmedia/src/pjmedia/g711.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/g711.c	(revision 319)
+++ /pjproject/trunk/pjmedia/src/pjmedia/g711.c	(revision 320)
@@ -27,4 +27,6 @@
 #include <pj/string.h>
 #include <pj/assert.h>
+
+#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0
 
 
@@ -473,4 +475,7 @@
 
 
+#endif	/* PJMEDIA_HAS_G711_CODEC */
+
+
 /*
  * This source code is a product of Sun Microsystems, Inc. and is provided
@@ -765,2 +770,3 @@
 
 
+
Index: /pjproject/trunk/pjmedia/src/pjmedia/nullsound.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/nullsound.c	(revision 319)
+++ /pjproject/trunk/pjmedia/src/pjmedia/nullsound.c	(revision 320)
@@ -19,4 +19,6 @@
 #include <pjmedia/sound.h>
 #include <pj/assert.h>
+
+#if defined(PJMEDIA_HAS_NULL_SOUND) && PJMEDIA_HAS_NULL_SOUND!=0
 
 static pj_snd_dev_info null_info = 
@@ -46,26 +48,46 @@
 }
 
-PJ_DEF(pj_snd_stream*) pj_snd_open_recorder( int index,
-					     const pj_snd_stream_info *param,
-					     pj_snd_rec_cb rec_cb,
-					     void *user_data)
+PJ_DEF(pj_status_t) pj_snd_open_recorder( int index,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned bits_per_sample,
+					  pj_snd_rec_cb rec_cb,
+					  void *user_data,
+					  pj_snd_stream **p_snd_strm)
 {
     PJ_UNUSED_ARG(index);
-    PJ_UNUSED_ARG(param);
+    PJ_UNUSED_ARG(clock_rate);
+    PJ_UNUSED_ARG(channel_count);
+    PJ_UNUSED_ARG(samples_per_frame);
+    PJ_UNUSED_ARG(bits_per_sample);
     PJ_UNUSED_ARG(rec_cb);
     PJ_UNUSED_ARG(user_data);
-    return (void*)1;
+
+    *p_snd_strm = (void*)1;
+
+    return PJ_SUCCESS;
 }
 
-PJ_DEF(pj_snd_stream*) pj_snd_open_player( int index,
-					   const pj_snd_stream_info *param,
-					   pj_snd_play_cb play_cb,
-					   void *user_data)
+PJ_DEF(pj_status_t) pj_snd_open_player( int index,
+					unsigned clock_rate,
+					unsigned channel_count,
+					unsigned samples_per_frame,
+					unsigned bits_per_sample,
+					pj_snd_play_cb play_cb,
+					void *user_data,
+					pj_snd_stream **p_snd_strm )
 {
     PJ_UNUSED_ARG(index);
-    PJ_UNUSED_ARG(param);
+    PJ_UNUSED_ARG(clock_rate);
+    PJ_UNUSED_ARG(channel_count);
+    PJ_UNUSED_ARG(samples_per_frame);
+    PJ_UNUSED_ARG(bits_per_sample);
     PJ_UNUSED_ARG(play_cb);
     PJ_UNUSED_ARG(user_data);
-    return (void*)1;
+
+    *p_snd_strm = (void*)1;
+
+    return PJ_SUCCESS;
 }
 
@@ -92,2 +114,5 @@
     return PJ_SUCCESS;
 }
+
+
+#endif	/* PJMEDIA_HAS_NULL_SOUND */
Index: /pjproject/trunk/pjmedia/src/pjmedia/pasound.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/pasound.c	(revision 319)
+++ /pjproject/trunk/pjmedia/src/pjmedia/pasound.c	(revision 320)
@@ -23,4 +23,6 @@
 #include <pj/string.h>
 #include <portaudio.h>
+
+#if defined(PJMEDIA_HAS_PORTAUDIO_SOUND) && PJMEDIA_HAS_PORTAUDIO_SOUND!=0
 
 #define THIS_FILE	"pasound.c"
@@ -435,2 +437,4 @@
 }
 
+
+#endif	/* PJMEDIA_HAS_PORTAUDIO_SOUND */
Index: /pjproject/trunk/pjsip-apps/build/Makefile
===================================================================
--- /pjproject/trunk/pjsip-apps/build/Makefile	(revision 319)
+++ /pjproject/trunk/pjsip-apps/build/Makefile	(revision 320)
@@ -45,4 +45,16 @@
 
 
+###############################################################################
+# Defines for building PJSIP-PERF
+#
+export PJSIPPERF_SRCDIR = ../src/pjsip-perf
+export PJSIPPERF_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
+			 handler_call.o handler_options.o main.o
+export PJSIPPERF_CFLAGS += $(_CFLAGS)
+export PJSIPPERF_LDFLAGS += $(_LDFLAGS)
+export PJSIPPERF_EXE:=../bin/pjsip-perf-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME)$(HOST_EXE)
+
+
+
 export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT 
 ###############################################################################
@@ -50,5 +62,5 @@
 #
 #
-TARGETS := pjsua
+TARGETS := pjsua pjsip-perf
 
 .PHONY: $(TARGETS)
@@ -67,4 +79,8 @@
 	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(PJSUA_EXE)
 
+pjsip-perf:
+	$(MAKE) -f $(RULES_MAK) APP=PJSIPPERF app=pjsip-perf $(PJSUA_EXE)
+
+
 .PHONY: ../lib/pjsua.ko
 ../lib/pjsua.ko:
@@ -73,6 +89,8 @@
 clean depend realclean:
 	$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $@
+	$(MAKE) -f $(RULES_MAK) APP=PJSIPPERF app=pjsip-perf $@
 	@if test "$@" == "depend"; then \
-	  echo '$(PJSUA_EXE): $(PJSIP_LIB) $(PJSIP_UA_LIB) $(PJSIP_SIMPLE) $(PJSUA_LIB_LIB) $(PJLIB_LIB) $(PJLIB_UTIL_LIB) $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB)' >> .pjsua-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
+	  echo '$(PJSUA_EXE): $(PJSIP_LIB) $(PJSIP_UA_LIB) $(PJSIP_SIMPLE) $(PJSUA_LIB_LIB) $(PJLIB_LIB) $(PJLIB_UTIL_LIB) $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB) Makefile' >> .pjsua-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
+	  echo '$(PJSIPPERF_EXE): $(PJSIP_LIB) $(PJSIP_UA_LIB) $(PJSIP_SIMPLE) $(PJSUA_LIB_LIB) $(PJLIB_LIB) $(PJLIB_UTIL_LIB) $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB)' >> .pjsip-perf-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
 	fi
 
Index: /pjproject/trunk/pjsip-apps/build/pjsip_apps.dsw
===================================================================
--- /pjproject/trunk/pjsip-apps/build/pjsip_apps.dsw	(revision 319)
+++ /pjproject/trunk/pjsip-apps/build/pjsip_apps.dsw	(revision 320)
@@ -79,10 +79,4 @@
     End Project Dependency
     Begin Project Dependency
-    Project_Dep_Name pjmedia
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name pjmedia_codec
-    End Project Dependency
-    Begin Project Dependency
     Project_Dep_Name pjsip_core
     End Project Dependency
@@ -95,4 +89,7 @@
     Begin Project Dependency
     Project_Dep_Name pjsua_lib
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name pjmedia
     End Project Dependency
 }}}
Index: /pjproject/trunk/pjsip-apps/build/pjsip_perf.dsp
===================================================================
--- /pjproject/trunk/pjsip-apps/build/pjsip_perf.dsp	(revision 319)
+++ /pjproject/trunk/pjsip-apps/build/pjsip_perf.dsp	(revision 320)
@@ -51,5 +51,5 @@
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ole32.lib user32.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\bin\pjsip-perf-i386-win32-vc6d.exe"
+# ADD LINK32 ole32.lib user32.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\bin\pjsip-perf-i386-win32-vc6.exe"
 
 !ELSEIF  "$(CFG)" == "pjsip_perf - Win32 Debug"
Index: /pjproject/trunk/pjsip-apps/build/pjsua.dsp
===================================================================
--- /pjproject/trunk/pjsip-apps/build/pjsua.dsp	(revision 319)
+++ /pjproject/trunk/pjsip-apps/build/pjsua.dsp	(revision 320)
@@ -52,5 +52,5 @@
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ole32.lib user32.lib dsound.lib dxguid.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /map /machine:I386 /out:"../bin/pjsua_vc6.exe" /fixed:no
+# ADD LINK32 ole32.lib user32.lib dsound.lib dxguid.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /map:"..\bin\pjsua_vc6.map" /machine:I386 /out:"../bin/pjsua_vc6.exe" /fixed:no
 # SUBTRACT LINK32 /pdb:none /debug
 
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 319)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 320)
@@ -618,4 +618,5 @@
     if (pjsua.codec_cnt == 0) {
 
+#if PJMEDIA_HAS_SPEEX_CODEC
 	unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB;
 
@@ -637,5 +638,7 @@
 	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_speex_deinit;
 	pjsua.codec_cnt++;
-
+#endif /* PJMEDIA_HAS_SPEEX_CODEC */
+
+#if PJMEDIA_HAS_GSM_CODEC
 	/* Register GSM */
 	status = pjmedia_codec_gsm_init(pjsua.med_endpt);
@@ -649,5 +652,7 @@
 	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_gsm_deinit;
 	pjsua.codec_cnt++;
-
+#endif /* PJMEDIA_HAS_GSM_CODEC */
+
+#if PJMEDIA_HAS_G711_CODEC
 	/* Register PCMA and PCMU */
 	status = pjmedia_codec_g711_init(pjsua.med_endpt);
@@ -664,4 +669,5 @@
 	pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_g711_deinit;
 	pjsua.codec_cnt++;
+#endif	/* PJMEDIA_HAS_G711_CODEC */
 
     } else {
@@ -674,6 +680,10 @@
 	for (i=0; i<pjsua.codec_cnt; ++i) {
 	
+	    if (0) {
+		/* Dummy */
+	    }
+#if PJMEDIA_HAS_SPEEX_CODEC
 	    /* Is it speex? */
-	    if (!pj_stricmp2(&pjsua.codec_arg[i], "speex")) {
+	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "speex")) {
 
 		unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB;
@@ -695,4 +705,7 @@
 		pjsua.codec_deinit[i] = &pjmedia_codec_speex_deinit;
 	    }
+#endif	/* PJMEDIA_HAS_SPEEX_CODEC */
+
+#if PJMEDIA_HAS_GSM_CODEC
 	    /* Is it gsm? */
 	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "gsm")) {
@@ -708,4 +721,7 @@
 
 	    }
+#endif	/* PJMEDIA_HAS_GSM_CODEC */
+
+#if PJMEDIA_HAS_G711_CODEC
 	    /* Is it pcma/pcmu? */
 	    else if (!pj_stricmp2(&pjsua.codec_arg[i], "pcmu") ||
@@ -723,4 +739,6 @@
 
 	    }
+#endif	/* PJMEDIA_HAS_G711_CODEC */
+
 	    /* Don't know about this codec... */
 	    else {
@@ -1059,8 +1077,10 @@
 
     /* Destroy file port */
-    pjmedia_port_destroy(pjsua.file_port);
+    if (pjsua.file_port)
+	pjmedia_port_destroy(pjsua.file_port);
 
     /* Destroy null port. */
-    pjmedia_port_destroy(pjsua.null_port);
+    if (pjsua.null_port)
+	pjmedia_port_destroy(pjsua.null_port);
 
 
