12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System.Runtime.InteropServices;
- using Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap.Interops;
- namespace Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap;
- /// <summary>
- /// Provides data for the <see cref="FfmpegUtils.FfmpegLogReceived"/> event.
- /// </summary>
- public class FfmpegLogReceivedEventArgs : EventArgs
- {
- /// <summary>
- /// Gets the message.
- /// </summary>
- /// <value>
- /// The message.
- /// </value>
- public string Message { get; private set; }
- /// <summary>
- /// Gets the level of the message.
- /// </summary>
- /// <value>
- /// The level of the message.
- /// </value>
- public LogLevel Level { get; private set; }
- /// <summary>
- /// Gets the name of the class.
- /// </summary>
- /// <value>
- /// The name of the class.
- /// </value>
- public string ClassName { get; private set; }
- /// <summary>
- /// Gets the item name of the class.
- /// </summary>
- /// <value>
- /// The item name of the class.
- /// </value>
- public string ItemName { get; private set; }
- /// <summary>
- /// Gets or sets the name of the parent log context class.
- /// </summary>
- /// <value>
- /// The name of the parent log context class. Might me empty.
- /// </value>
- public string ParentLogContextClassName { get; set; }
- /// <summary>
- /// Gets or sets the item name of the parent log context class.
- /// </summary>
- /// <value>
- /// The item name of the parent log context class. Might me empty.
- /// </value>
- public string ParentLogContextItemName { get; set; }
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate nint ItemNameFunc(nint avClass);
- internal unsafe FfmpegLogReceivedEventArgs(AVClass? avClass, AVClass? parentLogContext, LogLevel level, string line, void* ptr, void* ptr1)
- {
- ItemNameFunc itemNameFunc;
- nint strPtr;
- Message = line;
- Level = level;
- if (avClass != null)
- {
- var avc = avClass.Value;
- ClassName = Marshal.PtrToStringAnsi((nint)avc.class_name);
- if (avc.item_name != nint.Zero)
- {
- itemNameFunc = (ItemNameFunc)Marshal.GetDelegateForFunctionPointer(avc.item_name, typeof(ItemNameFunc));
- strPtr = itemNameFunc((nint)ptr);
- if (strPtr != nint.Zero)
- ItemName = Marshal.PtrToStringAnsi(strPtr);
- }
- }
- if (parentLogContext != null)
- {
- var pavc = parentLogContext.Value;
- ParentLogContextClassName = Marshal.PtrToStringAnsi((nint)pavc.class_name);
- if (pavc.item_name != nint.Zero)
- {
- itemNameFunc = (ItemNameFunc)Marshal.GetDelegateForFunctionPointer(pavc.item_name, typeof(ItemNameFunc));
- strPtr = itemNameFunc((nint)ptr1);
- if (strPtr != nint.Zero)
- ParentLogContextItemName = Marshal.PtrToStringAnsi(strPtr);
- }
- }
- }
- }
|