From 9557bd45e44753f1a9990ce1f2bad6041316d88c Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Mon, 22 Mar 2010 16:00:38 -0400
Subject: [PATCH] [#3200] Use default parameters in celt for VBR, get Back to
 32000, 320 samples

---
 .../src/audio/codecs/celtcodec.cpp            | 11 +++-----
 sflphone-common/src/sip/sdp.cpp               | 11 ++++++--
 sflphone-common/src/sip/sipvoiplink.cpp       | 28 +++++++++----------
 sflphone-common/src/sip/sipvoiplink.h         | 11 ++++----
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/sflphone-common/src/audio/codecs/celtcodec.cpp b/sflphone-common/src/audio/codecs/celtcodec.cpp
index 05864b0b60..aebbd2dfab 100644
--- a/sflphone-common/src/audio/codecs/celtcodec.cpp
+++ b/sflphone-common/src/audio/codecs/celtcodec.cpp
@@ -94,14 +94,11 @@ class Celt : public AudioCodec
 
             _dec = celt_decoder_create (_mode, _channel, &error);
 
-            celt_encoder_ctl (_enc, CELT_SET_COMPLEXITY (0));
-            celt_decoder_ctl(_dec, CELT_SET_COMPLEXITY (0));
+            celt_encoder_ctl (_enc, CELT_SET_COMPLEXITY (2));
+            celt_decoder_ctl(_dec, CELT_SET_COMPLEXITY (2));
 
-            celt_encoder_ctl (_enc, CELT_SET_PREDICTION(1));
-            celt_decoder_ctl(_dec, CELT_SET_PREDICTION(1));
-
-            celt_encoder_ctl (_enc, CELT_SET_VBR_RATE(0));
-            celt_decoder_ctl(_dec, CELT_SET_VBR_RATE(0));
+            celt_encoder_ctl (_enc, CELT_SET_PREDICTION(2));
+            celt_decoder_ctl(_dec, CELT_SET_PREDICTION(2));
 
         }
 
diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp
index 4d6505740f..94c8e64634 100644
--- a/sflphone-common/src/sip/sdp.cpp
+++ b/sflphone-common/src/sip/sdp.cpp
@@ -97,9 +97,16 @@ void Sdp::set_media_descriptor_line (sdpMedia *media, pjmedia_sdp_media** p_med)
         // connection, the rtpmap attribute will be useful to specify for which codec it is applicable
         rtpmap.pt = med->desc.fmt[i];
         rtpmap.enc_name = pj_str ( (char*) codec->getCodecName().c_str());
-        rtpmap.clock_rate = codec->getClockRate();
-        // Add the channel number only if different from 1
 
+        // G722 require G722/8000 media description even if it is 16000 codec
+        if(codec->getPayload () == 9) {
+        	  rtpmap.clock_rate = 8000;
+        }
+        else {
+        	rtpmap.clock_rate = codec->getClockRate();
+        }
+
+        // Add the channel number only if different from 1
         if (codec->getChannel() > 1)
             rtpmap.param = pj_str ( (char*) codec->getChannel());
         else
diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp
index 10bf2c4d70..d379217c05 100644
--- a/sflphone-common/src/sip/sipvoiplink.cpp
+++ b/sflphone-common/src/sip/sipvoiplink.cpp
@@ -2476,7 +2476,7 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
     pjsip_transport_type_e transportType;
     pjsip_tpselector *tp_sel;
 
-    _debug ("SIPVoIPLink::findLocalAddressFromUri");
+    _debug ("SIP: Find local address from URI");
 
     // Find the transport that must be used with the given uri
     pj_str_t tmp;
@@ -2489,7 +2489,7 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
     std::string machineName (pjMachineName.ptr, pjMachineName.slen);
 
     if (genericUri == NULL) {
-        _debug ("genericUri is NULL in findLocalAddressFromUri");
+        _warn ("SIP: generic URI is NULL in findLocalAddressFromUri");
         return machineName;
     }
 
@@ -2498,7 +2498,7 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
     sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri (genericUri);
 
     if (sip_uri == NULL) {
-        _debug ("Invalid uri in findLocalAddressFromTransport");
+        _warn ("SIP: Invalid uri in findLocalAddressFromURI");
         return machineName;
     }
 
@@ -2507,7 +2507,7 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
 
     } else {
         if (transport == NULL) {
-            _debug ("transport is NULL in findLocalAddressFromUri. Try the local UDP transport");
+            _warn ("SIP: Transport is NULL in findLocalAddressFromUri. Try the local UDP transport");
             transport = _localUDPTransport;
         }
 
@@ -2521,7 +2521,7 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
     tpmgr = pjsip_endpt_get_tpmgr (_endpt);
 
     if (tpmgr == NULL) {
-        _debug ("Unexpected: Cannot get tpmgr from endpoint.");
+        _warn ("SIP: Unexpected: Cannot get tpmgr from endpoint.");
         return machineName;
     }
 
@@ -2537,23 +2537,23 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
         status = init_transport_selector (transport, &tp_sel);
 
         if (status == PJ_SUCCESS) {
-	    _debug("pjsip_tpmgr_find_local_addr, UDP, tpsel");
             status = pjsip_tpmgr_find_local_addr (tpmgr, _pool, transportType, tp_sel, &localAddress, &port);
-	} else {
-	    _debug("pjsip_tpmgr_find_local_addr, UDP");
-            status = pjsip_tpmgr_find_local_addr (tpmgr, _pool, transportType, NULL, &localAddress, &port);
-	}
-    } else {
-        _debug("pjsip_tpmgr_find_local_addr, TLS");
+        }
+        else {
+        	status = pjsip_tpmgr_find_local_addr (tpmgr, _pool, transportType, NULL, &localAddress, &port);
+        }
+    }
+    else {
         status = pjsip_tpmgr_find_local_addr (tpmgr, _pool, transportType, NULL, &localAddress, &port);
     }
 
     if (status != PJ_SUCCESS) {
-        _debug ("Failed to find local address from transport");
+        _debug ("SIP: Failed to find local address from transport");
         return machineName;
     }
 
-    _debug ("Local address discovered from attached transport: %s", localAddress.ptr);
+	std::string localaddr(localAddress.ptr, localAddress.slen);
+    _debug ("SIP: Local address discovered from attached transport: %s", localaddr.c_str());
 
     return std::string (localAddress.ptr, localAddress.slen);
 }
diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h
index 445a28b6fd..8a3e45acd7 100644
--- a/sflphone-common/src/sip/sipvoiplink.h
+++ b/sflphone-common/src/sip/sipvoiplink.h
@@ -460,18 +460,19 @@ class SIPVoIPLink : public VoIPLink
          */
 	pj_status_t createAlternateUdpTransport (AccountID id);
 
+
 	/** 
 	 * UDP Transports are stored in this map in order to retreive them in case
 	 * several accounts would share the same port number.
 	 */
 	SipTransportMap _transportMap;
 
-        /** For registration use only */
-        int _regPort;
+	/** For registration use only */
+	int _regPort;
 
-        /** Threading object */
-        EventThread* _evThread;
-        ost::Mutex _mutexSIP;
+	/** Threading object */
+	EventThread* _evThread;
+	ost::Mutex _mutexSIP;
 
         /* Number of SIP accounts connected to the link */
         int _clients;
-- 
GitLab