Example #1
0
        public static void MFGetAttribute2UINT32asUINT64(IMFAttributes pAttributes, Guid g, out int nNumerator, out int nDenominator)
        {
            long    ul;
            HResult hr;

            hr = pAttributes.GetUINT64(g, out ul);
            MFError.ThrowExceptionForHR(hr);

            nDenominator = (int)ul;
            nNumerator   = (int)(ul >> 32);
        }
Example #2
0
        public static long GetInt64(this IMFAttributes obj, Guid key, long defaultValue = 0)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj.GetUINT64(key, out var value).IsError)
            {
                return(defaultValue);
            }

            return((long)value);
        }
Example #3
0
        public static ulong GetUInt64(this IMFAttributes input, Guid key, ulong defaultValue = 0)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (input.GetUINT64(key, out var value).IsError)
            {
                return(defaultValue);
            }

            return(value);
        }
        /// <summary>
        /// Retrieves an address location value associated with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies which value to retrieve.</param>
        /// <param name="value">Receives the requested value as an IntPtr.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        /// <remarks>Media Foundation attributes don't natively support pointer values. This method get them as a 64-bits unsigned integer and convert that value as a IntPtr.</remarks>
        public static HResult GetPointer(this IMFAttributes attributes, Guid guidKey, out IntPtr value)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            long result = 0;

            HResult hr = attributes.GetUINT64(guidKey, out result);

            value = new IntPtr(result);

            return(hr);
        }
        /// <summary>
        /// Retrieves a UInt64 value associated with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies which value to retrieve.</param>
        /// <param name="value">Receives the requested value.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        public static HResult GetUINT64(this IMFAttributes attributes, Guid guidKey, out ulong value)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            long result = 0;

            HResult hr = attributes.GetUINT64(guidKey, out result);

            value = (ulong)result;

            return(hr);
        }
Example #6
0
        public static HResult MFGetAttribute2UINT32asUINT64(IMFAttributes pAttributes, Guid guidKey, out int punHigh32, out int punLow32)
        {
            long    unPacked;
            HResult hr;

            hr = pAttributes.GetUINT64(guidKey, out unPacked);
            if (hr < 0)
            {
                punHigh32 = punLow32 = 0;
                return(hr);
            }
            Unpack2UINT32AsUINT64(unPacked, out punHigh32, out punLow32);

            return(hr);
        }
        /// <summary>
        /// Retrieves a size value (width and height) associated with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies which value to retrieve.</param>
        /// <param name="width">The width part of the size.</param>
        /// <param name="height">The height part of the size.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        /// <remarks>Width and height values are stored packed as 64-bits value.</remarks>
        public static HResult GetSize(this IMFAttributes attributes, Guid guidKey, out uint width, out uint height)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            width  = 0;
            height = 0;

            ulong value;

            HResult hr = attributes.GetUINT64(guidKey, out value);

            if (hr.Succeeded())
            {
                width  = (uint)(value >> 32);
                height = (uint)(value & 0xffffffff);
            }

            return(hr);
        }
        /// <summary>
        /// Retrieves a ratio value (numerator and denominator) associated with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies which value to retrieve.</param>
        /// <param name="numerator">The numerator part of the ratio.</param>
        /// <param name="denominator">The denominator part of the ratio.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        /// <remarks>Numerator and denominator values are stored packed as 64-bits value.</remarks>
        public static HResult GetRatio(this IMFAttributes attributes, Guid guidKey, out uint numerator, out uint denominator)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            numerator   = 0;
            denominator = 0;

            ulong value;

            HResult hr = attributes.GetUINT64(guidKey, out value);

            if (hr.Succeeded())
            {
                numerator   = (uint)(value >> 32);
                denominator = (uint)(value & 0xffffffff);
            }

            return(hr);
        }
Example #9
0
        public static void MFGetAttribute2UINT32asUINT64(IMFAttributes pAttributes, Guid g, out int nNumerator, out int nDenominator)
        {
            long ul;
            int hr;

            hr = pAttributes.GetUINT64(g, out ul);
            MFError.ThrowExceptionForHR(hr);

            nDenominator = (int)ul;
            nNumerator = (int)(ul >> 32);
        }
Example #10
0
 public HResult GetUINT64(Guid guidKey, out long punValue)
 {
     return(m_Attribs.GetUINT64(guidKey, out punValue));
 }