/// <summary> /// Creates a media source from a byte stream. /// </summary> /// <param name="sourceResolver">A valid IMFSourceResolver instance.</param> /// <param name="byteStream">An instance of the byte stream's IMFByteStream interface.</param> /// <param name="url">A string that contains the URL of the byte stream. The URL is optional and can be null.</param> /// <param name="flags">One or more members of the MFResolution enumeration.</param> /// <param name="properties">An instance of the IPropertyStore interface of a property store. The method passes the property store to the scheme handler or byte-stream handler that creates the object.</param> /// <param name="mediaSource">Receives a media source that can handle the provided byte stream.</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 CreateObjectFromByteStream(this IMFSourceResolver sourceResolver, IMFByteStream byteStream, string url, MFResolution flags, IPropertyStore properties, out IMFMediaSource mediaSource) { if (sourceResolver == null) { throw new ArgumentNullException("sourceResolver"); } flags &= ~MFResolution.ByteStream; flags |= MFResolution.MediaSource; MFObjectType objectType; object tmp; HResult hr = sourceResolver.CreateObjectFromByteStream(byteStream, url, flags, properties, out objectType, out tmp); mediaSource = hr.Succeeded() ? tmp as IMFMediaSource : null; return(hr); }