Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fea70d01 authored by Mark Harman's avatar Mark Harman
Browse files

Refactor, move VideoProfile to its own file.

parent cec57aab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ import net.sourceforge.opencamera.HDRProcessor;
import net.sourceforge.opencamera.HDRProcessorException;
import net.sourceforge.opencamera.MainActivity;
import net.sourceforge.opencamera.PreferenceKeys;
import net.sourceforge.opencamera.Preview.VideoProfile;
import net.sourceforge.opencamera.SaveLocationHistory;
import net.sourceforge.opencamera.CameraController.CameraController;
import net.sourceforge.opencamera.Preview.Preview;
@@ -790,7 +791,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
	    clickView(switchVideoButton);
		waitUntilCameraOpened();
	    assertTrue(mPreview.isVideo());
    	Preview.VideoProfile profile = mPreview.getVideoProfile();
    	VideoProfile profile = mPreview.getVideoProfile();
        CameraController.Size video_preview_size = mPreview.getCameraController().getPreviewSize();
        //targetRatio = mPreview.getTargetRatioForPreview(display_size);
        targetRatio = mPreview.getTargetRatio();
+3 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package net.sourceforge.opencamera;
import net.sourceforge.opencamera.CameraController.CameraController;
import net.sourceforge.opencamera.CameraController.CameraControllerManager2;
import net.sourceforge.opencamera.Preview.Preview;
import net.sourceforge.opencamera.Preview.VideoProfile;
import net.sourceforge.opencamera.UI.FolderChooserDialog;
import net.sourceforge.opencamera.UI.MainUI;

@@ -1336,7 +1337,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene
		if( preview.getVideoQualityHander().getCurrentVideoQuality() != null ) {
			bundle.putString("current_video_quality", preview.getVideoQualityHander().getCurrentVideoQuality());
		}
		Preview.VideoProfile camcorder_profile = preview.getVideoProfile();
		VideoProfile camcorder_profile = preview.getVideoProfile();
		bundle.putInt("video_frame_width", camcorder_profile.videoFrameWidth);
		bundle.putInt("video_frame_height", camcorder_profile.videoFrameHeight);
		bundle.putInt("video_bit_rate", camcorder_profile.videoBitRate);
@@ -2858,7 +2859,7 @@ public class MainActivity extends Activity implements AudioListener.AudioListene
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
		boolean simple = true;
		if( preview.isVideo() ) {
			Preview.VideoProfile profile = preview.getVideoProfile();
			VideoProfile profile = preview.getVideoProfile();
			String bitrate_string;
			if( profile.videoBitRate >= 10000000 )
				bitrate_string = profile.videoBitRate/1000000 + "Mbps";
+3 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ import java.util.TimerTask;
import net.sourceforge.opencamera.CameraController.CameraController;
import net.sourceforge.opencamera.Preview.ApplicationInterface;
import net.sourceforge.opencamera.Preview.Preview;
import net.sourceforge.opencamera.Preview.VideoProfile;
import net.sourceforge.opencamera.UI.DrawPreview;

import android.annotation.TargetApi;
@@ -29,7 +30,6 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.hardware.camera2.DngCreator;
import android.location.Location;
import android.media.CamcorderProfile;
import android.media.Image;
import android.media.MediaMetadataRetriever;
import android.media.MediaRecorder;
@@ -1325,7 +1325,7 @@ public class MyApplicationInterface implements ApplicationInterface {
	}
	
	@Override
	public void onVideoRecordStartError(Preview.VideoProfile profile) {
	public void onVideoRecordStartError(VideoProfile profile) {
		if( MyDebug.LOG )
			Log.d(TAG, "onVideoRecordStartError");
		String error_message;
@@ -1344,7 +1344,7 @@ public class MyApplicationInterface implements ApplicationInterface {
	}

	@Override
	public void onVideoRecordStopError(Preview.VideoProfile profile) {
	public void onVideoRecordStopError(VideoProfile profile) {
		if( MyDebug.LOG )
			Log.d(TAG, "onVideoRecordStopError");
		//main_activity.getPreview().showToast(null, R.string.failed_to_record_video);
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ public interface ApplicationInterface {
	void onPhotoError(); // callback for failing to take a photo
	void onVideoInfo(int what, int extra); // callback for info when recording video (see MediaRecorder.OnInfoListener)
	void onVideoError(int what, int extra); // callback for errors when recording video (see MediaRecorder.OnErrorListener)
	void onVideoRecordStartError(Preview.VideoProfile profile); // callback for video recording failing to start
	void onVideoRecordStopError(Preview.VideoProfile profile); // callback for video recording being corrupted
	void onVideoRecordStartError(VideoProfile profile); // callback for video recording failing to start
	void onVideoRecordStopError(VideoProfile profile); // callback for video recording being corrupted
	void onFailedReconnectError(); // failed to reconnect camera after stopping video recording
	void onFailedCreateVideoFileError(); // callback if unable to create file for recording video
	void hasPausedPreview(boolean paused); // called when the preview is paused or unpaused (due to getPausePreviewPref())
+0 −45
Original line number Diff line number Diff line
@@ -293,51 +293,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
	public volatile boolean test_video_failure;
	public volatile boolean test_ticker_called; // set from MySurfaceView or CanvasView

	/** This is essentially similar to CamcorderProfile in that it encapsulates a set of video settings
	 *  to be passed to MediaRecorder, but allows us to create values without having to create a
	 *  CamcorderProfile (needed for slow motion / high speed video recording).
	 */
	public class VideoProfile {
		final CamcorderProfile camcorderProfile;
		public final int audioCodec;
		public final int fileFormat;
		public final int videoBitRate;
		public final int videoCodec;
		public final int videoFrameHeight;
		public final int videoFrameRate;
		public final int videoFrameWidth;

		VideoProfile(CamcorderProfile camcorderProfile) {
			this.camcorderProfile = camcorderProfile;

			this.audioCodec = camcorderProfile.audioCodec;
			this.fileFormat = camcorderProfile.fileFormat;
			this.videoBitRate = camcorderProfile.videoBitRate;
			this.videoCodec = camcorderProfile.videoCodec;
			this.videoFrameHeight = camcorderProfile.videoFrameHeight;
			this.videoFrameRate = camcorderProfile.videoFrameRate;
			this.videoFrameWidth = camcorderProfile.videoFrameWidth;
		}
		VideoProfile(int audioCodec, int fileFormat, int videoBitRate, int videoCodec, int videoFrameHeight, int videoFrameRate, int videoFrameWidth) {
			this.camcorderProfile = null;

			this.audioCodec = audioCodec;
			this.fileFormat = fileFormat;
			this.videoBitRate = videoBitRate;
			this.videoCodec = videoCodec;
			this.videoFrameHeight = videoFrameHeight;
			this.videoFrameRate = videoFrameRate;
			this.videoFrameWidth = videoFrameWidth;
		}

		/** Returns the CamcorderProfile this VideoProfile was created with, or null if it was not
		 *  created with a CamcorderProfile.
		 */
		CamcorderProfile getCamcorderProfile() {
			return this.camcorderProfile;
		}
	}

	public Preview(ApplicationInterface applicationInterface, ViewGroup parent) {
		if( MyDebug.LOG ) {
			Log.d(TAG, "new Preview");
Loading