IMFSourceResolver::CreateObjectFromURL method (mfidl.h)

Creates a media source or a byte stream from a URL. This method is synchronous.

Syntax

HRESULT CreateObjectFromURL(
  [in]  LPCWSTR        pwszURL,
  [in]  DWORD          dwFlags,
  [in]  IPropertyStore *pProps,
  [out] MF_OBJECT_TYPE *pObjectType,
  [out] IUnknown       **ppObject
);

Parameters

[in] pwszURL

Null-terminated string that contains the URL to resolve.

[in] dwFlags

Bitwise OR of one or more flags. See Source Resolver Flags. See remarks below.

[in] pProps

Pointer to 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. The handler can use the property store to configure the object. This parameter can be NULL. For more information, see Configuring a Media Source.

[out] pObjectType

Receives a member of the MF_OBJECT_TYPE enumeration, specifying the type of object that was created.

[out] ppObject

Receives a pointer to the object's IUnknown interface. The caller must release the interface.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The method succeeded.
MF_E_SOURCERESOLVER_MUTUALLY_EXCLUSIVE_FLAGS
The dwFlags parameter contains mutually exclusive flags.
MF_E_UNSUPPORTED_SCHEME
The URL scheme is not supported.

Remarks

The dwFlags parameter must contain either the MF_RESOLUTION_MEDIASOURCE flag or the MF_RESOLUTION_BYTESTREAM flag, but should not contain both.

It is recommended that you do not set MF_RESOLUTION_WRITE on the input argument dwFlags unless it is necessary for your scenario. For most use-cases, media sources do not need to be created with write capability. Creating a media source with write capability may have a lower probability of success than creating a media source without write capability. This is because there can be stricter checks on the content represented by the URL when creating a media source with write capability.

For local files, you can pass the file name in the pwszURL parameter; the file: scheme is not required.

Note  This method cannot be called remotely.
 

Examples

//  Create a media source from a URL.
HRESULT CreateMediaSource(PCWSTR sURL, IMFMediaSource **ppSource)
{
    MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;

    IMFSourceResolver* pSourceResolver = NULL;
    IUnknown* pSource = NULL;

    // Create the source resolver.
    HRESULT hr = MFCreateSourceResolver(&pSourceResolver);
    if (FAILED(hr))
    {
        goto done;
    }

    // Use the source resolver to create the media source.

    // Note: For simplicity this sample uses the synchronous method to create 
    // the media source. However, creating a media source can take a noticeable
    // amount of time, especially for a network source. For a more responsive 
    // UI, use the asynchronous BeginCreateObjectFromURL method.

    hr = pSourceResolver->CreateObjectFromURL(
        sURL,                       // URL of the source.
        MF_RESOLUTION_MEDIASOURCE,  // Create a source object.
        NULL,                       // Optional property store.
        &ObjectType,        // Receives the created object type. 
        &pSource            // Receives a pointer to the media source.
        );
    if (FAILED(hr))
    {
        goto done;
    }

    // Get the IMFMediaSource interface from the media source.
    hr = pSource->QueryInterface(IID_PPV_ARGS(ppSource));

done:
    SafeRelease(&pSourceResolver);
    SafeRelease(&pSource);
    return hr;
}

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header mfidl.h
Library Mfuuid.lib

See also

IMFSourceResolver

Source Resolver