Index: /pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia-videodev/videodev.h
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia-videodev/videodev.h	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia-videodev/videodev.h	(revision 3579)
@@ -358,8 +358,8 @@
 
 /**
- * Initialize the video subsystem. This will register all supported video
- * device factories to the video subsystem. This function may be called
- * more than once, but each call to this function must have the
- * corresponding #pjmedia_vid_subsys_shutdown() call.
+ * Initialize the video device subsystem. This will register all supported
+ * video device factories to the video device subsystem. This function may be
+ * called more than once, but each call to this function must have the
+ * corresponding #pjmedia_vid_dev_subsys_shutdown() call.
  *
  * @param pf        The pool factory.
@@ -368,30 +368,31 @@
  *                  error code.
  */
-PJ_DECL(pj_status_t) pjmedia_vid_subsys_init(pj_pool_factory *pf);
-
-
-/**
- * Get the pool factory registered to the video subsystem.
+PJ_DECL(pj_status_t) pjmedia_vid_dev_subsys_init(pj_pool_factory *pf);
+
+
+/**
+ * Get the pool factory registered to the video device subsystem.
  *
  * @return          The pool factory.
  */
-PJ_DECL(pj_pool_factory*) pjmedia_vid_subsys_get_pool_factory(void);
-
-
-/**
- * Shutdown the video subsystem. This will destroy all video device factories
- * registered in the video subsystem. Note that currently opened video streams
- * may or may not be closed, depending on the implementation of the video
- * device factories.
- *
- * @return          PJ_SUCCESS on successful operation or the appropriate
- *                  error code.
- */
-PJ_DECL(pj_status_t) pjmedia_vid_subsys_shutdown(void);
-
-
-/**
- * Register a supported video device factory to the video subsystem. This
- * function can only be called after calling #pjmedia_vid_subsys_init().
+PJ_DECL(pj_pool_factory*) pjmedia_vid_dev_subsys_get_pool_factory(void);
+
+
+/**
+ * Shutdown the video device subsystem. This will destroy all video device
+ * factories registered in the video device subsystem. Note that currently
+ * opened video streams may or may not be closed, depending on the
+ * implementation of the video device factories.
+ *
+ * @return          PJ_SUCCESS on successful operation or the appropriate
+ *                  error code.
+ */
+PJ_DECL(pj_status_t) pjmedia_vid_dev_subsys_shutdown(void);
+
+
+/**
+ * Register a supported video device factory to the video device subsystem.
+ * This function can only be called after calling
+ * #pjmedia_vid_dev_subsys_init().
  *
  * @param vdf       The video device factory.
@@ -405,6 +406,6 @@
 
 /**
- * Unregister an video device factory from the video subsystem. This
- * function can only be called after calling #pjmedia_vid_subsys_init().
+ * Unregister a video device factory from the video device subsystem. This
+ * function can only be called after calling #pjmedia_vid_dev_subsys_init().
  * Devices from this factory will be unlisted. If a device from this factory
  * is currently in use, then the behavior is undefined.
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/videodev.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/videodev.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/videodev.c	(revision 3579)
@@ -105,5 +105,5 @@
 };
 
-/* The video subsystem */
+/* The video device subsystem */
 static struct vid_subsys
 {
@@ -309,6 +309,6 @@
 }
 
-/* API: Initialize the video subsystem. */
-PJ_DEF(pj_status_t) pjmedia_vid_subsys_init(pj_pool_factory *pf)
+/* API: Initialize the video device subsystem. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_subsys_init(pj_pool_factory *pf)
 {
     unsigned i;
@@ -367,5 +367,5 @@
 }
 
-/* API: register an video device factory to the video subsystem. */
+/* API: register a video device factory to the video device subsystem. */
 PJ_DEF(pj_status_t)
 pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr adf)
@@ -387,5 +387,5 @@
 }
 
-/* API: unregister an video device factory from the video subsystem. */
+/* API: unregister a video device factory from the video device subsystem. */
 PJ_DEF(pj_status_t)
 pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr adf)
@@ -414,12 +414,12 @@
 }
 
-/* API: get the pool factory registered to the video subsystem. */
-PJ_DEF(pj_pool_factory*) pjmedia_vid_subsys_get_pool_factory(void)
+/* API: get the pool factory registered to the video device subsystem. */
+PJ_DEF(pj_pool_factory*) pjmedia_vid_dev_subsys_get_pool_factory(void)
 {
     return vid_subsys.pf;
 }
 
-/* API: Shutdown the video subsystem. */
-PJ_DEF(pj_status_t) pjmedia_vid_subsys_shutdown(void)
+/* API: Shutdown the video device subsystem. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_subsys_shutdown(void)
 {
     unsigned i;
@@ -433,9 +433,11 @@
     --vid_subsys.init_count;
 
-    for (i=0; i<vid_subsys.drv_cnt; ++i) {
-	deinit_driver(i);
-    }
-
-    vid_subsys.pf = NULL;
+    if (vid_subsys.init_count == 0) {
+        for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	    deinit_driver(i);
+        }
+
+        vid_subsys.pf = NULL;
+    }
     return PJ_SUCCESS;
 }
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c	(revision 3579)
@@ -418,5 +418,5 @@
     pool = pj_pool_create(mem, "Vid codec test", 256, 256, 0);
 
-    status = pjmedia_vid_subsys_init(mem);
+    status = pjmedia_vid_dev_subsys_init(mem);
     if (status != PJ_SUCCESS)
         return -10;
@@ -436,5 +436,5 @@
 on_return:
     pjmedia_codec_ffmpeg_deinit();
-    pjmedia_vid_subsys_shutdown();
+    pjmedia_vid_dev_subsys_shutdown();
     pj_pool_release(pool);
     pj_log_set_level(orig_log_level);
Index: /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_dev_test.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_dev_test.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_dev_test.c	(revision 3579)
@@ -277,5 +277,5 @@
     pj_status_t status;
     
-    status = pjmedia_vid_subsys_init(mem);
+    status = pjmedia_vid_dev_subsys_init(mem);
     if (status != PJ_SUCCESS)
         return -10;
@@ -290,5 +290,5 @@
 
 on_return:
-    pjmedia_vid_subsys_shutdown();
+    pjmedia_vid_dev_subsys_shutdown();
     
     return rc;
Index: /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/aviplay.c	(revision 3579)
@@ -481,5 +481,5 @@
     pjmedia_vid_codec_mgr_create(pool, NULL);
     
-    status = pjmedia_vid_subsys_init(&cp.factory);
+    status = pjmedia_vid_dev_subsys_init(&cp.factory);
     if (status != PJ_SUCCESS)
         goto on_return;
@@ -508,5 +508,5 @@
     pjmedia_codec_ffmpeg_deinit();
     pjmedia_aud_subsys_shutdown();
-    pjmedia_vid_subsys_shutdown();
+    pjmedia_vid_dev_subsys_shutdown();
     
     pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance());
Index: /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/simpleua.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/simpleua.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/simpleua.c	(revision 3579)
@@ -383,5 +383,5 @@
     status = pjmedia_vid_codec_mgr_create(pool, NULL);
     PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
-    status = pjmedia_vid_subsys_init(&cp.factory);
+    status = pjmedia_vid_dev_subsys_init(&cp.factory);
     PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
 
Index: /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/vid_streamutil.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/vid_streamutil.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/vid_streamutil.c	(revision 3579)
@@ -566,5 +566,5 @@
 
     /* Init video subsystem */
-    pjmedia_vid_subsys_init(&cp.factory);
+    pjmedia_vid_dev_subsys_init(&cp.factory);
 
     /* Register all supported codecs */
@@ -912,5 +912,5 @@
 
     /* Shutdown video subsystem */
-    pjmedia_vid_subsys_shutdown();
+    pjmedia_vid_dev_subsys_shutdown();
 
     /* Release application pool */
Index: /pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c	(revision 3578)
+++ /pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_media.c	(revision 3579)
@@ -298,5 +298,5 @@
     }
 
-    status = pjmedia_vid_subsys_init(&pjsua_var.cp.factory);
+    status = pjmedia_vid_dev_subsys_init(&pjsua_var.cp.factory);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Error creating PJMEDIA video subsystem",
@@ -541,5 +541,5 @@
 	/* Videodev */
 #	if PJMEDIA_HAS_VIDEO
-	    pjmedia_vid_subsys_shutdown();
+	    pjmedia_vid_dev_subsys_shutdown();
 #	endif
 
