ijksdl_android_jni.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*****************************************************************************
  2. * ijksdl_android_jni.h
  3. *****************************************************************************
  4. *
  5. * Copyright (c) 2013 Bilibili
  6. * copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
  7. *
  8. * This file is part of ijkPlayer.
  9. *
  10. * ijkPlayer is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * ijkPlayer is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with ijkPlayer; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #ifndef IJKSDL_ANDROID__IJKSDL_ANDROID_JNI_H
  25. #define IJKSDL_ANDROID__IJKSDL_ANDROID_JNI_H
  26. #include <jni.h>
  27. #include "j4a/j4a_base.h"
  28. #include "j4a/j4a_allclasses.h"
  29. #define IJK_API_1_BASE 1 // 1.0
  30. #define IJK_API_2_BASE_1_1 2 // 1.1
  31. #define IJK_API_3_CUPCAKE 3 // 1.5
  32. #define IJK_API_4_DONUT 4 // 1.6
  33. #define IJK_API_5_ECLAIR 5 // 2.0
  34. #define IJK_API_6_ECLAIR_0_1 6 // 2.0.1
  35. #define IJK_API_7_ECLAIR_MR1 7 // 2.1
  36. #define IJK_API_8_FROYO 8 // 2.2
  37. #define IJK_API_9_GINGERBREAD 9 // 2.3
  38. #define IJK_API_10_GINGERBREAD_MR1 10 // 2.3.3
  39. #define IJK_API_11_HONEYCOMB 11 // 3.0
  40. #define IJK_API_12_HONEYCOMB_MR1 12 // 3.1
  41. #define IJK_API_13_HONEYCOMB_MR2 13 // 3.2
  42. #define IJK_API_14_ICE_CREAM_SANDWICH 14 // 4.0
  43. #define IJK_API_15_ICE_CREAM_SANDWICH_MR1 15 // 4.0.3
  44. #define IJK_API_16_JELLY_BEAN 16 // 4.1
  45. #define IJK_API_17_JELLY_BEAN_MR1 17 // 4.2
  46. #define IJK_API_18_JELLY_BEAN_MR2 18 // 4.3
  47. #define IJK_API_19_KITKAT 19 // 4.4
  48. #define IJK_API_20_KITKAT_WATCH 20 // 4.4W
  49. #define IJK_API_21_LOLLIPOP 21 // 5.0
  50. #define IJK_API_22_LOLLIPOP_MR1 22 // 5.1
  51. #define IJK_API_23_M 23 // 6.0
  52. JavaVM *SDL_JNI_GetJvm();
  53. jint SDL_JNI_SetupThreadEnv(JNIEnv **p_env);
  54. void SDL_JNI_DetachThreadEnv();
  55. int SDL_JNI_ThrowException(JNIEnv *env, const char *exception, const char* msg);
  56. int SDL_JNI_ThrowIllegalStateException(JNIEnv *env, const char* msg);
  57. jobject SDL_JNI_NewObjectAsGlobalRef(JNIEnv *env, jclass clazz, jmethodID methodID, ...);
  58. void SDL_JNI_DeleteGlobalRefP(JNIEnv *env, jobject *obj_ptr);
  59. void SDL_JNI_DeleteLocalRefP(JNIEnv *env, jobject *obj_ptr);
  60. int SDL_Android_GetApiLevel();
  61. #define IJK_FIND_JAVA_CLASS(env__, var__, classsign__) \
  62. do { \
  63. jclass clazz = (*env__)->FindClass(env__, classsign__); \
  64. if (J4A_ExceptionCheck__catchAll(env) || !(clazz)) { \
  65. ALOGE("FindClass failed: %s", classsign__); \
  66. return -1; \
  67. } \
  68. var__ = (*env__)->NewGlobalRef(env__, clazz); \
  69. if (J4A_ExceptionCheck__catchAll(env) || !(var__)) { \
  70. ALOGE("FindClass::NewGlobalRef failed: %s", classsign__); \
  71. (*env__)->DeleteLocalRef(env__, clazz); \
  72. return -1; \
  73. } \
  74. (*env__)->DeleteLocalRef(env__, clazz); \
  75. } while(0);
  76. #define JNI_CHECK_GOTO(condition__, env__, exception__, msg__, label__) \
  77. do { \
  78. if (!(condition__)) { \
  79. if (exception__) { \
  80. SDL_JNI_ThrowException(env__, exception__, msg__); \
  81. } \
  82. goto label__; \
  83. } \
  84. }while(0)
  85. #define JNI_CHECK_RET_VOID(condition__, env__, exception__, msg__) \
  86. do { \
  87. if (!(condition__)) { \
  88. if (exception__) { \
  89. SDL_JNI_ThrowException(env__, exception__, msg__); \
  90. } \
  91. return; \
  92. } \
  93. }while(0)
  94. #define JNI_CHECK_RET(condition__, env__, exception__, msg__, ret__) \
  95. do { \
  96. if (!(condition__)) { \
  97. if (exception__) { \
  98. SDL_JNI_ThrowException(env__, exception__, msg__); \
  99. } \
  100. return ret__; \
  101. } \
  102. }while(0)
  103. #endif