コード例 #1
0
ファイル: NetworkSource.cs プロジェクト: azdjdgh/VideoChat
        public HResult Start(IMFPresentationDescriptor pPresentationDescriptor, Guid pguidTimeFormat, ConstPropVariant pvarStartPos)
        {
            HResult hr = HResult.S_OK;

            // Check parameters.

            // Start position and presentation descriptor cannot be NULL.
            if (pvarStartPos == null || pPresentationDescriptor == null)
            {
                return(HResult.E_INVALIDARG);
            }

            // Check the time format.
            if ((pguidTimeFormat != null) && (pguidTimeFormat != Guid.Empty))
            {
                // Unrecognized time format GUID.
                return(HResult.MF_E_UNSUPPORTED_TIME_FORMAT);
            }

            // Check the data type of the start position.
            if (pvarStartPos.GetVariantType() != VariantType.None && pvarStartPos.GetVariantType() != VariantType.Int64)
            {
                return(HResult.MF_E_UNSUPPORTED_TIME_FORMAT);
            }

            if (_eSourceState != SourceState.SourceState_Stopped && _eSourceState != SourceState.SourceState_Started)
            {
                hr = HResult.MF_E_INVALIDREQUEST;
            }

            if (MFError.Succeeded(hr))
            {
                // Check if the presentation description is valid.
                hr = ValidatePresentationDescriptor(pPresentationDescriptor);
            }

            if (MFError.Succeeded(hr))
            {
                CSourceOperation op = new CSourceOperation
                {
                    Type = SourceOperationType.Operation_Start,
                    PresentationDescriptor = pPresentationDescriptor,
                    Data = pvarStartPos
                };
                doStart(op);
            }
            return(hr);
        }
コード例 #2
0
        /// <summary>
        /// Convert a PropVariant to a managed object
        /// </summary>
        /// <param name="variant">The PropVariant to convert.</param>
        /// <returns>A managed object corresponding to the given PropVariant or null if the PropVariant type is unsupported.</returns>
        public static object GetObject(this ConstPropVariant variant)
        {
            if (variant == null)
            {
                throw new ArgumentNullException("variant");
            }

            switch (variant.GetVariantType())
            {
            case ConstPropVariant.VariantType.None:
                return(null);

            case ConstPropVariant.VariantType.Short:
                return(variant.GetShort());

            case ConstPropVariant.VariantType.Int32:
                return(variant.GetInt());

            case ConstPropVariant.VariantType.Float:
                return(variant.GetFloat());

            case ConstPropVariant.VariantType.Double:
                return(variant.GetDouble());

            case ConstPropVariant.VariantType.IUnknown:
                return(variant.GetIUnknown());

            case ConstPropVariant.VariantType.UByte:
                return(variant.GetUByte());

            case ConstPropVariant.VariantType.UShort:
                return(variant.GetUShort());

            case ConstPropVariant.VariantType.UInt32:
                return(variant.GetUInt());

            case ConstPropVariant.VariantType.UInt64:
                return(variant.GetULong());

            case ConstPropVariant.VariantType.String:
                return(variant.GetString());

            case ConstPropVariant.VariantType.Guid:
                return(variant.GetGuid());

            case ConstPropVariant.VariantType.Blob:
                return(variant.GetBlob());

            case ConstPropVariant.VariantType.StringArray:
                return(variant.GetStringArray());
            }

            return(null);
        }