1 /* 2 * Copyright (C) 2012 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.example.android.rs.sto; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.provider.Settings.System; 22 import android.util.Log; 23 import android.view.View; 24 import android.graphics.SurfaceTexture; 25 26 import java.lang.Runtime; 27 28 public class SurfaceTextureOpaque extends Activity { 29 private SurfaceTextureOpaqueView mView; 30 CameraCapture mCC; 31 32 @Override 33 public void onCreate(Bundle icicle) { 34 super.onCreate(icicle); 35 36 mView = new SurfaceTextureOpaqueView(this); 37 setContentView(mView); 38 } 39 40 @Override 41 protected void onResume() { 42 super.onResume(); 43 mView.resume(); 44 startCamera(); 45 } 46 47 @Override 48 protected void onPause() { 49 super.onPause(); 50 mView.pause(); 51 mCC.endCapture(); 52 } 53 54 cfl mCFL; 55 public void startCamera() { 56 mCC = new CameraCapture(); 57 mCFL = new cfl(); 58 59 mCC.setCameraFrameListener(mCFL); 60 61 mCC.beginCapture(1, 640, 480, mView.getST()); 62 } 63 64 public class cfl implements CameraCapture.CameraFrameListener { 65 public void onNewCameraFrame() { 66 mView.mRender.newFrame(); 67 } 68 } 69 70 } 71 72