Search in sources :

Example 41 with SurfaceHolder

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

the class GLSurfaceView method init.

private void init() {
    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed
    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
// setFormat is done by SurfaceView in SDK 2.3 and newer. Uncomment
// this statement if back-porting to 2.2 or older:
// holder.setFormat(PixelFormat.RGB_565);
//
// setType is not needed for SDK 2.0 or newer. Uncomment this
// statement if back-porting this code to older SDKs.
// holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
}
Also used : SurfaceHolder(android.view.SurfaceHolder)

Example 42 with SurfaceHolder

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

the class EGLImpl method eglCreateWindowSurface.

public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
    Surface sur = null;
    if (native_window instanceof SurfaceView) {
        SurfaceView surfaceView = (SurfaceView) native_window;
        sur = surfaceView.getHolder().getSurface();
    } else if (native_window instanceof SurfaceHolder) {
        SurfaceHolder holder = (SurfaceHolder) native_window;
        sur = holder.getSurface();
    } else if (native_window instanceof Surface) {
        sur = (Surface) native_window;
    }
    long eglSurfaceId;
    if (sur != null) {
        eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
    } else if (native_window instanceof SurfaceTexture) {
        eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, native_window, attrib_list);
    } else {
        throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.");
    }
    if (eglSurfaceId == 0) {
        return EGL10.EGL_NO_SURFACE;
    }
    return new EGLSurfaceImpl(eglSurfaceId);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceTexture(android.graphics.SurfaceTexture) SurfaceView(android.view.SurfaceView) Surface(android.view.Surface)

Example 43 with SurfaceHolder

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

the class CameraFunctionalTest method testFunctionalCameraFocusModes.

/**
     * Functional test iterating on the various focus modes (auto, infinitiy, macro, etc.)
     */
@LargeTest
public void testFunctionalCameraFocusModes() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        List<String> supportedFocusModes = params.getSupportedFocusModes();
        assertNotNull("No focus modes supported", supportedFocusModes);
        for (int i = 0; i < supportedFocusModes.size(); i++) {
            runOnLooper(new Runnable() {

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

Example 44 with SurfaceHolder

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

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 45 with SurfaceHolder

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

the class CameraPairwiseTest method genericPairwiseTestCase.

/**
     * Generic pairwise test method
     */
private void genericPairwiseTestCase(Flash flash, Exposure exposure, WhiteBalance whitebalance, SceneMode scenemode, PictureSize picturesize, Geotagging geotagging) throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Camera.Parameters params = mCameraTestHelper.getCameraParameters();
        runOnLooper(new Runnable() {

            @Override
            public void run() {
                mCameraTestHelper.setupCameraTest();
            }
        });
        // Configure flash setting
        switch(flash) {
            case ON:
                params.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
                break;
            case OFF:
                params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                break;
            case AUTO:
                params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
                break;
        }
        // Configure exposure setting
        switch(exposure) {
            case MIN:
                params.setExposureCompensation(params.getMinExposureCompensation());
                break;
            case MAX:
                params.setExposureCompensation(params.getMaxExposureCompensation());
                break;
            case NONE:
                params.setExposureCompensation(0);
                break;
        }
        // Configure white balance setting
        switch(whitebalance) {
            case DAYLIGHT:
                params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_DAYLIGHT);
                break;
            case FLUORESCENT:
                params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_FLUORESCENT);
                break;
            case INCANDESCENT:
                params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_INCANDESCENT);
                break;
            case CLOUDY:
                params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
                break;
            case AUTO:
                params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO);
                break;
        }
        // Configure scene mode setting
        switch(scenemode) {
            case SUNSET:
                params.setSceneMode(Camera.Parameters.SCENE_MODE_SUNSET);
                break;
            case ACTION:
                params.setSceneMode(Camera.Parameters.SCENE_MODE_ACTION);
                break;
            case PARTY:
                params.setSceneMode(Camera.Parameters.SCENE_MODE_PARTY);
                break;
            case NIGHT:
                params.setSceneMode(Camera.Parameters.SCENE_MODE_NIGHT);
                break;
            case AUTO:
                params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
                break;
        }
        // Configure picture size setting
        List<Camera.Size> supportedPictureSizes = params.getSupportedPictureSizes();
        int mid = (int) Math.floor(supportedPictureSizes.size() / 2);
        int low = supportedPictureSizes.size() - 1;
        switch(picturesize) {
            case SMALL:
                params.setPictureSize(supportedPictureSizes.get(low).width, supportedPictureSizes.get(low).height);
                break;
            case MEDIUM:
                params.setPictureSize(supportedPictureSizes.get(mid).width, supportedPictureSizes.get(mid).height);
                break;
            case LARGE:
                params.setPictureSize(supportedPictureSizes.get(0).width, supportedPictureSizes.get(mid).height);
                break;
        }
        // Configure geotagging setting
        switch(geotagging) {
            case ON:
                params.setGpsLatitude(MOCK_LATITUDE);
                params.setGpsLongitude(MOCK_LONGITUDE);
                break;
            case OFF:
                break;
        }
        mCameraTestHelper.setParameters(params);
        mCameraTestHelper.startCameraPreview(surfaceHolder);
        mCameraTestHelper.capturePhoto();
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Test case failed");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Camera(android.hardware.Camera)

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