MediaPlayerEditor_Android.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 _optionBlitTextureFiltering = new FieldDescription(".blitTextureFiltering", new GUIContent("Blit Texture Filtering", "The texture filtering used for the final internal blit."));
  28. // 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."));
  29. private readonly static FieldDescription _optionPreferSoftwareDecoder = new FieldDescription(".preferSoftwareDecoder", GUIContent.none);
  30. private readonly static FieldDescription _optionForceRtpTCP = new FieldDescription(".forceRtpTCP", GUIContent.none);
  31. private readonly static FieldDescription _optionForceEnableMediaCodecAsynchronousQueueing = new FieldDescription(".forceEnableMediaCodecAsynchronousQueueing", GUIContent.none);
  32. private readonly static FieldDescription _optionPreferredMaximumResolution = new FieldDescription("._preferredMaximumResolution", new GUIContent("Preferred Maximum Resolution", "The desired maximum resolution of the video."));
  33. #if UNITY_2017_2_OR_NEWER
  34. private readonly static FieldDescription _optionCustomPreferredMaxResolution = new FieldDescription("._customPreferredMaximumResolution", new GUIContent(" "));
  35. #endif
  36. 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."));
  37. private readonly static FieldDescription _optionCustomPreferredPeakBitRateUnits = new FieldDescription("._preferredPeakBitRateUnits", new GUIContent());
  38. private readonly static FieldDescription _optionMinBufferMs = new FieldDescription(".minBufferMs", new GUIContent("Minimum Buffer Ms"));
  39. private readonly static FieldDescription _optionMaxBufferMs = new FieldDescription(".maxBufferMs", new GUIContent("Maximum Buffer Ms"));
  40. private readonly static FieldDescription _optionBufferForPlaybackMs = new FieldDescription(".bufferForPlaybackMs", new GUIContent("Buffer For Playback Ms"));
  41. private readonly static FieldDescription _optionBufferForPlaybackAfterRebufferMs = new FieldDescription(".bufferForPlaybackAfterRebufferMs", new GUIContent("Buffer For Playback After Rebuffer Ms"));
  42. private void OnInspectorGUI_Override_Android()
  43. {
  44. //MediaPlayer media = (this.target) as MediaPlayer;
  45. //MediaPlayer.OptionsAndroid options = media._optionsAndroid;
  46. GUILayout.Space(8f);
  47. string optionsVarName = MediaPlayer.GetPlatformOptionsVariable(Platform.Android);
  48. {
  49. EditorGUILayout.BeginVertical(GUI.skin.box);
  50. DisplayPlatformOption(optionsVarName, _optionVideoAPI);
  51. {
  52. SerializedProperty propFileOffset = DisplayPlatformOption(optionsVarName, _optionFileOffset);
  53. propFileOffset.intValue = Mathf.Max(0, propFileOffset.intValue);
  54. }
  55. {
  56. SerializedProperty propTextureFormat = DisplayPlatformOption(optionsVarName, _optionTextureFormat);
  57. if( (MediaPlayer.PlatformOptions.TextureFormat)( propTextureFormat.enumValueIndex ) == MediaPlayer.PlatformOptions.TextureFormat.YCbCr420_OES )
  58. {
  59. 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.");
  60. // PlayerSettings.virtualRealitySupported is deprecated from 2019.3
  61. #if !UNITY_2019_3_OR_NEWER
  62. if (PlayerSettings.virtualRealitySupported)
  63. #endif
  64. {
  65. if (PlayerSettings.stereoRenderingPath != StereoRenderingPath.MultiPass)
  66. {
  67. EditorHelper.IMGUI.NoticeBox(MessageType.Error, "OES only supports multi-pass stereo rendering path, please change in Player Settings.");
  68. }
  69. }
  70. 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.");
  71. }
  72. }
  73. // {
  74. // SerializedProperty propBlitTextureFiltering = DisplayPlatformOptionEnum(optionsVarName, _optionBlitTextureFiltering, _blitTextureFilteringAndroid);
  75. // propBlitTextureFiltering.intValue = Mathf.Max(0, propBlitTextureFiltering.intValue);
  76. // }
  77. EditorGUILayout.EndVertical();
  78. }
  79. if (_showUltraOptions)
  80. {
  81. SerializedProperty httpHeadersProp = serializedObject.FindProperty(optionsVarName + ".httpHeaders.httpHeaders");
  82. if (httpHeadersProp != null)
  83. {
  84. OnInspectorGUI_HttpHeaders(httpHeadersProp);
  85. }
  86. SerializedProperty keyAuthProp = serializedObject.FindProperty(optionsVarName + ".keyAuth");
  87. if (keyAuthProp != null)
  88. {
  89. OnInspectorGUI_HlsDecryption(keyAuthProp);
  90. }
  91. }
  92. #if false
  93. // MediaPlayer API options
  94. {
  95. EditorGUILayout.BeginVertical(GUI.skin.box);
  96. GUILayout.Label("MediaPlayer API Options", EditorStyles.boldLabel);
  97. DisplayPlatformOption(optionsVarName, _optionShowPosterFrames);
  98. EditorGUILayout.EndVertical();
  99. }
  100. #endif
  101. // ExoPlayer API options
  102. {
  103. EditorGUILayout.BeginVertical(GUI.skin.box);
  104. GUILayout.Label("ExoPlayer API Options", EditorStyles.boldLabel);
  105. DisplayPlatformOption(optionsVarName, _optionPreferSoftwareDecoder);
  106. DisplayPlatformOption(optionsVarName, _optionForceRtpTCP);
  107. DisplayPlatformOption(optionsVarName, _optionForceEnableMediaCodecAsynchronousQueueing);
  108. // Audio
  109. {
  110. SerializedProperty propAudioOutput = DisplayPlatformOptionEnum(optionsVarName, _optionAudioOutput, _audioModesAndroid);
  111. if ((Android.AudioOutput)propAudioOutput.enumValueIndex == Android.AudioOutput.FacebookAudio360)
  112. {
  113. if (_showUltraOptions)
  114. {
  115. EditorGUILayout.Space();
  116. EditorGUILayout.LabelField("Facebook Audio 360", EditorStyles.boldLabel);
  117. DisplayPlatformOptionEnum(optionsVarName, _optionAudio360ChannelMode, _audio360ChannelMapGuiNames);
  118. DisplayPlatformOption(optionsVarName, _optionAudio360LatencyMS);
  119. }
  120. }
  121. }
  122. GUILayout.Space(8f);
  123. // EditorGUILayout.BeginVertical();
  124. EditorGUILayout.LabelField("Adaptive Stream", EditorStyles.boldLabel);
  125. DisplayPlatformOption(optionsVarName, _optionStartMaxBitrate);
  126. {
  127. SerializedProperty preferredMaximumResolutionProp = DisplayPlatformOption(optionsVarName, _optionPreferredMaximumResolution);
  128. if ((MediaPlayer.OptionsAndroid.Resolution)preferredMaximumResolutionProp.intValue == MediaPlayer.OptionsAndroid.Resolution.Custom)
  129. {
  130. #if UNITY_2017_2_OR_NEWER
  131. DisplayPlatformOption(optionsVarName, _optionCustomPreferredMaxResolution);
  132. #endif
  133. }
  134. }
  135. {
  136. EditorGUILayout.BeginHorizontal();
  137. DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRate);
  138. DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRateUnits);
  139. EditorGUILayout.EndHorizontal();
  140. }
  141. DisplayPlatformOption(optionsVarName, _optionMinBufferMs);
  142. DisplayPlatformOption(optionsVarName, _optionMaxBufferMs);
  143. DisplayPlatformOption(optionsVarName, _optionBufferForPlaybackMs);
  144. DisplayPlatformOption(optionsVarName, _optionBufferForPlaybackAfterRebufferMs);
  145. EditorGUILayout.EndVertical();
  146. }
  147. GUI.enabled = true;
  148. /*
  149. SerializedProperty propFileOffsetLow = serializedObject.FindProperty(optionsVarName + ".fileOffsetLow");
  150. SerializedProperty propFileOffsetHigh = serializedObject.FindProperty(optionsVarName + ".fileOffsetHigh");
  151. if (propFileOffsetLow != null && propFileOffsetHigh != null)
  152. {
  153. propFileOffsetLow.intValue = ;
  154. EditorGUILayout.PropertyField(propFileOFfset);
  155. }*/
  156. }
  157. }
  158. }