Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c	(revision 3469)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c	(revision 3470)
@@ -611,5 +611,5 @@
 
                     for (i = 0; i < icount; i++) {
-                        RPC_STATUS rpcstatus;
+                        RPC_STATUS rpcstatus, rpcstatus2;
 
                         hr = IAMStreamConfig_GetStreamCaps(streamcaps, i,
@@ -619,12 +619,16 @@
                             continue;
 
-                        if (UuidCompare(&mediatype->subtype,
-                                        (UUID *)dshow_format,
-                                        &rpcstatus) == 0 &&
-                            rpcstatus == RPC_S_OK)
+                        if (UuidCompare(&mediatype->subtype, 
+					(UUID*)dshow_format,
+					&rpcstatus) == 0 && 
+			    rpcstatus == RPC_S_OK &&
+			    UuidCompare(&mediatype->formattype,
+					(UUID*)&FORMAT_VideoInfo,
+					&rpcstatus2) == 0 &&
+			    rpcstatus2 == RPC_S_OK)
                         {
                             srcpin = pPin;
                             graph->mediatype = mediatype;
-                            break;
+			    break;
                         }
                     }
@@ -674,6 +678,6 @@
     if (vfd->fps.num != 0)
         video_info->AvgTimePerFrame = (LONGLONG) (10000000 * 
-                                      vfd->fps.denum /
-                                      (double)vfd->fps.num);
+						  (double)vfd->fps.denum /
+						  vfd->fps.num);
     video_info->bmiHeader.biSizeImage = DIBSIZE(video_info->bmiHeader);
     mediatype->lSampleSize = DIBSIZE(video_info->bmiHeader);
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshowclasses.cpp
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshowclasses.cpp	(revision 3469)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshowclasses.cpp	(revision 3470)
@@ -17,10 +17,16 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#undef _DEBUG
-#undef DEBUG
+
+#include <pjmedia-videodev/config.h>
+
+#if PJMEDIA_VIDEO_DEV_HAS_DSHOW
 
 #include <streams.h>
 
-#pragma comment(lib, "Strmbase.lib")
+#if PJ_DEBUG
+#   pragma comment(lib, "Strmbasd.lib")
+#else
+#   pragma comment(lib, "Strmbase.lib")
+#endif
 
 typedef void (*input_callback)(void *user_data, IMediaSample *pMediaSample);
@@ -208,2 +214,4 @@
     ((OutputPin *)src->GetPin(0))->bufSize = size;
 }
+
+#endif	/* PJMEDIA_VIDEO_DEV_HAS_DSHOW */
Index: pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c
===================================================================
--- pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c	(revision 3469)
+++ pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c	(revision 3470)
@@ -19,4 +19,6 @@
 #include <pjmedia/videoport.h>
 #include <pjmedia/clock.h>
+#include <pjmedia/converter.h>
+#include <pjmedia/errno.h>
 #include <pjmedia/vid_codec.h>
 #include <pj/log.h>
@@ -48,4 +50,8 @@
     pj_bool_t		 destroy_client_port;
 
+    pjmedia_converter	*cap_conv;
+    void		*cap_conv_buf;
+    pj_size_t		 cap_conv_buf_size;
+
     pjmedia_clock	*enc_clock,
 		        *dec_clock;
@@ -116,4 +122,5 @@
     pj_status_t status;
     unsigned ptime_usec;
+    pjmedia_vid_param vparam;
 
     PJ_ASSERT_RETURN(pool && prm && p_vid_port, PJ_EINVAL);
@@ -152,4 +159,52 @@
 	return status;
 
+    vparam = prm->vidparam;
+
+    /* Check if we need converter */
+    if (vp->dir & PJMEDIA_DIR_CAPTURE) {
+	unsigned i;
+
+	for (i = 0; i < di.fmt_cnt; ++i) {
+	    if (prm->vidparam.fmt.id == di.fmt[i].id)
+		break;
+	}
+
+	if (i == di.fmt_cnt) {
+	    /* Yes, we need converter */
+	    pjmedia_conversion_param conv_param;
+	    const pjmedia_video_format_info *vfi;
+	    pjmedia_video_apply_fmt_param vafp;
+
+	    pjmedia_format_copy(&conv_param.src, &prm->vidparam.fmt);
+	    pjmedia_format_copy(&conv_param.dst, &prm->vidparam.fmt);
+	    for (i = 0; i < di.fmt_cnt; ++i) {
+		conv_param.src.id = di.fmt[i].id;
+		status = pjmedia_converter_create(NULL, pool, &conv_param, 
+						  &vp->cap_conv);
+		if (status == PJ_SUCCESS)
+		    break;
+	    }
+	    if (status != PJ_SUCCESS)
+		return status;
+
+	    /* Update format ID for the capture device */
+	    vparam.fmt.id = conv_param.src.id;
+
+	    /* Allocate buffer for conversion */
+	    vfi = pjmedia_get_video_format_info(NULL, conv_param.dst.id);
+	    if (!vfi)
+		return PJMEDIA_EBADFMT;
+
+	    pj_bzero(&vafp, sizeof(vafp));
+	    vafp.size = vfd->size;
+	    status = vfi->apply_fmt(vfi, &vafp);
+	    if (status != PJ_SUCCESS)
+		return PJMEDIA_EBADFMT;
+
+	    vp->cap_conv_buf = pj_pool_alloc(pool, vafp.framebytes);
+	    vp->cap_conv_buf_size = vafp.framebytes;
+	}
+    }
+
     PJ_LOG(4,(THIS_FILE, "Opening %s..", di.name));
 
@@ -175,5 +230,5 @@
     vid_cb.on_event_cb = &vidstream_event_cb;
 
-    status = pjmedia_vid_dev_stream_create(&prm->vidparam, &vid_cb, vp,
+    status = pjmedia_vid_dev_stream_create(&vparam, &vid_cb, vp,
 				           &vp->strm);
     if (status != PJ_SUCCESS)
@@ -222,5 +277,5 @@
 			        prm->vidparam.dir, &prm->vidparam.fmt);
 
-	if (vp->stream_role == ROLE_ACTIVE) {
+	if (vp->stream_role == ROLE_ACTIVE || vp->cap_conv) {
 	    need_frame_buf = PJ_TRUE;
 	}
@@ -231,5 +286,5 @@
 	pjmedia_video_apply_fmt_param vafp;
 
-	vfi = pjmedia_get_video_format_info(NULL, prm->vidparam.fmt.id);
+	vfi = pjmedia_get_video_format_info(NULL, vparam.fmt.id);
 	if (!vfi) {
 	    status = PJ_ENOTFOUND;
@@ -535,4 +590,5 @@
      */
     pjmedia_vid_port *vp = (pjmedia_vid_port*)user_data;
+    pjmedia_frame frame;
     pj_status_t status;
 
@@ -551,5 +607,15 @@
     //save_rgb_frame(vp->cap_size.w, vp->cap_size.h, vp->enc_frm_buf);
 
-    status = pjmedia_port_put_frame(vp->client_port, vp->enc_frm_buf);
+    frame = *vp->enc_frm_buf;
+    if (vp->cap_conv) {
+	frame.buf  = vp->cap_conv_buf;
+	frame.size = vp->cap_conv_buf_size;
+	status = pjmedia_converter_convert(vp->cap_conv,
+					   vp->enc_frm_buf, &frame);
+	if (status != PJ_SUCCESS)
+	    return;
+    }
+
+    status = pjmedia_port_put_frame(vp->client_port, &frame);
 }
 
@@ -699,15 +765,28 @@
 {
     pjmedia_vid_port *vp = (pjmedia_vid_port*)user_data;
+    pjmedia_frame frame_;
+
+    frame_ = *frame;
+    if (vp->cap_conv) {
+	pj_status_t status;
+
+	frame_.buf  = vp->cap_conv_buf;
+	frame_.size = vp->cap_conv_buf_size;
+	status = pjmedia_converter_convert(vp->cap_conv,
+					   frame, &frame_);
+	if (status != PJ_SUCCESS)
+	    return status;
+    }
 
     if (vp->role==ROLE_ACTIVE) {
         if (vp->client_port)
-	    return pjmedia_port_put_frame(vp->client_port, frame);
+	    return pjmedia_port_put_frame(vp->client_port, &frame_);
     } else {
 	pj_mutex_lock(vp->enc_frm_mutex);
-	copy_frame(vp->enc_frm_buf, frame);
+	copy_frame(vp->enc_frm_buf, &frame_);
 	pj_mutex_unlock(vp->enc_frm_mutex);
     }
     if (vp->strm_cb.capture_cb)
-        return (*vp->strm_cb.capture_cb)(stream, vp->strm_cb_data, frame);
+        return (*vp->strm_cb.capture_cb)(stream, vp->strm_cb_data, &frame_);
     return PJ_SUCCESS;
 }
@@ -774,5 +853,19 @@
 
     if (vp->stream_role==ROLE_PASSIVE) {
-	return pjmedia_vid_dev_stream_get_frame(vp->strm, frame);
+	if (vp->cap_conv) {
+	    pj_status_t status;
+
+	    vp->enc_frm_buf->size = vp->enc_frm_buf_size;
+	    status = pjmedia_vid_dev_stream_get_frame(vp->strm, vp->enc_frm_buf);
+	    if (status != PJ_SUCCESS)
+		return status;
+
+	    status = pjmedia_converter_convert(vp->cap_conv,
+					       vp->enc_frm_buf, frame);
+	    if (status != PJ_SUCCESS)
+		return status;
+	} else {
+	    return pjmedia_vid_dev_stream_get_frame(vp->strm, frame);
+	}
     } else {
 	pj_mutex_lock(vp->enc_frm_mutex);
