Ejemplo n.º 1
0
static gboolean
check_fourcc_list (const GValue * format_value)
{
  const GValue *fourcc_value;
  gboolean got_yv12 = FALSE;
  gboolean got_i420 = FALSE;
  gboolean got_yuy2 = FALSE;
  guint32 fourcc;

  fourcc_value = gst_value_list_get_value (format_value, 0);
  fail_unless (fourcc_value != NULL);
  fail_unless (GST_VALUE_HOLDS_FOURCC (fourcc_value));
  fourcc = gst_value_get_fourcc (fourcc_value);
  fail_unless (fourcc != 0);
  got_i420 = got_i420 || (fourcc == GST_STR_FOURCC ("I420"));
  got_yuy2 = got_yuy2 || (fourcc == GST_STR_FOURCC ("YUY2"));
  got_yv12 = got_yv12 || (fourcc == GST_STR_FOURCC ("YV12"));

  fourcc_value = gst_value_list_get_value (format_value, 1);
  fail_unless (fourcc_value != NULL);
  fail_unless (GST_VALUE_HOLDS_FOURCC (fourcc_value));
  fourcc = gst_value_get_fourcc (fourcc_value);
  fail_unless (fourcc != 0);
  got_i420 = got_i420 || (fourcc == GST_STR_FOURCC ("I420"));
  got_yuy2 = got_yuy2 || (fourcc == GST_STR_FOURCC ("YUY2"));
  got_yv12 = got_yv12 || (fourcc == GST_STR_FOURCC ("YV12"));

  fourcc_value = gst_value_list_get_value (format_value, 2);
  fail_unless (fourcc_value != NULL);
  fail_unless (GST_VALUE_HOLDS_FOURCC (fourcc_value));
  fourcc = gst_value_get_fourcc (fourcc_value);
  fail_unless (fourcc != 0);
  got_i420 = got_i420 || (fourcc == GST_STR_FOURCC ("I420"));
  got_yuy2 = got_yuy2 || (fourcc == GST_STR_FOURCC ("YUY2"));
  got_yv12 = got_yv12 || (fourcc == GST_STR_FOURCC ("YV12"));

  return (got_i420 && got_yuy2 && got_yv12);
}
Ejemplo n.º 2
0
/* this function is a bit of a last resort */
static void
gst_v4lsrc_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
    GstStructure *structure;
    int i;
    int targetwidth, targetheight;
    GstV4lSrc *v4lsrc = GST_V4LSRC (bsrc);
    struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
    struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin;

    if (GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
        GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d",
                          vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight);
        targetwidth = vcap->minwidth;
        targetheight = vcap->minheight;
        /* if we can get the current vwin settings, we use those to fixate */
        if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc)))
            GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities");
        else {
            targetwidth = vwin->width;
            targetheight = vwin->height;
        }
    } else {
        GST_DEBUG_OBJECT (v4lsrc, "device closed, guessing");
        targetwidth = 320;
        targetheight = 200;
    }

    GST_DEBUG_OBJECT (v4lsrc, "targetting %dx%d", targetwidth, targetheight);

    for (i = 0; i < gst_caps_get_size (caps); ++i) {
        const GValue *v;

        structure = gst_caps_get_structure (caps, i);
        gst_structure_fixate_field_nearest_int (structure, "width", targetwidth);
        gst_structure_fixate_field_nearest_int (structure, "height", targetheight);
        gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2);

        v = gst_structure_get_value (structure, "format");
        if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) {
            guint32 fourcc;

            g_return_if_fail (G_VALUE_TYPE (v) == GST_TYPE_LIST);

            fourcc = gst_value_get_fourcc (gst_value_list_get_value (v, 0));
            gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL);
        }
    }
}
Ejemplo n.º 3
0
/* this function is a bit of a last resort */
static void
gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps)
{
  GstStructure *structure;

  gint i;

  GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, caps);

  for (i = 0; i < gst_caps_get_size (caps); ++i) {
    const GValue *v;

    structure = gst_caps_get_structure (caps, i);

    /* FIXME such sizes? we usually fixate to something in the 320x200
     * range... */
    /* We are fixating to greater possble size (limited to GST_V4L2_MAX_SIZE)
       and the maximum framerate resolution for that size */
    gst_structure_fixate_field_nearest_int (structure, "width",
        GST_V4L2_MAX_SIZE);
    gst_structure_fixate_field_nearest_int (structure, "height",
        GST_V4L2_MAX_SIZE);
    gst_structure_fixate_field_nearest_fraction (structure, "framerate",
        G_MAXINT, 1);

    v = gst_structure_get_value (structure, "format");
    if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) {
      guint32 fourcc;

      g_return_if_fail (G_VALUE_TYPE (v) == GST_TYPE_LIST);

      fourcc = gst_value_get_fourcc (gst_value_list_get_value (v, 0));
      gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL);
    }
  }

  GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps);
}
Ejemplo n.º 4
0
static VALUE
fourcc_to_i(VALUE self)
{
    return UINT2NUM(gst_value_get_fourcc(DATA_PTR(self)));
}
Ejemplo n.º 5
0
static void
fourcc_rvalue2gvalue(VALUE value, GValue *result)
{
    gst_value_set_fourcc(result,
                         gst_value_get_fourcc(RVAL2GOBJ(value)));
}