Commit a04142e4 authored by Justin Kim's avatar Justin Kim

ahc2src: implement flash_mode

Signed-off-by: Justin Kim's avatarJustin Kim <justin.kim@collabora.com>
parent 34d2250c
......@@ -445,6 +445,78 @@ out:
return ret;
}
static gboolean
gst_ahc2_src_get_flash_mode (GstPhotography * photo,
GstPhotographyFlashMode * flash_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_FLASH_MODE, &entry) != ACAMERA_OK) {
GST_ERROR_OBJECT (self, "Failed to get FLASH MODE");
return FALSE;
}
switch (entry.data.u8[0]) {
case ACAMERA_FLASH_MODE_OFF:
*flash_mode = GST_PHOTOGRAPHY_FLASH_MODE_OFF;
break;
case ACAMERA_FLASH_MODE_SINGLE:
*flash_mode = GST_PHOTOGRAPHY_FLASH_MODE_AUTO;
break;
case ACAMERA_FLASH_MODE_TORCH:
*flash_mode = GST_PHOTOGRAPHY_FLASH_MODE_ON;
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
static gboolean
gst_ahc2_src_set_flash_mode (GstPhotography * photo,
GstPhotographyFlashMode flash_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 (flash_mode) {
case GST_PHOTOGRAPHY_FLASH_MODE_OFF:
mode = ACAMERA_FLASH_MODE_OFF;
break;
case GST_PHOTOGRAPHY_FLASH_MODE_ON:
mode = ACAMERA_FLASH_MODE_TORCH;
break;
case GST_PHOTOGRAPHY_FLASH_MODE_AUTO:
case GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN:
case GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE:
mode = ACAMERA_FLASH_MODE_SINGLE;
break;
default:
g_assert_not_reached ();
break;
}
ACameraCaptureSession_stopRepeating (priv->camera_capture_session);
ACaptureRequest_setEntry_u8 (priv->capture_request,
ACAMERA_FLASH_MODE, 1, &mode);
ACameraCaptureSession_setRepeatingRequest (priv->camera_capture_session,
NULL, 1, &priv->capture_request, NULL);
return TRUE;
}
static gboolean
gst_ahc2_src_get_white_balance_mode (GstPhotography * photo,
GstPhotographyWhiteBalanceMode * mode)
......@@ -1058,6 +1130,11 @@ gst_ahc2_src_set_property (GObject * object,
gst_ahc2_src_set_white_balance_mode (GST_PHOTOGRAPHY (self), wb);
break;
}
case PROP_FLASH_MODE: {
GstPhotographyFlashMode flash = g_value_get_enum (value);
gst_ahc2_src_set_flash_mode (GST_PHOTOGRAPHY (self), flash);
break;
}
case PROP_FOCUS_MODE: {
GstPhotographyFocusMode focus = g_value_get_enum (value);
gst_ahc2_src_set_focus_mode (GST_PHOTOGRAPHY (self), focus);
......@@ -1113,6 +1190,12 @@ gst_ahc2_src_get_property (GObject * object,
g_value_set_enum (value, wb);
break;
}
case PROP_FLASH_MODE: {
GstPhotographyFlashMode flash;
if (gst_ahc2_src_get_flash_mode (GST_PHOTOGRAPHY (self), &flash))
g_value_set_enum (value, flash);
break;
}
case PROP_FOCUS_MODE: {
GstPhotographyFocusMode focus;
if (gst_ahc2_src_get_focus_mode (GST_PHOTOGRAPHY (self), &focus))
......@@ -1582,6 +1665,9 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface->get_focus_mode = gst_ahc2_src_get_focus_mode;
iface->set_focus_mode = gst_ahc2_src_set_focus_mode;
iface->get_flash_mode = gst_ahc2_src_get_flash_mode;
iface->set_flash_mode = gst_ahc2_src_set_flash_mode;
iface->get_white_balance_mode = gst_ahc2_src_get_white_balance_mode;
iface->set_white_balance_mode = gst_ahc2_src_set_white_balance_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