Home | History | Annotate | Download | only in android
      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/include/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(
     37       const uint32_t streamId,
     38       I420VideoFrame& videoFrame);
     39 
     40   //Implements AndroidStream
     41   virtual void DeliverFrame(JNIEnv* jniEnv);
     42 
     43  private:
     44   static jint CreateOpenGLNativeStatic(
     45       JNIEnv * env,
     46       jobject,
     47       jlong context,
     48       jint width,
     49       jint height);
     50   jint CreateOpenGLNative(int width, int height);
     51 
     52   static void DrawNativeStatic(JNIEnv * env,jobject, jlong context);
     53   void DrawNative();
     54   uint32_t _id;
     55   CriticalSectionWrapper& _renderCritSect;
     56 
     57   I420VideoFrame _bufferToRender;
     58   VideoRenderAndroid& _renderer;
     59   JavaVM*     _jvm;
     60   jobject     _javaRenderObj;
     61 
     62   jmethodID      _redrawCid;
     63   jmethodID      _registerNativeCID;
     64   jmethodID      _deRegisterNativeCID;
     65   VideoRenderOpenGles20 _openGLRenderer;
     66 };
     67 
     68 
     69 class AndroidNativeOpenGl2Renderer: private VideoRenderAndroid {
     70  public:
     71   AndroidNativeOpenGl2Renderer(const int32_t id,
     72                                const VideoRenderType videoRenderType,
     73                                void* window,
     74                                const bool fullscreen);
     75 
     76   ~AndroidNativeOpenGl2Renderer();
     77   static bool UseOpenGL2(void* window);
     78 
     79   int32_t Init();
     80   virtual AndroidStream* CreateAndroidRenderChannel(
     81       int32_t streamId,
     82       int32_t zOrder,
     83       const float left,
     84       const float top,
     85       const float right,
     86       const float bottom,
     87       VideoRenderAndroid& renderer);
     88 
     89  private:
     90   jobject _javaRenderObj;
     91   jclass _javaRenderClass;
     92 };
     93 
     94 }  // namespace webrtc
     95 
     96 #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_NATIVE_OPENGL2_H_
     97