comparison stream/tvi_dshow.c @ 25065:54dba785e683

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).
author voroshil
date Sun, 18 Nov 2007 11:13:28 +0000
parents f9a966f36dae
children 89c42f6f6e89
comparison
equal deleted inserted replaced
25064:f9a966f36dae 25065:54dba785e683
1388 } 1388 }
1389 if(priv->tv_param->normalize_audio_chunks && !memcmp(&(arpmt[nFormatProbed]->majortype),&(MEDIATYPE_Audio),16)){ 1389 if(priv->tv_param->normalize_audio_chunks && !memcmp(&(arpmt[nFormatProbed]->majortype),&(MEDIATYPE_Audio),16)){
1390 set_buffer_preference(20,(WAVEFORMATEX*)(arpmt[nFormatProbed]->pbFormat),pCapturePin,pSGIn); 1390 set_buffer_preference(20,(WAVEFORMATEX*)(arpmt[nFormatProbed]->pbFormat),pCapturePin,pSGIn);
1391 } 1391 }
1392 1392
1393 for(nFormatProbed=0; arpmt[nFormatProbed]; nFormatProbed++)
1394 {
1395 DisplayMediaType("Probing format", arpmt[nFormatProbed]);
1393 hr = OLE_CALL_ARGS(pSG, SetMediaType, arpmt[nFormatProbed]); //set desired mediatype 1396 hr = OLE_CALL_ARGS(pSG, SetMediaType, arpmt[nFormatProbed]); //set desired mediatype
1394 if(FAILED(hr)){ 1397 if(FAILED(hr)){
1395 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetMediaType(pSG) call failed. Error:0x%x\n", (unsigned int)hr); 1398 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetMediaType(pSG) call failed. Error:0x%x\n", (unsigned int)hr);
1396 break; 1399 continue;
1397 } 1400 }
1398 /* connecting filters together: VideoCapture --> SampleGrabber */ 1401 /* connecting filters together: VideoCapture --> SampleGrabber */
1399 hr = OLE_CALL_ARGS(priv->pGraph, Connect, pCapturePin, pSGIn); 1402 hr = OLE_CALL_ARGS(priv->pGraph, Connect, pCapturePin, pSGIn);
1400 if(FAILED(hr)){ 1403 if(FAILED(hr)){
1401 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Unable to create pCapturePin<->pSGIn connection. Error:0x%x\n", (unsigned int)hr); 1404 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Unable to create pCapturePin<->pSGIn connection. Error:0x%x\n", (unsigned int)hr);
1405 continue;
1406 }
1407 break;
1408 }
1409 OLE_RELEASE_SAFE(pSG);
1410
1411 if(!arpmt[nFormatProbed])
1412 {
1413 mp_msg(MSGT_TV, MSGL_WARN, "tvi_dshow: Unable to negotiate media format\n");
1414 hr = E_FAIL;
1402 break; 1415 break;
1403 } 1416 }
1404 OLE_RELEASE_SAFE(pSG);
1405 1417
1406 hr = OLE_CALL_ARGS(pCapturePin, ConnectionMediaType, pmt); 1418 hr = OLE_CALL_ARGS(pCapturePin, ConnectionMediaType, pmt);
1407 if(FAILED(hr)) 1419 if(FAILED(hr))
1408 { 1420 {
1409 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_GetActualMediatypeFailed, (unsigned int)hr); 1421 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_GetActualMediatypeFailed, (unsigned int)hr);