Example #1
0
 /// <summary>
 ///     Returns a list of video filters that are available.
 /// </summary>
 public List <ModuleDescription> GetVideoFilterList()
 {
     using (var list = new ModuleDescriptionList(LibVlcManager
                                                 .GetFunctionDelegate <libvlc_video_filter_list_get>().Invoke(InstancePointer)))
     {
         return(new List <ModuleDescription>(list));
     }
 }
Example #2
0
 /// <summary>
 ///     Try to start a user interface for the libvlc instance.
 /// </summary>
 /// <param name="name">interface name, or NULL for default</param>
 /// <returns>true on success, false on error.</returns>
 public bool AddInterface(string name)
 {
     using (var handle = new StringHandle(name))
     {
         return(LibVlcManager.GetFunctionDelegate <libvlc_add_intf>()
                .Invoke(InstancePointer, handle.UnsafePointer) == 0);
     }
 }
Example #3
0
 /// <summary>
 ///     Sets the application name. LibVLC passes this as the user agent string when a protocol requires it.
 /// </summary>
 /// <param name="name">human-readable application name, e.g. "FooBar player 1.2.3"</param>
 /// <param name="http">HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"</param>
 public void SetUserAgent(string name, string http)
 {
     using (var nameHandle = new StringHandle(name))
     {
         using (var httpHandle = new StringHandle(http))
         {
             LibVlcManager.GetFunctionDelegate <libvlc_set_user_agent>().Invoke(InstancePointer,
                                                                                nameHandle.UnsafePointer, httpHandle.UnsafePointer);
         }
     }
 }
Example #4
0
        /// <summary>
        ///     Deattach a event with a callback.
        /// </summary>
        /// <param name="type">event type</param>
        public void Detach(EventType type)
        {
            if (!_attachedEvents.Contains(type))
            {
                return;
            }

            _attachedEvents.Remove(type);
            LibVlcManager.GetFunctionDelegate <libvlc_event_detach>()
            .Invoke(InstancePointer, (libvlc_event_e)type, _onVlcEventFired, null);
        }
Example #5
0
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero)
            {
                return;
            }

            LibVlcManager.ReleaseAudioDeviceList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero)
            {
                return;
            }

            LibVlcManager.ReleaseTrackDescriptionList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
Example #7
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            LibVlcManager.GetFunctionDelegate <libvlc_audio_equalizer_release>().Invoke(InstancePointer);
            InstancePointer = null;

            _disposed = true;
        }
Example #8
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _onExitHandle.Free();
            VlcObjectManager.Remove(this);
            LibVlcManager.GetFunctionDelegate <libvlc_release>().Invoke(InstancePointer);
            InstancePointer = null;

            _disposed = true;
        }
Example #9
0
 /// <summary>
 ///     Sets some meta-information about the application.
 /// </summary>
 /// <param name="id">Java-style application identifier, e.g. "com.acme.foobar"</param>
 /// <param name="version">application version numbers, e.g. "1.2.3"</param>
 /// <param name="icon">application icon name, e.g. "foobar"</param>
 public void SetAppId(string id, string version, string icon)
 {
     using (var idHandle = new StringHandle(id))
     {
         using (var versionHandle = new StringHandle(version))
         {
             using (var iconHandle = new StringHandle(icon))
             {
                 LibVlcManager.GetFunctionDelegate <libvlc_set_app_id>().Invoke(InstancePointer,
                                                                                idHandle.UnsafePointer, versionHandle.UnsafePointer, iconHandle.UnsafePointer);
             }
         }
     }
 }
Example #10
0
        /// <summary>
        ///     获取媒体的基本流的描述,注意,在调用该方法之前你需要首先调用 <see cref="ParseMedia" /> 方法,或者至少播放一次.
        ///     否则,你将的得到一个空数组
        /// </summary>
        /// <returns>一个 <see cref="MediaTrackInfo" /> 数组</returns>
        public MediaTrackInfo[] GetTrackInfo()
        {
            IntPtr pointer;
            var    count  = _getTracksInfoFunction.Delegate(InstancePointer, out pointer);
            var    result = new MediaTrackInfo[count];
            var    temp   = pointer;

            for (var i = 0; i < count; i++)
            {
                result[i] = (MediaTrackInfo)Marshal.PtrToStructure(temp, typeof(MediaTrackInfo));
                temp      = (IntPtr)((int)temp + Marshal.SizeOf(typeof(MediaTrackInfo)));
            }

            LibVlcManager.Free(pointer);
            return(result);
        }
Example #11
0
        /// <summary>
        ///     Create a Vlc instance by options.
        /// </summary>
        /// <param name="argv"></param>
        /// <exception cref="VlcCreateFailException">Can't create a Vlc instence, check your Vlc options.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public Vlc(string[] argv)
        {
            InstancePointer = argv == null
                ? LibVlcManager.GetFunctionDelegate <libvlc_new>().Invoke(0, IntPtr.Zero)
                : LibVlcManager.GetFunctionDelegate <libvlc_new>()
                              .Invoke(argv.Length, InteropHelper.StringArrayToPtr(argv));

            if (InstancePointer == null)
            {
                throw new VlcCreateFailException(VlcError.GetErrorMessage());
            }

            ExitHandler onExit = OnExit;

            _onExitHandle = GCHandle.Alloc(onExit);
            LibVlcManager.GetFunctionDelegate <libvlc_set_exit_handler>().Invoke(InstancePointer, onExit, null);

            VlcObjectManager.Add(this);
        }
Example #12
0
        private VlcMedia(IVlcObject parentVlcObject, void *pointer)
        {
            VlcInstance     = parentVlcObject.VlcInstance;
            InstancePointer = pointer;
            VlcObjectManager.Add(this);

            EventManager = new VlcEventManager(this,
                                               LibVlcManager.GetFunctionDelegate <libvlc_media_event_manager>().Invoke(InstancePointer));

            EventManager.Attach(EventType.MediaMetaChanged);
            EventManager.Attach(EventType.MediaSubItemAdded);
            EventManager.Attach(EventType.MediaDurationChanged);
            EventManager.Attach(EventType.MediaParsedChanged);
            EventManager.Attach(EventType.MediaFreed);
            EventManager.Attach(EventType.MediaStateChanged);
            EventManager.Attach(EventType.MediaSubItemTreeAdded);

            EventManager.VlcEventFired += OnVlcEventFired;
        }
Example #13
0
        private VlcMediaPlayer(IVlcObject parentVlcObject, void* pointer)
        {
            VlcInstance = parentVlcObject.VlcInstance;
            InstancePointer = pointer;
            VlcObjectManager.Add(this);

            EventManager = new VlcEventManager(this,
                LibVlcManager.GetFunctionDelegate<libvlc_media_player_event_manager>().Invoke(InstancePointer));

            EventManager.Attach(EventType.MediaPlayerPlaying);
            EventManager.Attach(EventType.MediaPlayerPaused);
            EventManager.Attach(EventType.MediaPlayerOpening);
            EventManager.Attach(EventType.MediaPlayerBuffering);
            EventManager.Attach(EventType.MediaPlayerStopped);
            EventManager.Attach(EventType.MediaPlayerForward);
            EventManager.Attach(EventType.MediaPlayerBackward);
            EventManager.Attach(EventType.MediaPlayerEndReached);
            EventManager.Attach(EventType.MediaPlayerMediaChanged);
            EventManager.Attach(EventType.MediaPlayerNothingSpecial);
            EventManager.Attach(EventType.MediaPlayerPausableChanged);
            EventManager.Attach(EventType.MediaPlayerPositionChanged);
            EventManager.Attach(EventType.MediaPlayerSeekableChanged);
            EventManager.Attach(EventType.MediaPlayerSnapshotTaken);
            EventManager.Attach(EventType.MediaPlayerTimeChanged);
            EventManager.Attach(EventType.MediaPlayerTitleChanged);
            EventManager.Attach(EventType.MediaPlayerLengthChanged);
            EventManager.Attach(EventType.MediaPlayerEncounteredError);
            EventManager.Attach(EventType.MediaPlayerVout);
            EventManager.Attach(EventType.MediaPlayerScrambledChanged);
            EventManager.Attach(EventType.MediaPlayerESAdded);
            EventManager.Attach(EventType.MediaPlayerESDeleted);
            EventManager.Attach(EventType.MediaPlayerESSelected);
            EventManager.Attach(EventType.MediaPlayerCorked);
            EventManager.Attach(EventType.MediaPlayerUncorked);
            EventManager.Attach(EventType.MediaPlayerMuted);
            EventManager.Attach(EventType.MediaPlayerUnmuted);
            EventManager.Attach(EventType.MediaPlayerAudioVolume);
            EventManager.Attach(EventType.MediaPlayerAudioDevice);
            EventManager.Attach(EventType.MediaPlayerChapterChanged);

            EventManager.VlcEventFired += OnVlcEventFired;
        }
Example #14
0
        /// <summary>
        ///     Create a list of media track from a pointer of array.
        /// </summary>
        /// <param name="pointer">pointer of media track array</param>
        /// <param name="count">count of media track array</param>
        public MediaTrackList(IntPtr pointer, uint count)
        {
            _list = new List <MediaTrack>();

            if (pointer == IntPtr.Zero)
            {
                return;
            }

            var tmp = pointer;

            for (var i = 0; i < count; i++)
            {
                var p = Marshal.ReadIntPtr(tmp);
                _list.Add(MediaTrack.CreateFromPointer(p));
                tmp = (IntPtr)((Int64)tmp + IntPtr.Size);
            }

            LibVlcManager.ReleaseTracks(pointer, count);
        }
Example #15
0
        /// <summary>
        ///     Convert a pointer of string to manmaged <see cref="String" />.
        /// </summary>
        /// <param name="ptr">pointer of string</param>
        /// <param name="count">count of string, -1 mean auto check the end char</param>
        /// <param name="toBeFree">free this pointer when convert over</param>
        /// <param name="encoding">encoding of string</param>
        /// <returns>result string</returns>
        public static string PtrToString(IntPtr ptr, int count = -1, bool toBeFree = false, Encoding encoding = null)
        {
            if (ptr == IntPtr.Zero)
            {
                return(null);
            }
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }

            var buffer = new List <byte>(1024);

            if (count == -1)
            {
                var offset = 0;
                var tmp    = Marshal.ReadByte(ptr, offset);
                while (tmp != 0)
                {
                    buffer.Add(tmp);
                    offset++;
                    tmp = Marshal.ReadByte(ptr, offset);
                }
            }
            else
            {
                byte tmp = 0;
                for (var i = 0; i < count; i++)
                {
                    tmp = Marshal.ReadByte(ptr, i);
                    buffer.Add(tmp);
                }
            }

            if (toBeFree)
            {
                LibVlcManager.Free(ptr.ToPointer());
            }

            return(encoding.GetString(buffer.ToArray()));
        }
Example #16
0
 /// <summary>
 ///     Release this event manager.
 /// </summary>
 /// <exception cref="Exception">A delegate callback throws an exception.</exception>
 public void Dispose()
 {
     HandleManager.Remove(this);
     LibVlcManager.Free(InstancePointer);
     InstancePointer = IntPtr.Zero;
 }
Example #17
0
 protected override void Release(void **data)
 {
     LibVlcManager.GetFunctionDelegate <libvlc_media_tracks_release>()
     .Invoke((libvlc_media_track_t **)data, (uint)Count);
 }
Example #18
0
 protected override void Release(void **data)
 {
     LibVlcManager.GetFunctionDelegate <libvlc_free>().Invoke(data);
 }
Example #19
0
 protected override void Release(void *data)
 {
     LibVlcManager.GetFunctionDelegate <libvlc_audio_output_device_list_release>()
     .Invoke((libvlc_audio_output_device_t *)data);
 }
Example #20
0
 /// <summary>
 ///     Clear error message of current thread.
 /// </summary>
 /// <exception cref="Exception">A delegate callback throws an exception.</exception>
 public static void CleanError()
 {
     LibVlcManager.GetFunctionDelegate <libvlc_clearerr>().Invoke();
 }
Example #21
0
 /// <summary>
 ///     Get a readable error message.
 /// </summary>
 /// <returns>return a readable LibVlc error message, if there are no error will return <see cref="null" /></returns>
 /// <exception cref="Exception">A delegate callback throws an exception.</exception>
 public static string GetErrorMessage()
 {
     return(InteropHelper.PtrToString(LibVlcManager.GetFunctionDelegate <libvlc_errmsg>().Invoke()));
 }
 protected override void Release(void *data)
 {
     LibVlcManager.GetFunctionDelegate <libvlc_module_description_list_release>()
     .Invoke((libvlc_module_description_t *)data);
 }
Example #23
0
 /// <summary>
 ///     Get event type name.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static string GetEventTypeName(EventType type)
 {
     return(InteropHelper.PtrToString(LibVlcManager.GetFunctionDelegate <libvlc_event_type_name>()
                                      .Invoke((libvlc_event_e)type)));
 }
Example #24
0
 /// <summary>
 ///     Create a new default equalizer, with all frequency values zeroed.
 /// </summary>
 public AudioEqualizer()
 {
     InstancePointer = LibVlcManager.GetFunctionDelegate <libvlc_audio_equalizer_new>().Invoke();
 }
Example #25
0
 /// <summary>
 ///     Create a new equalizer, with initial frequency values copied from an existing preset.
 /// </summary>
 /// <param name="index"></param>
 public AudioEqualizer(uint index)
 {
     InstancePointer = LibVlcManager.GetFunctionDelegate <libvlc_audio_equalizer_new_from_preset>().Invoke(index);
 }