1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_NATIVE_OPENGL2_H_ 12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_NATIVE_OPENGL2_H_ 13 14 #include <jni.h> 15 16 #include "webrtc/modules/video_render/android/video_render_android_impl.h" 17 #include "webrtc/modules/video_render/android/video_render_opengles20.h" 18 #include "webrtc/modules/video_render/video_render_defines.h" 19 20 namespace webrtc { 21 22 class CriticalSectionWrapper; 23 24 class AndroidNativeOpenGl2Channel: public AndroidStream { 25 public: 26 AndroidNativeOpenGl2Channel( 27 uint32_t streamId, 28 JavaVM* jvm, 29 VideoRenderAndroid& renderer,jobject javaRenderObj); 30 ~AndroidNativeOpenGl2Channel(); 31 32 int32_t Init(int32_t zOrder, const float left, const float top, 33 const float right, const float bottom); 34 35 //Implement VideoRenderCallback 36 virtual int32_t RenderFrame(const uint32_t streamId, 37 const VideoFrame& videoFrame); 38 39 //Implements AndroidStream 40 virtual void DeliverFrame(JNIEnv* jniEnv); 41 42 private: 43 static jint JNICALL CreateOpenGLNativeStatic( 44 JNIEnv * env, 45 jobject, 46 jlong context, 47 jint width, 48 jint height); 49 jint CreateOpenGLNative(int width, int height); 50 51 static void JNICALL DrawNativeStatic(JNIEnv * env,jobject, jlong context); 52 void DrawNative(); 53 uint32_t _id; 54 CriticalSectionWrapper& _renderCritSect; 55 56 VideoFrame _bufferToRender; 57 VideoRenderAndroid& _renderer; 58 JavaVM* _jvm; 59 jobject _javaRenderObj; 60 61 jmethodID _redrawCid; 62 jmethodID _registerNativeCID; 63 jmethodID _deRegisterNativeCID; 64 VideoRenderOpenGles20 _openGLRenderer; 65 }; 66 67 68 class AndroidNativeOpenGl2Renderer: private VideoRenderAndroid { 69 public: 70 AndroidNativeOpenGl2Renderer(const int32_t id, 71 const VideoRenderType videoRenderType, 72 void* window, 73 const bool fullscreen); 74 75 ~AndroidNativeOpenGl2Renderer(); 76 static bool UseOpenGL2(void* window); 77 78 int32_t Init(); 79 virtual AndroidStream* CreateAndroidRenderChannel( 80 int32_t streamId, 81 int32_t zOrder, 82 const float left, 83 const float top, 84 const float right, 85 const float bottom, 86 VideoRenderAndroid& renderer); 87 88 private: 89 jobject _javaRenderObj; 90 jclass _javaRenderClass; 91 }; 92 93 } // namespace webrtc 94 95 #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_NATIVE_OPENGL2_H_ 96