/// <summary>
        /// Associates a ratio value (numerator and denominator) with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies the value to set.</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 SetRatio(this IMFAttributes attributes, Guid guidKey, uint numerator, uint denominator)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            return(attributes.SetUINT64(guidKey, ((ulong)numerator << 32) | denominator));
        }
        /// <summary>
        /// Associates a Ratio value with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies the value to set.</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 SetSize(this IMFAttributes attributes, Guid guidKey, uint width, uint height)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            return(attributes.SetUINT64(guidKey, ((ulong)width << 32) | height));
        }
        /// <summary>
        /// Associates a UInt64 value with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies the value to set.</param>
        /// <param name="value">New value for this key.</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 SetUINT64(this IMFAttributes attributes, Guid guidKey, ulong value)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            return(attributes.SetUINT64(guidKey, unchecked ((long)value)));
        }
        /// <summary>
        /// Associates an address location value with a key.
        /// </summary>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies the value to set.</param>
        /// <param name="value">New value for this key as a 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 store them as a 64-bits unsigned integer.</remarks>
        public static HResult SetPointer(this IMFAttributes attributes, Guid guidKey, IntPtr value)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            return(attributes.SetUINT64(guidKey, value.ToInt64()));
        }
        private static IMFAttributes CreateVideoAttributes(VideoFormat videoOutput)
        {
            IMFAttributes videoAttributes = null;

            MFHelper.MFCreateAttributes(out videoAttributes, 0);
            videoAttributes.SetGUID(new Guid(Consts.MF_MT_SUBTYPE), videoOutput.Subtype);

            PackedINT32 pixelAspectRatio = new PackedINT32(1, 1);

            // Set the argument attributes
            videoAttributes.SetUINT64(new Guid(Consts.MF_MT_FRAME_RATE), videoOutput.FrameRate.Packed);
            videoAttributes.SetUINT64(new Guid(Consts.MF_MT_FRAME_SIZE), videoOutput.FrameSize.Packed);
            videoAttributes.SetUINT64(new Guid(Consts.MF_MT_PIXEL_ASPECT_RATIO), pixelAspectRatio.Packed);
            videoAttributes.SetUINT32(new Guid(Consts.MF_MT_INTERLACE_MODE), videoOutput.InterlaceMode);
            videoAttributes.SetUINT32(new Guid(Consts.MF_MT_AVG_BITRATE), videoOutput.AvgBitRate);

            return(videoAttributes);
        }
Esempio n. 6
0
 public static HResult MFSetAttribute2UINT32asUINT64(
     IMFAttributes pAttributes,
     Guid guidKey,
     int unHigh32,
     int unLow32
     )
 {
     return(pAttributes.SetUINT64(guidKey, Pack2UINT32AsUINT64(unHigh32, unLow32)));
 }
Esempio n. 7
0
        public static void MFSetAttribute2UINT32asUINT64(IMFAttributes pAttributes, Guid g, int nNumerator, int nDenominator)
        {
            HResult hr;
            long    ul = nNumerator;

            ul <<= 32;
            ul  |= (UInt32)nDenominator;

            hr = pAttributes.SetUINT64(g, ul);
            MFError.ThrowExceptionForHR(hr);
        }
Esempio n. 8
0
        public static void MFSetAttribute2UINT32asUINT64(IMFAttributes pAttributes, Guid g, int nNumerator, int nDenominator)
        {
            int hr;
            long ul = nNumerator;

            ul <<= 32;
            ul |= (UInt32)nDenominator;

            hr = pAttributes.SetUINT64(g, ul);
            MFError.ThrowExceptionForHR(hr);
        }
Esempio n. 9
0
 public HResult SetUINT64(Guid guidKey, long unValue)
 {
     return(m_Attribs.SetUINT64(guidKey, unValue));
 }