Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/colorbar_dev.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/colorbar_dev.c	(revision 3579)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/colorbar_dev.c	(revision 3580)
@@ -379,5 +379,6 @@
     PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL);
     PJ_ASSERT_RETURN(param->fmt.type == PJMEDIA_TYPE_VIDEO &&
-		     param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO,
+		     param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&
+                     param->dir == PJMEDIA_DIR_CAPTURE,
 		     PJ_EINVAL);
 
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 3579)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c	(revision 3580)
@@ -66,5 +66,5 @@
     {PJMEDIA_FORMAT_YUY2, &MEDIASUBTYPE_YUY2} ,
     {PJMEDIA_FORMAT_RGB24, &MEDIASUBTYPE_RGB24} ,
-    {PJMEDIA_FORMAT_RGB32, &MEDIASUBTYPE_RGB32} ,
+//    {PJMEDIA_FORMAT_RGB32, &MEDIASUBTYPE_RGB32} ,
     //{PJMEDIA_FORMAT_IYUV, &MEDIASUBTYPE_IYUV} ,
 };
@@ -114,5 +114,5 @@
         IBaseFilter         *rend_filter;
         AM_MEDIA_TYPE       *mediatype;
-    } dgraph[2];
+    } dgraph;
 
     pj_timestamp	     cap_ts;
@@ -384,9 +384,5 @@
 
     pj_bzero(param, sizeof(*param));
-    if (di->info.dir & PJMEDIA_DIR_CAPTURE_RENDER) {
-	param->dir = PJMEDIA_DIR_CAPTURE_RENDER;
-	param->cap_id = index;
-	param->rend_id = index;
-    } else if (di->info.dir & PJMEDIA_DIR_CAPTURE) {
+    if (di->info.dir & PJMEDIA_DIR_CAPTURE) {
 	param->dir = PJMEDIA_DIR_CAPTURE;
 	param->cap_id = index;
@@ -402,6 +398,4 @@
     /* Set the device capabilities here */
     param->clock_rate = DEFAULT_CLOCK_RATE;
-    //param->frame_rate.num = DEFAULT_FPS;
-    //param->frame_rate.denum = 1;
     param->flags = PJMEDIA_VID_DEV_CAP_FORMAT;
 
@@ -451,5 +445,5 @@
 {
     struct dshow_stream *stream = (struct dshow_stream*)strm;
-    unsigned i;
+    HRESULT hr;
 
     if (stream->quit_flag) {
@@ -458,15 +452,8 @@
     }
 
-    for (i = 0; i < 2; i++) {
-        if (stream->dgraph[i].csource_filter) {
-            HRESULT hr = SourceFilter_Deliver(stream->dgraph[i].csource_filter,
-					      frame->buf, frame->size);
-
-            if (FAILED(hr)) {
-                return hr;
-            }
-            break;
-        }
-    }
+    hr = SourceFilter_Deliver(stream->dgraph.csource_filter,
+                              frame->buf, frame->size);
+    if (FAILED(hr))
+        return hr;
 
     return PJ_SUCCESS;
@@ -728,23 +715,19 @@
 static void destroy_filter_graph(struct dshow_stream * stream)
 {
-    unsigned i;
-
-    for (i = 0; i < 2; i++) {
-        if (stream->dgraph[i].source_filter) {
-            IBaseFilter_Release(stream->dgraph[i].source_filter);
-            stream->dgraph[i].source_filter = NULL;
-        }
-        if (stream->dgraph[i].rend_filter) {
-            IBaseFilter_Release(stream->dgraph[i].rend_filter);
-            stream->dgraph[i].rend_filter = NULL;
-        }
-        if (stream->dgraph[i].media_filter) {
-            IMediaFilter_Release(stream->dgraph[i].media_filter);
-            stream->dgraph[i].media_filter = NULL;
-        }
-        if (stream->dgraph[i].filter_graph) {
-            IFilterGraph_Release(stream->dgraph[i].filter_graph);
-            stream->dgraph[i].filter_graph = NULL;
-        }
+    if (stream->dgraph.source_filter) {
+        IBaseFilter_Release(stream->dgraph.source_filter);
+        stream->dgraph.source_filter = NULL;
+    }
+    if (stream->dgraph.rend_filter) {
+        IBaseFilter_Release(stream->dgraph.rend_filter);
+        stream->dgraph.rend_filter = NULL;
+    }
+    if (stream->dgraph.media_filter) {
+        IMediaFilter_Release(stream->dgraph.media_filter);
+        stream->dgraph.media_filter = NULL;
+    }
+    if (stream->dgraph.filter_graph) {
+        IFilterGraph_Release(stream->dgraph.filter_graph);
+        stream->dgraph.filter_graph = NULL;
     }
 }
@@ -761,6 +744,8 @@
     pj_pool_t *pool;
     struct dshow_stream *strm;
-    unsigned ngraph = 0;
     pj_status_t status;
+
+    PJ_ASSERT_RETURN(param->dir == PJMEDIA_DIR_CAPTURE ||
+                     param->dir == PJMEDIA_DIR_RENDER, PJ_EINVAL);
 
     if (!get_dshow_format_info(param->fmt.id))
@@ -777,11 +762,11 @@
     strm->user_data = user_data;
 
-    /* Create capture stream here */
     if (param->dir & PJMEDIA_DIR_CAPTURE) {
 	const pjmedia_video_format_detail *vfd;
 
+        /* Create capture stream here */
         status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id,
                                      PJ_FALSE, PJ_FALSE, df, strm,
-                                     &strm->dgraph[ngraph++]);
+                                     &strm->dgraph);
         if (status != PJ_SUCCESS) {
             destroy_filter_graph(strm);
@@ -790,5 +775,5 @@
             status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id,
                                          PJ_FALSE, PJ_TRUE, df, strm,
-                                         &strm->dgraph[ngraph]);
+                                         &strm->dgraph);
 
             if (status != PJ_SUCCESS) {
@@ -801,5 +786,5 @@
                                              param->cap_id,
                                              PJ_TRUE, PJ_TRUE, df, strm,
-                                             &strm->dgraph[ngraph]);
+                                             &strm->dgraph);
             }
 
@@ -811,11 +796,9 @@
 	vfd = pjmedia_format_get_video_format_detail(&param->fmt, PJ_TRUE);
 	strm->cap_ts_inc = PJMEDIA_SPF2(param->clock_rate, &vfd->fps, 1);
-    }
-
-    /* Create render stream here */
-    if (param->dir & PJMEDIA_DIR_RENDER) {
+    } else if (param->dir & PJMEDIA_DIR_RENDER) {
+        /* Create render stream here */
         status = create_filter_graph(PJMEDIA_DIR_RENDER, param->rend_id,
                                      PJ_FALSE, PJ_FALSE, df, strm,
-                                     &strm->dgraph[ngraph++]);
+                                     &strm->dgraph);
         if (status != PJ_SUCCESS)
             goto on_error;
@@ -903,5 +886,5 @@
 {
     struct dshow_stream *stream = (struct dshow_stream*)strm;
-    unsigned i;
+    HRESULT hr;
 
     stream->quit_flag = PJ_FALSE;
@@ -909,17 +892,11 @@
     stream->rend_thread_exited = PJ_FALSE;
 
-    for (i = 0; i < 2; i++) {
-        HRESULT hr;
-
-        if (!stream->dgraph[i].media_filter)
-            continue;
-        hr = IMediaFilter_Run(stream->dgraph[i].media_filter, 0);
-        if (FAILED(hr)) {
-	    char msg[80];
-	    if (AMGetErrorText(hr, msg, sizeof(msg))) {
-		PJ_LOG(4,(THIS_FILE, "Error starting media: %s", msg));
-	    }
-            return PJ_EUNKNOWN;
+    hr = IMediaFilter_Run(stream->dgraph.media_filter, 0);
+    if (FAILED(hr)) {
+        char msg[80];
+        if (AMGetErrorText(hr, msg, sizeof(msg))) {
+            PJ_LOG(4,(THIS_FILE, "Error starting media: %s", msg));
         }
+        return PJ_EUNKNOWN;
     }
 
@@ -943,9 +920,5 @@
 	pj_thread_sleep(10);
 
-    for (i = 0; i < 2; i++) {
-        if (!stream->dgraph[i].media_filter)
-            continue;
-        IMediaFilter_Stop(stream->dgraph[i].media_filter);
-    }
+    IMediaFilter_Stop(stream->dgraph.media_filter);
 
     PJ_LOG(4, (THIS_FILE, "Stopping dshow video stream"));
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/sdl_dev.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/sdl_dev.c	(revision 3579)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/sdl_dev.c	(revision 3580)
@@ -392,19 +392,7 @@
 
     pj_bzero(param, sizeof(*param));
-    if (di->info.dir == PJMEDIA_DIR_CAPTURE_RENDER) {
-	param->dir = PJMEDIA_DIR_CAPTURE_RENDER;
-	param->cap_id = index;
-	param->rend_id = index;
-    } else if (di->info.dir & PJMEDIA_DIR_CAPTURE) {
-	param->dir = PJMEDIA_DIR_CAPTURE;
-	param->cap_id = index;
-	param->rend_id = PJMEDIA_VID_INVALID_DEV;
-    } else if (di->info.dir & PJMEDIA_DIR_RENDER) {
-	param->dir = PJMEDIA_DIR_RENDER;
-	param->rend_id = index;
-	param->cap_id = PJMEDIA_VID_INVALID_DEV;
-    } else {
-	return PJMEDIA_EVID_INVDEV;
-    }
+    param->dir = PJMEDIA_DIR_RENDER;
+    param->rend_id = index;
+    param->cap_id = PJMEDIA_VID_INVALID_DEV;
 
     /* Set the device capabilities here */
@@ -412,7 +400,5 @@
     param->fmt.type = PJMEDIA_TYPE_VIDEO;
     param->clock_rate = DEFAULT_CLOCK_RATE;
-    pjmedia_format_init_video(&param->fmt, sdl_fmts[0].fmt_id,
-			      DEFAULT_WIDTH, DEFAULT_HEIGHT,
-			      DEFAULT_FPS, 1);
+    pj_memcpy(&param->fmt, &di->info.fmt[0], sizeof(param->fmt));
 
     return PJ_SUCCESS;
@@ -1018,4 +1004,6 @@
     pj_status_t status;
 
+    PJ_ASSERT_RETURN(param->dir == PJMEDIA_DIR_RENDER, PJ_EINVAL);
+
     /* Create and Initialize stream descriptor */
     pool = pj_pool_create(sf->pf, "sdl-dev", 1000, 1000, NULL);
@@ -1027,8 +1015,4 @@
     pj_memcpy(&strm->vid_cb, cb, sizeof(*cb));
     strm->user_data = user_data;
-
-    /* Create capture stream here */
-    if (param->dir & PJMEDIA_DIR_CAPTURE) {
-    }
 
     /* Create render stream here */
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/v4l2_dev.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/v4l2_dev.c	(revision 3579)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/v4l2_dev.c	(revision 3580)
@@ -532,5 +532,6 @@
     PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL);
     PJ_ASSERT_RETURN(param->fmt.type == PJMEDIA_TYPE_VIDEO &&
-		     param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO,
+		     param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&
+                     param->dir == PJMEDIA_DIR_CAPTURE,
 		     PJ_EINVAL);
     PJ_ASSERT_RETURN(param->cap_id >= 0 && param->cap_id < cf->dev_count,
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c	(revision 3579)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c	(revision 3580)
@@ -141,5 +141,6 @@
     PJ_ASSERT_RETURN(pool && prm && p_vid_port, PJ_EINVAL);
     PJ_ASSERT_RETURN(prm->vidparam.fmt.type == PJMEDIA_TYPE_VIDEO &&
-                     prm->vidparam.dir != PJMEDIA_DIR_NONE,
+                     prm->vidparam.dir != PJMEDIA_DIR_NONE &&
+                     prm->vidparam.dir != PJMEDIA_DIR_CAPTURE_RENDER,
 		     PJ_EINVAL);
 
