using System.Runtime.InteropServices; using Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap.Interops; namespace Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap; /// /// Provides data for the event. /// public class FfmpegLogReceivedEventArgs : EventArgs { /// /// Gets the message. /// /// /// The message. /// public string Message { get; private set; } /// /// Gets the level of the message. /// /// /// The level of the message. /// public LogLevel Level { get; private set; } /// /// Gets the name of the class. /// /// /// The name of the class. /// public string ClassName { get; private set; } /// /// Gets the item name of the class. /// /// /// The item name of the class. /// public string ItemName { get; private set; } /// /// Gets or sets the name of the parent log context class. /// /// /// The name of the parent log context class. Might me empty. /// public string ParentLogContextClassName { get; set; } /// /// Gets or sets the item name of the parent log context class. /// /// /// The item name of the parent log context class. Might me empty. /// 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); } } } }