1 /*
2  opengles_display.h
3  Copyright (C) 2017 Belledonne Communications, Grenoble, France
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19 
20 #ifndef OPENGLES_DISPLAY_H
21 #define OPENGLES_DISPLAY_H
22 
23 #include "mediastreamer2/msvideo.h"
24 #include "mediastreamer2/msfilter.h"
25 
26 #include "opengl_functions.h"
27 
28 struct opengles_display;
29 
30 /**
31  * Create opaque structure to handle OpenGL display
32  */
33 struct opengles_display *ogl_display_new (void);
34 
35 /**
36  * Release opaque struct memory
37  */
38 void ogl_display_free (struct opengles_display *gldisp);
39 
40 /**
41  * Perform initialization of opaque structure.
42  *
43  * @param f OpenGL functions to use. Can be NULL.
44  * @param width Width of the display area
45  * @param height Height of the display area.
46  */
47 void ogl_display_init (struct opengles_display *gldisp, const OpenGlFunctions *f, int width, int height);
48 
49 /**
50  * Perform resize of opaque structure.
51  *
52  * Must be called every time the display area dimensions change
53  *
54  * @param width Width of the display area
55  * @param height Height of the display area.
56  */
57 void ogl_display_set_size (struct opengles_display *gldisp, int width, int height);
58 
59 /**
60  * Uninit opaque structure.
61  *
62  * @param freeGLresources Are we allowed to release GL resources. GL resources
63  * must only be freed within the correct GL context.
64  */
65 void ogl_display_uninit (struct opengles_display *gldisp, bool_t freeGLresources);
66 
67 /**
68  * Define the next yuv image to display. Note that yuv content will be copied.
69  */
70 void ogl_display_set_yuv_to_display (struct opengles_display *gldisp, mblk_t *yuv);
71 
72 /**
73  * Define the next preview image to diaplsy. Note that yuv its content will be copied.
74  */
75 void ogl_display_set_preview_yuv_to_display (struct opengles_display *gldisp, mblk_t *yuv);
76 
77 void ogl_display_render (struct opengles_display *gldisp, int deviceAngleFromPortrait);
78 
79 /**
80  * @params contains the zoom parameters: [0] = zoom_factor, [1][2] = zoom center x/y (between [0,1], relative coords to the gl surface. 0.5/0.5 = center)
81  */
82 void ogl_display_zoom (struct opengles_display *gldisp, float *params);
83 
84 #ifdef __ANDROID__
85 #include <jni.h>
86 JNIEXPORT void JNICALL Java_org_linphone_mediastream_video_display_OpenGLESDisplay_init (JNIEnv * env, jobject obj, jlong ptr, jint width, jint height);
87 JNIEXPORT void JNICALL Java_org_linphone_mediastream_video_display_OpenGLESDisplay_render (JNIEnv * env, jobject obj, jlong ptr);
88 #endif
89 
90 #endif
91