Commit 42ba3d33 authored by Justin Kim's avatar Justin Kim

ahc2src: implement flicker-mode

Signed-off-by: Justin Kim's avatarJustin Kim <justin.kim@collabora.com>
parent 493a786a
......@@ -630,6 +630,83 @@ gst_ahc2_src_set_flash_mode (GstPhotography * photo,
return TRUE;
}
static gboolean
gst_ahc2_src_get_flicker_mode (GstPhotography * photo,
GstPhotographyFlickerReductionMode * flicker_mode)
{
GstAHC2Src *self = GST_AHC2_SRC (photo);
GstAHC2SrcPrivate *priv = GST_AHC2_SRC_GET_PRIVATE (self);
ACameraMetadata_const_entry entry;
g_return_val_if_fail (priv->capture_request != NULL, FALSE);
if (ACaptureRequest_getConstEntry (priv->capture_request,
ACAMERA_CONTROL_AE_ANTIBANDING_MODE, &entry) != ACAMERA_OK) {
GST_ERROR_OBJECT (self, "Failed to get ANTIBANDING MODE");
return FALSE;
}
switch (entry.data.u8[0]) {
case ACAMERA_CONTROL_AE_ANTIBANDING_MODE_OFF:
*flicker_mode = GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF;
break;
case ACAMERA_CONTROL_AE_ANTIBANDING_MODE_50HZ:
*flicker_mode = GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ;
break;
case ACAMERA_CONTROL_AE_ANTIBANDING_MODE_60HZ:
*flicker_mode = GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ;
break;
case ACAMERA_CONTROL_AE_ANTIBANDING_MODE_AUTO:
*flicker_mode = GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO;
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
static gboolean
gst_ahc2_src_set_flicker_mode (GstPhotography * photo,
GstPhotographyFlickerReductionMode flicker_mode)
{
GstAHC2Src *self = GST_AHC2_SRC (photo);
GstAHC2SrcPrivate *priv = GST_AHC2_SRC_GET_PRIVATE (self);
guint8 mode;
g_return_val_if_fail (priv->capture_request != NULL, FALSE);
switch (flicker_mode) {
case GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF:
mode = ACAMERA_CONTROL_AE_ANTIBANDING_MODE_OFF;
break;
case GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ:
mode = ACAMERA_CONTROL_AE_ANTIBANDING_MODE_50HZ;
break;
case GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ:
mode = ACAMERA_CONTROL_AE_ANTIBANDING_MODE_60HZ;
break;
case GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO:
mode = ACAMERA_CONTROL_AE_ANTIBANDING_MODE_AUTO;
break;
default:
GST_WARNING_OBJECT (self, "Unsupported flicker-mode (%d)", flicker_mode);
break;
}
ACameraCaptureSession_stopRepeating (priv->camera_capture_session);
ACaptureRequest_setEntry_u8 (priv->capture_request,
ACAMERA_CONTROL_AE_ANTIBANDING_MODE, 1, &mode);
ACameraCaptureSession_setRepeatingRequest (priv->camera_capture_session,
NULL, 1, &priv->capture_request, NULL);
return TRUE;
}
static gboolean
gst_ahc2_src_get_scene_mode (GstPhotography * photo,
GstPhotographySceneMode * scene_mode)
......@@ -1414,6 +1491,11 @@ gst_ahc2_src_set_property (GObject * object,
gst_ahc2_src_set_flash_mode (GST_PHOTOGRAPHY (self), flash);
break;
}
case PROP_FLICKER_MODE:{
GstPhotographyFlickerReductionMode flicker = g_value_get_enum (value);
gst_ahc2_src_set_flicker_mode (GST_PHOTOGRAPHY (self), flicker);
break;
}
case PROP_FOCUS_MODE: {
GstPhotographyFocusMode focus = g_value_get_enum (value);
gst_ahc2_src_set_focus_mode (GST_PHOTOGRAPHY (self), focus);
......@@ -1481,6 +1563,12 @@ gst_ahc2_src_get_property (GObject * object,
g_value_set_enum (value, flash);
break;
}
case PROP_FLICKER_MODE:{
GstPhotographyFlickerReductionMode flicker;
if (gst_ahc2_src_get_flicker_mode (GST_PHOTOGRAPHY (self), &flicker))
g_value_set_enum (value, flicker);
break;
}
case PROP_FOCUS_MODE: {
GstPhotographyFocusMode focus;
if (gst_ahc2_src_get_focus_mode (GST_PHOTOGRAPHY (self), &focus))
......@@ -1962,6 +2050,9 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface->get_flash_mode = gst_ahc2_src_get_flash_mode;
iface->set_flash_mode = gst_ahc2_src_set_flash_mode;
iface->get_flicker_mode = gst_ahc2_src_get_flicker_mode;
iface->set_flicker_mode = gst_ahc2_src_set_flicker_mode;
iface->get_scene_mode = gst_ahc2_src_get_scene_mode;
iface->set_scene_mode = gst_ahc2_src_set_scene_mode;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment