Program: 103675
Project: 103675
Buggy source:
/** 
 * Creates and returns <tt>MediaFormat</tt> instance corresponding to the specified <tt>payloadType</tt> and the parameters in the <tt>rtpmap</tt> and <tt>fmtp</tt> <tt>Attribute</tt>s. The method would only return <tt>MediaFormat</tt> instances for formats known to our media service implementation and returns <tt>null</tt> otherwise.
 * @param payloadType a static or dynamic payload type number thatdetermines the encoding of the format we'd like to create.
 * @param rtpmap an SDP <tt>Attribute</tt> mapping the <tt>payloadType</tt>to an encoding name.
 * @param fmtp a list of format specific parameters
 * @param advp list of advanced parameters
 * @param ptRegistry the {@link DynamicPayloadTypeRegistry} that we are touse in case <tt>payloadType</tt> is dynamic and <tt>rtpmap</tt> is <tt>null</tt> (in which case we can hope its in the registry).
 * @return a <tt>MediaForamt</tt> instance corresponding to the specified<tt>payloadType</tt> and <tt>rtpmap</tt>, and <tt>fmtp</tt> attributes or <tt>null</tt> if such a format is not currently supported by our media service implementation.
 * @throws SdpException never, the exception is only there because thejain-sdp API declares exceptions in case of impls using lazy parsing but the one in the jain-sip-ri isn't doing it.
 */
private static MediaFormat createFormat(byte payloadType,Attribute rtpmap,Attribute fmtp,List<Attribute> advp,DynamicPayloadTypeRegistry ptRegistry) throws SdpException {
  String encoding=null;
  double clockRate=-1;
  int numChannels=1;
  if (rtpmap != null) {
    String rtpmapValue=rtpmap.getValue();
    StringTokenizer tokenizer=new StringTokenizer(rtpmapValue,"String_Node_Str",false);
    if (tokenizer.hasMoreTokens()) {
      tokenizer.nextToken();
    }
    if (tokenizer.hasMoreTokens()) {
      encoding=tokenizer.nextToken();
    }
    if (tokenizer.hasMoreTokens()) {
      clockRate=Double.parseDouble(tokenizer.nextToken());
    }
    if (tokenizer.hasMoreTokens()) {
      String nChansStr=tokenizer.nextToken();
      try {
        numChannels=Integer.parseInt(nChansStr);
      }
 catch (      NumberFormatException exc) {
        logger.debug(nChansStr + "String_Node_Str",exc);
      }
    }
  }
 else {
    MediaFormat fmt=ptRegistry.findFormat(payloadType);
    if (fmt != null)     return fmt;
  }
  Map<String,String> fmtParamsMap=null;
  Map<String,String> advancedAttrMap=null;
  if (fmtp != null)   fmtParamsMap=parseFmtpAttribute(fmtp);
  if (advp != null) {
    advancedAttrMap=parseAdvancedAttributes(advp);
  }
  MediaFormat format=SipActivator.getMediaService().getFormatFactory().createMediaFormat(payloadType,encoding,clockRate,numChannels,fmtParamsMap,advancedAttrMap);
  if ((payloadType >= MediaFormat.MIN_DYNAMIC_PAYLOAD_TYPE) && (payloadType <= MediaFormat.MAX_DYNAMIC_PAYLOAD_TYPE) && (format != null)&& (ptRegistry.findFormat(payloadType) == null))   ptRegistry.addMapping(format,payloadType);
  return format;
}

Fixed version (ground truth):
/** 
 * Creates and returns <tt>MediaFormat</tt> instance corresponding to the specified <tt>payloadType</tt> and the parameters in the <tt>rtpmap</tt> and <tt>fmtp</tt> <tt>Attribute</tt>s. The method would only return <tt>MediaFormat</tt> instances for formats known to our media service implementation and returns <tt>null</tt> otherwise.
 * @param payloadType a static or dynamic payload type number thatdetermines the encoding of the format we'd like to create.
 * @param rtpmap an SDP <tt>Attribute</tt> mapping the <tt>payloadType</tt>to an encoding name.
 * @param fmtp a list of format specific parameters
 * @param advp list of advanced parameters
 * @param ptRegistry the {@link DynamicPayloadTypeRegistry} that we are touse in case <tt>payloadType</tt> is dynamic and <tt>rtpmap</tt> is <tt>null</tt> (in which case we can hope its in the registry).
 * @return a <tt>MediaForamt</tt> instance corresponding to the specified<tt>payloadType</tt> and <tt>rtpmap</tt>, and <tt>fmtp</tt> attributes or <tt>null</tt> if such a format is not currently supported by our media service implementation.
 * @throws SdpException never, the exception is only there because thejain-sdp API declares exceptions in case of impls using lazy parsing but the one in the jain-sip-ri isn't doing it.
 */
private static MediaFormat createFormat(byte payloadType,Attribute rtpmap,Attribute fmtp,List<Attribute> advp,DynamicPayloadTypeRegistry ptRegistry) throws SdpException {
  String encoding=null;
  double clockRate=-1;
  int numChannels=1;
  if (rtpmap != null) {
    String rtpmapValue=rtpmap.getValue();
    StringTokenizer tokenizer=new StringTokenizer(rtpmapValue,"String_Node_Str",false);
    if (tokenizer.hasMoreTokens()) {
      tokenizer.nextToken();
    }
    if (tokenizer.hasMoreTokens()) {
      encoding=tokenizer.nextToken();
    }
    if (tokenizer.hasMoreTokens()) {
      clockRate=Double.parseDouble(tokenizer.nextToken());
    }
    if (tokenizer.hasMoreTokens()) {
      String nChansStr=tokenizer.nextToken();
      try {
        numChannels=Integer.parseInt(nChansStr);
      }
 catch (      NumberFormatException exc) {
        logger.debug(nChansStr + "String_Node_Str",exc);
      }
    }
  }
 else {
    MediaFormat fmt=ptRegistry.findFormat(payloadType);
    if (fmt != null)     return fmt;
  }
  Map<String,String> fmtParamsMap=null;
  Map<String,String> advancedAttrMap=null;
  if (fmtp != null)   fmtParamsMap=parseFmtpAttribute(fmtp);
  if (advp != null)   advancedAttrMap=parseAdvancedAttributes(advp);
  MediaFormat format=SipActivator.getMediaService().getFormatFactory().createMediaFormat(payloadType,encoding,clockRate,numChannels,fmtParamsMap,advancedAttrMap);
  if ((payloadType >= MediaFormat.MIN_DYNAMIC_PAYLOAD_TYPE) && (payloadType <= MediaFormat.MAX_DYNAMIC_PAYLOAD_TYPE) && (format != null)&& (ptRegistry.findFormat(payloadType) == null))   ptRegistry.addMapping(format,payloadType);
  return format;
}