Microsoft DirectX 9.0

Using the Demux with PSI Streams

To get PSI information from an MPEG-2 transport stream using the MPEG-2 demux filter, create an output pin on the demux with the following media type:

Then call the output pin's IMPEG2PIDMap::MapPID method with the desired PID and the flag MEDIA_MPEG2_PSI.

// Query the demux filter for IMpeg2Demultiplexer.
IMpeg2Demultiplexer *pDemux = NULL;
hr = pFilter->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux);
if (SUCCEEDED(hr))
    // Define the media type.
    ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
    mt.subtype = MEDIASUBTYPE_None;

    // Create a new output pin.
    IPin *pPin;
    hr = pDemux->CreateOutputPin(&mt, L"PSI Pin", &pPin);
    if (SUCCEEDED(hr))
        // Map the PID.
        IMPEG2PIDMap *pPidMap = NULL;
        hr = pPin->QueryInterface(IID_IMPEG2PIDMap, (void**)&pPidMap);
        if (SUCCEEDED(hr))
            ULONG Pid[] = { 0x00 }; // Map any desired PIDs. 
            ULONG cPid = 1;
            hr = pPidMap->MapPID(cPid, Pid, MEDIA_MPEG2_PSI);

Each complete PSI section is delivered in one media sample. To retrieve the PID number associated with a table section, call IMediaSample2::GetProperties on the media sample. The PID is given in the low 13 bits of the dwTypeSpecificFlags flag in the AM_SAMPLE2_PROPERTIES structure. This is useful if you map multiple PSI PIDs to the same output pin.

See Also