Luke
Luke

Reputation: 5971

Connection from my output pin to avi mux

I want my filter to be accepted as input to avi mux filter. But it rejects the connection with a VFW_E_CANNOT_CONNECT error.

Here's what I did:

In my outputpin class i implemented the Connect(IPin* pin, AM_MEDIA_TYPE *pmt) method. Then I call my GetMediaType function, which gives me CMediaType Object:

See bellow for GetMEdiaTypeMethod

As you can see it has major type of MEDIATYPE_Stream as well as a subtype of MEDIASUBTYPE_Avi as this is the format the avi mux filter will accept.

Finally in Connect I call ReceiveConnection method of my peer pin.

Here's my whole Connect method:

 HRESULT MCMyOutputPin::Connect(IPin* pPin, const AM_MEDIA_TYPE *pmt)
{



    CMediaType* mediatype;
    HRESULT hr = GetMediaType(0, mediatype);
    if (FAILED(hr)) return hr;
    hr = pPin->ReceiveConnection(this, mediatype);
    return hr;
}

edit: I still haven't solved the problem. It still keeps rejecting the connection. Here is my new GetMediaType Method that initializes AM_MEDIA_TYPE with all its needed values and structures:

HRESULT MCMyOutputPin::GetMediaType(int i, CMediaType *pmt)
{
    if (i < 0)
    {

        myLogger->LogDebug("Invalid arg in getmediatype", L"D:\\TEMP\\yc.log");
        return E_INVALIDARG;
    }
    if (i == 0)
    {
        myLogger->LogDebug("On GetMediaType", L"D:\\TEMP\\yc.log");
        VIDEOINFO *pvi = (VIDEOINFO *)pmt->AllocFormatBuffer(sizeof(VIDEOINFO));
        if (NULL == pvi)
            return(E_OUTOFMEMORY);

        ZeroMemory(pvi, sizeof(VIDEOINFO));



        pvi->bmiHeader.biCompression = 0x3231564e;
        pvi->bmiHeader.biBitCount = 12;

        pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        pvi->bmiHeader.biWidth = 256;
        pvi->bmiHeader.biHeight = 240;
        pvi->bmiHeader.biPlanes = 1;
        pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader);
        pvi->bmiHeader.biClrImportant = 0;


        pvi->AvgTimePerFrame = 333333;
        pvi->dwBitRate = 0;
        pvi->dwBitErrorRate = 0;
        SetRectEmpty(&(pvi->rcSource));
        SetRectEmpty(&(pvi->rcTarget));
        pmt->SetFormatType(&FORMAT_VideoInfo);
        pmt->SetFormat((BYTE*)pvi, sizeof(pvi));
        pmt->SetTemporalCompression(FALSE);
        pmt->SetType(&MEDIATYPE_Video);
        const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
        pmt->SetSubtype(&SubTypeGUID);
        pmt->SetSampleSize(pvi->bmiHeader.biSizeImage);

        return S_OK;


    }
    return VFW_S_NO_MORE_ITEMS;
}

Here are the filters I want to connect:

enter image description here

Here is the graph construction report I get when i try to connect the filters:

0.000 sec Filter Selected : ffdshow Video Decoder 

0.015 sec Created filter  
 CLSID {04FE9017-F873-410E-871E-AB91661A4EF7} 
Object Name  
Merit 0xff800001 
Version 0x00000002 

0.015 sec Filter Selected : DirectVobSub (auto-loading version) 

0.046 sec Created filter  
 CLSID {9852A670-F845-491B-9BE6-EBD841B8A613} 
Object Name  
Merit 0x00800002 
Version 0x00000002 


0.046 sec Filter Selected : WMVideo8 Encoder DMO 

0.046 sec  
 CLSID {94297043-BD82-4DFD-B0DE-8177739C6D20} 

0.046 sec Filter Selected : WMVideo9 Encoder DMO 

0.046 sec  
 CLSID {94297043-BD82-4DFD-B0DE-8177739C6D20} 

0.046 sec Filter Selected : AVI Decompressor 

0.046 sec Created filter  
 CLSID {CF49D4E0-1115-11CE-B03A-0020AF0BA770} 
Object Name  
Merit 0x00600000 
Version 0x00000002 

I updated my GetMediaType method according to a sample in the sdk. But it still doesnt work

Upvotes: 0

Views: 428

Answers (1)

Dee Mon
Dee Mon

Reputation: 1046

Your output pin says it provides Stream of AVI type but this is not what AVI Mux wants, this is what it should produce itself. What it wants for input is a video stream or an audio stream or maybe some other type of data but not an AVI stream. What kind of data your filter really produces? If it's some video, then output major type = Video, subtype = guid of your video format.

Upvotes: 1

Related Questions