public DisposableNativeString(IntPtr pointer)
 {
     if (pointer == IntPtr.Zero)
     {
         throw FFmpegException.NoMemory($"pointer = 0 in {nameof(DisposableNativeString)}.");
     }
     Pointer = pointer;
 }
Example #2
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));
            }
        }