"rtp.c unknown rtp codec 126 received from" error in asterisk

Friday, April 20, 2012

We have received an error while trying to forward a TDM call to a softphone like XLite through Asterisk. After a lot of struggle, we have figured out the answer as below,

1. Turn off your firewall settings (both Asterisk server)
2. Use the same audio codec you are using in the asterisk.
3. Configure your softphone in asterisk sip.conf as below,
  
[101]
type=friend
username=101
secret=101
host=dynamic
context=init ;my context name. give yours if you want to.
nat=yes
disallow=all
allow=GSM
allow=alaw
allow=ulaw

 4. Make sure that you are using the same codec in your softphone preferably GSM.
 5. It worked like a charm.

Thank you!

500 internal server error : Applicationpool

Wednesday, April 11, 2012

Problem:
I have an urgent scenario which is my site is down now due to an application pool error. i have moved my site recently to another vendor. after configuring the DNS, i am getting 500 error when i use asp.net 4.0 classic app pool. but when i use integrated, it gives me a httpcontext error which is related to the global.asax.

Answer:
Created an Application pool identity as IWPD_1 with asp.net 4.0 classic. Then it worked.

C# Interface Implementation

Tuesday, September 21, 2010

Interface implementation can be confusing…

I see a feature in C# that can be very confusing. In theexample below we have a class (Test) that implements 2 interfaces(I1 and I2). So the logic says that we should have implementations in the classTest for both MyFunction() methods from I1 and I2.

//EXAMPLE 1
using System;

namespace PavelTsekov
{
interface I1
{
void MyFunction();
}
interface I2
{
void MyFunction();
}
class Test : I1,I2
{
public void MyFunction()
{
Console.WriteLine("Guess which interface I represent???!");
}
}
class AppClass
{
public static void Main(string[] args)
{
Test t=new Test();
I1 i1=(I1)t;
i1.MyFunction();
I2 i2=(I2)t;
i2.MyFunction();
}
}
}
As you see in the example below everything works fine with only 1 implementation. This is not as correct as we expect, because we can't be sure which of the two interfacesis implemented in the MyFunction method in class Test.So the solution is in another example (EXAMPLE2).


In Example2 MyFunction() is implemented in class Test for each interface, by using a different method. (I1.MyFunction() -> for I1, I2.MyFunction() -> for I2).So now everything is clear, isn't it?

//EXAMPLE 2
using System;

namespace PavelTsekov
{
interface I1
{
void MyFunction();
}
interface I2
{
void MyFunction();
}
class Test : I1,I2
{
void I1.MyFunction()
{
Console.WriteLine("Now I can say this here is I1 implemented!");
}
void I2.MyFunction()
{
Console.WriteLine("Now I can say this here is I2 implemented!");
}
}
class AppClass
{
public static void Main(string[] args)
{
Test t=new Test();
I1 i1=(I1)t;
i1.MyFunction();
I2 i2=(I2)t;
i2.MyFunction();
}
}
}



Multiple Ternary Operators "?"

Friday, September 17, 2010

You want to compare two values and produce a third value that depends on the result of the comparison. Although this can be accomplished with if-statements or other constructs, the ternary operator in the C# programming language provides an elegant and equivalent solution to this requirement. Here we look at examples of the ternary operator and ternary expressions in action, using the C# programming language targeting the .NET Framework

Ternary expression initialization:

First, one common use of the ternary operator in the C# language and other C-like languages is to initialize a variable with the result of the expression. However, the high-level ternary statement is useful because it allows you to condense multiple if-statements and reduce nesting. It does not actually eliminate branching but simplifies the high-level representation of the branching at the level of the source code.

Example: #1

using System;
class Program
{
static void Main()
{
//
// If the expression is true, set value to 1.
// Otherwise, set value to -1.
//
int value = 100.ToString() == "100" ?
1 :
-1;
Console.WriteLine(value);
}
}


Question mark and colon characters.

The program text above shows how the ternary expression can be used when initializing a variable. If the subexpression (100.ToString() == "100") evaluates to true, the integer variable with the identifier 'value' has its location on the stack copied to the bit values of the integer 1. Otherwise, it has its location on the stack copied to the binary representation of -1. Internally, this code uses branch statements that are defined in the intermediate language.

Multiple Ternary Operator

Here we look at how you can check multiple condition and return multiple values respectively. following example shows you that it is possible in c# programming.

Example: #2

using System;
class Program
{
static void Main()
{
int nStatus = MethodCall(text);

int nUserStatus = (nStatus == 0 && !checkStatus.Checked) ? nStatus = 1
: (nStatus != 0 && checkStatus.Checked) ? nStatus = 0
: (nStatus == 0 && checkStatus.Checked) ? nStatus = -1
: (nStatus != 0 && !checkStatus.Checked) ? nStatus = -99
: nStatus;
}
}



The above program gets the value from a method call and sets different value based on the multiple condtions.

Ternary min and max

Here we note that one popular use of the ternary operator in C-like languages is to get the minimum or maximum of two numbers or one variable and an integer constant. This approach is still useful in the C# language, but the Math class in the .NET Framework provides the Math.Min and Math.Max methods, which handle certain cases more effectively and may have clearer calling syntax. The decimal type in the .NET Framework is handled separately by the Math.Max and Math.Min methods, and for this type the ternary expression may not be equivalent.

Implementation

Here we mention some details of how the ternary operator in the C# language can be translated by the C# compiler into the intermediate language. The author disassembled several versions of ternary expressions and found that they are identical to if-statements, with one small difference. The ternary statement sometimes produces code that tests the opposite condition that you would expect, as in it tests that the subexpression is false instead of testing if it is true. This reorders some of the instructions and can occasionally boost performance.
Summary

Here we looked at the ternary operator in the C# programming language, using it to initialize an integer variable and then using it to return a value. We noted that the ternary statement can receive an expression that it first evaluates before proceeding to part after the question mark. We reviewed some aspects of the intermediate language and some additional uses of the ternary statement and how it can produce branches in your control flow.

Rajan Chellappan