Program: 38161
Project: 38161
Buggy source:
private void initializeRecorder(){
  Log.v(TAG,"String_Node_Str");
  if (mCameraDevice == null)   return;
  if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
    mUI.showSurfaceView();
  }
  Intent intent=mActivity.getIntent();
  Bundle myExtras=intent.getExtras();
  videoWidth=mProfile.videoFrameWidth;
  videoHeight=mProfile.videoFrameHeight;
  mUnsupportedResolution=false;
  List<VideoEncoderCap> videoEncoders=EncoderCapabilities.getVideoEncoders();
  for (  VideoEncoderCap videoEncoder : videoEncoders) {
    if (videoEncoder.mCodec == mVideoEncoder) {
      if (videoWidth > videoEncoder.mMaxFrameWidth || videoWidth < videoEncoder.mMinFrameWidth || videoHeight > videoEncoder.mMaxFrameHeight || videoHeight < videoEncoder.mMinFrameHeight) {
        Log.e(TAG,"String_Node_Str" + mVideoEncoder + "String_Node_Str"+ videoWidth+ "String_Node_Str"+ videoHeight+ "String_Node_Str");
        Log.e(TAG,"String_Node_Str" + "String_Node_Str" + videoEncoder.mMinFrameWidth + "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMinFrameHeight+ "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMaxFrameWidth+ "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMaxFrameHeight);
        mUnsupportedResolution=true;
        RotateTextToast.makeText(mActivity,R.string.error_app_unsupported,Toast.LENGTH_LONG).show();
        return;
      }
      break;
    }
  }
  long requestedSizeLimit=0;
  closeVideoFileDescriptor();
  mCurrentVideoUriFromMediaSaved=false;
  if (mIsVideoCaptureIntent && myExtras != null) {
    Uri saveUri=(Uri)myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
    if (saveUri != null) {
      try {
        mVideoFileDescriptor=mContentResolver.openFileDescriptor(saveUri,"String_Node_Str");
        mCurrentVideoUri=saveUri;
      }
 catch (      java.io.FileNotFoundException ex) {
        Log.e(TAG,ex.toString());
      }
    }
    requestedSizeLimit=myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
  }
  mMediaRecorder=new MediaRecorder();
  mCameraDevice.unlock();
  mMediaRecorder.setCamera(mCameraDevice.getCamera());
  String hfr=mParameters.getVideoHighFrameRate();
  String hsr=mParameters.get(CameraSettings.KEY_VIDEO_HSR);
  Log.i(TAG,"String_Node_Str" + hfr + "String_Node_Str"+ hsr);
  int captureRate=0;
  boolean isHFR=(hfr != null && !hfr.equals("String_Node_Str"));
  boolean isHSR=(hsr != null && !hsr.equals("String_Node_Str"));
  try {
    captureRate=isHFR ? Integer.parseInt(hfr) : isHSR ? Integer.parseInt(hsr) : 0;
  }
 catch (  NumberFormatException nfe) {
    Log.e(TAG,"String_Node_Str" + hfr + "String_Node_Str"+ hsr+ "String_Node_Str");
  }
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  mProfile.videoCodec=mVideoEncoder;
  mProfile.audioCodec=mAudioEncoder;
  mProfile.duration=mMaxVideoDurationInMs;
  if ((mProfile.audioCodec == MediaRecorder.AudioEncoder.AMR_NB) && !mCaptureTimeLapse && !isHFR) {
    mProfile.fileFormat=MediaRecorder.OutputFormat.THREE_GPP;
  }
  if ((isHFR || isHSR) && captureRate > 0) {
    if (isHSR) {
      Log.i(TAG,"String_Node_Str");
      mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    }
    mMediaRecorder.setOutputFormat(mProfile.fileFormat);
    mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);
    mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate);
    mMediaRecorder.setVideoEncoder(mProfile.videoCodec);
    if (isHSR) {
      Log.i(TAG,"String_Node_Str");
      mMediaRecorder.setAudioEncodingBitRate(mProfile.audioBitRate);
      mMediaRecorder.setAudioChannels(mProfile.audioChannels);
      mMediaRecorder.setAudioSamplingRate(mProfile.audioSampleRate);
      mMediaRecorder.setAudioEncoder(mProfile.audioCodec);
    }
  }
 else {
    if (!mCaptureTimeLapse) {
      mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    }
    mMediaRecorder.setProfile(mProfile);
  }
  mMediaRecorder.setVideoSize(mProfile.videoFrameWidth,mProfile.videoFrameHeight);
  mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
  if (mCaptureTimeLapse) {
    double fps=1000 / (double)mTimeBetweenTimeLapseFrameCaptureMs;
    setCaptureRate(mMediaRecorder,fps);
  }
 else   if (captureRate > 0) {
    Log.i(TAG,"String_Node_Str" + captureRate);
    mMediaRecorder.setCaptureRate(captureRate);
    int targetFrameRate=isHSR ? captureRate : isHFR ? 30 : mProfile.videoFrameRate;
    Log.i(TAG,"String_Node_Str" + targetFrameRate);
    mMediaRecorder.setVideoFrameRate(targetFrameRate);
    int scaledBitrate=mProfile.videoBitRate * targetFrameRate / mProfile.videoFrameRate;
    Log.i(TAG,"String_Node_Str" + scaledBitrate);
    mMediaRecorder.setVideoEncodingBitRate(scaledBitrate);
  }
  setRecordLocation();
  if (mVideoFileDescriptor != null) {
    mMediaRecorder.setOutputFile(mVideoFileDescriptor.getFileDescriptor());
  }
 else {
    generateVideoFilename(mProfile.fileFormat);
    mMediaRecorder.setOutputFile(mVideoFilename);
  }
  long maxFileSize=mActivity.getStorageSpaceBytes() - Storage.LOW_STORAGE_THRESHOLD_BYTES;
  if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) {
    maxFileSize=requestedSizeLimit;
  }
  if (Storage.isSaveSDCard() && maxFileSize > SDCARD_SIZE_LIMIT) {
    maxFileSize=SDCARD_SIZE_LIMIT;
  }
  try {
    mMediaRecorder.setMaxFileSize(maxFileSize);
  }
 catch (  RuntimeException exception) {
  }
  int rotation=0;
  if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
    CameraInfo info=CameraHolder.instance().getCameraInfo()[mCameraId];
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
      rotation=(info.orientation - mOrientation + 360) % 360;
    }
 else {
      rotation=(info.orientation + mOrientation) % 360;
    }
  }
  mMediaRecorder.setOrientationHint(rotation);
  setupMediaRecorderPreviewDisplay();
  try {
    mMediaRecorder.prepare();
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + mVideoFilename,e);
    releaseMediaRecorder();
    throw new RuntimeException(e);
  }
  mMediaRecorder.setOnErrorListener(this);
  mMediaRecorder.setOnInfoListener(this);
}

Fixed version (ground truth):
private void initializeRecorder(){
  Log.v(TAG,"String_Node_Str");
  if (mCameraDevice == null)   return;
  if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
    mUI.showSurfaceView();
  }
  Intent intent=mActivity.getIntent();
  Bundle myExtras=intent.getExtras();
  videoWidth=mProfile.videoFrameWidth;
  videoHeight=mProfile.videoFrameHeight;
  mUnsupportedResolution=false;
  List<VideoEncoderCap> videoEncoders=EncoderCapabilities.getVideoEncoders();
  for (  VideoEncoderCap videoEncoder : videoEncoders) {
    if (videoEncoder.mCodec == mVideoEncoder) {
      if (videoWidth > videoEncoder.mMaxFrameWidth || videoWidth < videoEncoder.mMinFrameWidth || videoHeight > videoEncoder.mMaxFrameHeight || videoHeight < videoEncoder.mMinFrameHeight) {
        Log.e(TAG,"String_Node_Str" + mVideoEncoder + "String_Node_Str"+ videoWidth+ "String_Node_Str"+ videoHeight+ "String_Node_Str");
        Log.e(TAG,"String_Node_Str" + "String_Node_Str" + videoEncoder.mMinFrameWidth + "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMinFrameHeight+ "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMaxFrameWidth+ "String_Node_Str"+ "String_Node_Str"+ videoEncoder.mMaxFrameHeight);
        mUnsupportedResolution=true;
        RotateTextToast.makeText(mActivity,R.string.error_app_unsupported,Toast.LENGTH_LONG).show();
        return;
      }
      break;
    }
  }
  long requestedSizeLimit=0;
  closeVideoFileDescriptor();
  mCurrentVideoUriFromMediaSaved=false;
  if (mIsVideoCaptureIntent && myExtras != null) {
    Uri saveUri=(Uri)myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
    if (saveUri != null) {
      try {
        mVideoFileDescriptor=mContentResolver.openFileDescriptor(saveUri,"String_Node_Str");
        mCurrentVideoUri=saveUri;
      }
 catch (      java.io.FileNotFoundException ex) {
        Log.e(TAG,ex.toString());
      }
    }
    requestedSizeLimit=myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
  }
  mMediaRecorder=new MediaRecorder();
  mCameraDevice.unlock();
  mMediaRecorder.setCamera(mCameraDevice.getCamera());
  String hfr=mParameters.getVideoHighFrameRate();
  String hsr=mParameters.get(CameraSettings.KEY_VIDEO_HSR);
  Log.i(TAG,"String_Node_Str" + hfr + "String_Node_Str"+ hsr);
  int captureRate=0;
  boolean isHFR=(hfr != null && !hfr.equals("String_Node_Str"));
  boolean isHSR=(hsr != null && !hsr.equals("String_Node_Str"));
  try {
    captureRate=isHFR ? Integer.parseInt(hfr) : isHSR ? Integer.parseInt(hsr) : 0;
  }
 catch (  NumberFormatException nfe) {
    Log.e(TAG,"String_Node_Str" + hfr + "String_Node_Str"+ hsr+ "String_Node_Str");
  }
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  mProfile.videoCodec=mVideoEncoder;
  mProfile.audioCodec=mAudioEncoder;
  mProfile.duration=mMaxVideoDurationInMs;
  if ((mProfile.audioCodec == MediaRecorder.AudioEncoder.AMR_NB) && !mCaptureTimeLapse && !isHFR) {
    mProfile.fileFormat=MediaRecorder.OutputFormat.THREE_GPP;
  }
  if ((isHFR || isHSR) && captureRate > 0) {
    if (isHSR) {
      Log.i(TAG,"String_Node_Str");
      mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    }
    mMediaRecorder.setOutputFormat(mProfile.fileFormat);
    mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);
    mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate);
    mMediaRecorder.setVideoEncoder(mProfile.videoCodec);
    if (isHSR) {
      Log.i(TAG,"String_Node_Str");
      mMediaRecorder.setAudioEncodingBitRate(mProfile.audioBitRate);
      mMediaRecorder.setAudioChannels(mProfile.audioChannels);
      mMediaRecorder.setAudioSamplingRate(mProfile.audioSampleRate);
      mMediaRecorder.setAudioEncoder(mProfile.audioCodec);
    }
  }
 else {
    if (!mCaptureTimeLapse) {
      mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    }
    mMediaRecorder.setProfile(mProfile);
  }
  mMediaRecorder.setVideoSize(mProfile.videoFrameWidth,mProfile.videoFrameHeight);
  mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
  if (mCaptureTimeLapse) {
    double fps=1000 / (double)mTimeBetweenTimeLapseFrameCaptureMs;
    setCaptureRate(mMediaRecorder,fps);
  }
 else   if (captureRate > 0) {
    Log.i(TAG,"String_Node_Str" + captureRate);
    mMediaRecorder.setCaptureRate(captureRate);
    int targetFrameRate=isHSR ? captureRate : isHFR ? 30 : mProfile.videoFrameRate;
    Log.i(TAG,"String_Node_Str" + targetFrameRate);
    mMediaRecorder.setVideoFrameRate(targetFrameRate);
    int scaledBitrate=mProfile.videoBitRate * (targetFrameRate / mProfile.videoFrameRate);
    Log.i(TAG,"String_Node_Str" + scaledBitrate);
    mMediaRecorder.setVideoEncodingBitRate(scaledBitrate);
  }
  setRecordLocation();
  if (mVideoFileDescriptor != null) {
    mMediaRecorder.setOutputFile(mVideoFileDescriptor.getFileDescriptor());
  }
 else {
    generateVideoFilename(mProfile.fileFormat);
    mMediaRecorder.setOutputFile(mVideoFilename);
  }
  long maxFileSize=mActivity.getStorageSpaceBytes() - Storage.LOW_STORAGE_THRESHOLD_BYTES;
  if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) {
    maxFileSize=requestedSizeLimit;
  }
  if (Storage.isSaveSDCard() && maxFileSize > SDCARD_SIZE_LIMIT) {
    maxFileSize=SDCARD_SIZE_LIMIT;
  }
  try {
    mMediaRecorder.setMaxFileSize(maxFileSize);
  }
 catch (  RuntimeException exception) {
  }
  int rotation=0;
  if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
    CameraInfo info=CameraHolder.instance().getCameraInfo()[mCameraId];
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
      rotation=(info.orientation - mOrientation + 360) % 360;
    }
 else {
      rotation=(info.orientation + mOrientation) % 360;
    }
  }
  mMediaRecorder.setOrientationHint(rotation);
  setupMediaRecorderPreviewDisplay();
  try {
    mMediaRecorder.prepare();
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + mVideoFilename,e);
    releaseMediaRecorder();
    throw new RuntimeException(e);
  }
  mMediaRecorder.setOnErrorListener(this);
  mMediaRecorder.setOnInfoListener(this);
}