MediaPlayerEditor_Android.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4. //-----------------------------------------------------------------------------
  5. // Copyright 2015-2021 RenderHeads Ltd. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. namespace RenderHeads.Media.AVProVideo.Editor
  8. {
  9. /// <summary>
  10. /// Editor for the MediaPlayer component
  11. /// </summary>
  12. public partial class MediaPlayerEditor : UnityEditor.Editor
  13. {
  14. private readonly static GUIContent[] _audioModesAndroid =
  15. {
  16. new GUIContent("System Direct"),
  17. new GUIContent("Unity"),
  18. new GUIContent("Facebook Audio 360", "Initialises player with Facebook Audio 360 support"),
  19. };
  20. private readonly static GUIContent[] _blitTextureFilteringAndroid =
  21. {
  22. new GUIContent("Point"),
  23. new GUIContent("Bilinear"),
  24. new GUIContent("Trilinear"),
  25. };
  26. private readonly static FieldDescription _optionFileOffset = new FieldDescription(".fileOffset", GUIContent.none);
  27. private readonly static FieldDescription _optionUseFastOesPath = new FieldDescription(".useFastOesPath", new GUIContent("Use OES Rendering", "Enables a faster rendering path using OES textures. This requires that all rendering in Unity uses special GLSL shaders."));
  28. private readonly static FieldDescription _optionBlitTextureFiltering = new FieldDescription(".blitTextureFiltering", new GUIContent("Blit Texture Filtering", "The texture filtering used for the final internal blit."));
  29. private readonly static FieldDescription _optionShowPosterFrames = new FieldDescription(".showPosterFrame", new GUIContent("Show Poster Frame", "Allows a paused loaded video to display the initial frame. This uses up decoder resources."));
  30. private readonly static FieldDescription _optionPreferSoftwareDecoder = new FieldDescription(".preferSoftwareDecoder", GUIContent.none);
  31. private readonly static FieldDescription _optionPreferredMaximumResolution = new FieldDescription("._preferredMaximumResolution", new GUIContent("Preferred Maximum Resolution", "The desired maximum resolution of the video."));
  32. #if UNITY_2017_2_OR_NEWER
  33. private readonly static FieldDescription _optionCustomPreferredMaxResolution = new FieldDescription("._customPreferredMaximumResolution", new GUIContent(" "));
  34. #endif
  35. private readonly static FieldDescription _optionCustomPreferredPeakBitRate = new FieldDescription("._preferredPeakBitRate", new GUIContent("Preferred Peak BitRate", "The desired limit of network bandwidth consumption for playback, set to 0 for no preference."));
  36. private readonly static FieldDescription _optionCustomPreferredPeakBitRateUnits = new FieldDescription("._preferredPeakBitRateUnits", new GUIContent());
  37. private readonly static FieldDescription _optionMinBufferMs = new FieldDescription(".minBufferMs", new GUIContent("Minimum Buffer Ms"));
  38. private readonly static FieldDescription _optionMaxBufferMs = new FieldDescription(".maxBufferMs", new GUIContent("Maximum Buffer Ms"));
  39. private readonly static FieldDescription _optionBufferForPlaybackMs = new FieldDescription(".bufferForPlaybackMs", new GUIContent("Buffer For Playback Ms"));
  40. private readonly static FieldDescription _optionBufferForPlaybackAfterRebufferMs = new FieldDescription(".bufferForPlaybackAfterRebufferMs", new GUIContent("Buffer For Playback After Rebuffer Ms"));
  41. private void OnInspectorGUI_Override_Android()
  42. {
  43. //MediaPlayer media = (this.target) as MediaPlayer;
  44. //MediaPlayer.OptionsAndroid options = media._optionsAndroid;
  45. GUILayout.Space(8f);
  46. string optionsVarName = MediaPlayer.GetPlatformOptionsVariable(Platform.Android);
  47. {
  48. EditorGUILayout.BeginVertical(GUI.skin.box);
  49. DisplayPlatformOption(optionsVarName, _optionVideoAPI);
  50. {
  51. SerializedProperty propFileOffset = DisplayPlatformOption(optionsVarName, _optionFileOffset);
  52. propFileOffset.intValue = Mathf.Max(0, propFileOffset.intValue);
  53. }
  54. {
  55. SerializedProperty propUseFastOesPath = DisplayPlatformOption(optionsVarName, _optionUseFastOesPath);
  56. if (propUseFastOesPath.boolValue)
  57. {
  58. EditorHelper.IMGUI.NoticeBox(MessageType.Info, "OES can require special shaders. Make sure you assign an AVPro Video OES shader to your meshes/materials that need to display video.");
  59. // PlayerSettings.virtualRealitySupported is deprecated from 2019.3
  60. #if !UNITY_2019_3_OR_NEWER
  61. if (PlayerSettings.virtualRealitySupported)
  62. #endif
  63. {
  64. if (PlayerSettings.stereoRenderingPath != StereoRenderingPath.MultiPass)
  65. {
  66. EditorHelper.IMGUI.NoticeBox(MessageType.Error, "OES only supports multi-pass stereo rendering path, please change in Player Settings.");
  67. }
  68. }
  69. EditorHelper.IMGUI.NoticeBox(MessageType.Warning, "OES is not supported in the trial version. If your Android plugin is not trial then you can ignore this warning.");
  70. }
  71. }
  72. {
  73. SerializedProperty propBlitTextureFiltering = DisplayPlatformOptionEnum(optionsVarName, _optionBlitTextureFiltering, _blitTextureFilteringAndroid);
  74. propBlitTextureFiltering.intValue = Mathf.Max(0, propBlitTextureFiltering.intValue);
  75. }
  76. EditorGUILayout.EndVertical();
  77. }
  78. if (_showUltraOptions)
  79. {
  80. SerializedProperty httpHeadersProp = serializedObject.FindProperty(optionsVarName + ".httpHeaders.httpHeaders");
  81. if (httpHeadersProp != null)
  82. {
  83. OnInspectorGUI_HttpHeaders(httpHeadersProp);
  84. }
  85. SerializedProperty keyAuthProp = serializedObject.FindProperty(optionsVarName + ".keyAuth");
  86. if (keyAuthProp != null)
  87. {
  88. OnInspectorGUI_HlsDecryption(keyAuthProp);
  89. }
  90. }
  91. // MediaPlayer API options
  92. {
  93. EditorGUILayout.BeginVertical(GUI.skin.box);
  94. GUILayout.Label("MediaPlayer API Options", EditorStyles.boldLabel);
  95. DisplayPlatformOption(optionsVarName, _optionShowPosterFrames);
  96. EditorGUILayout.EndVertical();
  97. }
  98. // ExoPlayer API options
  99. {
  100. EditorGUILayout.BeginVertical(GUI.skin.box);
  101. GUILayout.Label("ExoPlayer API Options", EditorStyles.boldLabel);
  102. DisplayPlatformOption(optionsVarName, _optionPreferSoftwareDecoder);
  103. // Audio
  104. {
  105. SerializedProperty propAudioOutput = DisplayPlatformOptionEnum(optionsVarName, _optionAudioOutput, _audioModesAndroid);
  106. if ((Android.AudioOutput)propAudioOutput.enumValueIndex == Android.AudioOutput.FacebookAudio360)
  107. {
  108. if (_showUltraOptions)
  109. {
  110. EditorGUILayout.Space();
  111. EditorGUILayout.LabelField("Facebook Audio 360", EditorStyles.boldLabel);
  112. DisplayPlatformOptionEnum(optionsVarName, _optionAudio360ChannelMode, _audio360ChannelMapGuiNames);
  113. }
  114. }
  115. }
  116. GUILayout.Space(8f);
  117. // EditorGUILayout.BeginVertical();
  118. EditorGUILayout.LabelField("Adaptive Stream", EditorStyles.boldLabel);
  119. DisplayPlatformOption(optionsVarName, _optionStartMaxBitrate);
  120. {
  121. SerializedProperty preferredMaximumResolutionProp = DisplayPlatformOption(optionsVarName, _optionPreferredMaximumResolution);
  122. if ((MediaPlayer.OptionsAndroid.Resolution)preferredMaximumResolutionProp.intValue == MediaPlayer.OptionsAndroid.Resolution.Custom)
  123. {
  124. #if UNITY_2017_2_OR_NEWER
  125. DisplayPlatformOption(optionsVarName, _optionCustomPreferredMaxResolution);
  126. #endif
  127. }
  128. }
  129. {
  130. EditorGUILayout.BeginHorizontal();
  131. DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRate);
  132. DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRateUnits);
  133. EditorGUILayout.EndHorizontal();
  134. }
  135. DisplayPlatformOption(optionsVarName, _optionMinBufferMs);
  136. DisplayPlatformOption(optionsVarName, _optionMaxBufferMs);
  137. DisplayPlatformOption(optionsVarName, _optionBufferForPlaybackMs);
  138. DisplayPlatformOption(optionsVarName, _optionBufferForPlaybackAfterRebufferMs);
  139. EditorGUILayout.EndVertical();
  140. }
  141. GUI.enabled = true;
  142. /*
  143. SerializedProperty propFileOffsetLow = serializedObject.FindProperty(optionsVarName + ".fileOffsetLow");
  144. SerializedProperty propFileOffsetHigh = serializedObject.FindProperty(optionsVarName + ".fileOffsetHigh");
  145. if (propFileOffsetLow != null && propFileOffsetHigh != null)
  146. {
  147. propFileOffsetLow.intValue = ;
  148. EditorGUILayout.PropertyField(propFileOFfset);
  149. }*/
  150. }
  151. }
  152. }