Corrects displayed clock rate of G.722 encoding in CallInfoFrame. Reported by Lyubomir in dev mailing-list with subject: G.722 sample rate in Call Info.

cusax-fix
Vincent Lucas 15 years ago
parent a4ee99467b
commit a3292c9f05

@ -186,18 +186,9 @@ public Object getValueAt(int rowIndex, int columnIndex)
return encoding.getEncoding();
else
{
String e = encoding.getEncoding();
/*
* RFC 1890 erroneously assigned 8 kHz to the RTP clock rate for
* the G722 payload format. The actual sampling rate for G.722
* audio is 16 kHz.
*/
double cr
= "G722".equalsIgnoreCase(e)
? 16000
: encoding.getClockRate();
return e + "/" + ((long) cr);
return encoding.getEncoding()
+ "/"
+ encoding.getRealUsedClockRateString();
}
default:
return null;

@ -256,7 +256,7 @@ public String getEncoding()
public String getEncodingClockRate()
{
// Gets this stream encoding clock rate.
return mediaStreamImpl.getFormat().getClockRateString();
return mediaStreamImpl.getFormat().getRealUsedClockRateString();
}
/**

@ -507,6 +507,31 @@ public String getClockRateString()
return Double.toString(clockRate);
}
/**
* Returns a <tt>String</tt> representation of the real used clock rate
* associated with this <tt>MediaFormat</tt> making sure that the value
* appears as an integer (i.e. contains no decimal point) unless it is
* actually a non integer.
* This function corrects the problem of the G.722 codec which advertises
* its clock rate to be 8 kHz while 16 kHz is really used to encode the
* stream (that's an error noted in the respective RFC and kept for the sake
* of compatibility.).
*
* @return a <tt>String</tt> representation of the real used clock rate
* associated with this <tt>MediaFormat</tt>.
*/
public String getRealUsedClockRateString()
{
// RFC 1890 erroneously assigned 8 kHz to the RTP clock rate for the
// G722 payload format. The actual sampling rate for G.722 audio is 16
// kHz.
if(this.getEncoding().equalsIgnoreCase("G722"))
{
return "16000";
}
return this.getClockRateString();
}
/**
* Sets additional codec settings.
*

@ -79,6 +79,21 @@ public interface MediaFormat
*/
public String getClockRateString();
/**
* Returns a <tt>String</tt> representation of the real used clock rate
* associated with this <tt>MediaFormat</tt> making sure that the value
* appears as an integer (i.e. contains no decimal point) unless it is
* actually a non integer.
* This function corrects the problem of the G.722 codec which advertises
* its clock rate to be 8 kHz while 16 kHz is really used to encode the
* stream (that's an error noted in the respective RFC and kept for the sake
* of compatibility.).
*
* @return a <tt>String</tt> representation of the real used clock rate
* associated with this <tt>MediaFormat</tt>.
*/
public String getRealUsedClockRateString();
/**
* Determines whether this <tt>MediaFormat</tt> is equal to
* <tt>mediaFormat</tt> i.e. they have the same encoding, clock rate, format

Loading…
Cancel
Save