Commit b9452fee authored by Martin Finkel's avatar Martin Finkel

Core: renaming getTexture endpoint, unityplugin dll and add custom Unity initialization code

parent 64b1350c
...@@ -40,6 +40,12 @@ namespace LibVLCSharp.Shared ...@@ -40,6 +40,12 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.Kernel32, SetLastError = true)] [DllImport(Constants.Kernel32, SetLastError = true)]
internal static extern ErrorModes SetErrorMode(ErrorModes uMode); internal static extern ErrorModes SetErrorMode(ErrorModes uMode);
[DllImport(Constants.UnityPlugin)]
internal static extern void SetPluginPath(string path);
[DllImport(Constants.UnityPlugin)]
internal static extern void Print(string toPrint);
#elif ANDROID #elif ANDROID
[DllImport(Constants.LibraryName, EntryPoint = "JNI_OnLoad")] [DllImport(Constants.LibraryName, EntryPoint = "JNI_OnLoad")]
internal static extern int JniOnLoad(IntPtr javaVm, IntPtr reserved = default); internal static extern int JniOnLoad(IntPtr javaVm, IntPtr reserved = default);
...@@ -150,7 +156,17 @@ namespace LibVLCSharp.Shared ...@@ -150,7 +156,17 @@ namespace LibVLCSharp.Shared
static void InitializeDesktop(string libvlcDirectoryPath = null) static void InitializeDesktop(string libvlcDirectoryPath = null)
{ {
if(PlatformHelper.IsLinux) #if UNITY
if(string.IsNullOrEmpty(libvlcDirectoryPath))
{
throw new VLCException("Please provide UnityEngine.Application.dataPath to Core.Initialize for proper initialization.");
}
Native.SetPluginPath(libvlcDirectoryPath);
libvlcDirectoryPath = $"{libvlcDirectoryPath}\\Plugins";
#endif
if (PlatformHelper.IsLinux)
{ {
if (!string.IsNullOrEmpty(libvlcDirectoryPath)) if (!string.IsNullOrEmpty(libvlcDirectoryPath))
{ {
...@@ -302,18 +318,13 @@ namespace LibVLCSharp.Shared ...@@ -302,18 +318,13 @@ namespace LibVLCSharp.Shared
{ {
#if IOS #if IOS
internal const string LibraryName = "@rpath/DynamicMobileVLCKit.framework/DynamicMobileVLCKit"; internal const string LibraryName = "@rpath/DynamicMobileVLCKit.framework/DynamicMobileVLCKit";
#elif UNITY
/// <summary>
/// The vlc-unity C++ plugin which handles rendering (opengl/d3d) libvlc callbacks
/// </summary>
internal const string UnityPlugin = "RenderingPlugin";
internal const string LibraryName = "libvlc";
#elif TVOS #elif TVOS
internal const string LibraryName = "@rpath/DynamicTVVLCKit.framework/DynamicTVVLCKit"; internal const string LibraryName = "@rpath/DynamicTVVLCKit.framework/DynamicTVVLCKit";
#else #else
internal const string LibraryName = "libvlc"; internal const string LibraryName = "libvlc";
#endif #endif
internal const string CoreLibraryName = "libvlccore"; internal const string CoreLibraryName = "libvlccore";
internal const string UnityPlugin = "VLCUnityPlugin";
/// <summary> /// <summary>
/// The name of the folder that contains the per-architecture folders /// The name of the folder that contains the per-architecture folders
......
...@@ -602,8 +602,8 @@ namespace LibVLCSharp.Shared ...@@ -602,8 +602,8 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.UnityPlugin)] [DllImport(Constants.UnityPlugin)]
internal static extern IntPtr CreateAndInitMediaPlayer(IntPtr libvlc); internal static extern IntPtr CreateAndInitMediaPlayer(IntPtr libvlc);
[DllImport(Constants.UnityPlugin, EntryPoint = "getVideoFrameVLC")] [DllImport(Constants.UnityPlugin, EntryPoint = "getTexture")]
internal static extern IntPtr GetFrame(IntPtr mediaPlayer, out bool updated); internal static extern IntPtr GetTexture(IntPtr mediaPlayer, out bool updated);
#endif #endif
} }
...@@ -1779,15 +1779,15 @@ namespace LibVLCSharp.Shared ...@@ -1779,15 +1779,15 @@ namespace LibVLCSharp.Shared
#if UNITY #if UNITY
/// <summary> /// <summary>
/// Retrieve a video frame from the Unity plugin. /// Retrieve a video frame from the Unity plugin as a texture.
/// </summary> /// </summary>
/// <param name="updated">True if the video frame has been updated</param> /// <param name="updated">True if the video frame has been updated</param>
/// <returns>A decoded texture</returns> /// <returns>A decoded texture</returns>
public IntPtr GetFrame(out bool updated) public IntPtr GetTexture(out bool updated)
{ {
var frame = Native.GetFrame(NativeReference, out bool isUpdated); var texture = Native.GetTexture(NativeReference, out bool isUpdated);
updated = isUpdated; updated = isUpdated;
return frame; return texture;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment