Example #1
0
        /// <summary>
        ///     提供指定的参数初始化一个 Vlc 实例
        /// </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
                ? _newInstanceFunction.Delegate(0, IntPtr.Zero)
                : _newInstanceFunction.Delegate(argv.Length, InteropHelper.StringArrayToPtr(argv));

            if (InstancePointer == IntPtr.Zero)
            {
                var ex = VlcError.GetErrorMessage();
                throw new VlcCreateFailException(ex);
            }

            EventManager = new VlcEventManager(this, _getMediaEventManagerFunction.Delegate(InstancePointer));

            _onVlmMediaAdded                 = OnVlmMediaAdded;
            _onVlmMediaRemoved               = OnVlmMediaRemoved;
            _onVlmMediaChanged               = OnVlmMediaChanged;
            _onVlmMediaInstanceStarted       = OnVlmMediaInstanceStarted;
            _onVlmMediaInstanceStopped       = OnVlmMediaInstanceStopped;
            _onVlmMediaInstanceStatusInit    = OnVlmMediaInstanceStatusInit;
            _onVlmMediaInstanceStatusOpening = OnVlmMediaInstanceStatusOpening;
            _onVlmMediaInstanceStatusPlaying = OnVlmMediaInstanceStatusPlaying;
            _onVlmMediaInstanceStatusPause   = OnVlmMediaInstanceStatusPause;
            _onVlmMediaInstanceStatusEnd     = OnVlmMediaInstanceStatusEnd;
            _onVlmMediaInstanceStatusError   = OnVlmMediaInstanceStatusError;

            _onVlmMediaAddedHandle                 = GCHandle.Alloc(_onVlmMediaAdded);
            _onVlmMediaRemovedHandle               = GCHandle.Alloc(_onVlmMediaRemoved);
            _onVlmMediaChangedHandle               = GCHandle.Alloc(_onVlmMediaChanged);
            _onVlmMediaInstanceStartedHandle       = GCHandle.Alloc(_onVlmMediaInstanceStarted);
            _onVlmMediaInstanceStoppedHandle       = GCHandle.Alloc(_onVlmMediaInstanceStopped);
            _onVlmMediaInstanceStatusInitHandle    = GCHandle.Alloc(_onVlmMediaInstanceStatusInit);
            _onVlmMediaInstanceStatusOpeningHandle = GCHandle.Alloc(_onVlmMediaInstanceStatusOpening);
            _onVlmMediaInstanceStatusPlayingHandle = GCHandle.Alloc(_onVlmMediaInstanceStatusPlaying);
            _onVlmMediaInstanceStatusPauseHandle   = GCHandle.Alloc(_onVlmMediaInstanceStatusPause);
            _onVlmMediaInstanceStatusEndHandle     = GCHandle.Alloc(_onVlmMediaInstanceStatusEnd);
            _onVlmMediaInstanceStatusErrorHandle   = GCHandle.Alloc(_onVlmMediaInstanceStatusError);

            HandleManager.Add(this);

            EventManager.Attach(EventTypes.VlmMediaAdded, _onVlmMediaAdded, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaRemoved, _onVlmMediaRemoved, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaChanged, _onVlmMediaChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStarted, _onVlmMediaInstanceStarted, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStopped, _onVlmMediaInstanceStopped, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusInit, _onVlmMediaInstanceStatusInit, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusOpening, _onVlmMediaInstanceStatusOpening, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusPlaying, _onVlmMediaInstanceStatusPlaying, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusPause, _onVlmMediaInstanceStatusPause, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusEnd, _onVlmMediaInstanceStatusEnd, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusError, _onVlmMediaInstanceStatusError, IntPtr.Zero);
        }
Example #2
0
        public bool VlmAddBroadcast(String name, String input, String output, int options, String[] additionalOptions,
                                    int enable, int loop)
        {
            var nameHandle   = InteropHelper.StringToPtr(name);
            var inputHandle  = InteropHelper.StringToPtr(input);
            var outputHandle = InteropHelper.StringToPtr(output);

            var result = _newBroadCastInputFunction.Delegate(InstancePointer, nameHandle.AddrOfPinnedObject(),
                                                             inputHandle.AddrOfPinnedObject(), outputHandle.AddrOfPinnedObject(), options,
                                                             InteropHelper.StringArrayToPtr(additionalOptions), enable, loop) == 0;

            nameHandle.Free();
            inputHandle.Free();
            outputHandle.Free();

            return(result);
        }
Example #3
0
        /// <summary>
        /// 提供指定的参数初始化一个 Vlc 实例
        /// </summary>
        /// <param name="argv"></param>
        public Vlc(String[] argv)
        {
            if (!IsLibLoaded)
            {
                LoadLibVlc();
            }
            if (argv == null)
            {
                InstancePointer = NewInstanceFunction.Delegate(0, IntPtr.Zero);
            }
            else
            {
                InstancePointer = NewInstanceFunction.Delegate(argv.Length, InteropHelper.StringArrayToPtr(argv));
            }
            if (InstancePointer == IntPtr.Zero)
            {
                String ex = VlcError.GetErrorMessage();
                throw new Exception(ex);
            }

            HandleManager.Add(this);
        }
Example #4
0
        public bool VlmAddVod(String name, String input, int options, String[] additionalOptions, int enable,
                              String muxer)
        {
            var nameHandle  = InteropHelper.StringToPtr(name);
            var inputHandle = InteropHelper.StringToPtr(input);
            var muxerHandle = InteropHelper.StringToPtr(muxer);

            var result = _newVodInputFunction.Delegate(InstancePointer, nameHandle.AddrOfPinnedObject(),
                                                       inputHandle.AddrOfPinnedObject(), options, InteropHelper.StringArrayToPtr(additionalOptions), enable,
                                                       muxerHandle.AddrOfPinnedObject()) == 0;

            nameHandle.Free();
            inputHandle.Free();
            muxerHandle.Free();

            return(result);
        }