private int getPacketSize ( Format codecFormat , int milliseconds ) throws IllegalArgumentException { String encoding = codecFormat . getEncoding ( ) ; if ( encoding . equalsIgnoreCase ( AudioFormat . GSM ) || encoding . equalsIgnoreCase ( AudioFormat . GSM_RTP ) ) { return milliseconds * 4 ; // 1 byte per millisec } else if ( encoding . equalsIgnoreCase ( AudioFormat . ULAW ) || encoding . equalsIgnoreCase ( AudioFormat . ULAW_RTP ) ) { return milliseconds * 8 ; } else { throw new IllegalArgumentException ( "Unknown codec type" ) ; } }
Get the best stanza size for a given codec and a codec rate