+ /* Only force the chroma setting if it is specified by the user. */
+ if( p_sys->b_chroma )
+ {
+ /* Find out if the pin handles MEDIATYPE_Stream, in which case we
+ * won't add a prefered media type as this doesn't seem to work well
+ * -- to investigate. */
+ vlc_bool_t b_stream_type = VLC_FALSE;
+ for( size_t i = 0; i < media_count; i++ )
+ {
+ if( media_types[i].majortype == MEDIATYPE_Stream )
+ {
+ b_stream_type = VLC_TRUE;
+ break;
+ }
+ }
+
+ if( !b_stream_type && !b_audio )
+ {
+ // Insert prefered video media type
+ AM_MEDIA_TYPE mtr;
+ VIDEOINFOHEADER vh;
+
+ mtr.majortype = MEDIATYPE_Video;
+ mtr.subtype = MEDIASUBTYPE_I420;
+ mtr.bFixedSizeSamples = TRUE;
+ mtr.bTemporalCompression = FALSE;
+ mtr.pUnk = NULL;
+ mtr.formattype = FORMAT_VideoInfo;
+ mtr.cbFormat = sizeof(vh);
+ mtr.pbFormat = (BYTE *)&vh;
+
+ memset(&vh, 0, sizeof(vh));
+
+ vh.bmiHeader.biSize = sizeof(vh.bmiHeader);
+ vh.bmiHeader.biWidth = p_sys->i_width > 0 ? p_sys->i_width : 320;
+ vh.bmiHeader.biHeight = p_sys->i_height > 0 ? p_sys->i_height : 240;
+ vh.bmiHeader.biPlanes = 3;
+ vh.bmiHeader.biBitCount = 12;
+ vh.bmiHeader.biCompression = VLC_FOURCC('I','4','2','0');
+ vh.bmiHeader.biSizeImage = vh.bmiHeader.biWidth * 12 *
+ vh.bmiHeader.biHeight / 8;
+ mtr.lSampleSize = vh.bmiHeader.biSizeImage;
+
+ mt_count = 1;
+ mt = (AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
+ CopyMediaType(mt, &mtr);
+ }
+ else if( !b_stream_type )
+ {
+ // Insert prefered audio media type
+ AM_MEDIA_TYPE mtr;
+ WAVEFORMATEX wf;
+
+ mtr.majortype = MEDIATYPE_Audio;
+ mtr.subtype = MEDIASUBTYPE_PCM;
+ mtr.bFixedSizeSamples = TRUE;
+ mtr.bTemporalCompression = FALSE;
+ mtr.lSampleSize = 0;
+ mtr.pUnk = NULL;
+ mtr.formattype = FORMAT_WaveFormatEx;
+ mtr.cbFormat = sizeof(wf);
+ mtr.pbFormat = (BYTE *)&wf;
+
+ memset(&wf, 0, sizeof(wf));
+
+ wf.wFormatTag = WAVE_FORMAT_PCM;
+ wf.nChannels = 2;
+ wf.nSamplesPerSec = 44100;
+ wf.wBitsPerSample = 16;
+ wf.nBlockAlign = wf.nSamplesPerSec * wf.wBitsPerSample / 8;
+ wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
+ wf.cbSize = 0;
+
+ mt_count = 1;
+ mt = (AM_MEDIA_TYPE *)malloc( sizeof(AM_MEDIA_TYPE)*mt_count );
+ CopyMediaType(mt, &mtr);
+ }
+ }
+