예제 #1
0
파일: AvLib.cs 프로젝트: spccdt/sematena
        public void Initialize()
        {
            VlcContext.LibVlcDllsPath = getVlcLibPath();
            //VlcContext.LibVlcDllsPath = @"C:\Program Files (x86)\VideoLAN\VLC";
            VlcContext.LibVlcPluginsPath = getVlcPluginsPath();
            //VlcContext.LibVlcPluginsPath = @"C:\Program Files (x86)\VideoLAN\VLC\plugins";

            var loggingEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["LoggingEnabled"]);
            VlcContext.StartupOptions.IgnoreConfig = true;
            VlcContext.StartupOptions.LogOptions.LogInFile = loggingEnabled;
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = loggingEnabled;
            VlcContext.StartupOptions.LogOptions.Verbosity = loggingEnabled ? VlcLogVerbosities.Debug : VlcLogVerbosities.None;

            _vlcInstancePtr = VlcContext.Initialize();

            _libPlayer = VlcContext.InteropManager.MediaPlayerInterops;
            _libMedia = VlcContext.InteropManager.MediaInterops;
            _libEvents = VlcContext.InteropManager.EventInterops;

            var funcNewPlayerInst = _libPlayer.NewInstance;
            _vlcPlayerPtr = funcNewPlayerInst.Invoke(_vlcInstancePtr);

            _vlcEventManagerPtr = _libPlayer.EventManagerNewIntance.Invoke( _vlcPlayerPtr );
            _eventCallbackDelegate = new EventCallbackDelegate(this.OnVlcEvent);
            _libEvents.Attach.Invoke(_vlcEventManagerPtr, EventTypes.MediaPlayerPlaying, _eventCallbackDelegate, IntPtr.Zero);
            _libEvents.Attach.Invoke(_vlcEventManagerPtr, EventTypes.MediaPlayerStopped, _eventCallbackDelegate, IntPtr.Zero);
        }
예제 #2
0
        private void InitVlcLib(string libVlcDllsDirectory)
        {
            if (!Directory.Exists(libVlcDllsDirectory))
            {
                throw new DirectoryNotFoundException(string.Format("The directory : {0} not found.", libVlcDllsDirectory));
            }

            string libVlcFilePath = Path.Combine(libVlcDllsDirectory, "libvlc.dll");

            if (!File.Exists(libVlcFilePath))
            {
                throw new FileNotFoundException("Libvlc library not found in directory.");
            }
            string libVlcCoreFilePath = Path.Combine(libVlcDllsDirectory, "libvlccore.dll");

            if (!File.Exists(libVlcCoreFilePath))
            {
                throw new FileNotFoundException("Libvlccore library not found in directory.");
            }

            myLibVlcCoreDllHandle = Win32Interop.LoadLibrary(libVlcCoreFilePath);
            if (myLibVlcCoreDllHandle == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            myLibVlcDllHandle = Win32Interop.LoadLibrary(libVlcFilePath);
            if (myLibVlcDllHandle == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            GetVersion = new LibVlcFunction <GetVersion>(myLibVlcDllHandle);

            var reg   = new Regex("^[0-9.]*");
            var match = reg.Match(GetVersion.Invoke());

            VlcVersion = new Version(match.Groups[0].Value);

            NewInstance     = new LibVlcFunction <NewInstance>(myLibVlcDllHandle, VlcVersion);
            ReleaseInstance = new LibVlcFunction <ReleaseInstance>(myLibVlcDllHandle, VlcVersion);
            RetainInstance  = new LibVlcFunction <RetainInstance>(myLibVlcDllHandle, VlcVersion);
            AddInterface    = new LibVlcFunction <AddInterface>(myLibVlcDllHandle, VlcVersion);
            SetExitCallback = new LibVlcFunction <SetExitCallback>(myLibVlcDllHandle, VlcVersion);
            Wait            = new LibVlcFunction <Wait>(myLibVlcDllHandle, VlcVersion);
            SetUserAgent    = new LibVlcFunction <SetUserAgent>(myLibVlcDllHandle, VlcVersion);
            GetCompiler     = new LibVlcFunction <GetCompiler>(myLibVlcDllHandle, VlcVersion);
            GetChangeSet    = new LibVlcFunction <GetChangeSet>(myLibVlcDllHandle, VlcVersion);
            FreeMemory      = new LibVlcFunction <FreeMemory>(myLibVlcDllHandle, VlcVersion);
            //GetModuleDescriptionList = new LibVlcFunction<GetModuleDescriptionList>(myLibVlcDllHandle, VlcVersion);
            //ReleaseModule = new LibVlcFunction<ReleaseModuleDescription>(myLibVlcDllHandle, VlcVersion);

            EventInterops         = new LibVlcAsynchronousEvents(myLibVlcDllHandle, VlcVersion);
            MediaPlayerInterops   = new LibVlcMediaPlayer(myLibVlcDllHandle, VlcVersion);
            MediaInterops         = new LibVlcMedia(myLibVlcDllHandle, VlcVersion);
            MediaListInterops     = new LibVlcMediaList(myLibVlcDllHandle, VlcVersion);
            AudioInterops         = new LibVlcAudio(myLibVlcDllHandle, VlcVersion);
            VideoInterops         = new LibVlcVideo(myLibVlcDllHandle, VlcVersion);
            LoggingInterops       = new LibVlcLogging(myLibVlcDllHandle, VlcVersion);
            ErrorHandlingInterops = new LibVlcErrorHandling(myLibVlcDllHandle, VlcVersion);
        }
예제 #3
0
        private void InitVlcLib(string libVlcDllsDirectory)
        {
            if (!Directory.Exists(libVlcDllsDirectory))
                throw new DirectoryNotFoundException(string.Format("The directory : {0} not found.", libVlcDllsDirectory));

            string libVlcFilePath = Path.Combine(libVlcDllsDirectory, "libvlc.dll");
            if (!File.Exists(libVlcFilePath))
                throw new FileNotFoundException("Libvlc library not found in directory.");
            string libVlcCoreFilePath = Path.Combine(libVlcDllsDirectory, "libvlccore.dll");
            if (!File.Exists(libVlcCoreFilePath))
                throw new FileNotFoundException("Libvlccore library not found in directory.");

            myLibVlcCoreDllHandle = Win32Interop.LoadLibrary(libVlcCoreFilePath);
            if (myLibVlcCoreDllHandle == IntPtr.Zero)
                throw new Win32Exception(Marshal.GetLastWin32Error());
            myLibVlcDllHandle = Win32Interop.LoadLibrary(libVlcFilePath);
            if (myLibVlcDllHandle == IntPtr.Zero)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            GetVersion = new LibVlcFunction<GetVersion>(myLibVlcDllHandle);

            var reg = new Regex("^[0-9.]*");
            var match = reg.Match(IntPtrExtensions.ToStringAnsi(GetVersion.Invoke()));
            VlcVersion = new Version(match.Groups[0].Value);

            NewInstance = new LibVlcFunction<NewInstance>(myLibVlcDllHandle, VlcVersion);
            ReleaseInstance = new LibVlcFunction<ReleaseInstance>(myLibVlcDllHandle, VlcVersion);
            RetainInstance = new LibVlcFunction<RetainInstance>(myLibVlcDllHandle, VlcVersion);
            AddInterface = new LibVlcFunction<AddInterface>(myLibVlcDllHandle, VlcVersion);
            SetExitCallback = new LibVlcFunction<SetExitCallback>(myLibVlcDllHandle, VlcVersion);
            Wait = new LibVlcFunction<Wait>(myLibVlcDllHandle, VlcVersion);
            SetUserAgent = new LibVlcFunction<SetUserAgent>(myLibVlcDllHandle, VlcVersion);
            GetCompiler = new LibVlcFunction<GetCompiler>(myLibVlcDllHandle, VlcVersion);
            GetChangeSet = new LibVlcFunction<GetChangeSet>(myLibVlcDllHandle, VlcVersion);
            FreeMemory = new LibVlcFunction<FreeMemory>(myLibVlcDllHandle, VlcVersion);
            //GetModuleDescriptionList = new LibVlcFunction<GetModuleDescriptionList>(myLibVlcDllHandle, VlcVersion);
            //ReleaseModule = new LibVlcFunction<ReleaseModuleDescription>(myLibVlcDllHandle, VlcVersion);

            EventInterops = new LibVlcAsynchronousEvents(myLibVlcDllHandle, VlcVersion);
            MediaPlayerInterops = new LibVlcMediaPlayer(myLibVlcDllHandle, VlcVersion);
            MediaInterops = new LibVlcMedia(myLibVlcDllHandle, VlcVersion);
            MediaListInterops = new LibVlcMediaList(myLibVlcDllHandle, VlcVersion);
            AudioInterops = new LibVlcAudio(myLibVlcDllHandle, VlcVersion);
            VideoInterops = new LibVlcVideo(myLibVlcDllHandle, VlcVersion);
            LoggingInterops = new LibVlcLogging(myLibVlcDllHandle, VlcVersion);
            ErrorHandlingInterops = new LibVlcErrorHandling(myLibVlcDllHandle, VlcVersion);
            MediaListPlayerInterops = new LibVlcMediaListPlayer(myLibVlcDllHandle, VlcVersion);
        }