Search in sources :

Example 66 with SurfaceHolder

use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.

the class CameraTest method checkTakePicture.

private void checkTakePicture() {
    SurfaceHolder mSurfaceHolder;
    try {
        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        mCamera.setPreviewDisplay(mSurfaceHolder);
        Log.v(TAG, "Start preview");
        mCamera.startPreview();
        waitForPreviewDone();
        mCamera.setPreviewCallback(null);
        mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
        waitForSnapshotDone();
    } catch (Exception e) {
        Log.v(TAG, e.toString());
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder)

Example 67 with SurfaceHolder

use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.

the class SurfaceHolderTarget method onBindToView.

@Override
public void onBindToView(View view) {
    if (view instanceof SurfaceView) {
        SurfaceHolder holder = ((SurfaceView) view).getHolder();
        if (holder == null) {
            throw new RuntimeException("Could not get SurfaceHolder from SurfaceView " + view + "!");
        }
        setSurfaceHolder(holder);
    } else {
        throw new IllegalArgumentException("View must be a SurfaceView!");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Example 68 with SurfaceHolder

use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.

the class CameraFunctionalTest method testFunctionalCameraExposureCompensation.

/**
     * Functional test iterating on the range of supported exposure compensation levels
     */
@LargeTest
public void testFunctionalCameraExposureCompensation() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        int min = params.getMinExposureCompensation();
        int max = params.getMaxExposureCompensation();
        assertFalse("Adjusting exposure not supported", (max == 0 && min == 0));
        float step = params.getExposureCompensationStep();
        int stepsPerEV = (int) Math.round(Math.pow((double) step, -1));
        // only get integer values for exposure compensation
        for (int i = min; i <= max; i += stepsPerEV) {
            runOnLooper(new Runnable() {

                @Override
                public void run() {
                    mCameraTestHelper.setupCameraTest();
                }
            });
            Log.v(TAG, "Setting exposure compensation index to " + i);
            params.setExposureCompensation(i);
            mCameraTestHelper.setParameters(params);
            mCameraTestHelper.startCameraPreview(surfaceHolder);
            mCameraTestHelper.capturePhoto();
        }
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Camera exposure compensation test Exception");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Parameters(android.hardware.Camera.Parameters) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 69 with SurfaceHolder

use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.

the class CameraFunctionalTest method testFunctionalCameraFlashModes.

/**
     * Functional test iterating on the various flash modes (on, off, auto, torch)
     */
@LargeTest
public void testFunctionalCameraFlashModes() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        List<String> supportedFlashModes = params.getSupportedFlashModes();
        assertNotNull("No flash modes supported", supportedFlashModes);
        for (int i = 0; i < supportedFlashModes.size(); i++) {
            runOnLooper(new Runnable() {

                @Override
                public void run() {
                    mCameraTestHelper.setupCameraTest();
                }
            });
            Log.v(TAG, "Setting flash mode to " + supportedFlashModes.get(i));
            params.setFlashMode(supportedFlashModes.get(i));
            mCameraTestHelper.setParameters(params);
            mCameraTestHelper.startCameraPreview(surfaceHolder);
            mCameraTestHelper.capturePhoto();
        }
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Camera flash mode test Exception");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Parameters(android.hardware.Camera.Parameters) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 70 with SurfaceHolder

use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.

the class DisplaySinkService method setSurfaceView.

public void setSurfaceView(final SurfaceView surfaceView) {
    if (mSurfaceView != surfaceView) {
        final SurfaceView oldSurfaceView = mSurfaceView;
        mSurfaceView = surfaceView;
        if (oldSurfaceView != null) {
            oldSurfaceView.post(new Runnable() {

                @Override
                public void run() {
                    final SurfaceHolder holder = oldSurfaceView.getHolder();
                    holder.removeCallback(DisplaySinkService.this);
                    updateSurfaceFromUi(null);
                }
            });
        }
        if (surfaceView != null) {
            surfaceView.post(new Runnable() {

                @Override
                public void run() {
                    final SurfaceHolder holder = surfaceView.getHolder();
                    holder.addCallback(DisplaySinkService.this);
                    updateSurfaceFromUi(holder);
                }
            });
        }
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Aggregations

SurfaceHolder (android.view.SurfaceHolder)189 SurfaceView (android.view.SurfaceView)62 LargeTest (android.test.suitebuilder.annotation.LargeTest)50 Parameters (android.hardware.Camera.Parameters)37 IOException (java.io.IOException)29 MediaPlayer (android.media.MediaPlayer)17 Surface (android.view.Surface)16 SurfaceTexture (android.graphics.SurfaceTexture)14 CamcorderProfile (android.media.CamcorderProfile)13 MediaRecorder (android.media.MediaRecorder)13 Camera (android.hardware.Camera)9 OverlayData (android.media.videoeditor.VideoEditor.OverlayData)9 Paint (android.graphics.Paint)8 AudioManager (android.media.AudioManager)8 SharedPreferences (android.content.SharedPreferences)7 MediaVideoItem (android.media.videoeditor.MediaVideoItem)7 CameraManager (com.google.zxing.client.android.camera.CameraManager)7 Intent (android.content.Intent)6 VideoEditor (android.media.videoeditor.VideoEditor)6 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)6