Example #1
0
 public static long ThrowIfError(this long errorCode, string?message = null)
 {
     if (errorCode < 0)
     {
         throw FFmpegException.FromErrorCode((int)errorCode, message);
     }
     return(errorCode);
 }
 public DisposableNativeString(IntPtr pointer)
 {
     if (pointer == IntPtr.Zero)
     {
         throw FFmpegException.NoMemory($"pointer = 0 in {nameof(DisposableNativeString)}.");
     }
     Pointer = pointer;
 }
Example #3
0
        public BufferReference Create(Span <byte> data, Action <IntPtr, IntPtr> free, IntPtr opaque, int flags)
        {
            if (data.Length == 0)
                throw new ArgumentOutOfRangeException(nameof(data));
            fixed(byte *ptr = data)
            {
                AVBufferRef *res = av_buffer_create(ptr, data.Length, new av_buffer_create_free((o, d) => free((IntPtr)o, (IntPtr)d)), (void *)opaque, flags);

                if (res == null)
                {
                    throw FFmpegException.NoMemory("falied to allocate AVBufferRef");
                }
                return(FromNative(res, isOwner: true));
            }
        }