Beispiel #1
0
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero)
            {
                return;
            }

            LibVlcManager.ReleaseModuleDescriptionList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
Beispiel #2
0
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero)
            {
                return;
            }

            LibVlcManager.ReleaseAudioDeviceList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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;
            }

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

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

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

            return(encoding.GetString(buffer.ToArray()));
        }
Beispiel #6
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;
 }