예제 #1
0
        public VlcManager(DirectoryInfo dynamicLinkLibrariesPath, string[] args)
        {
            this.myLibraryLoader = VlcLibraryLoader.GetOrCreateLoader(dynamicLinkLibrariesPath);

            IntPtr[] utf8Args = new IntPtr[args?.Length ?? 0];
            try
            {
                for (var i = 0; i < utf8Args.Length; i++)
                {
                    byte[] bytes  = Encoding.UTF8.GetBytes(args[i]);
                    var    buffer = Marshal.AllocHGlobal(bytes.Length + 1);
                    Marshal.Copy(bytes, 0, buffer, bytes.Length);
                    Marshal.WriteByte(buffer, bytes.Length, 0);
                    utf8Args[i] = buffer;
                }

                myVlcInstance = new VlcInstance(this, myLibraryLoader.GetInteropDelegate <CreateNewInstance>().Invoke(utf8Args.Length, utf8Args));
            }
            finally
            {
                foreach (var arg in utf8Args)
                {
                    if (arg != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(arg);
                    }
                }
            }
        }
        public void CreateNewInstance(string[] args)
        {
            IntPtr[] utf8Args = new IntPtr[args?.Length ?? 0];
            try
            {
                for (var i = 0; i < utf8Args.Length; i++)
                {
                    byte[] bytes  = Encoding.UTF8.GetBytes(args[i]);
                    var    buffer = Marshal.AllocHGlobal(bytes.Length + 1);
                    Marshal.Copy(bytes, 0, buffer, bytes.Length);
                    Marshal.WriteByte(buffer, bytes.Length, 0);
                    utf8Args[i] = buffer;
                }

                myVlcInstance = new VlcInstance(this, GetInteropDelegate <CreateNewInstance>().Invoke(utf8Args.Length, utf8Args));
            }
            finally
            {
                foreach (var arg in utf8Args)
                {
                    if (arg != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(arg);
                    }
                }
            }
        }
예제 #3
0
 public void CreateNewInstance(string[] args)
 {
     if (args == null)
     {
         args = new string[0];
     }
     myVlcInstance = new VlcInstance(this, GetInteropDelegate <CreateNewInstance>().Invoke(args.Length, args));
 }
예제 #4
0
 public void ReleaseInstance(VlcInstance instance)
 {
     if (instance == IntPtr.Zero)
     {
         return;
     }
     myLibraryLoader.GetInteropDelegate <ReleaseInstance>().Invoke(instance);
 }
 public void ReleaseInstance(VlcInstance instance)
 {
     if (instance == IntPtr.Zero)
         return;
     GetInteropDelegate<ReleaseInstance>().Invoke(instance);
 }
 public void CreateNewInstance(string[] args)
 {
     if (args == null)
         args = new string[0];
     myVlcInstance = new VlcInstance(this, GetInteropDelegate<CreateNewInstance>().Invoke(args.Length, args));
 }