1 /* 2 * Copyright (C) 2017 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 #ifndef VIDEOTEX_H 17 #define VIDEOTEX_H 18 19 #include "StreamHandler.h" 20 #include "TexWrapper.h" 21 22 #include <EGL/egl.h> 23 #include <EGL/eglext.h> 24 #include <GLES2/gl2.h> 25 #include <GLES2/gl2ext.h> 26 #include <GLES3/gl3.h> 27 #include <GLES3/gl3ext.h> 28 29 #include <android/hardware/automotive/evs/1.1/IEvsEnumerator.h> 30 #include <android/hardware/camera/device/3.2/ICameraDevice.h> 31 #include <system/graphics-base.h> 32 33 using ::android::hardware::camera::device::V3_2::Stream; 34 using namespace ::android::hardware::automotive::evs::V1_1; 35 36 37 class VideoTex: public TexWrapper { 38 friend VideoTex* createVideoTexture(sp<IEvsEnumerator> pEnum, 39 const char *evsCameraId, 40 std::unique_ptr<Stream> streamCfg, 41 EGLDisplay glDisplay, 42 bool useExternalMemory, 43 android_pixel_format_t format); 44 45 public: 46 VideoTex() = delete; 47 virtual ~VideoTex(); 48 49 bool refresh(); // returns true if the texture contents were updated 50 51 private: 52 VideoTex(sp<IEvsEnumerator> pEnum, 53 sp<IEvsCamera> pCamera, 54 sp<StreamHandler> pStreamHandler, 55 EGLDisplay glDisplay); 56 57 sp<IEvsEnumerator> mEnumerator; 58 sp<IEvsCamera> mCamera; 59 sp<StreamHandler> mStreamHandler; 60 BufferDesc mImageBuffer; 61 62 EGLDisplay mDisplay; 63 EGLImageKHR mKHRimage = EGL_NO_IMAGE_KHR; 64 }; 65 66 67 // Creates a video texture to draw the camera preview. format is effective only 68 // when useExternalMemory is true. 69 VideoTex* createVideoTexture(sp<IEvsEnumerator> pEnum, 70 const char * deviceName, 71 std::unique_ptr<Stream> streamCfg, 72 EGLDisplay glDisplay, 73 bool useExternalMemory = false, 74 android_pixel_format_t format = HAL_PIXEL_FORMAT_RGBA_8888); 75 76 #endif // VIDEOTEX_H 77