IRenderView.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2015 Bilibili
  3. * Copyright (C) 2015 Zhang Rui <bbcallen@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.edufound.mobile.ijkplayer.media;
  18. import android.graphics.SurfaceTexture;
  19. import android.support.annotation.NonNull;
  20. import android.support.annotation.Nullable;
  21. import android.view.Surface;
  22. import android.view.SurfaceHolder;
  23. import android.view.View;
  24. import tv.danmaku.ijk.media.player.IMediaPlayer;
  25. public interface IRenderView {
  26. int AR_ASPECT_FIT_PARENT = 0; // without clip
  27. int AR_ASPECT_FILL_PARENT = 1; // may clip
  28. int AR_ASPECT_WRAP_CONTENT = 2;
  29. int AR_MATCH_PARENT = 3;
  30. int AR_16_9_FIT_PARENT = 4;
  31. int AR_4_3_FIT_PARENT = 5;
  32. View getView();
  33. boolean shouldWaitForResize();
  34. void setVideoSize(int videoWidth, int videoHeight);
  35. void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
  36. void setVideoRotation(int degree);
  37. void setAspectRatio(int aspectRatio);
  38. void addRenderCallback(@NonNull IRenderCallback callback);
  39. void removeRenderCallback(@NonNull IRenderCallback callback);
  40. interface ISurfaceHolder {
  41. void bindToMediaPlayer(IMediaPlayer mp);
  42. @NonNull
  43. IRenderView getRenderView();
  44. @Nullable
  45. SurfaceHolder getSurfaceHolder();
  46. @Nullable
  47. Surface openSurface();
  48. @Nullable
  49. SurfaceTexture getSurfaceTexture();
  50. }
  51. interface IRenderCallback {
  52. /**
  53. * @param holder
  54. * @param width could be 0
  55. * @param height could be 0
  56. */
  57. void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
  58. /**
  59. * @param holder
  60. * @param format could be 0
  61. * @param width
  62. * @param height
  63. */
  64. void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
  65. void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
  66. }
  67. }