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 <EGL/egl.h>
20 #include <EGL/eglext.h>
21 #include <GLES2/gl2.h>
22 #include <GLES2/gl2ext.h>
23 #include <GLES3/gl3.h>
24 #include <GLES3/gl3ext.h>
25 
26 #include <android/hardware/automotive/evs/1.0/IEvsEnumerator.h>
27 
28 #include "TexWrapper.h"
29 #include "StreamHandler.h"
30 
31 
32 using namespace ::android::hardware::automotive::evs::V1_0;
33 
34 
35 class VideoTex: public TexWrapper {
36     friend VideoTex* createVideoTexture(sp<IEvsEnumerator> pEnum,
37                                         const char * evsCameraId,
38                                         EGLDisplay glDisplay);
39 
40 public:
41     VideoTex() = delete;
42     virtual ~VideoTex();
43 
44     bool refresh();     // returns true if the texture contents were updated
45 
46 private:
47     VideoTex(sp<IEvsEnumerator> pEnum,
48              sp<IEvsCamera> pCamera,
49              sp<StreamHandler> pStreamHandler,
50              EGLDisplay glDisplay);
51 
52     sp<IEvsEnumerator>  mEnumerator;
53     sp<IEvsCamera>      mCamera;
54     sp<StreamHandler>   mStreamHandler;
55     BufferDesc          mImageBuffer;
56 
57     EGLDisplay          mDisplay;
58     EGLImageKHR mKHRimage = EGL_NO_IMAGE_KHR;
59 };
60 
61 
62 VideoTex* createVideoTexture(sp<IEvsEnumerator> pEnum,
63                              const char * deviceName,
64                              EGLDisplay glDisplay);
65 
66 #endif // VIDEOTEX_H