Exemple #1
0
/**
 * cheese_camera_device_get_device_node:
 * @device: a #CheeseCameraDevice
 *
 * Get the path to the device node associated with the @device.
 *
 * Returns: (transfer none): the path to the device node of the video capture
 * device
 */
const gchar *
cheese_camera_device_get_device_node (CheeseCameraDevice *device)
{
  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

  return device->priv->device_node;
}
Exemple #2
0
/**
 * cheese_camera_device_get_best_format:
 * @device: a #CheeseCameraDevice
 *
 * Get the #CheeseVideoFormat with the highest resolution with a width greater
 * than 640 pixels and a framerate of greater than 15 FPS for this @device. If
 * no such format is found, get the highest available resolution instead.
 *
 * Returns: (transfer full): the highest-resolution supported
 * #CheeseVideoFormat
 */
CheeseVideoFormat *
cheese_camera_device_get_best_format (CheeseCameraDevice *device)
{
  CheeseVideoFormatFull *format = NULL;
  GList *l;

  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

  /* Check for the highest resolution with width >= 640 and FPS >= 15. */
  for (l = device->priv->formats; l != NULL; l = g_list_next (l))
  {
    CheeseVideoFormatFull *item = l->data;
    float frame_rate = (float)item->fr_numerator / (float)item->fr_denominator;

    if (item->width >= 640 && frame_rate >= 15)
    {
      format = item;
      break;
    }
  }

  /* Else simply return the highest resolution. */
  if (!format)
  {
    format = device->priv->formats->data;
  }

  GST_INFO ("%dx%d@%d/%d", format->width, format->height,
            format->fr_numerator, format->fr_denominator);

  return g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT, format);
}
Exemple #3
0
/**
 * cheese_camera_device_get_format_list:
 * @device: a #CheeseCameraDevice
 *
 * Get the sorted list of #CheeseVideoFormat that the @device supports.
 *
 * Returns: (element-type Cheese.VideoFormat) (transfer container): list of
 * #CheeseVideoFormat
 */
GList *
cheese_camera_device_get_format_list (CheeseCameraDevice *device)
{
  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

  return g_list_copy (device->priv->formats);
}
Exemple #4
0
static gboolean
cheese_camera_device_initable_init (GInitable    *initable,
                                    GCancellable *cancellable,
                                    GError      **error)
{
  CheeseCameraDevice        *device = CHEESE_CAMERA_DEVICE (initable);
  CheeseCameraDevicePrivate *priv   = device->priv;

  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (initable), FALSE);

  if (cancellable != NULL)
  {
    g_set_error_literal (error,
                         CHEESE_CAMERA_DEVICE_ERROR,
                         CHEESE_CAMERA_DEVICE_ERROR_NOT_SUPPORTED,
                         _("Cancellable initialization not supported"));
    return FALSE;
  }

  if (priv->construct_error)
  {
    if (error)
      *error = g_error_copy (priv->construct_error);
    return FALSE;
  }

  return TRUE;
}
/**
 * cheese_camera_device_get_device_node:
 * @device: a #CheeseCameraDevice
 *
 * Get the path to the device node associated with the @device.
 *
 * Returns: (transfer none): the path to the device node of the video capture
 * device
 */
const gchar *
cheese_camera_device_get_device_node (CheeseCameraDevice *device)
{
    CheeseCameraDevicePrivate *priv;

  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

    priv = cheese_camera_device_get_instance_private (device);

    return priv->device_node;
}
/**
 * cheese_camera_device_get_format_list:
 * @device: a #CheeseCameraDevice
 *
 * Get the sorted list of #CheeseVideoFormat that the @device supports.
 *
 * Returns: (element-type Cheese.VideoFormat) (transfer container): list of
 * #CheeseVideoFormat
 */
GList *
cheese_camera_device_get_format_list (CheeseCameraDevice *device)
{
    CheeseCameraDevicePrivate *priv;

  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

    priv = cheese_camera_device_get_instance_private (device);

    return g_list_copy (priv->formats);
}
/**
 * cheese_camera_device_get_caps_for_format:
 * @device: a #CheeseCameraDevice
 * @format: a #CheeseVideoFormat
 *
 * Get the #GstCaps for the given @format on the @device.
 *
 * Returns: (transfer full): the #GstCaps for the given @format
 */
GstCaps *
cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
                                          CheeseVideoFormat  *format)
{
    CheeseCameraDevicePrivate *priv;
  CheeseVideoFormatFull *full_format;
  GstCaps *desired_caps;
  GstCaps *subset_caps;
  gsize i;

  g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);

  full_format = cheese_camera_device_find_full_format (device, format);

  if (!full_format)
  {
    GST_INFO ("Getting caps for %dx%d: no such format!",
              format->width, format->height);
    return gst_caps_new_empty ();
  }

  GST_INFO ("Getting caps for %dx%d @ %d/%d fps",
            full_format->width, full_format->height,
            full_format->fr_numerator, full_format->fr_denominator);

  desired_caps = gst_caps_new_empty ();

  for (i = 0; supported_formats[i] != NULL; i++)
  {
    gst_caps_append (desired_caps,
                     cheese_camera_device_format_to_caps (supported_formats[i],
                                                          full_format));
  }

    priv = cheese_camera_device_get_instance_private (device);
    subset_caps = gst_caps_intersect (desired_caps, priv->caps);
  subset_caps = gst_caps_simplify (subset_caps);
  gst_caps_unref (desired_caps);

  GST_INFO ("Got %" GST_PTR_FORMAT, subset_caps);

  return subset_caps;
}