예제 #1
0
        public static void MFGetBlob(IMFAttributes p, Guid g, object obj)
        {
            HResult hr;
            int     iSize;
            int     i;

            // Get the blob into a byte array
            hr = p.GetBlobSize(g, out iSize);
            MFError.ThrowExceptionForHR(hr);

            byte[] b = new byte[iSize];
            hr = p.GetBlob(g, b, iSize, out i);
            MFError.ThrowExceptionForHR(hr);

            GCHandle h = GCHandle.Alloc(b, GCHandleType.Pinned);

            try
            {
                IntPtr ip = h.AddrOfPinnedObject();

                // Convert the byte array to an IntPtr
                Marshal.PtrToStructure(ip, obj);
            }
            finally
            {
                h.Free();
            }
        }
예제 #2
0
        public static byte[] GetBlob(this IMFAttributes obj, Guid key)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj.GetBlobSize(key, out var size).IsError || size == 0)
            {
                return(null);
            }

            var bytes = new byte[(int)size];

            obj.GetBlob(key, bytes, size, ref size).ThrowOnError();
            return(bytes);
        }
예제 #3
0
        public static byte[] GetBlob(this IMFAttributes input, Guid key)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (input.GetBlobSize(key, out var size).IsError || size == 0)
            {
                return(null);
            }

            var bytes = new byte[(int)size];

            input.GetBlob(key, bytes, (int)size, IntPtr.Zero).ThrowOnError();
            return(bytes);
        }
예제 #4
0
        public static void MFGetBlob(IMFAttributes p, Guid g, object obj)
        {
            int hr;
            int iSize;
            int i;

            // Get the blob into a byte array
            hr = p.GetBlobSize(g, out iSize);
            MFError.ThrowExceptionForHR(hr);

            byte[] b = new byte[iSize];
            hr = p.GetBlob(g, b, iSize, out i);
            MFError.ThrowExceptionForHR(hr);

            GCHandle h = GCHandle.Alloc(b, GCHandleType.Pinned);

            try
            {
                IntPtr ip = h.AddrOfPinnedObject();

                // Convert the byte array to an IntPtr
                Marshal.PtrToStructure(ip, obj);
            }
            finally
            {
                h.Free();
            }
        }
예제 #5
0
 public HResult GetBlobSize(Guid guidKey, out int pcbBlobSize)
 {
     return(m_Attribs.GetBlobSize(guidKey, out pcbBlobSize));
 }