コード例 #1
0
            private LogMessage GetMessage(libvlc_log_message_t msg)
            {
                StringBuilder sb = new StringBuilder();

                sb.AppendFormat("{0} ", Marshal.PtrToStringAnsi(msg.psz_header));
                sb.AppendFormat("{0} ", Marshal.PtrToStringAnsi(msg.psz_message));
                sb.AppendFormat("{0} ", Marshal.PtrToStringAnsi(msg.psz_name));
                sb.Append(Marshal.PtrToStringAnsi(msg.psz_type));

                return(new LogMessage()
                {
                    Message = sb.ToString(), Severity = (libvlc_log_messate_t_severity)msg.i_severity
                });
            }
コード例 #2
0
            public IEnumerator <LogMessage> GetEnumerator()
            {
                IntPtr i = LibVlcMethods.libvlc_log_get_iterator(m_hLog);

                while (LibVlcMethods.libvlc_log_iterator_has_next(i) != 0)
                {
                    libvlc_log_message_t msg = new libvlc_log_message_t();
                    msg.sizeof_msg = (uint)Marshal.SizeOf(msg);
                    LibVlcMethods.libvlc_log_iterator_next(i, ref msg);

                    yield return(GetMessage(msg));
                }

                LibVlcMethods.libvlc_log_iterator_free(i);
                LibVlcMethods.libvlc_log_clear(m_hLog);
            }
コード例 #3
0
        public void UpdateMessages()
        {
            VerifyObjectIsNotDisposed();
            //
            libvlc_exception_t exc = new libvlc_exception_t();

            LibVlcInterop.libvlc_exception_init(ref exc);
            IntPtr iterator = LibVlcInterop.libvlc_log_get_iterator(descriptor, ref exc);

            if (exc.b_raised != 0)
            {
                throw new VlcInternalException(exc.Message);
            }
            //
            try {
                while (0 != LibVlcInterop.libvlc_log_iterator_has_next(iterator, ref exc))
                {
                    if (exc.b_raised != 0)
                    {
                        throw new VlcInternalException(exc.Message);
                    }
                    //
                    libvlc_log_message_t messageBuffer = new libvlc_log_message_t();
                    messageBuffer.sizeof_msg = Convert.ToUInt32(Marshal.SizeOf(typeof(libvlc_log_message_t)));
                    IntPtr ptrStructRes = LibVlcInterop.libvlc_log_iterator_next(iterator, ref messageBuffer, ref exc);
                    if (exc.b_raised != 0)
                    {
                        throw new VlcInternalException(exc.Message);
                    }
                    //
                    libvlc_log_message_t msgRes = (libvlc_log_message_t)Marshal.PtrToStructure(ptrStructRes, typeof(libvlc_log_message_t));
                    string text = String.Format("{0} {1} {2} : {3}", msgRes.Type, msgRes.Name, msgRes.Header, msgRes.Message);
                    //
                    switch (msgRes.Severity)
                    {
                    case libvlc_log_messate_t_severity.INFO: {
                        // INFO
                        logger.Info(text);
                        break;
                    }

                    case libvlc_log_messate_t_severity.ERR: {
                        // ERR
                        logger.Error(text);
                        break;
                    }

                    case libvlc_log_messate_t_severity.WARN: {
                        // WARN
                        logger.Warn(text);
                        break;
                    }

                    case libvlc_log_messate_t_severity.DBG: {
                        // DBG
                        logger.Debug(text);
                        break;
                    }

                    default: {
                        logger.Trace("Unknown severity : " + text);
                        break;
                    }
                    }
                }
            } finally {
                LibVlcInterop.libvlc_log_iterator_free(iterator, ref exc);
            }
        }