ijksdl_vout.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*****************************************************************************
  2. * ijksdl_vout.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.h"
  25. #include <stdlib.h>
  26. #include <assert.h>
  27. #if defined(__ANDROID__)
  28. #include <android/native_window_jni.h>
  29. #endif
  30. void SDL_VoutFree(SDL_Vout *vout)
  31. {
  32. if (!vout)
  33. return;
  34. if (vout->free_l) {
  35. vout->free_l(vout);
  36. } else {
  37. free(vout);
  38. }
  39. }
  40. void SDL_VoutFreeP(SDL_Vout **pvout)
  41. {
  42. if (!pvout)
  43. return;
  44. SDL_VoutFree(*pvout);
  45. *pvout = NULL;
  46. }
  47. int SDL_VoutDisplayYUVOverlay(SDL_Vout *vout, SDL_VoutOverlay *overlay)
  48. {
  49. if (vout && overlay && vout->display_overlay)
  50. return vout->display_overlay(vout, overlay);
  51. return -1;
  52. }
  53. int SDL_VoutSetOverlayFormat(SDL_Vout *vout, Uint32 overlay_format)
  54. {
  55. if (!vout)
  56. return -1;
  57. vout->overlay_format = overlay_format;
  58. return 0;
  59. }
  60. SDL_VoutOverlay *SDL_Vout_CreateOverlay(int width, int height, int frame_format, SDL_Vout *vout)
  61. {
  62. if (vout && vout->create_overlay)
  63. return vout->create_overlay(width, height, frame_format, vout);
  64. return NULL;
  65. }
  66. int SDL_VoutLockYUVOverlay(SDL_VoutOverlay *overlay)
  67. {
  68. if (overlay && overlay->lock)
  69. return overlay->lock(overlay);
  70. return -1;
  71. }
  72. int SDL_VoutUnlockYUVOverlay(SDL_VoutOverlay *overlay)
  73. {
  74. if (overlay && overlay->unlock)
  75. return overlay->unlock(overlay);
  76. return -1;
  77. }
  78. void SDL_VoutFreeYUVOverlay(SDL_VoutOverlay *overlay)
  79. {
  80. if (!overlay)
  81. return;
  82. if (overlay->free_l) {
  83. overlay->free_l(overlay);
  84. } else {
  85. free(overlay);
  86. }
  87. }
  88. void SDL_VoutUnrefYUVOverlay(SDL_VoutOverlay *overlay)
  89. {
  90. if (overlay && overlay->unref)
  91. overlay->unref(overlay);
  92. }
  93. int SDL_VoutFillFrameYUVOverlay(SDL_VoutOverlay *overlay, const AVFrame *frame)
  94. {
  95. if (!overlay || !overlay->func_fill_frame)
  96. return -1;
  97. return overlay->func_fill_frame(overlay, frame);
  98. }