Commit 495d6b39 authored by Justin Kim's avatar Justin Kim

ahc2src: implement zoom

Signed-off-by: Justin Kim's avatarJustin Kim <justin.kim@collabora.com>
parent 1eeec779
......@@ -440,7 +440,77 @@ gst_ahc2_src_set_white_balance_mode (GstPhotography * photo,
return TRUE;
}
static gboolean
gst_ahc2_src_get_zoom (GstPhotography * photo, gfloat * zoom)
{
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_LENS_FOCAL_LENGTH, &entry) != ACAMERA_OK) {
GST_WARNING_OBJECT (self, "Failed to get FOCAL LENGTH (optical zoom)");
return FALSE;
}
*zoom = entry.data.f[0];
return TRUE;
}
static gboolean
gst_ahc2_src_set_zoom (GstPhotography * photo, gfloat zoom)
{
GstAHC2Src *self = GST_AHC2_SRC (photo);
GstAHC2SrcPrivate *priv = GST_AHC2_SRC_GET_PRIVATE (self);
gboolean ret = FALSE;
ACameraMetadata* metadata = NULL;
ACameraMetadata_const_entry entry;
g_return_val_if_fail (priv->camera_manager != NULL, FALSE);
g_return_val_if_fail (priv->camera_id_list != NULL, FALSE);
g_return_val_if_fail (priv->camera_index < priv->camera_id_list->numCameras,
FALSE);
g_return_val_if_fail (priv->capture_request != NULL, FALSE);
if (ACameraManager_getCameraCharacteristics (priv->camera_manager,
priv->camera_id_list->cameraIds[priv->camera_index],
&metadata) != ACAMERA_OK) {
GST_WARNING_OBJECT (self, "Failed to get metadata");
return FALSE;
}
if (ACameraMetadata_getConstEntry (metadata,
ACAMERA_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, &entry) != ACAMERA_OK) {
goto out;
}
if (entry.count == 1) {
GST_WARNING_OBJECT (self,
"This device has fixed focal length(%.2f).", entry.data.f[0]);
goto out;
}
ACameraCaptureSession_stopRepeating (priv->camera_capture_session);
/* FIXME: Do we need to set nearest value? */
ACaptureRequest_setEntry_float (priv->capture_request,
ACAMERA_LENS_FOCAL_LENGTH, 1, &zoom);
ACameraCaptureSession_setRepeatingRequest (priv->camera_capture_session,
NULL, 1, &priv->capture_request, NULL);
ret = TRUE;
out:
g_clear_pointer (&metadata, (GDestroyNotify) ACameraMetadata_free);
return ret;
}
static GstCaps *
gst_ahc2_src_fixate (GstBaseSrc * src, GstCaps * caps)
{
......@@ -875,6 +945,11 @@ gst_ahc2_src_set_property (GObject * object,
gst_ahc2_src_set_white_balance_mode (GST_PHOTOGRAPHY (self), wb);
break;
}
case PROP_ZOOM: {
gfloat zoom = g_value_get_float (value);
gst_ahc2_src_set_zoom (GST_PHOTOGRAPHY (self), zoom);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -920,6 +995,12 @@ gst_ahc2_src_get_property (GObject * object,
g_value_set_enum (value, wb);
break;
}
case PROP_ZOOM: {
gfloat zoom;
if (gst_ahc2_src_get_zoom (GST_PHOTOGRAPHY (self), &zoom))
g_value_set_float (value, zoom);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -1378,6 +1459,9 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface->get_ev_compensation = gst_ahc2_src_get_ev_compensation;
iface->set_ev_compensation = gst_ahc2_src_set_ev_compensation;
iface->get_zoom = gst_ahc2_src_get_zoom;
iface->set_zoom = gst_ahc2_src_set_zoom;
}
static gboolean
......
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