Index: pjproject/trunk/pjlib/include/pj/ssl_sock.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/ssl_sock.h	(revision 2997)
+++ pjproject/trunk/pjlib/include/pj/ssl_sock.h	(revision 2998)
@@ -27,4 +27,5 @@
 #include <pj/ioqueue.h>
 #include <pj/sock.h>
+#include <pj/sock_qos.h>
 
 
@@ -532,5 +533,32 @@
      */
     pj_str_t server_name;
-    
+
+    /**
+     * QoS traffic type to be set on this transport. When application wants
+     * to apply QoS tagging to the transport, it's preferable to set this
+     * field rather than \a qos_param fields since this is more portable.
+     *
+     * Default value is PJ_QOS_TYPE_BEST_EFFORT.
+     */
+    pj_qos_type qos_type;
+
+    /**
+     * Set the low level QoS parameters to the transport. This is a lower
+     * level operation than setting the \a qos_type field and may not be
+     * supported on all platforms.
+     *
+     * By default all settings in this structure are disabled.
+     */
+    pj_qos_params qos_params;
+
+    /**
+     * Specify if the transport should ignore any errors when setting the QoS
+     * traffic type/parameters.
+     *
+     * Default: PJ_TRUE
+     */
+    pj_bool_t qos_ignore_error;
+
+
 } pj_ssl_sock_param;
 
Index: pjproject/trunk/pjlib/src/pj/sock_qos_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/sock_qos_symbian.cpp	(revision 2997)
+++ pjproject/trunk/pjlib/src/pj/sock_qos_symbian.cpp	(revision 2998)
@@ -23,4 +23,6 @@
 					   pj_qos_params *param)
 {
+    PJ_ASSERT_RETURN(sock!=0 && sock!=PJ_INVALID_SOCKET, PJ_EINVAL);
+    
     CPjSocket *pjsock = (CPjSocket*)sock;
     RSocket & rsock = pjsock->Socket();
@@ -61,4 +63,6 @@
 					   pj_qos_params *p_param)
 {
+    PJ_ASSERT_RETURN(sock!=0 && sock!=PJ_INVALID_SOCKET, PJ_EINVAL);
+    
     CPjSocket *pjsock = (CPjSocket*)sock;
     RSocket & rsock = pjsock->Socket();
Index: pjproject/trunk/pjlib/src/pj/ssl_sock_common.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/ssl_sock_common.c	(revision 2997)
+++ pjproject/trunk/pjlib/src/pj/ssl_sock_common.c	(revision 2998)
@@ -121,4 +121,6 @@
     param->read_buffer_size = 1500;
 #endif
+    param->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
+    param->qos_ignore_error = PJ_TRUE;
 
     /* Security config */
Index: pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 2997)
+++ pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 2998)
@@ -1207,4 +1207,11 @@
 	    goto on_return;
     }
+
+    /* Apply QoS, if specified */
+    status = pj_sock_apply_qos2(ssock->sock, ssock->param.qos_type,
+				&ssock->param.qos_params, 1, 
+				ssock->pool->obj_name, NULL);
+    if (status != PJ_SUCCESS && !ssock->param.qos_ignore_error)
+	goto on_return;
 
     /* Update local address */
@@ -1954,4 +1961,11 @@
 	goto on_error;
 
+    /* Apply QoS, if specified */
+    status = pj_sock_apply_qos2(ssock->sock, ssock->param.qos_type,
+				&ssock->param.qos_params, 2, 
+				ssock->pool->obj_name, NULL);
+    if (status != PJ_SUCCESS && !ssock->param.qos_ignore_error)
+	goto on_error;
+
     /* Bind socket */
     status = pj_sock_bind(ssock->sock, localaddr, addr_len);
@@ -2029,4 +2043,11 @@
 	goto on_error;
 
+    /* Apply QoS, if specified */
+    status = pj_sock_apply_qos2(ssock->sock, ssock->param.qos_type,
+				&ssock->param.qos_params, 2, 
+				ssock->pool->obj_name, NULL);
+    if (status != PJ_SUCCESS && !ssock->param.qos_ignore_error)
+	goto on_error;
+
     /* Bind socket */
     status = pj_sock_bind(ssock->sock, localaddr, addr_len);
Index: pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp
===================================================================
--- pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp	(revision 2997)
+++ pjproject/trunk/pjlib/src/pj/ssl_sock_symbian.cpp	(revision 2998)
@@ -98,6 +98,9 @@
     };
     
-    static CPjSSLSocket *NewL(const TDesC8 &ssl_proto) {
-	CPjSSLSocket *self = new (ELeave) CPjSSLSocket();
+    static CPjSSLSocket *NewL(const TDesC8 &ssl_proto,
+			      pj_qos_type qos_type,
+			      const pj_qos_params &qos_params) 
+    {
+	CPjSSLSocket *self = new (ELeave) CPjSSLSocket(qos_type, qos_params);
 	CleanupStack::PushL(self);
 	self->ConstructL(ssl_proto);
@@ -131,4 +134,8 @@
     CSecureSocket  	*securesock_;
     bool	    	 is_connected_;
+    
+    pj_qos_type 	 qos_type_;
+    pj_qos_params 	 qos_params_;
+    			      
     CPjSSLSocketReader  *reader_;
     TBuf<32> 	    	 ssl_proto_;
@@ -144,9 +151,9 @@
     void RunL();
 
-    CPjSSLSocket() :
+    CPjSSLSocket(pj_qos_type qos_type, const pj_qos_params &qos_params) :
 	CActive(0), state_(SSL_STATE_NULL), sock_(PJ_INVALID_SOCKET), 
-	securesock_(NULL), 
-	is_connected_(false), reader_(NULL),
-	cb_(NULL), key_(NULL)
+	securesock_(NULL), is_connected_(false),
+	qos_type_(qos_type), qos_params_(qos_params),
+	reader_(NULL), 	cb_(NULL), key_(NULL)
     {}
     
@@ -165,5 +172,5 @@
 	}
 	if (sock_ != PJ_INVALID_SOCKET) {
-	    delete (CPjSocket*)sock_;
+	    pj_sock_close(sock_);
 	    sock_ = PJ_INVALID_SOCKET;
 	}	    
@@ -184,4 +191,8 @@
 	return status;
 
+    // Apply QoS
+    status = pj_sock_apply_qos2(sock_, qos_type_, &qos_params_, 
+    				2,  THIS_FILE, NULL);
+    
     RSocket &rSock = ((CPjSocket*)sock_)->Socket();
 
@@ -412,4 +423,10 @@
     pj_sockaddr		 local_addr;
     pj_sockaddr		 rem_addr;
+
+    /* QoS settings */
+    pj_qos_type		 qos_type;
+    pj_qos_params	 qos_params;
+    pj_bool_t		 qos_ignore_error;
+
 
     pj_ssl_sock_proto	 proto;
@@ -502,4 +519,9 @@
     }
     pj_strdup_with_null(pool, &ssock->servername, &param->server_name);
+
+    ssock->qos_type = param->qos_type;
+    ssock->qos_ignore_error = param->qos_ignore_error;
+    pj_memcpy(&ssock->qos_params, &param->qos_params,
+	      sizeof(param->qos_params));
 
     /* Finally */
@@ -1062,5 +1084,6 @@
 
     /* Init SSL engine */
-    TRAPD(err, sock = CPjSSLSocket::NewL(proto));
+    TRAPD(err, sock = CPjSSLSocket::NewL(proto, ssock->qos_type, 
+				         ssock->qos_params));
     if (err != KErrNone)
 	return PJ_ENOMEM;
Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 2997)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 2998)
@@ -4601,4 +4601,9 @@
 	pjsua_acc_id acc_id;
 
+	/* Copy the QoS settings */
+	tcp_cfg.tls_setting.qos_type = tcp_cfg.qos_type;
+	pj_memcpy(&tcp_cfg.tls_setting.qos_params, &tcp_cfg.qos_params, 
+		  sizeof(tcp_cfg.qos_params));
+
 	/* Set TLS port as TCP port+1 */
 	tcp_cfg.port++;
Index: pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
===================================================================
--- pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2997)
+++ pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp	(revision 2998)
@@ -93,4 +93,14 @@
 
 //
+// Set QoS on transports? Yes!
+// As an example, we set SIP transports DSCP value to CS3 (DSCP
+// value 24 or 0x18), for no reason, and tag RTP/RTCP packets 
+// with VOICE type.
+//
+#define SIP_QOS_DSCP	0x18
+#define RTP_QOS_TYPE	PJ_QOS_TYPE_VOICE
+
+
+//
 // Globals
 //
@@ -385,4 +395,8 @@
     pjsua_transport_config_default(&tcfg);
     tcfg.port = SIP_PORT;
+    if (SIP_QOS_DSCP) {
+	tcfg.qos_params.flags |= PJ_QOS_PARAM_HAS_DSCP;
+	tcfg.qos_params.dscp_val = SIP_QOS_DSCP;
+    }
     status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &tcfg, &tid);
     if (status != PJ_SUCCESS) {
@@ -397,4 +411,8 @@
     pjsua_transport_config_default(&tcfg);
     tcfg.port = SIP_PORT;
+    if (SIP_QOS_DSCP) {
+	tcfg.qos_params.flags |= PJ_QOS_PARAM_HAS_DSCP;
+	tcfg.qos_params.dscp_val = SIP_QOS_DSCP;
+    }
     status = pjsua_transport_create(PJSIP_TRANSPORT_TCP, &tcfg, &tid);
     if (status != PJ_SUCCESS) {
@@ -409,4 +427,9 @@
     pjsua_transport_config_default(&tcfg);
     tcfg.port = SIP_PORT + 1;
+    if (SIP_QOS_DSCP) {
+	tcfg.qos_params.flags |= PJ_QOS_PARAM_HAS_DSCP;
+	tcfg.qos_params.dscp_val = SIP_QOS_DSCP;
+	tcfg.tls_setting.qos_params = tcfg.qos_params;
+    }
     status = pjsua_transport_create(PJSIP_TRANSPORT_TLS, &tcfg, &tid);
     if (status != PJ_SUCCESS) {
@@ -420,5 +443,16 @@
     pjsua_acc_add_local(tid, PJ_TRUE, &g_acc_id);
 
-
+    /* Create media transports */
+    pjsua_transport_config mtcfg;
+    pjsua_transport_config_default(&mtcfg);
+    mtcfg.port = 4000;
+    mtcfg.qos_type = RTP_QOS_TYPE;
+    status = pjsua_media_transports_create(&mtcfg);
+    if (status != PJ_SUCCESS) {
+    	pjsua_perror(THIS_FILE, "Error creating media transports", status);
+    	pjsua_destroy();
+    	return status;
+    }
+    
     /* Initialization is done, now start pjsua */
     status = pjsua_start();
Index: pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h	(revision 2997)
+++ pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h	(revision 2998)
@@ -28,4 +28,5 @@
 #include <pjsip/sip_transport.h>
 #include <pj/string.h>
+#include <pj/sock_qos.h>
 
 
@@ -161,4 +162,30 @@
     pj_time_val	timeout;
 
+    /**
+     * QoS traffic type to be set on this transport. When application wants
+     * to apply QoS tagging to the transport, it's preferable to set this
+     * field rather than \a qos_param fields since this is more portable.
+     *
+     * Default value is PJ_QOS_TYPE_BEST_EFFORT.
+     */
+    pj_qos_type qos_type;
+
+    /**
+     * Set the low level QoS parameters to the transport. This is a lower
+     * level operation than setting the \a qos_type field and may not be
+     * supported on all platforms.
+     *
+     * By default all settings in this structure are disabled.
+     */
+    pj_qos_params qos_params;
+
+    /**
+     * Specify if the transport should ignore any errors when setting the QoS
+     * traffic type/parameters.
+     *
+     * Default: PJ_TRUE
+     */
+    pj_bool_t qos_ignore_error;
+
 } pjsip_tls_setting;
 
@@ -172,4 +199,6 @@
 {
     pj_memset(tls_opt, 0, sizeof(*tls_opt));
+    tls_opt->qos_type = PJ_QOS_TYPE_BEST_EFFORT;
+    tls_opt->qos_ignore_error = PJ_TRUE;
 }
 
Index: pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 2997)
+++ pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c	(revision 2998)
@@ -251,4 +251,8 @@
     if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN)
 	ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN;
+    ssock_param.qos_type = listener->tls_setting.qos_type;
+    ssock_param.qos_ignore_error = listener->tls_setting.qos_ignore_error;
+    pj_memcpy(&ssock_param.qos_params, &listener->tls_setting.qos_params,
+	      sizeof(ssock_param.qos_params));
 
     has_listener = PJ_FALSE;
@@ -798,4 +802,8 @@
     if (ssock_param.read_buffer_size < PJSIP_MAX_PKT_LEN)
 	ssock_param.read_buffer_size = PJSIP_MAX_PKT_LEN;
+    ssock_param.qos_type = listener->tls_setting.qos_type;
+    ssock_param.qos_ignore_error = listener->tls_setting.qos_ignore_error;
+    pj_memcpy(&ssock_param.qos_params, &listener->tls_setting.qos_params,
+	      sizeof(ssock_param.qos_params));
 
     switch(listener->tls_setting.method) {
