ijksdl_vout_android_surface.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*****************************************************************************
  2. * ijksdl_vout_android_surface.c
  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. #include "ijksdl_vout_android_surface.h"
  25. #include <android/native_window_jni.h>
  26. #include "../ijksdl_inc_internal.h"
  27. #include "ijksdl_android_jni.h"
  28. #include "ijksdl_vout_android_nativewindow.h"
  29. SDL_Vout *SDL_VoutAndroid_CreateForAndroidSurface()
  30. {
  31. return SDL_VoutAndroid_CreateForANativeWindow();
  32. }
  33. void SDL_VoutAndroid_SetAndroidSurface(JNIEnv *env, SDL_Vout *vout, jobject android_surface)
  34. {
  35. ANativeWindow *native_window = NULL;
  36. if (android_surface) {
  37. native_window = ANativeWindow_fromSurface(env, android_surface);
  38. if (!native_window) {
  39. ALOGE("%s: ANativeWindow_fromSurface: failed\n", __func__);
  40. // do not return fail here;
  41. }
  42. }
  43. SDL_VoutAndroid_SetNativeWindow(vout, native_window);
  44. if (native_window)
  45. ANativeWindow_release(native_window);
  46. }