public MemoryRenderer(IntPtr hMediaPlayer)
        {
            m_hMediaPlayer = hMediaPlayer;

            LockEventHandler    leh = OnpLock;
            UnlockEventHandler  ueh = OnpUnlock;
            DisplayEventHandler deh = OnpDisplay;

            pLockCallback    = Marshal.GetFunctionPointerForDelegate(leh);
            pUnlockCallback  = Marshal.GetFunctionPointerForDelegate(ueh);
            pDisplayCallback = Marshal.GetFunctionPointerForDelegate(deh);

            m_callbacks.Add(leh);
            m_callbacks.Add(deh);
            m_callbacks.Add(ueh);

            m_timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            m_timer.Interval = 1000;
        }
Esempio n. 2
0
        /// <summary>
        /// 是否开启视频帧解析
        /// </summary>
        /// <param name="isoncallback"></param>
        public VlcPlayerCore(bool isoncallback = false)
        {
            this.isoncallback = isoncallback;
            string[] args = new string[]
            {
                "-I",
                "dumy",
                "--ignore-config",
                "--no-osd",
                "--disable-screensaver",
                "--ffmpeg-hw",
                "--plugin-path=./plugins"
            };

            dMediaPlaying        = MediaPlaying;
            dMediaPaused         = MediaPaused;
            dMediaPos            = MediaPos;
            dMediaStoped         = MediaStoped;
            dMediaEndReached     = MediaEndReached;
            dlockEventHandler    = mLockEventHandler;
            dunlockEventHandler  = mUnlockEventHandler;
            ddisplayEventHandler = mDisplayEventHandler;

            m_hMediaLib     = LibVlcMethods.libvlc_new(args.Length, args);
            m_hMediaPlayer  = LibVlcMethods.libvlc_media_player_new(m_hMediaLib);
            m_hEventManager = LibVlcMethods.libvlc_media_player_event_manager(m_hMediaPlayer);

            EventManager.Attach(m_hEventManager, libvlc_event_e.libvlc_MediaPlayerPlaying, dMediaPlaying);
            EventManager.Attach(m_hEventManager, libvlc_event_e.libvlc_MediaPlayerPaused, dMediaPaused);
            EventManager.Attach(m_hEventManager, libvlc_event_e.libvlc_MediaPlayerPositionChanged, dMediaPos);
            EventManager.Attach(m_hEventManager, libvlc_event_e.libvlc_MediaPlayerStopped, dMediaStoped);
            EventManager.Attach(m_hEventManager, libvlc_event_e.libvlc_MediaPlayerEndReached, dMediaEndReached);

            if (isoncallback)
            {
                //LibVlcMethods.libvlc_video_set_format(m_hMediaPlayer, new char[] { 'R', 'V', '3', '2' }, frameWidth, height, frameWidth * framePixelBits);
                LibVlcMethods.libvlc_video_set_callbacks(m_hMediaPlayer, dlockEventHandler, dunlockEventHandler, ddisplayEventHandler, IntPtr.Zero);
            }
        }
Esempio n. 3
0
 public static extern void libvlc_video_set_callbacks(IntPtr mp, LockEventHandler @lock, UnlockEventHandler unlock, DisplayEventHandler display, IntPtr opaque);