public VlcMediaPlayerInternal CreateVlcMediaPlayerInternal() {
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     IntPtr mediaplayerDescriptor = LibVlcInterop.libvlc_media_player_new(vlclibDescriptor, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
     //
     return new VlcMediaPlayerInternal(mediaplayerDescriptor);
 }
 public VlcMediaInternal CreateVlcMediaInternal(MediaInput mediaInput) {
     if (mediaInput == null) {
         throw new ArgumentNullException("mediaInput");
     }
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     IntPtr mediaDescriptor = LibVlcInterop.libvlc_media_new(vlclibDescriptor, mediaInput.Source, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
     //
     return new VlcMediaInternal(mediaDescriptor);
 }
        public static IntPtr libvlc_new(string[] parameters, ref libvlc_exception_t exception)
        {
            if (parameters.Length > 10)
            {
                throw new ArgumentException("Too many items in array, maximum 10 allowed", "parameters");
            }
            //
            PointerToArrayOfPointerHelper argv = new PointerToArrayOfPointerHelper();

            argv.pointers = new IntPtr[11];
            //
            Assembly assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                argv.pointers[0] = Marshal.StringToHGlobalAnsi(assembly.Location);
            }
            else
            {
                assembly         = Assembly.GetExecutingAssembly();
                argv.pointers[0] = Marshal.StringToHGlobalAnsi(assembly.Location);
            }

            for (int i = 0; i < parameters.Length; i++)
            {
                argv.pointers[i + 1] = Marshal.StringToHGlobalAnsi(parameters[i]);
            }

            IntPtr argvPtr = IntPtr.Zero;

            try {
                int size = Marshal.SizeOf(typeof(PointerToArrayOfPointerHelper));
                argvPtr = Marshal.AllocHGlobal(size);
                Marshal.StructureToPtr(argv, argvPtr, false);

                return(libvlc_new(parameters.Length + 1, argvPtr, ref exception));
            } finally {
                for (int i = 0; i < parameters.Length + 1; i++)
                {
                    if (argv.pointers[i] != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(argv.pointers[i]);
                    }
                }
                if (argvPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(argvPtr);
                }
            }
        }
 public VlcLog CreateVlcLog(ILog log, ILogVerbosityManager logVerbosityManager) {
     if (log == null) {
         throw new ArgumentNullException("log");
     }
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     IntPtr libvlc_log_t = LibVlcInterop.libvlc_log_open(vlclibDescriptor, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
     //
     return new VlcLog(libvlc_log_t, logVerbosityManager, log);
 }
 private void addOption(string option) {
     if (option == null) {
         throw new ArgumentNullException("option");
     }
     if (option.Length == 0) {
         throw new ArgumentException("String is empty.", "option");
     }
     //
     VerifyObjectIsNotDisposed();
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     LibVlcInterop.libvlc_media_add_option(descriptor, option, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
 }
        /// <summary>
        /// Helper to the original function, <paramref name="mrl"/> string will be
        /// converted to the UTF-8 encoding automatically and marshalled to the libvlc.
        /// </summary>
        public static IntPtr libvlc_media_new(IntPtr p_instance, string mrl, ref libvlc_exception_t exception)
        {
            IntPtr pMrl = IntPtr.Zero;

            try {
                byte[] bytes = Encoding.UTF8.GetBytes(mrl);
                //
                pMrl = Marshal.AllocHGlobal(bytes.Length + 1);
                Marshal.Copy(bytes, 0, pMrl, bytes.Length);
                Marshal.WriteByte(pMrl, bytes.Length, 0);
                //
                return(libvlc_media_new(p_instance, pMrl, ref exception));
            } finally {
                if (pMrl != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(pMrl);
                }
            }
        }
 public static extern void libvlc_media_player_set_time(IntPtr libvlc_mediaplayer, Int64 time, ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_set_drawable(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable,
                                                            ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_set_position(IntPtr libvlc_mediaplayer, float position, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_log_iterator_next(IntPtr libvlc_log_iterator_t, ref libvlc_log_message_t p_buffer, ref libvlc_exception_t exception);
 public static extern void libvlc_log_clear(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public static extern UInt32 libvlc_get_log_verbosity(IntPtr libvlc_instance_t, ref libvlc_exception_t exception);
 public static bool libvlc_video_reparent(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable_t,
                                          ref libvlc_exception_t exc)
 {
     return(libvlc_video_reparent_internal(libvlc_mediaplayer, libvlc_drawable_t, ref exc) != 0);
 }
 public static extern void libvlc_video_set_spu(IntPtr libvlc_mediaplayer, int spu, ref libvlc_exception_t exception);
 public static extern int libvlc_video_get_spu(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static bool libvlc_video_reparent(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable_t,
                                          ref libvlc_exception_t exc) {
     return libvlc_video_reparent_internal(libvlc_mediaplayer, libvlc_drawable_t, ref exc) != 0;
 }
 private static extern Int32 libvlc_video_reparent_internal(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable_t,
                                                            ref libvlc_exception_t exc);
 public static extern float libvlc_media_player_get_fps(IntPtr libvlc_media_player_t, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_media_player_event_manager(IntPtr libvlc_media_player_t, ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_set_position(IntPtr libvlc_mediaplayer, float position, ref libvlc_exception_t exception);
 public static extern float libvlc_media_player_get_fps(IntPtr libvlc_media_player_t, ref libvlc_exception_t exception);
 public static extern void libvlc_video_take_snapshot(IntPtr libvlc_media_player_t,
                                                      IntPtr filePath, UInt32 i_width, UInt32 i_height, ref libvlc_exception_t exc);
 public static extern void libvlc_video_set_spu(IntPtr libvlc_mediaplayer, int spu, ref libvlc_exception_t exception);
 public static extern UInt32 libvlc_get_log_verbosity(IntPtr libvlc_instance_t, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_log_open(IntPtr libvlc_instance_t, ref libvlc_exception_t exception);
 public static extern void libvlc_set_log_verbosity(IntPtr libvlc_instance_t, UInt32 level, ref libvlc_exception_t exception);
 public static extern void libvlc_log_iterator_free(IntPtr libvlc_log_iterator_t, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_log_open(IntPtr libvlc_instance_t, ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_set_drawable(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable,
                                                            ref libvlc_exception_t exception);
 public static extern UInt32 libvlc_log_count(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_stop(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static extern void libvlc_log_clear(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public static extern Int64 libvlc_media_player_get_time(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_log_get_iterator(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public static extern float libvlc_media_player_get_position(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static extern void libvlc_log_iterator_free(IntPtr libvlc_log_iterator_t, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_media_player_event_manager(IntPtr libvlc_media_player_t, ref libvlc_exception_t exception);
 public static extern Int32 libvlc_log_iterator_has_next(IntPtr libvlc_log_iterator_t, ref libvlc_exception_t exception);
 private static extern Int32 libvlc_video_reparent_internal(IntPtr libvlc_mediaplayer, Int32 libvlc_drawable_t,
                                                            ref libvlc_exception_t exc);
 public static extern IntPtr libvlc_log_iterator_next(IntPtr libvlc_log_iterator_t, ref libvlc_log_message_t p_buffer, ref libvlc_exception_t exception);
 public static extern int libvlc_video_get_spu(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static extern void libvlc_media_player_set_time(IntPtr libvlc_mediaplayer, Int64 time, ref libvlc_exception_t exception);
 public static extern void libvlc_video_take_snapshot(IntPtr libvlc_media_player_t,
                                                      IntPtr filePath, UInt32 i_width, UInt32 i_height, ref libvlc_exception_t exc);
 public static extern int libvlc_audio_get_volume(IntPtr libvlc_instance, ref libvlc_exception_t exception);
 public static extern void libvlc_set_log_verbosity(IntPtr libvlc_instance_t, UInt32 level, ref libvlc_exception_t exception);
 public static extern libvlc_state_t libvlc_media_get_state(IntPtr libvlc_media_inst, ref libvlc_exception_t exc);
 public static extern UInt32 libvlc_log_count(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_media_player_new(IntPtr libvlc_instance, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_log_get_iterator(IntPtr libvlc_log_t, ref libvlc_exception_t exception);
 public void SetMedia(VlcMediaInternal media) {
     if (media == null) {
         throw new ArgumentNullException("media");
     }
     //
     VerifyObjectIsNotDisposed();
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     LibVlcInterop.libvlc_media_player_set_media(descriptor, media.Descriptor, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
 }
 public static extern Int32 libvlc_log_iterator_has_next(IntPtr libvlc_log_iterator_t, ref libvlc_exception_t exception);
 public void Pause() {
     VerifyObjectIsNotDisposed();
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     LibVlcInterop.libvlc_media_player_pause(descriptor, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
 }
 public static extern Int64 libvlc_media_player_get_time(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public static extern void libvlc_audio_set_volume(IntPtr libvlc_instance, int volume, ref libvlc_exception_t exception);
 public static extern IntPtr libvlc_media_player_new_from_media(IntPtr libvlc_media,
                                                                ref libvlc_exception_t exception);
 public static extern float libvlc_media_player_get_position(IntPtr libvlc_mediaplayer, ref libvlc_exception_t exception);
 public void SetDisplayOutput(Int32 handle) {
     VerifyObjectIsNotDisposed();
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     LibVlcInterop.libvlc_media_player_set_drawable(descriptor, handle, ref exc);
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
 }
 public static extern void libvlc_audio_set_volume(IntPtr libvlc_instance, int volume, ref libvlc_exception_t exception);
 public void TakeSnapshot(string filePath, int width, int height) {
     VerifyObjectIsNotDisposed();
     //
     libvlc_exception_t exc = new libvlc_exception_t();
     LibVlcInterop.libvlc_exception_init(ref exc);
     IntPtr filePathPtr = Marshal.StringToHGlobalAnsi(filePath);
     //
     uint uwidth = Convert.ToUInt32(width);
     uint uheight = Convert.ToUInt32(height);
     //
     try {
         LibVlcInterop.libvlc_video_take_snapshot(descriptor, filePathPtr, uwidth, uheight, ref exc);
     } finally {
         Marshal.FreeHGlobal(filePathPtr);
     }
     //
     if (exc.b_raised != 0) {
         throw new VlcInternalException(exc.Message);
     }
 }
 public static extern void libvlc_media_player_set_media(IntPtr libvlc_media_player_t, IntPtr libvlc_media_t, ref libvlc_exception_t exception);