Code cleanup for the photography interface. Fix the fps_n/fps_d is NULL which cause...
authorHu Gang <gang.a.hu@intel.com>
Tue, 15 Feb 2011 06:12:58 +0000 (14:12 +0800)
committerHu Gang <gang.a.hu@intel.com>
Wed, 16 Mar 2011 15:32:12 +0000 (23:32 +0800)
gst-libs/gst/camera/gstmfldcameraphotoiface.c
gst-libs/gst/camera/gstmfldcameraphotoiface.h
gst/mfldv4l2cam/v4l2camsrc_calls.c

index de4b5ce..b5692cd 100644 (file)
@@ -34,19 +34,11 @@ GST_DEBUG_CATEGORY_EXTERN (gst_camerasrc_debug);
 #define GST_CAT_DEFAULT gst_camerasrc_debug
 
 
-static gboolean
-gst_camerasrc_photo_parse_capture_caps (GstCameraSrc * camerasrc,
-    GstCaps * op_mode_caps);
-static gboolean
-gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
-    GstCaps * op_mode_caps);
-
-
 /*
  *
  */
 GstPhotoCaps
-gst_camerasrc_photo_get_capabilities (GstCameraSrc * camerasrc)
+gst_camerasrc_photo_get_capabilities (GstCameraSrc *camerasrc)
 {
   GstCameraSrcClass *bclass;
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
@@ -61,11 +53,12 @@ gst_camerasrc_photo_get_capabilities (GstCameraSrc * camerasrc)
  *
  */
 gboolean
-gst_camerasrc_photo_prepare_for_capture (GstCameraSrc * camerasrc,
-    GstPhotoCapturePrepared func, GstCaps * desired_caps, gpointer user_data)
+gst_camerasrc_photo_prepare_for_capture (GstCameraSrc *camerasrc,
+                                    GstPhotoCapturePrepared func,
+                                    GstCaps *desired_caps,
+                                    gpointer user_data)
 {
   GstCameraSrcClass *bclass;
-  gboolean use_vf_caps = TRUE;
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
@@ -74,44 +67,6 @@ gst_camerasrc_photo_prepare_for_capture (GstCameraSrc * camerasrc,
   camerasrc->prep_func = func;
   camerasrc->prep_udata = user_data;
 
-  if (!camerasrc->capture_resolution_set) {
-    if (desired_caps) {
-      GstStructure *cstr;
-
-      GST_DEBUG_OBJECT (camerasrc, "parsing capture caps");
-
-      cstr = gst_caps_get_structure (desired_caps, 0);
-
-      /* FIXME: Don't require FPS in capture caps */
-      if (gst_structure_get_int (cstr, "width",
-              (gint *) & camerasrc->capture_w) &&
-          gst_structure_get_int (cstr, "height",
-              (gint *) & camerasrc->capture_h) &&
-          gst_structure_get_fraction (cstr, "framerate",
-              (gint *) & camerasrc->capture_fps_n,
-              (gint *) & camerasrc->capture_fps_d)) {
-        if (gst_structure_has_field (cstr, "format")) {
-          gst_structure_get_fourcc (cstr, "format", &camerasrc->capture_fourcc);
-        } else {
-          /* If color format is not set, use the viewfinder format then */
-          GST_DEBUG_OBJECT (camerasrc, "using viewfinder color format");
-          camerasrc->capture_fourcc = camerasrc->current_fourcc;
-        }
-        use_vf_caps = FALSE;
-      }
-    }
-
-    if (use_vf_caps) {
-      GST_DEBUG_OBJECT (camerasrc, "given caps inadequate, using VF caps");
-
-      camerasrc->capture_w = camerasrc->current_w;
-      camerasrc->capture_h = camerasrc->current_h;
-      camerasrc->capture_fps_n = camerasrc->fps_n;
-      camerasrc->capture_fps_d = camerasrc->fps_d;
-      camerasrc->capture_fourcc = camerasrc->current_fourcc;
-    }
-  }
-
   GST_DEBUG_OBJECT (camerasrc, "starting preparations for capture (%dx%d @ %f)",
       camerasrc->capture_w, camerasrc->capture_h,
       (gfloat) camerasrc->capture_fps_n / camerasrc->capture_fps_d);
@@ -135,8 +90,8 @@ gst_camerasrc_photo_prepare_for_capture (GstCameraSrc * camerasrc,
  *
  */
 void
-gst_camerasrc_photo_ready_for_capture (GstCameraSrc * camerasrc,
-    GstCaps * newcaps)
+gst_camerasrc_photo_ready_for_capture (GstCameraSrc *camerasrc,
+                                        GstCaps *newcaps)
 {
   GST_DEBUG_OBJECT (camerasrc, "prepare for capture is complete");
 
@@ -173,25 +128,27 @@ create_debug_string (const char *base_str, GType type, gint value)
  *
  */
 gboolean
-gst_camerasrc_photo_set_ev_compensation (GstCameraSrc * camerasrc,
-    gfloat ev_comp)
+gst_camerasrc_photo_set_ev_compensation (GstCameraSrc *camerasrc,
+                                          gfloat ev_comp)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
 
+  /* FIXME: Remove this artificial limit, let subclass handle it */
   if (ev_comp >= -2.5 && ev_comp <= 2.5) {
 
     bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+    GST_OBJECT_LOCK (camerasrc);
     camerasrc->photoconf.ev_compensation = ev_comp;
+    GST_OBJECT_UNLOCK (camerasrc);
 
     if (bclass->is_active (camerasrc)) {
       ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
     }
     GST_DEBUG_OBJECT (camerasrc, "set EV: %.2f, ret = %d", ev_comp, ret);
   } else {
-    GST_DEBUG_OBJECT (camerasrc,
-        "requested ev compensation value out of range");
+    GST_DEBUG_OBJECT (camerasrc, "requested ev compensation value out of range");
     ret = FALSE;
   }
   return ret;
@@ -202,8 +159,8 @@ gst_camerasrc_photo_set_ev_compensation (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_get_ev_compensation (GstCameraSrc * camerasrc,
-    gfloat * ev_comp)
+gst_camerasrc_photo_get_ev_compensation (GstCameraSrc *camerasrc,
+                                          gfloat *ev_comp)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -213,9 +170,13 @@ gst_camerasrc_photo_get_ev_compensation (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *ev_comp = camerasrc->photoconf.ev_compensation;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got ev compensation: %.2f, ret = %d",
-      *ev_comp, ret);
+                    *ev_comp, ret);
 
   return ret;
 }
@@ -225,17 +186,20 @@ gst_camerasrc_photo_get_ev_compensation (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_iso_speed (GstCameraSrc * camerasrc, guint iso_speed)
+gst_camerasrc_photo_set_iso_speed (GstCameraSrc *camerasrc,
+                                    guint iso_speed)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.iso_speed = iso_speed;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
-    return bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
+    ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
   }
   GST_DEBUG_OBJECT (camerasrc, "set ISO: %d, ret = %d", iso_speed, ret);
 
@@ -247,7 +211,8 @@ gst_camerasrc_photo_set_iso_speed (GstCameraSrc * camerasrc, guint iso_speed)
  *
  */
 gboolean
-gst_camerasrc_photo_get_iso_speed (GstCameraSrc * camerasrc, guint * iso_speed)
+gst_camerasrc_photo_get_iso_speed (GstCameraSrc *camerasrc,
+                                    guint *iso_speed)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -257,7 +222,11 @@ gst_camerasrc_photo_get_iso_speed (GstCameraSrc * camerasrc, guint * iso_speed)
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *iso_speed = camerasrc->photoconf.iso_speed;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got iso speed: %d, ret = %d", *iso_speed, ret);
 
   return ret;
@@ -268,14 +237,17 @@ gst_camerasrc_photo_get_iso_speed (GstCameraSrc * camerasrc, guint * iso_speed)
  *
  */
 gboolean
-gst_camerasrc_photo_set_aperture (GstCameraSrc * camerasrc, guint aperture)
+gst_camerasrc_photo_set_aperture (GstCameraSrc *camerasrc,
+                                   guint aperture)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.aperture = aperture;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -290,7 +262,8 @@ gst_camerasrc_photo_set_aperture (GstCameraSrc * camerasrc, guint aperture)
  *
  */
 gboolean
-gst_camerasrc_photo_get_aperture (GstCameraSrc * camerasrc, guint * aperture)
+gst_camerasrc_photo_get_aperture (GstCameraSrc *camerasrc,
+                                   guint *aperture)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -300,7 +273,11 @@ gst_camerasrc_photo_get_aperture (GstCameraSrc * camerasrc, guint * aperture)
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *aperture = camerasrc->photoconf.aperture;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got aperture: %d, ret = %d", *aperture, ret);
 
   return ret;
@@ -311,14 +288,17 @@ gst_camerasrc_photo_get_aperture (GstCameraSrc * camerasrc, guint * aperture)
  *
  */
 gboolean
-gst_camerasrc_photo_set_exposure (GstCameraSrc * camerasrc, guint32 exposure)
+gst_camerasrc_photo_set_exposure (GstCameraSrc *camerasrc,
+                                   guint32 exposure)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.exposure = exposure;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -333,7 +313,8 @@ gst_camerasrc_photo_set_exposure (GstCameraSrc * camerasrc, guint32 exposure)
  *
  */
 gboolean
-gst_camerasrc_photo_get_exposure (GstCameraSrc * camerasrc, guint32 * exposure)
+gst_camerasrc_photo_get_exposure (GstCameraSrc *camerasrc,
+                                   guint32 *exposure)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -343,7 +324,11 @@ gst_camerasrc_photo_get_exposure (GstCameraSrc * camerasrc, guint32 * exposure)
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *exposure = camerasrc->photoconf.exposure;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got exposure: %d, ret = %d", *exposure, ret);
 
   return ret;
@@ -354,8 +339,8 @@ gst_camerasrc_photo_get_exposure (GstCameraSrc * camerasrc, guint32 * exposure)
  *
  */
 gboolean
-gst_camerasrc_photo_set_wb_mode (GstCameraSrc * camerasrc,
-    GstWhiteBalanceMode mode)
+gst_camerasrc_photo_set_wb_mode (GstCameraSrc *camerasrc,
+                                  GstWhiteBalanceMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -363,7 +348,9 @@ gst_camerasrc_photo_set_wb_mode (GstCameraSrc * camerasrc,
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.wb_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -380,8 +367,8 @@ gst_camerasrc_photo_set_wb_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_get_wb_mode (GstCameraSrc * camerasrc,
-    GstWhiteBalanceMode * mode)
+gst_camerasrc_photo_get_wb_mode (GstCameraSrc *camerasrc,
+                                  GstWhiteBalanceMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -391,7 +378,11 @@ gst_camerasrc_photo_get_wb_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.wb_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got AWB mode:%d, ret = %d", *mode, ret);
 
   return ret;
@@ -402,8 +393,8 @@ gst_camerasrc_photo_get_wb_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_tone_mode (GstCameraSrc * camerasrc,
-    GstColourToneMode mode)
+gst_camerasrc_photo_set_tone_mode (GstCameraSrc *camerasrc,
+                                    GstColourToneMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -411,7 +402,9 @@ gst_camerasrc_photo_set_tone_mode (GstCameraSrc * camerasrc,
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.tone_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -428,8 +421,8 @@ gst_camerasrc_photo_set_tone_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_get_tone_mode (GstCameraSrc * camerasrc,
-    GstColourToneMode * mode)
+gst_camerasrc_photo_get_tone_mode (GstCameraSrc *camerasrc,
+                                    GstColourToneMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -439,7 +432,11 @@ gst_camerasrc_photo_get_tone_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.tone_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got tone mode: %d, ret = %d", *mode, ret);
 
   return ret;
@@ -450,7 +447,8 @@ gst_camerasrc_photo_get_tone_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_scene_mode (GstCameraSrc * camerasrc, GstSceneMode mode)
+gst_camerasrc_photo_set_scene_mode (GstCameraSrc *camerasrc,
+                                     GstSceneMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -461,10 +459,13 @@ gst_camerasrc_photo_set_scene_mode (GstCameraSrc * camerasrc, GstSceneMode mode)
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.scene_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, TRUE);
+
     if (ret) {
       /* Read the changed parameters to local settings cache */
       bclass->read_settings (camerasrc, &camerasrc->photoconf);
@@ -496,8 +497,8 @@ gst_camerasrc_photo_set_scene_mode (GstCameraSrc * camerasrc, GstSceneMode mode)
  *
  */
 gboolean
-gst_camerasrc_photo_get_scene_mode (GstCameraSrc * camerasrc,
-    GstSceneMode * mode)
+gst_camerasrc_photo_get_scene_mode (GstCameraSrc *camerasrc,
+                                     GstSceneMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -507,7 +508,11 @@ gst_camerasrc_photo_get_scene_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.scene_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got scene mode: %d, ret = %d", *mode, ret);
 
   return ret;
@@ -518,7 +523,8 @@ gst_camerasrc_photo_get_scene_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_flash_mode (GstCameraSrc * camerasrc, GstFlashMode mode)
+gst_camerasrc_photo_set_flash_mode (GstCameraSrc *camerasrc,
+                                     GstFlashMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -526,7 +532,9 @@ gst_camerasrc_photo_set_flash_mode (GstCameraSrc * camerasrc, GstFlashMode mode)
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.flash_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -543,8 +551,8 @@ gst_camerasrc_photo_set_flash_mode (GstCameraSrc * camerasrc, GstFlashMode mode)
  *
  */
 gboolean
-gst_camerasrc_photo_get_flash_mode (GstCameraSrc * camerasrc,
-    GstFlashMode * mode)
+gst_camerasrc_photo_get_flash_mode (GstCameraSrc *camerasrc,
+                                     GstFlashMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -554,7 +562,11 @@ gst_camerasrc_photo_get_flash_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.flash_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got flash mode: %d, ret = %d", *mode, ret);
 
   return ret;
@@ -565,20 +577,23 @@ gst_camerasrc_photo_get_flash_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_zoom (GstCameraSrc * camerasrc, gfloat zoom)
+gst_camerasrc_photo_set_zoom (GstCameraSrc *camerasrc, gfloat zoom)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.zoom = zoom;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   GST_DEBUG_OBJECT (camerasrc, "setting zoom to %f", camerasrc->photoconf.zoom);
 
   if (bclass->set_zoom) {
     ret = bclass->set_zoom (camerasrc, camerasrc->photoconf.zoom);
-  } else {
+  }
+  else {
     /* FIXME: Check if the zoom is within known limits */
   }
   GST_DEBUG_OBJECT (camerasrc, "setting zoom %s", ret ? "success" : "failed");
@@ -591,9 +606,11 @@ gst_camerasrc_photo_set_zoom (GstCameraSrc * camerasrc, gfloat zoom)
  *
  */
 gboolean
-gst_camerasrc_photo_get_zoom (GstCameraSrc * camerasrc, gfloat * zoom)
+gst_camerasrc_photo_get_zoom (GstCameraSrc *camerasrc, gfloat *zoom)
 {
+  GST_OBJECT_LOCK (camerasrc);
   *zoom = camerasrc->photoconf.zoom;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   GST_DEBUG_OBJECT (camerasrc, "current zoom = %f", *zoom);
   return TRUE;
@@ -604,8 +621,8 @@ gst_camerasrc_photo_get_zoom (GstCameraSrc * camerasrc, gfloat * zoom)
 *
 */
 gboolean
-gst_camerasrc_photo_set_flicker_mode (GstCameraSrc * camerasrc,
-    GstFlickerReductionMode mode)
+gst_camerasrc_photo_set_flicker_mode (GstCameraSrc *camerasrc,
+                                       GstFlickerReductionMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -613,7 +630,9 @@ gst_camerasrc_photo_set_flicker_mode (GstCameraSrc * camerasrc,
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.flicker_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -632,8 +651,8 @@ gst_camerasrc_photo_set_flicker_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_get_flicker_mode (GstCameraSrc * camerasrc,
-    GstFlickerReductionMode * mode)
+gst_camerasrc_photo_get_flicker_mode (GstCameraSrc *camerasrc,
+                                       GstFlickerReductionMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -643,7 +662,11 @@ gst_camerasrc_photo_get_flicker_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.flicker_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got flicker mode: %d, ret = %d", *mode, ret);
 
   return ret;
@@ -654,7 +677,8 @@ gst_camerasrc_photo_get_flicker_mode (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_focus_mode (GstCameraSrc * camerasrc, GstFocusMode mode)
+gst_camerasrc_photo_set_focus_mode (GstCameraSrc *camerasrc,
+                                     GstFocusMode mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -662,7 +686,9 @@ gst_camerasrc_photo_set_focus_mode (GstCameraSrc * camerasrc, GstFocusMode mode)
 
   bclass = GST_CAMERA_SRC_GET_CLASS (camerasrc);
 
+  GST_OBJECT_LOCK (camerasrc);
   camerasrc->photoconf.focus_mode = mode;
+  GST_OBJECT_UNLOCK (camerasrc);
 
   if (bclass->is_active (camerasrc)) {
     ret = bclass->write_settings (camerasrc, &camerasrc->photoconf, FALSE);
@@ -679,8 +705,8 @@ gst_camerasrc_photo_set_focus_mode (GstCameraSrc * camerasrc, GstFocusMode mode)
  *
  */
 gboolean
-gst_camerasrc_photo_get_focus_mode (GstCameraSrc * camerasrc,
-    GstFocusMode * mode)
+gst_camerasrc_photo_get_focus_mode (GstCameraSrc *camerasrc,
+                                     GstFocusMode *mode)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -690,7 +716,11 @@ gst_camerasrc_photo_get_focus_mode (GstCameraSrc * camerasrc,
   if (bclass->is_active (camerasrc)) {
     ret = bclass->read_settings (camerasrc, &camerasrc->photoconf);
   }
+
+  GST_OBJECT_LOCK (camerasrc);
   *mode = camerasrc->photoconf.focus_mode;
+  GST_OBJECT_UNLOCK (camerasrc);
+
   GST_DEBUG_OBJECT (camerasrc, "got focus mode: %d, ret = %d", *mode, ret);
 
   return ret;
@@ -744,7 +774,8 @@ gst_camerasrc_photo_get_noise_reduction (GstCameraSrc * camerasrc,
  *
  */
 void
-gst_camerasrc_photo_set_autofocus (GstCameraSrc * camerasrc, gboolean on)
+gst_camerasrc_photo_set_autofocus (GstCameraSrc *camerasrc,
+                                    gboolean on)
 {
   GST_DEBUG_OBJECT (camerasrc, "setting autofocus %s", on ? "ON" : "OFF");
 
@@ -752,7 +783,8 @@ gst_camerasrc_photo_set_autofocus (GstCameraSrc * camerasrc, gboolean on)
 
   if (on) {
     camerasrc->requested_af_mode = AF_ON_REQUESTED;
-  } else {
+  }
+  else {
     camerasrc->requested_af_mode = AF_OFF_REQUESTED;
   }
 
@@ -766,8 +798,8 @@ gst_camerasrc_photo_set_autofocus (GstCameraSrc * camerasrc, gboolean on)
  *
  */
 gboolean
-gst_camerasrc_photo_set_config (GstCameraSrc * camerasrc,
-    GstPhotoSettings * config)
+gst_camerasrc_photo_set_config (GstCameraSrc *camerasrc,
+                                 GstPhotoSettings * config)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = TRUE;
@@ -787,7 +819,9 @@ gst_camerasrc_photo_set_config (GstCameraSrc * camerasrc,
   GST_DEBUG_OBJECT (camerasrc, "set config, ret = %d", ret);
 
   if (ret) {
+    GST_OBJECT_LOCK (camerasrc);
     memcpy (&camerasrc->photoconf, config, sizeof (GstPhotoSettings));
+    GST_OBJECT_UNLOCK (camerasrc);
   }
 
   return ret;
@@ -799,10 +833,12 @@ gst_camerasrc_photo_set_config (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_get_config (GstCameraSrc * camerasrc,
-    GstPhotoSettings * config)
+gst_camerasrc_photo_get_config (GstCameraSrc *camerasrc,
+                                 GstPhotoSettings * config)
 {
+  GST_OBJECT_LOCK (camerasrc);
   memcpy (config, &camerasrc->photoconf, sizeof (GstPhotoSettings));
+  GST_OBJECT_UNLOCK (camerasrc);
 
   GST_DEBUG_OBJECT (camerasrc, "got config");
   return TRUE;
@@ -813,8 +849,9 @@ gst_camerasrc_photo_get_config (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_format (GstCameraSrc * camerasrc,
-    GstOperationMode op_mode, GstCaps * op_mode_caps)
+gst_camerasrc_photo_set_format (GstCameraSrc *camerasrc,
+                                GstOperationMode op_mode,
+                                GstCaps * op_mode_caps)
 {
   gboolean ret = TRUE;
 
@@ -868,12 +905,13 @@ gst_camerasrc_photo_get_format (GstCameraSrc * camerasrc,
 }
 
 
+
 /*
  *
  */
 gboolean
-gst_camerasrc_photo_get_property (GstCameraSrc * camerasrc,
-    guint prop_id, GValue * value)
+gst_camerasrc_photo_get_property (GstCameraSrc *camerasrc,
+                                   guint prop_id, GValue * value)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = FALSE;
@@ -1000,16 +1038,6 @@ gst_camerasrc_photo_get_property (GstCameraSrc * camerasrc,
       ret = TRUE;
       break;
     }
-    case PROP_NOISE_REDUCTION:
-    {
-      GstPhotographyNoiseReduction noise_reduction;
-      GST_DEBUG_OBJECT (camerasrc, "==== GETTING PROP_NOISE_REDUCTION ====");
-      if (gst_camerasrc_photo_get_noise_reduction (camerasrc, &noise_reduction)) {
-        g_value_set_flags (value, noise_reduction);
-      }
-      ret = TRUE;
-      break;
-    }
     case PROP_IMAGE_CAPTURE_CAPS:
     {
       GstCaps *caps;
@@ -1042,8 +1070,9 @@ gst_camerasrc_photo_get_property (GstCameraSrc * camerasrc,
     {
       GST_DEBUG_OBJECT (camerasrc, "==== GETTING PROP_AUTOFOCUS ====");
       g_mutex_lock (camerasrc->af_lock);
-      if (camerasrc->photo_capture_phase == GST_CAMERA_AUTOFOCUS ||
-          camerasrc->requested_af_mode == AF_ON_REQUESTED) {
+      if  (camerasrc->photo_capture_phase == GST_CAMERA_AUTOFOCUS ||
+           camerasrc->requested_af_mode == AF_ON_REQUESTED)
+      {
         g_value_set_boolean (value, TRUE);
       } else {
         g_value_set_boolean (value, FALSE);
@@ -1053,6 +1082,16 @@ gst_camerasrc_photo_get_property (GstCameraSrc * camerasrc,
       ret = TRUE;
       break;
     }
+    case PROP_NOISE_REDUCTION:
+    {
+      GstPhotographyNoiseReduction noise_reduction;
+      GST_DEBUG_OBJECT (camerasrc, "==== GETTING PROP_NOISE_REDUCTION ====");
+      if (gst_camerasrc_photo_get_noise_reduction (camerasrc, &noise_reduction)) {
+        g_value_set_flags (value, noise_reduction);
+      }
+      ret = TRUE;
+      break;
+    }
     default:
       break;
   }
@@ -1065,8 +1104,8 @@ gst_camerasrc_photo_get_property (GstCameraSrc * camerasrc,
  *
  */
 gboolean
-gst_camerasrc_photo_set_property (GstCameraSrc * camerasrc,
-    guint prop_id, const GValue * value)
+gst_camerasrc_photo_set_property (GstCameraSrc *camerasrc,
+                                   guint prop_id, const GValue * value)
 {
   gboolean ret = FALSE;
 
@@ -1093,8 +1132,7 @@ gst_camerasrc_photo_set_property (GstCameraSrc * camerasrc,
       break;
     case PROP_EV_COMP:
       GST_DEBUG_OBJECT (camerasrc, "==== SETTING PROP_EV_COMP ====");
-      gst_camerasrc_photo_set_ev_compensation (camerasrc,
-          g_value_get_float (value));
+      gst_camerasrc_photo_set_ev_compensation (camerasrc, g_value_get_float (value));
       ret = TRUE;
       break;
     case PROP_ISO_SPEED:
@@ -1150,7 +1188,7 @@ gst_camerasrc_photo_set_property (GstCameraSrc * camerasrc,
 
 /*** Internal API ***/
 
-static gboolean
+gboolean
 gst_camerasrc_photo_parse_capture_caps (GstCameraSrc * camerasrc,
     GstCaps * op_mode_caps)
 {
@@ -1254,9 +1292,9 @@ done:
 }
 
 
-static gboolean
-gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
-    GstCaps * op_mode_caps)
+gboolean
+gst_camerasrc_photo_parse_preview_caps (GstCameraSrc *camerasrc,
+    GstCaps *op_mode_caps)
 {
   GstCameraSrcClass *bclass;
   gboolean ret = FALSE;
@@ -1271,7 +1309,8 @@ gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
      * In this case resolution 0x0 will be given to subclass */
     GST_DEBUG_OBJECT (camerasrc, "NULL caps received for preview image");
     ret = TRUE;
-  } else {
+  }
+  else {
     GstStructure *cstr;
 
     GST_DEBUG_OBJECT (camerasrc, "parsing preview caps");
@@ -1280,12 +1319,13 @@ gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
 
     /* FIXME: Use VF format if fourcc is not given */
     if (gst_structure_get_fourcc (cstr, "format", &fourcc) &&
-        gst_structure_get_int (cstr, "width", &tmp_w) &&
-        gst_structure_get_int (cstr, "height", &tmp_h)) {
+        gst_structure_get_int (cstr, "width",  &tmp_w) &&
+        gst_structure_get_int (cstr, "height", &tmp_h))
+    {
 #if 0
       /* check if the requested fourcc format is supported */
-      GstCaps *s_caps = NULL;
-      GstCaps *r_caps = NULL;
+      GstCaps * s_caps = NULL;
+      GstCaps * r_caps = NULL;
 
       /* get camsrc sourcepad caps, because the pad has
        * caps-template including supported formats */
@@ -1306,7 +1346,8 @@ gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
         gst_caps_unref (r_caps);
 #endif
       ret = TRUE;
-    } else {
+    }
+    else {
       GST_DEBUG_OBJECT (camerasrc, "Unable to parse given caps");
       ret = FALSE;
     }
@@ -1316,26 +1357,29 @@ gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
    * currently configured to be in use. If so, no need to set it again.
    */
   if (ret && (camerasrc->preview_w != tmp_w || camerasrc->preview_h != tmp_h ||
-          camerasrc->preview_fourcc != fourcc)) {
+      camerasrc->preview_fourcc != fourcc))
+  {
     GST_DEBUG_OBJECT (camerasrc,
-        "set preview width: %d, height: %d, format: %"
-        GST_FOURCC_FORMAT, tmp_w, tmp_h, GST_FOURCC_ARGS (fourcc));
+          "set preview width: %d, height: %d, format: %"
+          GST_FOURCC_FORMAT, tmp_w, tmp_h, GST_FOURCC_ARGS (fourcc));
 
     ret = bclass->set_capture (camerasrc,
         GST_PHOTOGRAPHY_OPERATION_MODE_PREVIEW, FALSE,
-        &fourcc, (guint *) & tmp_w, (guint *) & tmp_h, NULL, NULL);
+        &fourcc, (guint *) &tmp_w, (guint *) &tmp_h, NULL, NULL);
 
     if (fourcc == 0) {
-      /* Special case: preview image creation is canceled (NULL caps) */
+      /* Special case: preview image creation is canceled (NULL caps)*/
       camerasrc->preview_resolution_set = FALSE;
       ret = TRUE;
-    } else {
+    }
+    else {
       if (ret && op_mode_caps && GST_CAPS_REFCOUNT_VALUE (op_mode_caps) == 1) {
         /* Write the assigned values back to the caps structure */
         gst_caps_set_simple (op_mode_caps,
             "width", G_TYPE_INT, tmp_w,
             "height", G_TYPE_INT, tmp_h,
-            "format", GST_TYPE_FOURCC, fourcc, NULL);
+            "format", GST_TYPE_FOURCC, fourcc,
+            NULL);
       }
 
       GST_DEBUG_OBJECT (camerasrc,
@@ -1357,3 +1401,8 @@ gst_camerasrc_photo_parse_preview_caps (GstCameraSrc * camerasrc,
 
   return ret;
 }
+
+
+
+
+
index d598693..f3583cb 100644 (file)
@@ -50,10 +50,10 @@ typedef enum {
   PROP_ZOOM,
   PROP_FLICKER_MODE,
   PROP_FOCUS_MODE,
-  PROP_NOISE_REDUCTION,
   PROP_IMAGE_CAPTURE_CAPS,
   PROP_IMAGE_PREVIEW_CAPS,
-  PROP_AUTOFOCUS
+  PROP_AUTOFOCUS,
+  PROP_NOISE_REDUCTION
 } GstCameraSrcProperties;
 
 
@@ -144,14 +144,12 @@ gboolean
 gst_camerasrc_photo_get_focus_mode (GstCameraSrc * camerasrc,
                                GstFocusMode *mode);
 
-
 gboolean
 gst_camerasrc_photo_set_noise_reduction (GstCameraSrc * camerasrc,
-                               guint mode);
+                                         GstPhotographyNoiseReduction mode);
 gboolean
 gst_camerasrc_photo_get_noise_reduction (GstCameraSrc * camerasrc,
-                               guint *mode);
-
+                                         GstPhotographyNoiseReduction *mode);
 
 void
 gst_camerasrc_photo_set_autofocus (GstCameraSrc * camerasrc,
@@ -196,6 +194,10 @@ gst_camerasrc_photo_get_property (GstCameraSrc *camerasrc,
                              guint prop_id,
                              GValue * value);
 
+gboolean
+gst_camerasrc_photo_parse_preview_caps (GstCameraSrc *camerasrc,
+                                        GstCaps *op_mode_caps);
+
 #define GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, function_name, param_type) \
                                                                                       \
 gboolean                                                                              \
@@ -228,7 +230,7 @@ GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, flash_mode, GstFlashMode
 GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, zoom, gfloat)                 \
 GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, flicker_mode, GstFlickerReductionMode) \
 GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, focus_mode, GstFocusMode)     \
-GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, noise_reduction, guint)     \
+GST_CAMERA_SRC_PHOTO_FUNCS(Type, interface_as_function, noise_reduction, GstPhotographyNoiseReduction) \
                                                                                       \
 GstPhotoCaps                                                                          \
 interface_as_function ## _photo_get_capabilities (GstPhotography * photo)             \
@@ -318,13 +320,12 @@ interface_as_function ## _photo_interface_init (GstPhotographyInterface * iface)
   iface->get_config = interface_as_function ## _photo_get_config;                     \
   iface->set_format = interface_as_function ## _photo_set_format;                     \
   iface->get_format = interface_as_function ## _photo_get_format;                     \
+  iface->set_noise_reduction = interface_as_function ## _photo_set_noise_reduction;   \
+  iface->get_noise_reduction = interface_as_function ## _photo_get_noise_reduction;   \
                                                                                       \
   iface->get_capabilities = interface_as_function ## _photo_get_capabilities;         \
   iface->prepare_for_capture = interface_as_function ## _photo_prepare_for_capture;   \
   iface->set_autofocus = interface_as_function ## _photo_set_autofocus;               \
-                                                                                                                                                                        \
-  iface->set_noise_reduction = interface_as_function ## _photo_set_noise_reduction;             \
-  iface->get_noise_reduction = interface_as_function ## _photo_get_noise_reduction;             \
 }                                                                                     \
 
 
index d7b6ae9..2b77bb2 100644 (file)
@@ -2246,8 +2246,10 @@ gst_v4l2camsrc_set_capture (GstCameraSrc * camsrc, GstOperationMode mode,
 
       v4l2camsrc->capture_w = *width;
       v4l2camsrc->capture_h = *height;
-      v4l2camsrc->capture_fps_n = *fps_n;
-      v4l2camsrc->capture_fps_d = *fps_d;
+      if (fps_n && fps_d) {
+       v4l2camsrc->capture_fps_n = *fps_n;
+       v4l2camsrc->capture_fps_d = *fps_d;
+      }
       v4l2camsrc->capture_fourcc = *pixelformat;
     }
   } else {
@@ -2262,8 +2264,10 @@ gst_v4l2camsrc_set_capture (GstCameraSrc * camsrc, GstOperationMode mode,
     v4l2camsrc->vf_w = *width;
     v4l2camsrc->vf_h = *height;
     v4l2camsrc->vf_fourcc = *pixelformat;
-    v4l2camsrc->vf_fps_n = *fps_n;
-    v4l2camsrc->vf_fps_d = *fps_d;
+    if (fps_n && fps_d) {
+      v4l2camsrc->vf_fps_n = *fps_n;
+      v4l2camsrc->vf_fps_d = *fps_d;
+    }
   }
   if (err != CAM_ERR_NONE)
     ret = FALSE;