Add new internal APIs for extra preview stream format
[platform/core/api/camera.git] / src / camera_internal.c
index 1d91e36..2e6f19e 100644 (file)
@@ -567,4 +567,86 @@ int camera_unset_extra_preview_cb(camera_h camera)
 
        return ret;
 }
+
+
+int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
+{
+       int ret = CAMERA_ERROR_NONE;
+       int send_ret = 0;
+       int stream_format[4] = {pixel_format, width, height, fps};
+       char *msg = NULL;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
+
+       if (!pc || !pc->cb_info) {
+               CAM_LOG_ERROR("NULL handle");
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - stream_id[%d],[%d,%dx%d,%d]",
+               stream_id, pixel_format, width, height, fps);
+
+       msg = muse_core_msg_new(api,
+               MUSE_TYPE_INT, "stream_id", stream_id,
+               MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
+               NULL);
+       if (!msg) {
+               CAM_LOG_ERROR("msg creation failed: api %d", api);
+               return CAMERA_ERROR_OUT_OF_MEMORY;
+       }
+
+       if (pc->cb_info->is_server_connected) {
+               _camera_update_api_waiting(pc->cb_info, api, 1);
+
+               g_mutex_lock(&pc->cb_info->fd_lock);
+               send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+               g_mutex_unlock(&pc->cb_info->fd_lock);
+       }
+
+       if (send_ret < 0) {
+               CAM_LOG_ERROR("message send failed");
+               ret = CAMERA_ERROR_INVALID_OPERATION;
+       } else {
+               ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+       }
+
+       _camera_update_api_waiting(pc->cb_info, api, -1);
+
+       muse_core_msg_free(msg);
+
+       CAM_LOG_INFO("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e *pixel_format, int *width, int *height, int *fps)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       camera_msg_param param;
+       muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
+
+       if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
+               CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - stream_id[%d]", stream_id);
+
+       CAMERA_MSG_PARAM_SET(param, INT, stream_id);
+
+       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+
+       if (ret == CAMERA_ERROR_NONE) {
+               *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
+               *width = pc->cb_info->get_extra_preview_stream_format[1];
+               *height = pc->cb_info->get_extra_preview_stream_format[2];
+               *fps = pc->cb_info->get_extra_preview_stream_format[3];
+       }
+
+       CAM_LOG_INFO("ret : 0x%x", ret);
+
+       return ret;
+}
 //LCOV_EXCL_STOP