/// <summary>
        /// Create a <seealso cref="com.samsung.android.sdk.camera.SCameraCaptureSession"/> for preview.
        /// </summary>
        private void createPreviewSession()
        {
            if (null == mSCamera || null == mSCameraDevice || null == mSCameraManager || null == mPreviewSize || !mTextureView.Available)
            {
                return;
            }

            try
            {
                SurfaceTexture texture = mTextureView.SurfaceTexture;
                texture.setDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height);

                Surface surface = new Surface(texture);

                mPreviewBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_PREVIEW);
                mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_MODE, SCaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                mPreviewBuilder.addTarget(surface);
                mPreviewBuilder.addTarget(mProcessor.InputSurface);

                //HAL Workaround
                mPreviewBuilder.set(SCaptureRequest.METERING_MODE, SCaptureRequest.METERING_MODE_MATRIX);

                IList <Surface> outputSurface = Arrays.asList(surface, mProcessor.InputSurface);
                mSCameraDevice.createCaptureSession(outputSurface, new StateCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
            }
            catch (CameraAccessException e)
            {
                showAlertDialog("Fail to session. " + e.Message, true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a <seealso cref="com.samsung.android.sdk.camera.SCameraCaptureSession"/> for preview.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("deprecation") private void createPreviewSession()
        private void createPreviewSession()
        {
            if (null == mSCamera || null == mSCameraDevice || null == mSCameraManager || !mTextureView.Available)
            {
                return;
            }

            try
            {
                mPreviewSize = mVideoParameter.mVideoSize;

                // Android Camera HAL3.2
                // Note that for the use case of multiple output streams, application must select one
                // unique size from this metadata to use. Otherwise a request error might occur.
                // The camera device will only support up to 2 output high speed streams
                // (processed non-stalling format defined in android.request.maxNumOutputStreams) in this mode.
                // This control will be effective only if all of below conditions are true:
                //
                // The application created no more than maxNumHighSpeedStreams processed non-stalling format output streams,
                // where maxNumHighSpeedStreams is calculated as min(2, android.request.maxNumOutputStreams[Processed (but not-stalling)]).
                // The stream sizes are selected from the sizes reported by android.control.availableHighSpeedVideoConfigurations.
                // No processed non-stalling or raw streams are configured.

                Log.e(TAG, "Preview size: " + mPreviewSize + " Video size: " + mVideoParameter.mVideoSize);

                // Set the aspect ratio to TextureView
                int orientation = Resources.Configuration.orientation;
                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    mTextureView.setAspectRatio(mPreviewSize.Width, mPreviewSize.Height);
                }
                else
                {
                    mTextureView.setAspectRatio(mPreviewSize.Height, mPreviewSize.Width);
                }

                prepareMediaRecorder();

                SurfaceTexture texture = mTextureView.SurfaceTexture;

                // Set default buffer size to camera preview size.
                texture.setDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height);

                Surface previewSurface  = new Surface(texture);
                Surface recorderSurface = mMediaRecorder.Surface;

                // Creates SCaptureRequest.Builder for preview and recording with output target.
                mPreviewBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_RECORD);

                // {@link com.samsung.android.sdk.camera.processor.SCameraEffectProcessor} supports only 24fps.
                mPreviewBuilder.set(SCaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, mVideoParameter.mFpsRange);
                mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_MODE, SCaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
                mPreviewBuilder.set(SCaptureRequest.CONTROL_SCENE_MODE, SCaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
                mPreviewBuilder.addTarget(previewSurface);
                mPreviewBuilder.addTarget(recorderSurface);

                // limit preview fps up to 30.
                int requestListSize = mVideoParameter.mFpsRange.Upper > 30 ? mVideoParameter.mFpsRange.Upper / 30 : 1;

                mRepeatingList = new List <>();
                mRepeatingList.Add(mPreviewBuilder.build());
                mPreviewBuilder.removeTarget(previewSurface);

                for (int i = 0; i < requestListSize - 1; i++)
                {
                    mRepeatingList.Add(mPreviewBuilder.build());
                }

                Log.e(TAG, "Request size: " + mRepeatingList.Count);

                // Creates a SCameraCaptureSession here.
                IList <Surface> outputSurface = Arrays.asList(previewSurface, recorderSurface);
                mSCameraDevice.createCaptureSession(outputSurface, new StateCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
            }
            catch (CameraAccessException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Esempio n. 3
0
		/// <summary>
		/// Create a <seealso cref="com.samsung.android.sdk.camera.SCameraCaptureSession"/> for preview.
		/// </summary>
		private void createPreviewSession()
		{
			if (null == mSCamera || null == mSCameraDevice || null == mSCameraManager || null == mPreviewSize || !mTextureView.Available)
			{
				return;
			}

			try
			{
				SurfaceTexture texture = mTextureView.SurfaceTexture;

				// Set default buffer size to camera preview size.
				texture.setDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height);

				Surface surface = new Surface(texture);

				// Creates SCaptureRequest.Builder for preview with output target.
				mPreviewBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_PREVIEW);
				mPreviewBuilder.addTarget(surface);

				mCaptureBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_STILL_CAPTURE);
				mCaptureBuilder.addTarget(mImageReader.Surface);

				// remove af default lens distance
				mPreviewBuilder.set(SCaptureRequest.LENS_FOCUS_DISTANCE, null);
				mCaptureBuilder.set(SCaptureRequest.LENS_FOCUS_DISTANCE, null);

				// set default AF trigger
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCameraMetadata.CONTROL_AF_TRIGGER_IDLE);
				mCaptureBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCameraMetadata.CONTROL_AF_TRIGGER_IDLE);

				// Creates a SCameraCaptureSession here.
				IList<Surface> outputSurface = Arrays.asList(surface, mImageReader.Surface);
				mSCameraDevice.createCaptureSession(outputSurface, new StateCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);

			}
			catch (CameraAccessException e)
			{
				showAlertDialog("Fail to create session. " + e.Message, true);
			}
		}
Esempio n. 4
0
		/// <summary>
		/// Create a <seealso cref="com.samsung.android.sdk.camera.SCameraCaptureSession"/> for preview.
		/// </summary>
		private void createPreviewSession()
		{
			if (null == mSCamera || null == mSCameraDevice || null == mSCameraManager || null == mPreviewSize || !mTextureView.Available)
			{
				return;
			}

			try
			{
				SurfaceTexture texture = mTextureView.SurfaceTexture;

				// Set default buffer size to camera preview size.
				texture.setDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height);

				Surface surface = new Surface(texture);

				// Creates SCaptureRequest.Builder for preview with output target.
				mPreviewBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_PREVIEW);
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_MODE, SCaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
				mPreviewBuilder.addTarget(surface);

				mCaptureBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_STILL_CAPTURE);
				mCaptureBuilder.set(SCaptureRequest.CONTROL_AF_MODE, SCaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
				mCaptureBuilder.addTarget(mImageReader.Surface);

				// HAL Workaround
				mPreviewBuilder.set(SCaptureRequest.METERING_MODE, SCaptureRequest.METERING_MODE_MATRIX);
				mCaptureBuilder.set(SCaptureRequest.METERING_MODE, SCaptureRequest.METERING_MODE_MATRIX);

				// Creates a SCameraCaptureSession here.
				IList<Surface> outputSurface = Arrays.asList(surface, mImageReader.Surface);
				mSCameraDevice.createCaptureSession(outputSurface, new StateCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);

			}
			catch (CameraAccessException e)
			{
				showAlertDialog("Fail to create session. " + e.Message, true);
			}
		}