static GstCaps *
generate_sink_template (void)
{
  GstCaps *caps;
  GstStructure *struc;

  caps = gst_caps_new_empty ();

  struc = gst_structure_new ("audio/x-iLBC", NULL);

  {
    GValue list;
    GValue val;

    list.g_type = val.g_type = 0;

    g_value_init (&list, GST_TYPE_LIST);
    g_value_init (&val, G_TYPE_INT);

    g_value_set_int (&val, 20);
    gst_value_list_append_value (&list, &val);

    g_value_set_int (&val, 30);
    gst_value_list_append_value (&list, &val);

    gst_structure_set_value (struc, "mode", &list);

    g_value_unset (&val);
    g_value_unset (&list);
  }

  gst_caps_append_structure (caps, struc);

  return caps;
}
Beispiel #2
0
static GstCaps *
gst_yadif_transform_caps (GstBaseTransform * trans,
    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
  GstCaps *othercaps;

  othercaps = gst_caps_copy (caps);

  if (direction == GST_PAD_SRC) {
    GValue value = G_VALUE_INIT;
    GValue v = G_VALUE_INIT;

    g_value_init (&value, GST_TYPE_LIST);
    g_value_init (&v, G_TYPE_STRING);

    g_value_set_string (&v, "interleaved");
    gst_value_list_append_value (&value, &v);
    g_value_set_string (&v, "mixed");
    gst_value_list_append_value (&value, &v);
    g_value_set_string (&v, "progressive");
    gst_value_list_append_value (&value, &v);

    gst_caps_set_value (othercaps, "interlace-mode", &value);
    g_value_unset (&value);
    g_value_unset (&v);
  } else {
    gst_caps_set_simple (othercaps, "interlace-mode", G_TYPE_STRING,
        "progressive", NULL);
  }

  return othercaps;
}
static GstCaps *
gst_decklink_audio_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
{
  GstDecklinkAudioSink *self = GST_DECKLINK_AUDIO_SINK_CAST (bsink);
  GstCaps *caps;

  if ((caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (bsink))))
    return caps;

  caps = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink));

  GST_OBJECT_LOCK (self);
  if (self->output && self->output->attributes) {
    int64_t max_channels = 0;
    HRESULT ret;
    GstStructure *s;
    GValue arr = G_VALUE_INIT;
    GValue v = G_VALUE_INIT;

    ret =
        self->output->attributes->GetInt (BMDDeckLinkMaximumAudioChannels,
        &max_channels);
    /* 2 should always be supported */
    if (ret != S_OK) {
      max_channels = 2;
    }

    caps = gst_caps_make_writable (caps);
    s = gst_caps_get_structure (caps, 0);

    g_value_init (&arr, GST_TYPE_LIST);
    g_value_init (&v, G_TYPE_INT);
    if (max_channels >= 16) {
      g_value_set_int (&v, 16);
      gst_value_list_append_value (&arr, &v);
    }
    if (max_channels >= 8) {
      g_value_set_int (&v, 8);
      gst_value_list_append_value (&arr, &v);
    }
    g_value_set_int (&v, 2);
    gst_value_list_append_value (&arr, &v);

    gst_structure_set_value (s, "channels", &arr);
    g_value_unset (&v);
    g_value_unset (&arr);
  }
  GST_OBJECT_UNLOCK (self);

  if (filter) {
    GstCaps *intersection =
        gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
    gst_caps_unref (caps);
    caps = intersection;
  }

  return caps;
}
Beispiel #4
0
static GstCaps *
gst_real_audio_dec_getcaps (GstPad * pad)
{
  GstRealAudioDec *dec = GST_REAL_AUDIO_DEC (GST_PAD_PARENT (pad));
  GstCaps *res;

  if (dec->checked_modules) {
    GValue versions = { 0 };
    GValue version = { 0 };

    GST_LOG_OBJECT (dec, "constructing caps");
    res = gst_caps_new_empty ();

    g_value_init (&versions, GST_TYPE_LIST);
    g_value_init (&version, G_TYPE_INT);

    if (dec->valid_atrk) {
      g_value_set_int (&version, GST_REAL_AUDIO_DEC_VERSION_ATRK);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_ra14_4) {
      g_value_set_int (&version, GST_REAL_AUDIO_DEC_VERSION_14_4);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_ra28_8) {
      g_value_set_int (&version, GST_REAL_AUDIO_DEC_VERSION_28_8);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_sipr) {
      g_value_set_int (&version, GST_REAL_AUDIO_DEC_VERSION_SIPR);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_cook) {
      g_value_set_int (&version, GST_REAL_AUDIO_DEC_VERSION_COOK);
      gst_value_list_append_value (&versions, &version);
    }

    if (gst_value_list_get_size (&versions) > 0) {
      res = gst_caps_new_simple ("audio/x-pn-realaudio", NULL);
      gst_structure_set_value (gst_caps_get_structure (res, 0),
          "raversion", &versions);
    } else {
      res = gst_caps_new_empty ();
    }

    if (dec->valid_sipr) {
      gst_caps_append (res, gst_caps_new_simple ("audio/x-sipro", NULL));
    }
    g_value_unset (&versions);
    g_value_unset (&version);
  } else {
    GST_LOG_OBJECT (dec, "returning padtemplate caps");
    res = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
  }
  GST_LOG_OBJECT (dec, "returning caps %" GST_PTR_FORMAT, res);

  return res;
}
Beispiel #5
0
static GstCaps *
gst_ivtc_transform_caps (GstBaseTransform * trans,
                         GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
    GstCaps *othercaps;
    int i;

    othercaps = gst_caps_copy (caps);

    if (direction == GST_PAD_SRC) {
        GValue value = G_VALUE_INIT;
        GValue v = G_VALUE_INIT;

        g_value_init (&value, GST_TYPE_LIST);
        g_value_init (&v, G_TYPE_STRING);

        g_value_set_string (&v, "interleaved");
        gst_value_list_append_value (&value, &v);
        g_value_set_string (&v, "mixed");
        gst_value_list_append_value (&value, &v);
        g_value_set_string (&v, "progressive");
        gst_value_list_append_value (&value, &v);

        for (i = 0; i < gst_caps_get_size (othercaps); i++) {
            GstStructure *structure = gst_caps_get_structure (othercaps, i);
            gst_structure_set_value (structure, "interlace-mode", &value);
            gst_structure_remove_field (structure, "framerate");
        }
        g_value_reset (&value);
        g_value_reset (&v);
    } else {
        for (i = 0; i < gst_caps_get_size (othercaps); i++) {
            GstStructure *structure = gst_caps_get_structure (othercaps, i);
            gst_structure_set (structure, "interlace-mode", G_TYPE_STRING,
                               "progressive", NULL);
            gst_structure_remove_field (structure, "framerate");
        }
    }

    if (filter) {
        GstCaps *intersect;

        intersect = gst_caps_intersect (othercaps, filter);
        gst_caps_unref (othercaps);
        othercaps = intersect;
    }

    return othercaps;
}
Beispiel #6
0
static GstMessage *
gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime endtime)
{
  GstStructure *s;
  GValue v = { 0, };
  GValue *l;
  guint i;
  gfloat *spect_magnitude = spectrum->spect_magnitude;
  gfloat *spect_phase = spectrum->spect_phase;

  GST_DEBUG_OBJECT (spectrum, "preparing message, spect = %p, bands =%d ",
      spect_magnitude, spectrum->bands);

  s = gst_structure_new ("spectrum", "endtime", GST_TYPE_CLOCK_TIME,
      endtime, NULL);

  if (spectrum->message_magnitude) {
    g_value_init (&v, GST_TYPE_LIST);
    /* will copy-by-value */
    gst_structure_set_value (s, "magnitude", &v);
    g_value_unset (&v);

    g_value_init (&v, G_TYPE_FLOAT);
    l = (GValue *) gst_structure_get_value (s, "magnitude");
    for (i = 0; i < spectrum->bands; i++) {
      g_value_set_float (&v, spect_magnitude[i]);
      gst_value_list_append_value (l, &v);      /* copies by value */
    }
    g_value_unset (&v);
  }

  if (spectrum->message_phase) {
    g_value_init (&v, GST_TYPE_LIST);
    /* will copy-by-value */
    gst_structure_set_value (s, "phase", &v);
    g_value_unset (&v);

    g_value_init (&v, G_TYPE_FLOAT);
    l = (GValue *) gst_structure_get_value (s, "phase");
    for (i = 0; i < spectrum->bands; i++) {
      g_value_set_float (&v, spect_phase[i]);
      gst_value_list_append_value (l, &v);      /* copies by value */
    }
    g_value_unset (&v);
  }

  return gst_message_new_element (GST_OBJECT (spectrum), s);
}
Beispiel #7
0
static void
set_value (GValue * val, gint count, ...)
{
  const gchar *fmt = NULL;
  GValue sval = G_VALUE_INIT;
  va_list ap;
  gint i;

  g_value_init (&sval, G_TYPE_STRING);

  if (count > 1)
    g_value_init (val, GST_TYPE_LIST);

  va_start (ap, count);
  for (i = 0; i < count; i++) {
    fmt = va_arg (ap, const gchar *);
    g_value_set_string (&sval, fmt);
    if (count > 1) {
      gst_value_list_append_value (val, &sval);
    }
  }
  va_end (ap);

  if (count == 1)
    *val = sval;
  else
    g_value_unset (&sval);
}
bool fill_structure_fixed_resolution (GstStructure* structure,
                                      const tcam::VideoFormatDescription& format,
                                      const tcam_resolution_description& res)
{

    std::vector<double> framerates = format.get_frame_rates(res);
    int framerate_count = framerates.size();

    GValue fps_list = G_VALUE_INIT;
    g_value_init(&fps_list, GST_TYPE_LIST);

    for (int f = 0; f < framerate_count; f++)
    {
        int frame_rate_numerator;
        int frame_rate_denominator;
        gst_util_double_to_fraction(framerates[f],
                                    &frame_rate_numerator,
                                    &frame_rate_denominator);

        GValue fraction = G_VALUE_INIT;
        g_value_init(&fraction, GST_TYPE_FRACTION);
        gst_value_set_fraction(&fraction, frame_rate_numerator, frame_rate_denominator);
        gst_value_list_append_value(&fps_list, &fraction);
        g_value_unset(&fraction);
    }

    gst_structure_set (structure,
                       "width", G_TYPE_INT, res.max_size.width,
                       "height", G_TYPE_INT, res.max_size.height,
                       NULL);

    gst_structure_take_value(structure, "framerate", &fps_list);

    return true;
}
Beispiel #9
0
static gint
gst_dc1394_caps_set_framerate_list (GstStructure * gs,
                                    dc1394framerates_t * framerates)
{
    GValue framefrac = { 0 };
    GValue frameratelist = { 0 };
    gint f;

    g_value_init (&frameratelist, GST_TYPE_LIST);
    g_value_init (&framefrac, GST_TYPE_FRACTION);

    // figure out the frame rate
    for (f = framerates->num - 1; f >= 0; f--) {
        /* reverse order so we place the faster frame rates higher in
           the sequence */
        if (framerates->framerates[f]) {
            gst_dc1394_framerate_const_to_frac (framerates->framerates[f],
                                                &framefrac);

            gst_value_list_append_value (&frameratelist, &framefrac);
        }
    }
    gst_structure_set_value (gs, "framerate", &frameratelist);

    g_value_unset (&framefrac);
    g_value_unset (&frameratelist);
    return 0;
}
Beispiel #10
0
static void
gst_droidcamsrc_dev_preview_metadata_callback (void *user,
    const DroidMediaCameraFace * faces, size_t num_faces)
{
  GstDroidCamSrcDev *dev = (GstDroidCamSrcDev *) user;
  GstDroidCamSrc *src = GST_DROIDCAMSRC (GST_PAD_PARENT (dev->imgsrc->pad));
  GstStructure *s;
  gint width, height;
  GValue regions = G_VALUE_INIT;
  gint i;

  GST_DEBUG_OBJECT (src, "dev preview metadata callback");

  GST_INFO_OBJECT (src, "camera detected %d faces", num_faces);

  GST_OBJECT_LOCK (src);
  width = src->width;
  height = src->height;
  GST_OBJECT_UNLOCK (src);

  s = gst_structure_new ("regions-of-interest", "frame-width", G_TYPE_UINT,
      width, "frame-height", G_TYPE_UINT, height, "type", G_TYPE_UINT,
      GST_DROIDCAMSRC_ROI_FACE_AREA, NULL);

  g_value_init (&regions, GST_TYPE_LIST);

  for (i = 0; i < num_faces; i++) {
    GValue region = G_VALUE_INIT;
    int x, y, w, h, r, b;
    GstStructure *rs;

    g_value_init (&region, GST_TYPE_STRUCTURE);

    GST_DEBUG_OBJECT (src,
        "face %d: score=%d, left=%d, top=%d, right=%d, bottom=%d", i,
        faces[i].score, faces[i].left, faces[i].top, faces[i].right,
        faces[i].bottom);
    x = gst_util_uint64_scale (faces[i].left + 1000, width, 2000);
    y = gst_util_uint64_scale (faces[i].top + 1000, height, 2000);
    r = gst_util_uint64_scale (faces[i].right + 1000, width, 2000);
    b = gst_util_uint64_scale (faces[i].bottom + 1000, height, 2000);
    w = r - x;
    h = b - y;
    rs = gst_structure_new ("region-of-interest",
        "region-x", G_TYPE_UINT, x,
        "region-y", G_TYPE_UINT, y,
        "region-w", G_TYPE_UINT, w,
        "region-h", G_TYPE_UINT, h,
        "region-id", G_TYPE_INT, faces[i].id,
        "region-score", G_TYPE_INT, faces[i].score, NULL);

    gst_value_set_structure (&region, rs);
    gst_structure_free (rs);
    gst_value_list_append_value (&regions, &region);
    g_value_unset (&region);
  }

  gst_structure_take_value (s, "regions", &regions);
  gst_droidcamsrc_post_message (src, s);
}
Beispiel #11
0
static GstCaps *
generate_sink_template(void)
{
	GstCaps *caps;
	GstStructure *struc;

	caps = gst_caps_new_empty();

	struc = gst_structure_new("video/x-raw-yuv",
			"width", GST_TYPE_INT_RANGE, 16, 4096,
			"height", GST_TYPE_INT_RANGE, 16, 4096,
			"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30, 1,
			NULL);

	{
		GValue list;
		GValue val;

		list.g_type = val.g_type = 0;

		g_value_init(&list, GST_TYPE_LIST);
		g_value_init(&val, GST_TYPE_FOURCC);

#if 0
		gst_value_set_fourcc(&val, GST_MAKE_FOURCC('I', '4', '2', '0'));
		gst_value_list_append_value(&list, &val);

		gst_value_set_fourcc(&val, GST_MAKE_FOURCC('Y', 'U', 'Y', '2'));
		gst_value_list_append_value(&list, &val);

		gst_value_set_fourcc(&val, GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'));
		gst_value_list_append_value(&list, &val);
#else
		gst_value_set_fourcc(&val, GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'));
		gst_value_list_append_value(&list, &val);
#endif

		gst_structure_set_value(struc, "format", &list);

		g_value_unset(&val);
		g_value_unset(&list);
	}

	gst_caps_append_structure(caps, struc);

	return caps;
}
Beispiel #12
0
static GstCaps *
gst_real_video_dec_getcaps (GstPad * pad)
{
  GstRealVideoDec *dec = GST_REAL_VIDEO_DEC (GST_PAD_PARENT (pad));
  GstCaps *res;

  if (dec->checked_modules) {
    GValue versions = { 0 };
    GValue version = { 0 };

    GST_LOG_OBJECT (dec, "constructing caps");
    res = gst_caps_new_empty ();

    g_value_init (&versions, GST_TYPE_LIST);
    g_value_init (&version, G_TYPE_INT);

    if (dec->valid_rv20) {
      g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_2);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_rv30) {
      g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_3);
      gst_value_list_append_value (&versions, &version);
    }
    if (dec->valid_rv40) {
      g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_4);
      gst_value_list_append_value (&versions, &version);
    }

    if (gst_value_list_get_size (&versions) > 0) {
      res = gst_caps_new_simple ("video/x-pn-realvideo", NULL);
      gst_structure_set_value (gst_caps_get_structure (res, 0),
          "rmversion", &versions);
    } else {
      res = gst_caps_new_empty ();
    }
    g_value_unset (&versions);
    g_value_unset (&version);
  } else {
    GST_LOG_OBJECT (dec, "returning padtemplate caps");
    res = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
  }
  GST_LOG_OBJECT (dec, "returning caps %" GST_PTR_FORMAT, res);

  return res;
}
Beispiel #13
0
void test_channel_layout_value_intersect()
{
  GValue layout = { 0, };
  GValue list = { 0, };
  GValue res = { 0, };
  
          	xmlfile = "test_channel_layout_value_intersect";
  std_log(LOG_FILENAME_LINE, "Test Started test_channel_layout_value_intersect");

  g_value_init (&list, GST_TYPE_LIST);
  init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
      GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
  gst_value_list_append_value (&list, &layout);
  g_value_unset (&layout);
  init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
      GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
  gst_value_list_append_value (&list, &layout);
  g_value_unset (&layout);

  init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
      GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);

  /* we should get the second layout in the list, as it matches the input */
  fail_unless (gst_value_intersect (&res, &layout, &list));
  g_value_unset (&layout);
  fail_unless (GST_VALUE_HOLDS_ARRAY (&res));
  fail_unless_equals_int (gst_value_array_get_size (&res), 2);
  fail_unless_equals_int (g_value_get_enum (gst_value_array_get_value (&res,
              0)), GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT);
  fail_unless_equals_int (g_value_get_enum (gst_value_array_get_value (&res,
              1)), GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT);
  g_value_unset (&res);

  /* this (with rear position) should not yield any results */
  init_value_to_channel_layout (&layout, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
      GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT);
  fail_if (gst_value_intersect (&res, &layout, &list));
  g_value_unset (&layout);

  g_value_unset (&list);
  
      std_log(LOG_FILENAME_LINE, "Test Successful");
  create_xml(0);
}
Beispiel #14
0
static void
gst_query_list_add_command (GValue * list, GstNavigationCommand val)
{
  GValue item = { 0, };

  g_value_init (&item, GST_TYPE_NAVIGATION_COMMAND);
  g_value_set_enum (&item, val);
  gst_value_list_append_value (list, &item);
  g_value_unset (&item);
}
Beispiel #15
0
static void
gst_query_list_add_format (GValue * list, GstFormat format)
{
  GValue item = { 0, };

  g_value_init (&item, GST_TYPE_FORMAT);
  g_value_set_enum (&item, format);
  gst_value_list_append_value (list, &item);
  g_value_unset (&item);
}
static void
gst_opus_dec_value_list_append_int (GValue * list, gint i)
{
  GValue v = { 0 };

  g_value_init (&v, G_TYPE_INT);
  g_value_set_int (&v, i);
  gst_value_list_append_value (list, &v);
  g_value_unset (&v);
}
static GstCaps *
stereosplit_get_src_caps (GstGLStereoSplit * split,
    GstPad * pad, GstVideoMultiviewMode preferred_mode)
{
  GstCaps *outcaps, *tmp, *templ_caps;
  GValue item = G_VALUE_INIT, list = G_VALUE_INIT;

  /* Get the template format */
  templ_caps = gst_pad_get_pad_template_caps (pad);

  /* And limit down to the preferred mode or mono */
  templ_caps = gst_caps_make_writable (templ_caps);

  g_value_init (&item, G_TYPE_STRING);
  g_value_init (&list, GST_TYPE_LIST);
  g_value_set_static_string (&item,
      gst_video_multiview_mode_to_caps_string (preferred_mode));
  gst_value_list_append_value (&list, &item);
  g_value_set_static_string (&item,
      gst_video_multiview_mode_to_caps_string (GST_VIDEO_MULTIVIEW_MODE_MONO));
  gst_value_list_append_value (&list, &item);

  gst_caps_set_value (templ_caps, "multiview-mode", &list);

  g_value_unset (&list);
  g_value_unset (&item);

  /* And intersect with the peer */
  if ((tmp = gst_pad_peer_query_caps (pad, NULL)) == NULL) {
    gst_caps_unref (templ_caps);
    return NULL;
  }

  outcaps = gst_caps_intersect_full (tmp, templ_caps, GST_CAPS_INTERSECT_FIRST);
  gst_caps_unref (tmp);
  gst_caps_unref (templ_caps);

  GST_DEBUG_OBJECT (split, "Src pad %" GST_PTR_FORMAT " caps %" GST_PTR_FORMAT,
      pad, outcaps);
  return outcaps;
}
Beispiel #18
0
static void
gst_dc1394_set_caps_framesize_range (GstStructure * gs,
                                     gint minwidth,
                                     gint maxwidth,
                                     gint incwidth, gint minheight, gint maxheight, gint incheight)
{
    /*
       Format 7 cameras allow you to change the camera width/height in multiples
       of incwidth/incheight up to some max. This sets the necessary
       list structure in the gst caps structure
     */

    GValue widthlist = { 0 };
    GValue widthval = { 0 };
    GValue heightlist = { 0 };
    GValue heightval = { 0 };
    gint x = 0;

    g_value_init (&widthlist, GST_TYPE_LIST);
    g_value_init (&widthval, G_TYPE_INT);
    for (x = minwidth; x <= maxwidth; x += incwidth) {
        g_value_set_int (&widthval, x);
        gst_value_list_append_value (&widthlist, &widthval);
    }
    gst_structure_set_value (gs, "width", &widthlist);

    g_value_unset (&widthlist);
    g_value_unset (&widthval);

    g_value_init (&heightlist, GST_TYPE_LIST);
    g_value_init (&heightval, G_TYPE_INT);
    for (x = minheight; x <= maxheight; x += incheight) {
        g_value_set_int (&heightval, x);
        gst_value_list_append_value (&heightlist, &heightval);
    }

    gst_structure_set_value (gs, "height", &heightlist);

    g_value_unset (&heightlist);
    g_value_unset (&heightval);
}
Beispiel #19
0
void QtCamRoi::setRegionOfInterest(const QRectF& roi) {
  if (!d_ptr->dev || !d_ptr->dev->viewfinder()) {
    return;
  }

  QSizeF vf = d_ptr->dev->viewfinder()->videoResolution();
  if (vf.isEmpty()) {
    return;
  }

  int frameWidth = vf.width();
  int frameHeight = vf.height();
  int x = roi.x() * frameWidth;
  int y = roi.y() * frameHeight;
  int width = roi.width() * frameWidth;
  int height = roi.height() * frameHeight;

  // if we have an empty roi then we reset:
  int priority = roi.isEmpty() ? 0 : 1;

  GstStructure *region = gst_structure_new("region0",
					   "region-x", G_TYPE_UINT, x,
					   "region-y", G_TYPE_UINT, y,
					   "region-w", G_TYPE_UINT, width,
					   "region-h", G_TYPE_UINT, height,
					   "region-priority", G_TYPE_UINT, priority,
					   "region-id", G_TYPE_UINT, 0,
					   NULL);

  GValue regionValue = G_VALUE_INIT;
  GValue regionList = G_VALUE_INIT;

  g_value_init(&regionValue, GST_TYPE_STRUCTURE);
  g_value_init(&regionList, GST_TYPE_LIST);

  gst_value_set_structure(&regionValue, region);
  gst_value_list_append_value(&regionList, &regionValue);

  GstStructure *s = gst_structure_new("regions-of-interest",
				      "frame-width", G_TYPE_UINT, frameWidth,
				      "frame-height", G_TYPE_UINT, frameHeight,
				      NULL);
  gst_structure_set_value(s, "regions", &regionList);

  GstEvent *event = gst_event_new_custom(GST_EVENT_CUSTOM_UPSTREAM, s);
  gst_structure_free(region);
  g_value_unset(&regionValue);
  g_value_unset(&regionList);

  if (!d_ptr->sendEventToSource(event)) {
    qWarning() << "Failed to send ROI event";
  }
}
static void
gst_mio_video_device_append_framerate (GstMIOVideoDevice * self,
    GstMIOVideoFormat * format, TundraFramerate * rate, gpointer user_data)
{
  GValue *rates = user_data;
  GValue value = { 0, };

  g_value_init (&value, GST_TYPE_FRACTION);
  gst_mio_video_device_framerate_to_fraction_value (rate, &value);
  gst_value_list_append_value (rates, &value);
  g_value_unset (&value);
}
static GstCaps *
generate_src_template (void)
{
    GstCaps *caps;

    GstStructure *struc;

    caps = gst_caps_new_empty ();

    struc = gst_structure_new ("audio/mpeg",
                               "mpegversion", G_TYPE_INT, 4,
                               "rate", GST_TYPE_INT_RANGE, 8000, 48000,
                               "channels", GST_TYPE_INT_RANGE, 1, 2,
                               NULL);

    {
        GValue list;
        GValue val;

        list.g_type = val.g_type = 0;

        g_value_init (&list, GST_TYPE_LIST);
        g_value_init (&val, G_TYPE_INT);

        g_value_set_int (&val, 2);
        gst_value_list_append_value (&list, &val);

        g_value_set_int (&val, 4);
        gst_value_list_append_value (&list, &val);

        gst_structure_set_value (struc, "mpegversion", &list);

        g_value_unset (&val);
        g_value_unset (&list);
    }

    gst_caps_append_structure (caps, struc);

    return caps;
}
Beispiel #22
0
static void
value_list_rvalue2gvalue(VALUE value, GValue *result)
{
    guint i, len;

    len = RARRAY_LEN(value);
    for (i = 0; i < len; i++) {
        GValue val = {0};
        rbgobj_initialize_gvalue(&val, RARRAY_PTR(value)[i]);
        gst_value_list_append_value(result, &val);
        g_value_unset(&val);
    }
}
Beispiel #23
0
/**
 * gst_gl_value_set_texture_target_from_mask:
 * @value: an uninitialized #GValue
 * @target_mask: a bitwise mask of #GstGLTextureTarget's
 *
 * A mask is a bitwise OR of (1 << target) where target is a valid
 * #GstGLTextureTarget
 *
 * Returns: whether the @target_mask could be set on @value
 */
gboolean
gst_gl_value_set_texture_target_from_mask (GValue * value,
    GstGLTextureTarget target_mask)
{
  g_return_val_if_fail (value != NULL, FALSE);
  g_return_val_if_fail (target_mask != GST_GL_TEXTURE_TARGET_NONE, FALSE);

  if ((target_mask & (target_mask - 1)) == 0) {
    /* only one texture target set */
    g_value_init (value, G_TYPE_STRING);
    return gst_gl_value_set_texture_target (value,
        _gst_gl_log2_int64 (target_mask));
  } else {
    GValue item = G_VALUE_INIT;
    gboolean ret = FALSE;

    g_value_init (value, GST_TYPE_LIST);
    g_value_init (&item, G_TYPE_STRING);
    if (target_mask & (1 << GST_GL_TEXTURE_TARGET_2D)) {
      gst_gl_value_set_texture_target (&item, GST_GL_TEXTURE_TARGET_2D);
      gst_value_list_append_value (value, &item);
      ret = TRUE;
    }
    if (target_mask & (1 << GST_GL_TEXTURE_TARGET_RECTANGLE)) {
      gst_gl_value_set_texture_target (&item, GST_GL_TEXTURE_TARGET_RECTANGLE);
      gst_value_list_append_value (value, &item);
      ret = TRUE;
    }
    if (target_mask & (1 << GST_GL_TEXTURE_TARGET_EXTERNAL_OES)) {
      gst_gl_value_set_texture_target (&item,
          GST_GL_TEXTURE_TARGET_EXTERNAL_OES);
      gst_value_list_append_value (value, &item);
      ret = TRUE;
    }

    g_value_unset (&item);
    return ret;
  }
}
static void
gst_spectrum_message_add_list (GValue * cv, gfloat * data, guint num_values)
{
  GValue v = { 0, };
  guint i;

  g_value_init (&v, G_TYPE_FLOAT);
  for (i = 0; i < num_values; i++) {
    g_value_set_float (&v, data[i]);
    gst_value_list_append_value (cv, &v);       /* copies by value */
  }
  g_value_unset (&v);
}
Beispiel #25
0
static GstCaps *
gst_smpte_alpha_transform_caps (GstBaseTransform * trans,
    GstPadDirection direction, GstCaps * from)
{
  GstCaps *to = gst_caps_copy (from);
  GstStructure *s;

  gst_caps_truncate (to);
  s = gst_caps_get_structure (to, 0);

  if (gst_structure_has_name (s, "video/x-raw-yuv")) {
    GValue list = { 0, };
    GValue val = { 0, };

    gst_structure_remove_field (s, "format");

    g_value_init (&list, GST_TYPE_LIST);
    g_value_init (&val, GST_TYPE_FOURCC);
    gst_value_set_fourcc (&val, GST_STR_FOURCC ("AYUV"));
    gst_value_list_append_value (&list, &val);
    g_value_reset (&val);
    gst_value_set_fourcc (&val, GST_STR_FOURCC ("I420"));
    gst_value_list_append_value (&list, &val);
    g_value_reset (&val);
    gst_value_set_fourcc (&val, GST_STR_FOURCC ("YV12"));
    gst_value_list_append_value (&list, &val);
    g_value_unset (&val);
    gst_structure_set_value (s, "format", &list);
    g_value_unset (&list);
  } else if (!gst_structure_has_name (s, "video/x-raw-rgb")) {
    gst_caps_unref (to);
    to = gst_caps_new_empty ();
  }

  return to;
}
Beispiel #26
0
static GstCaps *
gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
{
  GstWaylandSink *sink;
  GstCaps *caps;

  sink = GST_WAYLAND_SINK (bsink);

  caps = gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (sink));

  g_mutex_lock (&sink->display_lock);

  if (sink->display) {
    GValue list = G_VALUE_INIT;
    GValue value = G_VALUE_INIT;
    GArray *formats;
    gint i;
    enum wl_shm_format fmt;

    g_value_init (&list, GST_TYPE_LIST);
    g_value_init (&value, G_TYPE_STRING);

    formats = sink->display->shm_formats;
    for (i = 0; i < formats->len; i++) {
      fmt = g_array_index (formats, uint32_t, i);
      g_value_set_string (&value, gst_wl_shm_format_to_string (fmt));
      gst_value_list_append_value (&list, &value);
    }

    caps = gst_caps_make_writable (caps);
    gst_structure_set_value (gst_caps_get_structure (caps, 0), "format", &list);

    GST_DEBUG_OBJECT (sink, "display caps: %" GST_PTR_FORMAT, caps);
  }

  g_mutex_unlock (&sink->display_lock);

  if (filter) {
    GstCaps *intersection;

    intersection =
        gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
    gst_caps_unref (caps);
    caps = intersection;
  }

  return caps;
}
Beispiel #27
0
static void
_add_vk_format_to_list (GValue * list, VkFormat format)
{
  GstVideoFormat v_format;
  const gchar *format_str;

  v_format = _vk_format_to_video_format (format);
  if (v_format) {
    GValue item = G_VALUE_INIT;

    g_value_init (&item, G_TYPE_STRING);
    format_str = gst_video_format_to_string (v_format);
    g_value_set_string (&item, format_str);
    gst_value_list_append_value (list, &item);
    g_value_unset (&item);
  }
}
gboolean
gst_vaapi_value_set_format_list (GValue * value, GArray * formats)
{
  GValue v_format = G_VALUE_INIT;
  guint i;

  g_value_init (value, GST_TYPE_LIST);
  for (i = 0; i < formats->len; i++) {
    GstVideoFormat const format = g_array_index (formats, GstVideoFormat, i);

    if (!gst_vaapi_value_set_format (&v_format, format))
      continue;
    gst_value_list_append_value (value, &v_format);
    g_value_unset (&v_format);
  }
  return TRUE;
}
static void
transform_value (GValue * dest)
{
  GValue fourcc = { 0 };

  g_value_init (dest, GST_TYPE_LIST);
  g_value_init (&fourcc, GST_TYPE_FOURCC);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('I', '4', '2', '0'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('Y', 'V', '1', '2'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('Y', '4', '2', 'B'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('Y', '4', '4', '4'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('v', '2', '1', '0'));
  gst_value_list_append_value (dest, &fourcc);

  gst_value_set_fourcc (&fourcc, GST_MAKE_FOURCC ('v', '2', '1', '6'));
  gst_value_list_append_value (dest, &fourcc);

  g_value_unset (&fourcc);
}
Beispiel #30
0
static void appendRegion(GValue *regions, int priority, const QRect &rectangle)
{
    GstStructure *region = gst_structure_new(
                "region",
                "region-x"        , G_TYPE_UINT , rectangle.x(),
                "region-y"        , G_TYPE_UINT,  rectangle.y(),
                "region-w"        , G_TYPE_UINT , rectangle.width(),
                "region-h"        , G_TYPE_UINT,  rectangle.height(),
                "region-priority" , G_TYPE_UINT,  priority,
                NULL);

    GValue regionValue = G_VALUE_INIT;
    g_value_init(&regionValue, GST_TYPE_STRUCTURE);
    gst_value_set_structure(&regionValue, region);
    gst_structure_free(region);

    gst_value_list_append_value(regions, &regionValue);
    g_value_unset(&regionValue);
}