[asterisk-commits] pcadach: branch pcadach/chan_h323-live r40517 - /team/pcadach/chan_h323-live/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Aug 19 00:44:09 MST 2006


Author: pcadach
Date: Sat Aug 19 02:44:09 2006
New Revision: 40517

URL: http://svn.digium.com/view/asterisk?rev=40517&view=rev
Log:
Workaround for empty preferenced codec list when specifying allow=all in configuration file. IMHO solution I've found looks very nice!!! ;-)

Modified:
    team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp?rev=40517&r1=40516&r2=40517&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp Sat Aug 19 02:44:09 2006
@@ -1147,20 +1147,31 @@
 	PINDEX lastcap = -1; /* last common capability index */
 	int alreadysent = 0;
 	int codec;
-	int x;
+	int x, y;
 	char caps_str[1024];
 	
 	localCapabilities.RemoveAll();
 
 	if (h323debug) {	
 		cout << "Setting capabilities to " << ast_getformatname_multiple(caps_str, sizeof(caps_str), cap) << endl;
-	}
-	for (x = -1; x < 32; ++x) {
+		ast_codec_pref_string(prefs, caps_str, sizeof(caps_str));
+		cout << "Capabilities in preference order is " << caps_str << endl;
+	}
+	/* Add audio codecs in preference order first, then
+	   audio codecs without preference as allowed by mask */
+	for (y = 0, x = -1; x < 32 + 32; ++x) {
 		if (x < 0)
 			codec = pref_codec;
-		else if (!(codec = ast_codec_pref_index(prefs, x)))
-			break;
-		if (!(cap & codec) || (alreadysent & codec))
+		else if (y || (!(codec = ast_codec_pref_index(prefs, x)))) {
+			if (!y)
+				y = 1;
+			else if (y == AST_FORMAT_MAX_AUDIO)
+				break;
+			else
+				y <<= 1;
+			codec = y;
+		}
+		if (!(cap & codec) || (alreadysent & codec) || !(codec & AST_FORMAT_AUDIO_MASK))
 			continue;
 		alreadysent |= codec;
 		switch(codec) {
@@ -1208,21 +1219,6 @@
 		}
 	}
 	
-	if ((alreadysent & cap) != cap) {
-		lastcap++;
-		for (x = 0; x < 32; ++x) {
-			if (!(codec = ast_codec_pref_index(prefs, x)))
-				break;
-			if (!(cap & codec) || (alreadysent & codec))
-				continue;
-			
-			alreadysent |= codec;
-			switch(codec) {
-			/* Put video codecs here */
-			}
-		}
-	}
-
 	lastcap++;
 	lastcap = localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::HookFlashH245));
 



More information about the asterisk-commits mailing list