Indexer Creation and Configuration

The ASF indexer is a WMContainer layer component that is used to read or write Index Objects in an Advanced Systems Format (ASF) file. This topic provides information about creating the default indexer object provided by Media Foundation.

For information about the structure of an ASF file, see ASF File Structure.

Dd757276.wedge(en-us,VS.85).gifTo create and initialize the ASF indexer

  1. Call the MFCreateASFIndexer function to receive an IMFASFIndexer pointer to the indexer object.
  2. Call IMFASFIndexer::SetFlags to specify the read or write mode for indexer object. By default, the indexer is configured for forward seeking.

    UseFlag
    Reading (forward seeking)Zero (default)
    Reading (reverse seeking)MFASF_INDEXER_READ_FOR_REVERSEPLAYBACK
    WritingMFASF_INDEXER_WRITE_NEW_INDEX

     

    Note  The same instance of the indexer cannot be used for both reading and writing. You must configure the indexer for one or the other.

  3. Call IMFASFIndexer::Initialize to initialize the indexer by specifying the IMFASFContentInfo pointer of the ContentInfo object that describes the file to be written or read. The ContentInfo object contains information that constitutes the ASF Header Object. The indexer object requires a valid ContentInfo object before generating or reading index entries of an ASF file.

The following code example shows how an application can create and initialize the indexer object to work with specific ASF content. The ContentInfo object represents the ASF Header Object; the content is passed as a byte stream.


HRESULT CreateASFIndexer(
    IMFASFContentInfo* pContentInfo, 
    DWORD dwFlags,
    IMFASFIndexer** ppIndexer
    )
{
    *ppIndexer = NULL;

    IMFASFIndexer *pIndexer = NULL;

    HRESULT hr = MFCreateASFIndexer(&pIndexer);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pIndexer->SetFlags(dwFlags);
    if (FAILED(hr))
    {
        goto done;
    }

    hr =  pIndexer->Initialize(pContentInfo);
    if (FAILED(hr))
    {
        goto done;
    }

    // Return the object to the caller.
    *ppIndexer = pIndexer;
    (*ppIndexer)->AddRef();

done:
    // Clean up.
    SafeRelease(&pIndexer);
    return hr;
}


Related topics

Using the Indexer to Seek Within an ASF File
Using the Indexer to Write a New Index

 

 

Community Additions

ADD
Show:
© 2014 Microsoft