1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.camera.burst; 18 19 import android.content.Context; 20 import android.graphics.SurfaceTexture; 21 import android.view.Surface; 22 23 import com.android.camera.app.OrientationManager.DeviceOrientation; 24 import com.android.camera.one.OneCamera.Facing; 25 import com.android.camera.session.CaptureSession; 26 27 /** 28 * Factory for creating burst manager objects. 29 */ 30 public class BurstFacadeFactory { BurstFacadeFactory()31 private BurstFacadeFactory() { 32 /* cannot be instantiated */ 33 } 34 35 /** 36 * An empty burst manager that is instantiated when burst is not supported. 37 * <p> 38 * It keeps a hold of the current surface texture so it can be used when 39 * burst is not enabled. 40 */ 41 public static class BurstFacadeStub implements BurstFacade { 42 @Override startBurst(CaptureSession.CaptureSessionCreator captureSessionCreator, DeviceOrientation deviceOrientation, Facing cameraFacing, int imageOrientationDegrees)43 public void startBurst(CaptureSession.CaptureSessionCreator captureSessionCreator, 44 DeviceOrientation deviceOrientation, Facing cameraFacing, 45 int imageOrientationDegrees) { 46 } 47 48 @Override stopBurst()49 public boolean stopBurst() { 50 return false; 51 } 52 53 @Override initialize(SurfaceTexture surfaceTexture)54 public void initialize(SurfaceTexture surfaceTexture) {} 55 56 @Override release()57 public void release() {} 58 59 @Override getInputSurface()60 public Surface getInputSurface() { 61 return null; 62 } 63 64 @Override setBurstTaker(BurstTaker burstTaker)65 public void setBurstTaker(BurstTaker burstTaker) {} 66 } 67 68 /** 69 * Creates and returns an instance of {@link BurstFacade} 70 * 71 * @param appContext the Android application context which is passes through 72 * to the burst controller. 73 * @param orientationController for locking orientation when burst is running. 74 * @param readyStateListener gets called when the ready state of Burst 75 * changes. 76 */ create(Context appContext, OrientationLockController orientationController, BurstReadyStateChangeListener readyStateListener)77 public static BurstFacade create(Context appContext, 78 OrientationLockController orientationController, 79 BurstReadyStateChangeListener readyStateListener) { 80 if (BurstControllerImpl.isBurstModeSupported(appContext.getContentResolver())) { 81 BurstFacade burstController = new BurstFacadeImpl(appContext, orientationController, 82 readyStateListener); 83 ToastingBurstFacadeDecorator.BurstToaster toaster = 84 new ToastingBurstFacadeDecorator.BurstToaster(appContext); 85 return new ToastingBurstFacadeDecorator(burstController, toaster); 86 } else { 87 // Burst is not supported return a stub instance. 88 return new BurstFacadeStub(); 89 } 90 } 91 } 92