From a3292c9f051a8bb06b0303d3fa2a8ca2ae47ec23 Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Thu, 15 Mar 2012 07:59:13 +0000 Subject: [PATCH] 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. --- .../EncodingConfigurationTableModel.java | 15 +++-------- .../impl/neomedia/MediaStreamStatsImpl.java | 2 +- .../impl/neomedia/format/MediaFormatImpl.java | 25 +++++++++++++++++++ .../service/neomedia/format/MediaFormat.java | 15 +++++++++++ 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java b/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java index fc3bbd91c..cf8a763e2 100644 --- a/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java +++ b/src/net/java/sip/communicator/impl/neomedia/EncodingConfigurationTableModel.java @@ -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; diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java b/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java index 8407b37d7..8dd29abc4 100644 --- a/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java +++ b/src/net/java/sip/communicator/impl/neomedia/MediaStreamStatsImpl.java @@ -256,7 +256,7 @@ public String getEncoding() public String getEncodingClockRate() { // Gets this stream encoding clock rate. - return mediaStreamImpl.getFormat().getClockRateString(); + return mediaStreamImpl.getFormat().getRealUsedClockRateString(); } /** diff --git a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java b/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java index 1ded5299d..5f0c13f11 100644 --- a/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java +++ b/src/net/java/sip/communicator/impl/neomedia/format/MediaFormatImpl.java @@ -507,6 +507,31 @@ public String getClockRateString() return Double.toString(clockRate); } + /** + * Returns a String representation of the real used clock rate + * associated with this MediaFormat 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 String representation of the real used clock rate + * associated with this MediaFormat. + */ + 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. * diff --git a/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java b/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java index 9bd54a301..1ffab4868 100644 --- a/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java +++ b/src/net/java/sip/communicator/service/neomedia/format/MediaFormat.java @@ -79,6 +79,21 @@ public interface MediaFormat */ public String getClockRateString(); + /** + * Returns a String representation of the real used clock rate + * associated with this MediaFormat 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 String representation of the real used clock rate + * associated with this MediaFormat. + */ + public String getRealUsedClockRateString(); + /** * Determines whether this MediaFormat is equal to * mediaFormat i.e. they have the same encoding, clock rate, format