1/*
2 * Copyright (C) 2015 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
17package com.android.camera.burst;
18
19import android.graphics.SurfaceTexture;
20import android.view.Surface;
21
22import com.android.camera.async.SafeCloseable;
23
24/**
25 * A container that stores the {@link SurfaceTexture} and the stored
26 * {@link Surface} instance together.
27 */
28public class SurfaceTextureContainer implements SafeCloseable {
29    private final SurfaceTexture mSurfaceTexture;
30    private final Surface mSurface;
31
32    public SurfaceTextureContainer(SurfaceTexture surfaceTexture) {
33        mSurfaceTexture = surfaceTexture;
34        mSurface = new Surface(mSurfaceTexture);
35    }
36
37    public SurfaceTexture getSurfaceTexture() {
38        return mSurfaceTexture;
39    }
40
41    public Surface getSurface() {
42        return mSurface;
43    }
44
45    @Override
46    public void close() {
47        mSurfaceTexture.release();
48    }
49}
50