# HG changeset patch # User voroshil # Date 1195384408 0 # Node ID 54dba785e6830505f9a6ba30090337a4489d3c41 # Parent f9a966f36dae615c8500de9fd082142358893ca2 New media format negotiation code: loop through all available formats trying to establish connection between pins. Negotiation stops either when all formats are rejected (error reported in this case) or when connection is established (which can happen only when current media format is accepted by both of the pins). diff -r f9a966f36dae -r 54dba785e683 stream/tvi_dshow.c --- a/stream/tvi_dshow.c Sun Nov 18 10:55:51 2007 +0000 +++ b/stream/tvi_dshow.c Sun Nov 18 11:13:28 2007 +0000 @@ -1390,18 +1390,30 @@ set_buffer_preference(20,(WAVEFORMATEX*)(arpmt[nFormatProbed]->pbFormat),pCapturePin,pSGIn); } + for(nFormatProbed=0; arpmt[nFormatProbed]; nFormatProbed++) + { + DisplayMediaType("Probing format", arpmt[nFormatProbed]); hr = OLE_CALL_ARGS(pSG, SetMediaType, arpmt[nFormatProbed]); //set desired mediatype if(FAILED(hr)){ mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetMediaType(pSG) call failed. Error:0x%x\n", (unsigned int)hr); - break; + continue; } /* connecting filters together: VideoCapture --> SampleGrabber */ hr = OLE_CALL_ARGS(priv->pGraph, Connect, pCapturePin, pSGIn); if(FAILED(hr)){ mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Unable to create pCapturePin<->pSGIn connection. Error:0x%x\n", (unsigned int)hr); + continue; + } + break; + } + OLE_RELEASE_SAFE(pSG); + + if(!arpmt[nFormatProbed]) + { + mp_msg(MSGT_TV, MSGL_WARN, "tvi_dshow: Unable to negotiate media format\n"); + hr = E_FAIL; break; } - OLE_RELEASE_SAFE(pSG); hr = OLE_CALL_ARGS(pCapturePin, ConnectionMediaType, pmt); if(FAILED(hr))