Search in sources :

Example 36 with SurfaceHolder

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

the class RSSurfaceView 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);
}
Also used : SurfaceHolder(android.view.SurfaceHolder)

Example 37 with SurfaceHolder

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

the class Camera2SurfaceViewTestCase method updatePreviewSurface.

/**
     * Update the preview surface size.
     *
     * @param size The preview size to be updated.
     */
protected void updatePreviewSurface(Size size) {
    if (size.equals(mPreviewSize) && mPreviewSurface != null) {
        Log.w(TAG, "Skipping update preview surface size...");
        return;
    }
    mPreviewSize = size;
    Camera2SurfaceViewActivity ctsActivity = getActivity();
    final SurfaceHolder holder = ctsActivity.getSurfaceView().getHolder();
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        @Override
        public void run() {
            holder.setFixedSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
        }
    });
    boolean res = ctsActivity.waitForSurfaceSizeChanged(WAIT_FOR_SURFACE_CHANGE_TIMEOUT_MS, mPreviewSize.getWidth(), mPreviewSize.getHeight());
    assertTrue("wait for surface change to " + mPreviewSize.toString() + " timed out", res);
    mPreviewSurface = holder.getSurface();
    assertNotNull("Preview surface is null", mPreviewSurface);
    assertTrue("Preview surface is invalid", mPreviewSurface.isValid());
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Handler(android.os.Handler)

Example 38 with SurfaceHolder

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

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

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

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

use of android.view.SurfaceHolder in project weex-example by KalicyZhou.

the class CaptureActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    // historyManager must be initialized here to update the history
    // preference
    historyManager = new HistoryManager(this);
    historyManager.trimHistory();
    // CameraManager must be initialized here, not in onCreate(). This is
    // necessary because we don't
    // want to open the camera driver and measure the screen size if we're
    // going to show the help on
    // first launch. That led to bugs where the scanning rectangle was the
    // wrong size and partially
    // off screen.
    cameraManager = new CameraManager(getApplication());
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    viewfinderView.setCameraManager(cameraManager);
    resultView = findViewById(R.id.result_view);
    statusView = (TextView) findViewById(R.id.status_view);
    handler = null;
    lastResult = null;
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    //		if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION,
    //				true)) {
    //			setRequestedOrientation(getCurrentOrientation());
    //		} else {
    //			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    //		}
    resetStatusView();
    beepManager.updatePrefs();
    ambientLightManager.start(cameraManager);
    inactivityTimer.onResume();
    Intent intent = getIntent();
    copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true));
    source = IntentSource.NONE;
    sourceUrl = null;
    scanFromWebPageManager = null;
    decodeFormats = null;
    characterSet = null;
    if (intent != null) {
        String action = intent.getAction();
        String dataString = intent.getDataString();
        if (Intents.Scan.ACTION.equals(action)) {
            // Scan the formats the intent requested, and return the result
            // to the calling activity.
            source = IntentSource.NATIVE_APP_INTENT;
            decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
            decodeHints = DecodeHintManager.parseDecodeHints(intent);
            if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) {
                int width = intent.getIntExtra(Intents.Scan.WIDTH, 0);
                int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0);
                if (width > 0 && height > 0) {
                    cameraManager.setManualFramingRect(width, height);
                }
            }
            if (intent.hasExtra(Intents.Scan.CAMERA_ID)) {
                int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1);
                if (cameraId >= 0) {
                    cameraManager.setManualCameraId(cameraId);
                }
            }
            String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE);
            if (customPromptMessage != null) {
                statusView.setText(customPromptMessage);
            }
        } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) {
            // Scan only products and send the result to mobile Product
            // Search.
            source = IntentSource.PRODUCT_SEARCH_LINK;
            sourceUrl = dataString;
            decodeFormats = DecodeFormatManager.PRODUCT_FORMATS;
        } else if (isZXingURL(dataString)) {
            // Scan formats requested in query string (all formats if none
            // specified).
            // If a return URL is specified, send the results there.
            // Otherwise, handle it ourselves.
            source = IntentSource.ZXING_LINK;
            sourceUrl = dataString;
            Uri inputUri = Uri.parse(dataString);
            scanFromWebPageManager = new ScanFromWebPageManager(inputUri);
            decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri);
            // Allow a sub-set of the hints to be specified by the caller.
            decodeHints = DecodeHintManager.parseDecodeHints(inputUri);
        }
        characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);
    }
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        // The activity was paused but not stopped, so the surface still
        // exists. Therefore
        // surfaceCreated() won't be called, so init the camera here.
        initCamera(surfaceHolder);
    } else {
        // Install the callback and wait for surfaceCreated() to init the
        // camera.
        surfaceHolder.addCallback(this);
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SharedPreferences(android.content.SharedPreferences) HistoryManager(com.google.zxing.client.android.history.HistoryManager) CameraManager(com.google.zxing.client.android.camera.CameraManager) Intent(android.content.Intent) Uri(android.net.Uri) ResultPoint(com.google.zxing.ResultPoint) Paint(android.graphics.Paint) 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