nus-yam/ex-repair huggingface dataset:
Program: 107627
Project: 107627
Buggy source:
/** 
 * Initializes a new <tt>DtlsTransformEngine</tt> instance to be associated with and used by this <tt>DtlsControlImpl</tt> instance.
 * @return a new <tt>DtlsTransformEngine</tt> instance to be associated withand used by this <tt>DtlsControlImpl</tt> instance
 */
protected DtlsTransformEngine createTransformEngine(){
  DtlsTransformEngine transformEngine=new DtlsTransformEngine(this);
  transformEngine.setConnector(connector);
  transformEngine.setDtlsProtocol(dtlsProtocol);
  return transformEngine;
}

Fixed version (ground truth):
/** 
 * Initializes a new <tt>DtlsTransformEngine</tt> instance to be associated with and used by this <tt>DtlsControlImpl</tt> instance.
 * @return a new <tt>DtlsTransformEngine</tt> instance to be associated withand used by this <tt>DtlsControlImpl</tt> instance
 */
@Override protected DtlsTransformEngine createTransformEngine(){
  DtlsTransformEngine transformEngine=new DtlsTransformEngine(this);
  transformEngine.setConnector(connector);
  transformEngine.setSetup(setup);
  return transformEngine;
}
Program: 107629
Project: 107629
Buggy source:
/** 
 * Initializes a new <tt>DtlsPacketTransformer</tt> instance which is to work on control/RTCP or data/RTP packets.
 * @param componentID the ID of the component for which the new instance isto work
 * @return a new <tt>DtlsPacketTransformer</tt> instance which is to work oncontrol/RTCP or data/RTP packets (in accord with <tt>data</tt>)
 */
private DtlsPacketTransformer createPacketTransformer(int componentID){
  DtlsPacketTransformer packetTransformer=new DtlsPacketTransformer(this,componentID);
  packetTransformer.setConnector(connector);
  packetTransformer.setDtlsProtocol(dtlsProtocol);
  packetTransformer.setMediaType(mediaType);
  return packetTransformer;
}

Fixed version (ground truth):
/** 
 * Initializes a new <tt>DtlsPacketTransformer</tt> instance which is to work on control/RTCP or data/RTP packets.
 * @param componentID the ID of the component for which the new instance isto work
 * @return a new <tt>DtlsPacketTransformer</tt> instance which is to work oncontrol/RTCP or data/RTP packets (in accord with <tt>data</tt>)
 */
private DtlsPacketTransformer createPacketTransformer(int componentID){
  DtlsPacketTransformer packetTransformer=new DtlsPacketTransformer(this,componentID);
  packetTransformer.setConnector(connector);
  packetTransformer.setSetup(setup);
  packetTransformer.setMediaType(mediaType);
  return packetTransformer;
}
Program: 107630
Project: 107630
Buggy source:
/** 
 * Sets the preset.
 * @param preset the desired video settings
 * @throws OperationFailedException
 */
private void setRemoteReceivePreset(QualityPreset preset) throws OperationFailedException {
  if (preset.compareTo(getPreferredSendPreset()) > 0)   this.preset=getPreferredSendPreset();
 else {
    this.preset=preset;
    Dimension resolution;
    if (logger.isInfoEnabled() && (preset != null) && ((resolution=preset.getResolution()) != null)) {
      logger.info("String_Node_Str" + resolution.width + "String_Node_Str"+ resolution.height);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the preset.
 * @param preset the desired video settings
 * @throws OperationFailedException
 */
private void setRemoteReceivePreset(QualityPreset preset) throws OperationFailedException {
  QualityPreset preferredSendPreset=getPreferredSendPreset();
  if (preset.compareTo(preferredSendPreset) > 0)   this.preset=preferredSendPreset;
 else {
    this.preset=preset;
    Dimension resolution;
    if (logger.isInfoEnabled() && (preset != null) && ((resolution=preset.getResolution()) != null)) {
      logger.info("String_Node_Str" + resolution.width + "String_Node_Str"+ resolution.height);
    }
  }
}
Program: 107631
Project: 107631
Buggy source:
/** 
 * Returns the FMJ format of a specific <tt>InputStream</tt> providing audio media.
 * @param audioInputStream the <tt>InputStream</tt> providing audio media todetermine the FMJ format of
 * @return the FMJ format of the specified <tt>audioInputStream</tt> or<tt>null</tt> if such an FMJ format could not be determined
 */
public Format getFormat(InputStream audioInputStream){
  if ((audioInputStream instanceof AudioInputStream)) {
    AudioFormat audioInputStreamFormat=((AudioInputStream)audioInputStream).getFormat();
    return new javax.media.format.AudioFormat(javax.media.format.AudioFormat.LINEAR,audioInputStreamFormat.getSampleRate(),audioInputStreamFormat.getSampleSizeInBits(),audioInputStreamFormat.getChannels());
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the FMJ format of a specific <tt>InputStream</tt> providing audio media.
 * @param audioInputStream the <tt>InputStream</tt> providing audio media todetermine the FMJ format of
 * @return the FMJ format of the specified <tt>audioInputStream</tt> or<tt>null</tt> if such an FMJ format could not be determined
 */
public javax.media.format.AudioFormat getFormat(InputStream audioInputStream){
  if ((audioInputStream instanceof AudioInputStream)) {
    AudioFormat af=((AudioInputStream)audioInputStream).getFormat();
    return new javax.media.format.AudioFormat(javax.media.format.AudioFormat.LINEAR,af.getSampleRate(),af.getSampleSizeInBits(),af.getChannels());
  }
  return null;
}
Program: 107636
Project: 107636
Buggy source:
/** 
 * {@inheritDoc}The <tt>Format</tt>s supported by this <tt>CaptureDevice</tt>/<tt>DataSource</tt> are either the ones supported by the capture endpoint device or the ones supported by the voice capture DMO that implements the acoustic echo cancellation (AEC) feature depending on whether the feature in question is disabled or enabled.
 */
@Override protected Format[] getSupportedFormats(int streamIndex){
  List<AudioFormat> aecSupportedFormats=audioSystem.getAECSupportedFormats();
  if (aec) {
    return aecSupportedFormats.toArray(new Format[aecSupportedFormats.size()]);
  }
 else {
    return getIAudioClientSupportedFormats(streamIndex,aecSupportedFormats);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}The <tt>Format</tt>s supported by this <tt>CaptureDevice</tt>/<tt>DataSource</tt> are either the ones supported by the capture endpoint device or the ones supported by the voice capture DMO that implements the acoustic echo cancellation (AEC) feature depending on whether the feature in question is disabled or enabled.
 */
@Override protected Format[] getSupportedFormats(int streamIndex){
  if (aec) {
    List<AudioFormat> aecSupportedFormats=audioSystem.getAECSupportedFormats();
    return aecSupportedFormats.toArray(new Format[aecSupportedFormats.size()]);
  }
 else {
    return getIAudioClientSupportedFormats(streamIndex);
  }
}
Program: 107637
Project: 107637
Buggy source:
/** 
 * Gets the <tt>Format</tt>s of media data supported by the audio endpoint device associated with this instance.
 * @param streamIndex the index of the <tt>SourceStream</tt> within the listof <tt>SourceStream</tt>s of this <tt>DataSource</tt> on behalf of which the query is being made
 * @param aecSupportedFormats the list of <tt>AudioFormat</tt>s supported bythe voice capture DMO implementing acoustic echo cancellation
 * @return the <tt>Format</tt>s of media data supported by the audioendpoint device associated with this instance
 */
private Format[] getIAudioClientSupportedFormats(int streamIndex,List<AudioFormat> aecSupportedFormats){
  Format[] superSupportedFormats=super.getSupportedFormats(streamIndex);
  if ((superSupportedFormats == null) || (superSupportedFormats.length == 0))   return superSupportedFormats;
  Format[] array;
  if (aecSupportedFormats.isEmpty())   array=superSupportedFormats;
 else {
    List<Format> list=new ArrayList<Format>(superSupportedFormats.length);
    for (    Format superSupportedFormat : superSupportedFormats) {
      boolean equals=false;
      for (      Format aecSupportedFormat : aecSupportedFormats) {
        if (superSupportedFormat == aecSupportedFormat) {
          equals=true;
          break;
        }
      }
      if (!equals)       list.add(superSupportedFormat);
    }
    array=list.toArray(new Format[list.size()]);
  }
  return array;
}

Fixed version (ground truth):
/** 
 * Gets the <tt>Format</tt>s of media data supported by the audio endpoint device associated with this instance.
 * @param streamIndex the index of the <tt>SourceStream</tt> within the listof <tt>SourceStream</tt>s of this <tt>DataSource</tt> on behalf of which the query is being made
 * @return the <tt>Format</tt>s of media data supported by the audioendpoint device associated with this instance
 */
private Format[] getIAudioClientSupportedFormats(int streamIndex){
  Format[] superSupportedFormats=super.getSupportedFormats(streamIndex);
  if ((superSupportedFormats == null) || (superSupportedFormats.length == 0))   return superSupportedFormats;
  List<Format> supportedFormats=new ArrayList<Format>(superSupportedFormats.length);
  for (  Format format : superSupportedFormats) {
    if ((format instanceof NativelySupportedAudioFormat) && !supportedFormats.contains(format)) {
      supportedFormats.add(format);
    }
  }
  int supportedFormatCount=supportedFormats.size();
  return (supportedFormatCount == superSupportedFormats.length) ? superSupportedFormats : supportedFormats.toArray(new Format[supportedFormatCount]);
}
Program: 107638
Project: 107638
Buggy source:
/** 
 * Finds an <tt>AudioFormat</tt> in a specific list of <tt>Format</tt>s which is as similar to a specific <tt>AudioFormat</tt> as possible.
 * @param formats the list of <tt>Format</tt>s into which an<tt>AudioFormat</tt> as similar to the specified <tt>format</tt> as possible is to be found 
 * @param format the <tt>AudioFormat</tt> for which a similar<tt>AudioFormat</tt> is to be found in <tt>formats</tt>
 * @return an <tt>AudioFormat</tt> which is an element of <tt>formats</tt>and is as similar to the specified <tt>format</tt> as possible or <tt>null</tt> if no similarity could be established
 */
private static AudioFormat findClosestMatch(Format[] formats,AudioFormat format){
  AudioFormat match=findFirstMatch(formats,format);
  if (match == null) {
    match=findFirstMatch(formats,new AudioFormat(format.getEncoding(),format.getSampleRate(),format.getSampleSizeInBits(),Format.NOT_SPECIFIED,format.getEndian(),format.getSigned(),Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,format.getDataType()));
    if (match == null) {
      match=findFirstMatch(formats,new AudioFormat(format.getEncoding(),Format.NOT_SPECIFIED,format.getSampleSizeInBits(),Format.NOT_SPECIFIED,format.getEndian(),format.getSigned(),Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,format.getDataType()));
    }
  }
  return match;
}

Fixed version (ground truth):
/** 
 * Finds an <tt>AudioFormat</tt> in a specific list of <tt>Format</tt>s which is as similar to a specific <tt>AudioFormat</tt> as possible.
 * @param formats the list of <tt>Format</tt>s into which an<tt>AudioFormat</tt> as similar to the specified <tt>format</tt> as possible is to be found 
 * @param format the <tt>AudioFormat</tt> for which a similar<tt>AudioFormat</tt> is to be found in <tt>formats</tt>
 * @param clazz the runtime type of the matches to be considered or<tt>null</tt> if the runtime type is to not be limited
 * @return an <tt>AudioFormat</tt> which is an element of <tt>formats</tt>and is as similar to the specified <tt>format</tt> as possible or <tt>null</tt> if no similarity could be established
 */
private static AudioFormat findClosestMatch(Format[] formats,AudioFormat format,Class<? extends AudioFormat> clazz){
  AudioFormat match=findFirstMatch(formats,format,clazz);
  if (match == null) {
    match=findFirstMatch(formats,new AudioFormat(format.getEncoding(),format.getSampleRate(),format.getSampleSizeInBits(),Format.NOT_SPECIFIED,format.getEndian(),format.getSigned(),Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,format.getDataType()),clazz);
    if (match == null) {
      match=findFirstMatch(formats,new AudioFormat(format.getEncoding(),Format.NOT_SPECIFIED,format.getSampleSizeInBits(),Format.NOT_SPECIFIED,format.getEndian(),format.getSigned(),Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,format.getDataType()),clazz);
    }
  }
  return match;
}
Program: 107639
Project: 107639
Buggy source:
private AudioFormat findClosestMatchCaptureSupportedFormat(AudioFormat format){
  return findClosestMatch(dataSource.getIAudioClientSupportedFormats(),format);
}

Fixed version (ground truth):
private AudioFormat findClosestMatchCaptureSupportedFormat(AudioFormat format){
  return findClosestMatch(dataSource.getIAudioClientSupportedFormats(),format,NativelySupportedAudioFormat.class);
}
Program: 107641
Project: 107641
Buggy source:
/** 
 * Finds the first element of a specific array of <tt>Format</tt>s which matches in the sense of   {@link Format#matches(Format)} a specific<tt>AudioFormat</tt>.
 * @param formats the array of <tt>Format</tt>s which si to be searched
 * @param format the <tt>AudioFormat</tt> for which a match is to be foundin the specified <tt>formats</tt>
 * @return the first element of <tt>formats</tt> which matches the specified<tt>format</tt> or <tt>null</tt> if no match could be found
 */
private static AudioFormat findFirstMatch(Format[] formats,AudioFormat format){
  for (  Format aFormat : formats)   if (aFormat.matches(format))   return (AudioFormat)aFormat.intersects(format);
  return null;
}

Fixed version (ground truth):
/** 
 * Finds the first element of a specific array of <tt>Format</tt>s which matches in the sense of   {@link Format#matches(Format)} a specific<tt>AudioFormat</tt>.
 * @param formats the array of <tt>Format</tt>s which si to be searched
 * @param format the <tt>AudioFormat</tt> for which a match is to be foundin the specified <tt>formats</tt>
 * @param clazz the runtime type of the matches to be considered or<tt>null</tt> if the runtime type is to not be limited
 * @return the first element of <tt>formats</tt> which matches the specified<tt>format</tt> or <tt>null</tt> if no match could be found
 */
private static AudioFormat findFirstMatch(Format[] formats,AudioFormat format,Class<? extends AudioFormat> clazz){
  for (  Format aFormat : formats) {
    if (aFormat.matches(format) && ((clazz == null) || clazz.isInstance(aFormat))) {
      return (AudioFormat)aFormat.intersects(format);
    }
  }
  return null;
}
Program: 107642
Project: 107642
Buggy source:
/** 
 * Invokes <tt>IMediaObject::ProcessOutput</tt> on   {@link #iMediaObject}that represents the Voice Capture DSP implementing the acoustic echo cancellation (AEC) feature.
 */
private void processOutput(){
  int dwStatus=0;
  do {
    try {
      IMediaObject_ProcessOutput(iMediaObject,0,1,dmoOutputDataBuffer);
    }
 catch (    HResultException hre) {
      dwStatus=0;
      logger.error("String_Node_Str",hre);
    }
    try {
      int toRead=IMediaBuffer_GetLength(iMediaBuffer);
      if (toRead > 0) {
        int toPop=toRead - (processed.length - processedLength);
        if (toPop > 0)         popFromProcessed(toPop);
        int read=MediaBuffer_pop(iMediaBuffer,processed,processedLength,toRead);
        if (read > 0)         processedLength+=read;
      }
    }
 catch (    HResultException hre) {
      logger.error("String_Node_Str" + "String_Node_Str",hre);
      break;
    }
  }
 while ((dwStatus & DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE) == DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE);
}

Fixed version (ground truth):
/** 
 * Invokes <tt>IMediaObject::ProcessOutput</tt> on   {@link #iMediaObject}that represents the Voice Capture DSP implementing the acoustic echo cancellation (AEC) feature.
 */
private void processOutput(){
  int dwStatus=0;
  do {
    try {
      IMediaObject_ProcessOutput(iMediaObject,0,1,dmoOutputDataBuffer);
      dwStatus=DMO_OUTPUT_DATA_BUFFER_getDwStatus(dmoOutputDataBuffer);
    }
 catch (    HResultException hre) {
      dwStatus=0;
      logger.error("String_Node_Str",hre);
    }
    try {
      int toRead=IMediaBuffer_GetLength(iMediaBuffer);
      if (toRead > 0) {
        int toPop=toRead - (processed.length - processedLength);
        if (toPop > 0)         popFromProcessed(toPop);
        int read=MediaBuffer_pop(iMediaBuffer,processed,processedLength,toRead);
        if (read > 0)         processedLength+=read;
      }
    }
 catch (    HResultException hre) {
      logger.error("String_Node_Str" + "String_Node_Str",hre);
      break;
    }
  }
 while ((dwStatus & DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE) == DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE);
}
Program: 107643
Project: 107643
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override protected AbstractPullBufferStream createStream(int streamIndex,FormatControl formatControl){
  return new WASAPIStream(this,formatControl);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override protected WASAPIStream createStream(int streamIndex,FormatControl formatControl){
  return new WASAPIStream(this,formatControl);
}
Program: 107644
Project: 107644
Buggy source:
/** 
 * Notifies this <tt>RTCPFeedbackListener</tt> that an RTCP feedback message has been received
 * @param event an <tt>RTCPFeedbackEvent</tt> which specifies the details ofthe notification event such as the feedback message type and the payload type
 */
public void rtcpFeedbackReceived(RTCPFeedbackEvent event){
  if (event.getPayloadType() == RTCPFeedbackEvent.PT_PS) {
switch (event.getFeedbackMessageType()) {
case RTCPFeedbackEvent.FMT_PLI:
case RTCPFeedbackEvent.FMT_FIR:
      keyFrameRequest();
    break;
default :
  break;
}
}
}

Fixed version (ground truth):
/** 
 * Notifies this <tt>RTCPFeedbackListener</tt> that an RTCP feedback message has been received
 * @param event an <tt>RTCPFeedbackEvent</tt> which specifies the details ofthe notification event such as the feedback message type and the payload type
 */
public void rtcpFeedbackReceived(RTCPFeedbackEvent event){
  if (event.getPayloadType() == RTCPFeedbackEvent.PT_PS) {
switch (event.getFeedbackMessageType()) {
case RTCPFeedbackEvent.FMT_PLI:
case RTCPFeedbackEvent.FMT_FIR:
      if (logger.isTraceEnabled()) {
        logger.trace("String_Node_Str" + "String_Node_Str");
      }
    keyFrameRequest();
  break;
default :
break;
}
}
}
Program: 107645
Project: 107645
Buggy source:
/** 
 * Use or not RTCP feedback Picture Loss Indication.
 * @param usePLI <tt>true</tt> to use PLI; otherwise, <tt>false</tt>
 */
public void setRtcpFeedbackPLI(boolean usePLI){
  if (this.usePLI != usePLI) {
    this.usePLI=usePLI;
    if (this.usePLI) {
      if (keyFrameRequester == null) {
        keyFrameRequester=new KeyFrameControl.KeyFrameRequester(){
          public boolean requestKeyFrame(){
            boolean requested=false;
            if (VideoMediaDeviceSession.this.usePLI) {
              try {
                new RTCPFeedbackPacket(1,206,localSSRC,remoteSSRC).writeTo(rtpConnector.getControlOutputStream());
                requested=true;
              }
 catch (              IOException ioe) {
              }
            }
            return requested;
          }
        }
;
      }
      if (keyFrameControl != null)       keyFrameControl.addKeyFrameRequester(-1,keyFrameRequester);
    }
 else     if (keyFrameRequester != null) {
      if (keyFrameControl != null)       keyFrameControl.removeKeyFrameRequester(keyFrameRequester);
      keyFrameRequester=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Use or not RTCP feedback Picture Loss Indication.
 * @param usePLI <tt>true</tt> to use PLI; otherwise, <tt>false</tt>
 */
public void setRtcpFeedbackPLI(boolean usePLI){
  if (this.usePLI != usePLI) {
    this.usePLI=usePLI;
    if (this.usePLI) {
      if (keyFrameRequester == null) {
        keyFrameRequester=new KeyFrameControl.KeyFrameRequester(){
          public boolean requestKeyFrame(){
            boolean requested=false;
            if (VideoMediaDeviceSession.this.usePLI) {
              try {
                new RTCPFeedbackPacket(RTCPFeedbackEvent.FMT_PLI,RTCPFeedbackEvent.PT_PS,localSSRC,remoteSSRC).writeTo(rtpConnector.getControlOutputStream());
                requested=true;
              }
 catch (              IOException ioe) {
              }
            }
            return requested;
          }
        }
;
      }
      if (keyFrameControl != null)       keyFrameControl.addKeyFrameRequester(-1,keyFrameRequester);
    }
 else     if (keyFrameRequester != null) {
      if (keyFrameControl != null)       keyFrameControl.removeKeyFrameRequester(keyFrameRequester);
      keyFrameRequester=null;
    }
  }
}
Program: 107646
Project: 107646
Buggy source:
/** 
 * Adds RTCPFeedbackListener to the stream when the listener is created.
 * @param rtcpFeedbackListener the listener to be added.
 */
public void onRTCPFeedbackCreate(RTCPFeedbackListener rtcpFeedbackListener){
  if (!OSUtils.IS_ANDROID && usePLI && "String_Node_Str".equalsIgnoreCase(getFormat().getEncoding())) {
    try {
      ((ControlTransformInputStream)rtpConnector.getControlInputStream()).addRTCPFeedbackListener(rtcpFeedbackListener);
    }
 catch (    IOException ioe) {
      logger.error("String_Node_Str",ioe);
    }
  }
}

Fixed version (ground truth):
/** 
 * Notifies this <tt>VideoMediaDeviceSession</tt> of a new <tt>RTCPFeedbackListener</tt>
 * @param rtcpFeedbackListener the listener to be added.
 */
public void onRTCPFeedbackCreate(RTCPFeedbackListener rtcpFeedbackListener){
  if (rtpConnector != null) {
    try {
      ((ControlTransformInputStream)rtpConnector.getControlInputStream()).addRTCPFeedbackListener(rtcpFeedbackListener);
    }
 catch (    IOException ioe) {
      logger.error("String_Node_Str",ioe);
    }
  }
}
Program: 107647
Project: 107647
Buggy source:
public boolean requestKeyFrame(){
  boolean requested=false;
  if (VideoMediaDeviceSession.this.usePLI) {
    try {
      new RTCPFeedbackPacket(1,206,localSSRC,remoteSSRC).writeTo(rtpConnector.getControlOutputStream());
      requested=true;
    }
 catch (    IOException ioe) {
    }
  }
  return requested;
}

Fixed version (ground truth):
public boolean requestKeyFrame(){
  boolean requested=false;
  if (VideoMediaDeviceSession.this.usePLI) {
    try {
      new RTCPFeedbackPacket(RTCPFeedbackEvent.FMT_PLI,RTCPFeedbackEvent.PT_PS,localSSRC,remoteSSRC).writeTo(rtpConnector.getControlOutputStream());
      requested=true;
    }
 catch (    IOException ioe) {
    }
  }
  return requested;
}
Program: 107651
Project: 107651
Buggy source:
/** 
 * Releases the resources allocated by a specific local <tt>Player</tt> in the course of its execution and prepares it to be garbage collected. If the specified <tt>Player</tt> is rendering video, notifies the <tt>VideoListener</tt>s of this instance that its visual <tt>Component</tt> is to no longer be used by firing a  {@link VideoEvent#VIDEO_REMOVED} <tt>VideoEvent</tt>.
 * @param player the <tt>Player</tt> to dispose of
 * @see MediaDeviceSession#disposePlayer(Player)
 */
private void disposeLocalPlayer(Player player){
  Component visualComponent=null;
  try {
    visualComponent=getVisualComponent(player);
    player.stop();
    player.deallocate();
    player.close();
  }
  finally {
synchronized (localPlayerSyncRoot) {
      if (localPlayer == player)       localPlayer=null;
    }
    if (visualComponent != null) {
      fireVideoEvent(VideoEvent.VIDEO_REMOVED,visualComponent,VideoEvent.LOCAL,false);
    }
  }
}

Fixed version (ground truth):
/** 
 * Releases the resources allocated by a specific local <tt>Player</tt> in the course of its execution and prepares it to be garbage collected. If the specified <tt>Player</tt> is rendering video, notifies the <tt>VideoListener</tt>s of this instance that its visual <tt>Component</tt> is to no longer be used by firing a  {@link VideoEvent#VIDEO_REMOVED} <tt>VideoEvent</tt>.
 * @param player the <tt>Player</tt> to dispose of
 * @see MediaDeviceSession#disposePlayer(Player)
 */
protected void disposeLocalPlayer(Player player){
  Component visualComponent=null;
  try {
    visualComponent=getVisualComponent(player);
    player.stop();
    player.deallocate();
    player.close();
  }
  finally {
synchronized (localPlayerSyncRoot) {
      if (localPlayer == player)       localPlayer=null;
    }
    if (visualComponent != null) {
      fireVideoEvent(VideoEvent.VIDEO_REMOVED,visualComponent,VideoEvent.LOCAL,false);
    }
  }
}
Program: 107652
Project: 107652
Buggy source:
/** 
 * Sets the <tt>RTPConnector</tt> that will be used to initialize some codec for RTCP feedback and adds the instance to RTCPFeedbackCreateListners of deviceSession.
 * @param rtpConnector the RTP connector
 */
@Override public void setConnector(AbstractRTPConnector rtpConnector){
  super.setConnector(rtpConnector);
  if (deviceSession != null && deviceSession instanceof VideoMediaDeviceSession) {
    ((VideoMediaDeviceSession)deviceSession).addRTCPFeedbackCreateListner(this);
  }
}

Fixed version (ground truth):
/** 
 * Sets the <tt>RTPConnector</tt> that will be used to initialize some codec for RTCP feedback and adds the instance to RTCPFeedbackCreateListners of deviceSession.
 * @param rtpConnector the RTP connector
 */
@Override public void setConnector(AbstractRTPConnector rtpConnector){
  super.setConnector(rtpConnector);
  if (deviceSession != null) {
    deviceSession.addRTCPFeedbackCreateListner(this);
  }
}
Program: 107653
Project: 107653
Buggy source:
/** 
 * Creates a <tt>DataSource</tt> instance for this <tt>MediaDevice</tt> which gives access to the captured media.
 * @return a <tt>DataSource</tt> instance which gives access to the mediacaptured by this <tt>MediaDevice</tt>
 * @see AbstractMediaDevice#createOutputDataSource()
 */
@Override protected synchronized DataSource createOutputDataSource(){
  if (deviceSession == null) {
    MediaFormatImpl<? extends Format> format=null;
    MediaDirection startedDirection=MediaDirection.INACTIVE;
    for (    MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
      MediaFormatImpl<? extends Format> streamFormat=streamDeviceSession.getFormat();
      if ((streamFormat != null) && (format == null))       format=streamFormat;
      startedDirection=startedDirection.or(streamDeviceSession.getStartedDirection());
    }
    deviceSession=device.createSession();
    if (deviceSession instanceof VideoMediaDeviceSession) {
      VideoMediaDeviceSession videoMediaDeviceSession=(VideoMediaDeviceSession)deviceSession;
      for (      MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
        videoMediaDeviceSession.addRTCPFeedbackCreateListner(streamDeviceSession);
      }
    }
    if (format != null)     deviceSession.setFormat(format);
    deviceSession.start(startedDirection);
  }
  return (deviceSession == null) ? null : deviceSession.getOutputDataSource();
}

Fixed version (ground truth):
/** 
 * Creates a <tt>DataSource</tt> instance for this <tt>MediaDevice</tt> which gives access to the captured media.
 * @return a <tt>DataSource</tt> instance which gives access to the mediacaptured by this <tt>MediaDevice</tt>
 * @see AbstractMediaDevice#createOutputDataSource()
 */
@Override protected synchronized DataSource createOutputDataSource(){
  if (deviceSession == null) {
    MediaFormatImpl<? extends Format> format=null;
    MediaDirection startedDirection=MediaDirection.INACTIVE;
    for (    MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
      MediaFormatImpl<? extends Format> streamFormat=streamDeviceSession.getFormat();
      if ((streamFormat != null) && (format == null))       format=streamFormat;
      startedDirection=startedDirection.or(streamDeviceSession.getStartedDirection());
    }
    MediaDeviceSession newDeviceSession=device.createSession();
    if (newDeviceSession instanceof VideoMediaDeviceSession) {
      deviceSession=(VideoMediaDeviceSession)newDeviceSession;
      deviceSession.addVideoListener(this);
      for (      MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
        deviceSession.addRTCPFeedbackCreateListner(streamDeviceSession);
      }
    }
    if (format != null)     deviceSession.setFormat(format);
    deviceSession.start(startedDirection);
  }
  return (deviceSession == null) ? null : deviceSession.getOutputDataSource();
}
Program: 107655
Project: 107655
Buggy source:
/** 
 * Creates a <tt>DataSource</tt> instance for this <tt>MediaDevice</tt> which gives access to the captured media.
 * @return a <tt>DataSource</tt> instance which gives access to the mediacaptured by this <tt>MediaDevice</tt>
 * @see AbstractMediaDevice#createOutputDataSource()
 */
protected synchronized DataSource createOutputDataSource(){
  if (deviceSession == null) {
    MediaFormatImpl<? extends Format> format=null;
    MediaDirection startedDirection=MediaDirection.INACTIVE;
    for (    MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
      MediaFormatImpl<? extends Format> streamFormat=streamDeviceSession.getFormat();
      if ((streamFormat != null) && (format == null))       format=streamFormat;
      startedDirection=startedDirection.or(streamDeviceSession.getStartedDirection());
    }
    deviceSession=device.createSession();
    if (format != null)     deviceSession.setFormat(format);
    deviceSession.start(startedDirection);
  }
  return (deviceSession == null) ? null : deviceSession.getOutputDataSource();
}

Fixed version (ground truth):
/** 
 * Creates a <tt>DataSource</tt> instance for this <tt>MediaDevice</tt> which gives access to the captured media.
 * @return a <tt>DataSource</tt> instance which gives access to the mediacaptured by this <tt>MediaDevice</tt>
 * @see AbstractMediaDevice#createOutputDataSource()
 */
protected synchronized DataSource createOutputDataSource(){
  if (deviceSession == null) {
    MediaFormatImpl<? extends Format> format=null;
    MediaDirection startedDirection=MediaDirection.INACTIVE;
    for (    MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
      MediaFormatImpl<? extends Format> streamFormat=streamDeviceSession.getFormat();
      if ((streamFormat != null) && (format == null))       format=streamFormat;
      startedDirection=startedDirection.or(streamDeviceSession.getStartedDirection());
    }
    deviceSession=device.createSession();
    if (deviceSession instanceof VideoMediaDeviceSession) {
      for (      MediaStreamMediaDeviceSession streamDeviceSession : streamDeviceSessions) {
        ((VideoMediaDeviceSession)deviceSession).addRTCPFeedbackCreateListner(streamDeviceSession);
      }
    }
    if (format != null)     deviceSession.setFormat(format);
    deviceSession.start(startedDirection);
  }
  return (deviceSession == null) ? null : deviceSession.getOutputDataSource();
}
Program: 107660
Project: 107660
Buggy source:
/** 
 * Processes the data provided in a specific <tt>Buffer</tt> and renders it to the output device represented by this <tt>Renderer</tt>.
 * @param buffer a <tt>Buffer</tt> containing the data to be processed andrendered
 * @return <tt>BUFFER_PROCESSED_OK</tt> if the processing is successful;otherwise, the other possible return codes defined in the <tt>PlugIn</tt> interface
 */
public synchronized int process(Buffer buffer){
  if (buffer.isDiscard())   return BUFFER_PROCESSED_OK;
  int bufferLength=buffer.getLength();
  if (bufferLength == 0)   return BUFFER_PROCESSED_OK;
  Format format=buffer.getFormat();
  if ((format != null) && (format != this.inputFormat) && !format.equals(this.inputFormat)&& (setInputFormat(format) == null)) {
    return BUFFER_PROCESSED_FAILED;
  }
  if (handle == 0)   return BUFFER_PROCESSED_FAILED;
 else {
    Dimension size=null;
    if (format != null)     size=((VideoFormat)format).getSize();
    if (size == null) {
      size=this.inputFormat.getSize();
      if (size == null)       return BUFFER_PROCESSED_FAILED;
    }
    Component component=getComponent();
    boolean repaint=false;
    repaint=process(handle,component,(int[])buffer.getData(),buffer.getOffset(),bufferLength,size.width,size.height);
    if (repaint)     component.repaint();
    return BUFFER_PROCESSED_OK;
  }
}

Fixed version (ground truth):
/** 
 * Processes the data provided in a specific <tt>Buffer</tt> and renders it to the output device represented by this <tt>Renderer</tt>.
 * @param buffer a <tt>Buffer</tt> containing the data to be processed andrendered
 * @return <tt>BUFFER_PROCESSED_OK</tt> if the processing is successful;otherwise, the other possible return codes defined in the <tt>PlugIn</tt> interface
 */
public synchronized int process(Buffer buffer){
  if (buffer.isDiscard())   return BUFFER_PROCESSED_OK;
  int bufferLength=buffer.getLength();
  if (bufferLength == 0)   return BUFFER_PROCESSED_OK;
  Format format=buffer.getFormat();
  if ((format != null) && (format != this.inputFormat) && !format.equals(this.inputFormat)&& (setInputFormat(format) == null)) {
    return BUFFER_PROCESSED_FAILED;
  }
  if (handle == 0)   return BUFFER_PROCESSED_FAILED;
 else {
    Dimension size=null;
    if (format != null)     size=((VideoFormat)format).getSize();
    if (size == null) {
      size=this.inputFormat.getSize();
      if (size == null)       return BUFFER_PROCESSED_FAILED;
    }
    if ((size.width >= SwScale.MIN_SWS_SCALE_HEIGHT_OR_WIDTH) && (size.height >= SwScale.MIN_SWS_SCALE_HEIGHT_OR_WIDTH)) {
      Component component=getComponent();
      boolean repaint=process(handle,component,(int[])buffer.getData(),buffer.getOffset(),bufferLength,size.width,size.height);
      if (repaint)       component.repaint();
    }
    return BUFFER_PROCESSED_OK;
  }
}
Program: 107661
Project: 107661
Buggy source:
/** 
 * Overrides   {@link Canvas#paint(Graphics)} to paint this <tt>Component</tt>in the native counterpart of its associated <tt>JAWTRenderer</tt>.
 */
@Override public void paint(Graphics g){
  if (wantsPaint) {
synchronized (getHandleLock()) {
      long handle;
      if ((handle=getHandle()) != 0) {
        Container parent=getParent();
        int zOrder=(parent == null) ? -1 : parent.getComponentZOrder(this);
        wantsPaint=JAWTRenderer.paint(handle,this,g,zOrder);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Overrides   {@link Canvas#paint(Graphics)} to paint this <tt>Component</tt>in the native counterpart of its associated <tt>JAWTRenderer</tt>.
 */
@Override public void paint(Graphics g){
  if (wantsPaint && (getWidth() >= SwScale.MIN_SWS_SCALE_HEIGHT_OR_WIDTH) && (getHeight() >= SwScale.MIN_SWS_SCALE_HEIGHT_OR_WIDTH)) {
synchronized (getHandleLock()) {
      long handle;
      if ((handle=getHandle()) != 0) {
        Container parent=getParent();
        int zOrder=(parent == null) ? -1 : parent.getComponentZOrder(this);
        wantsPaint=JAWTRenderer.paint(handle,this,g,zOrder);
      }
    }
  }
}
Program: 107663
Project: 107663
Buggy source:
public void run(){
  showPreview(previewContainer,preview,player);
}

Fixed version (ground truth):
@Override public void run(){
  player.stop();
  player.deallocate();
  player.close();
}
Program: 107664
Project: 107664
Buggy source:
/** 
 * Dispose the player used for the preview.
 * @param player the player.
 */
private static void disposePlayer(Player player){
  player.stop();
  player.deallocate();
  player.close();
}

Fixed version (ground truth):
/** 
 * Dispose the player used for the preview.
 * @param player the player.
 */
private static void disposePlayer(final Player player){
  new Thread(new Runnable(){
    @Override public void run(){
      player.stop();
      player.deallocate();
      player.close();
    }
  }
).start();
}
Program: 107665
Project: 107665
Buggy source:
public void hierarchyChanged(HierarchyEvent event){
  if ((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == 0)   return;
  if (!preview.isDisplayable()) {
    dispose();
    return;
  }
 else   player.start();
  if (windowListener == null) {
    window=SwingUtilities.windowForComponent(preview);
    if (window != null) {
      windowListener=new WindowAdapter(){
        @Override public void windowClosing(        WindowEvent event){
          dispose();
        }
      }
;
      window.addWindowListener(windowListener);
    }
  }
}

Fixed version (ground truth):
/** 
 * Change in container.
 * @param event the event for the chnage.
 */
public void hierarchyChanged(HierarchyEvent event){
  if ((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == 0)   return;
  if (!container.isDisplayable()) {
    dispose();
    return;
  }
 else {
    if (preview != null) {
      player.start();
    }
  }
  if (windowListener == null) {
    window=SwingUtilities.windowForComponent(container);
    if (window != null) {
      windowListener=new WindowAdapter(){
        @Override public void windowClosing(        WindowEvent event){
          dispose();
        }
      }
;
      window.addWindowListener(windowListener);
    }
  }
}
Program: 107666
Project: 107666
Buggy source:
public void controllerUpdate(ControllerEvent event){
  controllerUpdateForPreview(event,videoContainer,locator);
}

Fixed version (ground truth):
public void controllerUpdate(ControllerEvent event){
  controllerUpdateForPreview(event,videoContainer,locator,listener);
}
Program: 107667
Project: 107667
Buggy source:
/** 
 * Shows the preview panel.
 * @param previewContainer the container
 * @param preview the preview component.
 * @param player the player.
 */
private static void showPreview(final JComponent previewContainer,final Component preview,final Player player){
  if (!SwingUtilities.isEventDispatchThread()) {
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        showPreview(previewContainer,preview,player);
      }
    }
);
    return;
  }
  previewContainer.removeAll();
  if (preview != null) {
    HierarchyListener hierarchyListener=new HierarchyListener(){
      private Window window;
      private WindowListener windowListener;
      public void dispose(){
        if (windowListener != null) {
          if (window != null) {
            window.removeWindowListener(windowListener);
            window=null;
          }
          windowListener=null;
        }
        preview.removeHierarchyListener(this);
        disposePlayer(player);
        previewContainer.remove(preview);
      }
      public void hierarchyChanged(      HierarchyEvent event){
        if ((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == 0)         return;
        if (!preview.isDisplayable()) {
          dispose();
          return;
        }
 else         player.start();
        if (windowListener == null) {
          window=SwingUtilities.windowForComponent(preview);
          if (window != null) {
            windowListener=new WindowAdapter(){
              @Override public void windowClosing(              WindowEvent event){
                dispose();
              }
            }
;
            window.addWindowListener(windowListener);
          }
        }
      }
    }
;
    preview.addHierarchyListener(hierarchyListener);
    previewContainer.add(preview);
    if (previewContainer.isDisplayable()) {
      previewContainer.revalidate();
      previewContainer.repaint();
    }
 else     previewContainer.doLayout();
  }
 else   disposePlayer(player);
}

Fixed version (ground truth):
/** 
 * Shows the preview panel.
 * @param previewContainer the container
 * @param preview the preview component.
 * @param player the player.
 */
private static void showPreview(final JComponent previewContainer,final Component preview,final Player player){
  if (!SwingUtilities.isEventDispatchThread()) {
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        showPreview(previewContainer,preview,player);
      }
    }
);
    return;
  }
  previewContainer.removeAll();
  if (preview != null) {
    previewContainer.add(preview);
    player.start();
    if (previewContainer.isDisplayable()) {
      previewContainer.revalidate();
      previewContainer.repaint();
    }
 else     previewContainer.doLayout();
  }
 else   disposePlayer(player);
}
Program: 107668
Project: 107668
Buggy source:
/** 
 * Listens and shows the video in the video container when needed.
 * @param event the event when player has ready visual component.
 * @param videoContainer the container.
 * @param locator input DataSource locator
 */
private static void controllerUpdateForPreview(ControllerEvent event,JComponent videoContainer,MediaLocator locator){
  if (event instanceof ConfigureCompleteEvent) {
    Processor player=(Processor)event.getSourceController();
    TrackControl[] trackControls=player.getTrackControls();
    if ((trackControls != null) && (trackControls.length != 0))     try {
      for (      TrackControl trackControl : trackControls) {
        Codec codecs[]=null;
        SwScale scaler=new SwScale();
        if (DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals(locator.getProtocol()))         codecs=new Codec[]{scaler};
 else         codecs=new Codec[]{new HFlip(),scaler};
        trackControl.setCodecChain(codecs);
        break;
      }
    }
 catch (    UnsupportedPlugInException upiex) {
      logger.warn("String_Node_Str" + "String_Node_Str",upiex);
    }
    try {
      player.setContentDescriptor(null);
    }
 catch (    NotConfiguredError nce) {
      logger.error("String_Node_Str",nce);
    }
    player.realize();
  }
 else   if (event instanceof RealizeCompleteEvent) {
    Player player=(Player)event.getSourceController();
    Component video=player.getVisualComponent();
    showPreview(videoContainer,video,player);
  }
}

Fixed version (ground truth):
/** 
 * Listens and shows the video in the video container when needed.
 * @param event the event when player has ready visual component.
 * @param videoContainer the container.
 * @param locator input DataSource locator
 * @param listener the hierarchy listener we created for the video container.
 */
private static void controllerUpdateForPreview(ControllerEvent event,JComponent videoContainer,MediaLocator locator,VideoContainerHierarchyListener listener){
  if (event instanceof ConfigureCompleteEvent) {
    Processor player=(Processor)event.getSourceController();
    TrackControl[] trackControls=player.getTrackControls();
    if ((trackControls != null) && (trackControls.length != 0))     try {
      for (      TrackControl trackControl : trackControls) {
        Codec codecs[]=null;
        SwScale scaler=new SwScale();
        if (DeviceSystem.LOCATOR_PROTOCOL_IMGSTREAMING.equals(locator.getProtocol()))         codecs=new Codec[]{scaler};
 else         codecs=new Codec[]{new HFlip(),scaler};
        trackControl.setCodecChain(codecs);
        break;
      }
    }
 catch (    UnsupportedPlugInException upiex) {
      logger.warn("String_Node_Str" + "String_Node_Str",upiex);
    }
    try {
      player.setContentDescriptor(null);
    }
 catch (    NotConfiguredError nce) {
      logger.error("String_Node_Str",nce);
    }
    player.realize();
  }
 else   if (event instanceof RealizeCompleteEvent) {
    Player player=(Player)event.getSourceController();
    Component video=player.getVisualComponent();
    listener.setPreview(video);
    showPreview(videoContainer,video,player);
  }
}
Program: 107669
Project: 107669
Buggy source:
public void dispose(){
  if (windowListener != null) {
    if (window != null) {
      window.removeWindowListener(windowListener);
      window=null;
    }
    windowListener=null;
  }
  preview.removeHierarchyListener(this);
  disposePlayer(player);
  previewContainer.remove(preview);
}

Fixed version (ground truth):
/** 
 * Disposes player and cleans listeners as we will no longer need them.
 */
public void dispose(){
  if (windowListener != null) {
    if (window != null) {
      window.removeWindowListener(windowListener);
      window=null;
    }
    windowListener=null;
  }
  container.removeHierarchyListener(this);
  disposePlayer(player);
  if (preview != null)   container.remove(preview);
}
Program: 107672
Project: 107672
Buggy source:
/** 
 * Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.
 * @see MediaStream#close()
 */
public void close(){
  stop();
  closeSendStreams();
  srtpControl.cleanup();
  if (csrcEngine != null) {
    csrcEngine.close();
    csrcEngine=null;
  }
  if (rtpManager != null) {
    if (logger.isInfoEnabled())     printFlowStatistics(rtpManager);
    rtpManager.removeReceiveStreamListener(this);
    rtpManager.removeSendStreamListener(this);
    rtpManager.removeSessionListener(this);
    rtpManager.removeRemoteListener(this);
    try {
      rtpManager.dispose();
      rtpManager=null;
    }
 catch (    Throwable t) {
      if (t instanceof ThreadDeath)       throw (ThreadDeath)t;
      logger.error("String_Node_Str",t);
    }
  }
  if (rtpConnector != null)   rtpConnector.removeTargets();
  rtpConnectorTarget=null;
  if (deviceSession != null)   deviceSession.close();
}

Fixed version (ground truth):
/** 
 * Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.
 * @see MediaStream#close()
 */
public void close(){
  if (logger.isInfoEnabled())   printReceiveStreamStatistics();
  stop();
  closeSendStreams();
  srtpControl.cleanup();
  if (csrcEngine != null) {
    csrcEngine.close();
    csrcEngine=null;
  }
  if (rtpManager != null) {
    if (logger.isInfoEnabled())     printFlowStatistics(rtpManager);
    rtpManager.removeReceiveStreamListener(this);
    rtpManager.removeSendStreamListener(this);
    rtpManager.removeSessionListener(this);
    rtpManager.removeRemoteListener(this);
    try {
      rtpManager.dispose();
      rtpManager=null;
    }
 catch (    Throwable t) {
      if (t instanceof ThreadDeath)       throw (ThreadDeath)t;
      logger.error("String_Node_Str",t);
    }
  }
  if (rtpConnector != null)   rtpConnector.removeTargets();
  rtpConnectorTarget=null;
  if (deviceSession != null)   deviceSession.close();
}
Program: 107673
Project: 107673
Buggy source:
/** 
 * Gets this <tt>MediaDevice</tt>'s <tt>PacketLossAwareEncoder</tt> if any, <tt>null</tt> otherwise. To find such an instance, the codec chain contained in the <tt>DeviceSession</tt>'s processor is searched.
 * @return this <tt>MediaDevice</tt>'s <tt>PacketLossAwareEncoder</tt> ifany, <tt>null</tt> otherwise.
 */
public PacketLossAwareEncoder getPacketLossAwareEncoder(){
  if (packetLossAwareEncoder != null)   return packetLossAwareEncoder;
  MediaDeviceSession mediaDeviceSession=getDeviceSession();
  if (mediaDeviceSession == null)   return null;
  Processor processor=mediaDeviceSession.getProcessor();
  if (processor == null)   return null;
  for (  TrackControl tc : processor.getTrackControls()) {
    Object obj=tc.getControl(PacketLossAwareEncoder.class.getName());
    if (obj instanceof PacketLossAwareEncoder) {
      packetLossAwareEncoder=(PacketLossAwareEncoder)obj;
      return packetLossAwareEncoder;
    }
  }
  return packetLossAwareEncoder;
}

Fixed version (ground truth):
/** 
 * Gets this <tt>MediaDevice</tt>'s <tt>PacketLossAwareEncoder</tt> if any, <tt>null</tt> otherwise. To find such an instance, the codec chain contained in the <tt>DeviceSession</tt>'s processor is searched.
 * @return this <tt>MediaDevice</tt>'s <tt>PacketLossAwareEncoder</tt> ifany, <tt>null</tt> otherwise.
 */
public PacketLossAwareEncoder getPacketLossAwareEncoder(){
  MediaDeviceSession mediaDeviceSession=getDeviceSession();
  if (mediaDeviceSession == null)   return null;
  return mediaDeviceSession.getPacketLossAwareEncoder();
}