changeset 25068:4b14d188ed34

Add all passed to VID_SET_FORMAT formats to the end of available format list (but report call as failed, to continue checking formats). This gives small chance to build graph even if device does not report about particular format as supported. This makes mplayer be able to work with PVR-150 card (card's driver does not report about yuy2 format, but accepts connection and works with it).
author voroshil
date Sun, 18 Nov 2007 13:17:00 +0000
parents 5abe2c29b7d8
children d2f7027f0556
files stream/tvi_dshow.c
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stream/tvi_dshow.c	Sun Nov 18 11:36:57 2007 +0000
+++ b/stream/tvi_dshow.c	Sun Nov 18 13:17:00 2007 +0000
@@ -3090,6 +3090,7 @@
 	{
 	    int fcc, i;
 	    void* tmp;
+	    int result = TVI_CONTROL_TRUE;
 
 	    if (priv->state)
 		return TVI_CONTROL_FALSE;
@@ -3102,7 +3103,31 @@
 		    (priv->arpmtVideo[i], fcc, priv->width, priv->height))
 		    break;
 	    if (!priv->arpmtVideo[i])
-		return TVI_CONTROL_FALSE;
+	    {
+		int fps = 0;
+		VIDEOINFOHEADER* Vhdr = NULL;
+		AM_MEDIA_TYPE *pmt;
+
+		mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: will try also use undeclared video format: %dx%d, %s\n",priv->width, priv->height, vo_format_name(fcc));
+
+		if (priv->arpmtVideo[0])
+		    Vhdr = (VIDEOINFOHEADER *) priv->arpmtVideo[0]->pbFormat;
+
+		if(Vhdr && Vhdr->bmiHeader.biSizeImage)
+		    fps = Vhdr->dwBitRate / (8 * Vhdr->bmiHeader.biSizeImage);
+
+		pmt=create_video_format(fcc, priv->width, priv->height, fps);
+		if(!pmt)
+		{
+		    mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to create AM_MEDIA_TYPE structure for given format\n");
+		    return TVI_CONTROL_FALSE;
+		}
+		priv->arpmtVideo=realloc(priv->arpmtVideo, (i+2)*sizeof(AM_MEDIA_TYPE*));
+		priv->arpmtVideo[i+1] = NULL;
+		priv->arpmtVideo[i] = pmt;
+
+		result = TVI_CONTROL_FALSE;
+	    }
 
 	    tmp = priv->arpmtVideo[0];
 	    priv->arpmtVideo[0] = priv->arpmtVideo[i];
@@ -3125,7 +3150,7 @@
 	    extract_video_format(priv->arpmtVideo[priv->nVideoFormatUsed],
 				 &(priv->fcc), &(priv->width),
 				 &(priv->height));
-	    return TVI_CONTROL_TRUE;
+	    return result;
 	}
     case TVI_CONTROL_VID_GET_FORMAT:
 	{