static gboolean gst_mio_video_device_add_framerates_to_structure (GstMIOVideoDevice * self, GstMIOVideoFormat * format, GstStructure * s) { GValue rates = { 0, }; const GValue *rates_value; g_value_init (&rates, GST_TYPE_LIST); gst_mio_video_device_format_framerates_foreach (self, format, gst_mio_video_device_append_framerate, &rates); if (gst_value_list_get_size (&rates) == 0) goto no_framerates; if (gst_value_list_get_size (&rates) > 1) rates_value = &rates; else rates_value = gst_value_list_get_value (&rates, 0); gst_structure_set_value (s, "framerate", rates_value); g_value_unset (&rates); return TRUE; /* ERRORS */ no_framerates: { g_value_unset (&rates); return FALSE; } }
static void dvb_base_bin_add_pmt_streams (DvbBaseBin * dvbbasebin, GstStructure * pmt) { DvbBaseBinStream *stream; const GValue *streams; guint program_number; gint i; const GValue *value; GstStructure *stream_info; guint pid; guint stream_type; gst_structure_get_uint (pmt, "program-number", &program_number); streams = gst_structure_get_value (pmt, "streams"); for (i = 0; i < gst_value_list_get_size (streams); ++i) { value = gst_value_list_get_value (streams, i); stream_info = g_value_get_boxed (value); gst_structure_get_uint (stream_info, "pid", &pid); gst_structure_get_uint (stream_info, "stream-type", &stream_type); GST_DEBUG ("filtering stream %d stream_type %d", pid, stream_type); stream = dvb_base_bin_get_stream (dvbbasebin, (guint16) pid); if (stream == NULL) stream = dvb_base_bin_add_stream (dvbbasebin, (guint16) pid); ++stream->usecount; } }
static gboolean struct_field_has_line (GstStructure *s, const gchar *field, const gchar *value) { const gchar *tmp = gst_structure_get_string (s, field); const GValue *v = NULL; gint i; if (tmp) return !strcmp (value, tmp); if (!gst_structure_has_field_typed (s, field, GST_TYPE_LIST)) return FALSE; v = gst_structure_get_value (s, field); for (i=0; i < gst_value_list_get_size (v); i++) { const GValue *listval = gst_value_list_get_value (v, i); if (G_VALUE_HOLDS_STRING(listval) && !strcmp (value, g_value_get_string (listval))) return TRUE; } return FALSE; }
/** * gst_gl_value_get_texture_target_mask: * @value: an initialized #GValue of type G_TYPE_STRING * * See gst_gl_value_set_texture_target_from_mask() for what entails a mask * * Returns: the mask of #GstGLTextureTarget's in @value */ GstGLTextureTarget gst_gl_value_get_texture_target_mask (const GValue * targets) { guint new_targets = 0; g_return_val_if_fail (targets != NULL, GST_GL_TEXTURE_TARGET_NONE); if (G_TYPE_CHECK_VALUE_TYPE (targets, G_TYPE_STRING)) { GstGLTextureTarget target; const gchar *str; str = g_value_get_string (targets); target = gst_gl_texture_target_from_string (str); if (target) new_targets |= 1 << target; } else if (G_TYPE_CHECK_VALUE_TYPE (targets, GST_TYPE_LIST)) { gint j, m; m = gst_value_list_get_size (targets); for (j = 0; j < m; j++) { const GValue *val = gst_value_list_get_value (targets, j); GstGLTextureTarget target; const gchar *str; str = g_value_get_string (val); target = gst_gl_texture_target_from_string (str); if (target) new_targets |= 1 << target; } } return new_targets; }
static void dvb_base_bin_remove_pmt_streams (DvbBaseBin * dvbbasebin, GstStructure * pmt) { const GValue *streams; guint program_number; gint i; const GValue *value; GstStructure *stream_info; DvbBaseBinStream *stream; guint pid; guint stream_type; gst_structure_get_uint (pmt, "program-number", &program_number); streams = gst_structure_get_value (pmt, "streams"); for (i = 0; i < gst_value_list_get_size (streams); ++i) { value = gst_value_list_get_value (streams, i); stream_info = g_value_get_boxed (value); gst_structure_get_uint (stream_info, "pid", &pid); gst_structure_get_uint (stream_info, "stream-type", &stream_type); stream = dvb_base_bin_get_stream (dvbbasebin, (guint16) pid); if (stream == NULL) { GST_WARNING_OBJECT (dvbbasebin, "removing unknown stream %d ??", pid); continue; } --stream->usecount; } }
/** * gst_navigation_query_parse_commands_nth: * @query: a #GstQuery * @nth: the nth command to retrieve. * @cmd: a pointer to store the nth command into. * * Parse the #GstNavigation command query and retrieve the @nth command from * it into @cmd. If the list contains less elements than @nth, @cmd will be * set to #GST_NAVIGATION_COMMAND_INVALID. * * Returns: %TRUE if the query could be successfully parsed. %FALSE if not. */ gboolean gst_navigation_query_parse_commands_nth (GstQuery * query, guint nth, GstNavigationCommand * cmd) { const GstStructure *structure; const GValue *list; g_return_val_if_fail (GST_NAVIGATION_QUERY_HAS_TYPE (query, COMMANDS), FALSE); if (cmd == NULL) return TRUE; structure = gst_query_get_structure (query); list = gst_structure_get_value (structure, "commands"); if (list == NULL) { *cmd = GST_NAVIGATION_COMMAND_INVALID; } else { if (nth < gst_value_list_get_size (list)) { *cmd = (GstNavigationCommand) g_value_get_enum (gst_value_list_get_value (list, nth)); } else *cmd = GST_NAVIGATION_COMMAND_INVALID; } return TRUE; }
static void get_supported_framerates (ofGstVideoFormat &video_format, GstStructure &structure) { const GValue *framerates; int i, j; framerates = gst_structure_get_value (&structure, "framerate"); if (GST_VALUE_HOLDS_FRACTION (framerates)) { video_format.num_framerates = 1; video_format.framerates = new ofGstFramerate[video_format.num_framerates]; video_format.framerates[0].numerator = gst_value_get_fraction_numerator (framerates); video_format.framerates[0].denominator = gst_value_get_fraction_denominator (framerates); } else if (GST_VALUE_HOLDS_LIST (framerates)) { video_format.num_framerates = gst_value_list_get_size (framerates); video_format.framerates = new ofGstFramerate[video_format.num_framerates]; for (i = 0; i < video_format.num_framerates; i++) { const GValue *value; value = gst_value_list_get_value (framerates, i); video_format.framerates[i].numerator = gst_value_get_fraction_numerator (value); video_format.framerates[i].denominator = gst_value_get_fraction_denominator (value); } } else if (GST_VALUE_HOLDS_FRACTION_RANGE (framerates)) { int numerator_min, denominator_min, numerator_max, denominator_max; const GValue *fraction_range_min; const GValue *fraction_range_max; fraction_range_min = gst_value_get_fraction_range_min (framerates); numerator_min = gst_value_get_fraction_numerator (fraction_range_min); denominator_min = gst_value_get_fraction_denominator (fraction_range_min); fraction_range_max = gst_value_get_fraction_range_max (framerates); numerator_max = gst_value_get_fraction_numerator (fraction_range_max); denominator_max = gst_value_get_fraction_denominator (fraction_range_max); g_print ("FractionRange: %d/%d - %d/%d\n", numerator_min, denominator_min, numerator_max, denominator_max); video_format.num_framerates = (numerator_max - numerator_min + 1) * (denominator_max - denominator_min + 1); video_format.framerates = new ofGstFramerate[video_format.num_framerates]; int k = 0; for (i = numerator_min; i <= numerator_max; i++) { for (j = denominator_min; j <= denominator_max; j++) { video_format.framerates[k].numerator = i; video_format.framerates[k].denominator = j; k++; } } } else { g_critical ("GValue type %s, cannot be handled for framerates", G_VALUE_TYPE_NAME (framerates)); } }
static void gst_video_convert_fixate_format (GstBaseTransform * base, GstCaps * caps, GstCaps * result) { GstStructure *ins, *outs; const gchar *in_format; const GstVideoFormatInfo *in_info, *out_info = NULL; gint min_loss = G_MAXINT; guint i, capslen; ins = gst_caps_get_structure (caps, 0); in_format = gst_structure_get_string (ins, "format"); if (!in_format) return; GST_DEBUG_OBJECT (base, "source format %s", in_format); in_info = gst_video_format_get_info (gst_video_format_from_string (in_format)); if (!in_info) return; outs = gst_caps_get_structure (result, 0); capslen = gst_caps_get_size (result); GST_DEBUG_OBJECT (base, "iterate %d structures", capslen); for (i = 0; i < capslen; i++) { GstStructure *tests; const GValue *format; tests = gst_caps_get_structure (result, i); format = gst_structure_get_value (tests, "format"); /* should not happen */ if (format == NULL) continue; if (GST_VALUE_HOLDS_LIST (format)) { gint j, len; len = gst_value_list_get_size (format); GST_DEBUG_OBJECT (base, "have %d formats", len); for (j = 0; j < len; j++) { const GValue *val; val = gst_value_list_get_value (format, j); if (G_VALUE_HOLDS_STRING (val)) { score_value (base, in_info, val, &min_loss, &out_info); if (min_loss == 0) break; } } } else if (G_VALUE_HOLDS_STRING (format)) { score_value (base, in_info, format, &min_loss, &out_info); } } if (out_info) gst_structure_set (outs, "format", G_TYPE_STRING, GST_VIDEO_FORMAT_INFO_NAME (out_info), NULL); }
static GstVideoFormat gst_vaapi_find_preferred_format (const GValue * format_list, GstVideoFormat native_format) { const GValue *frmt; GstVideoFormat out_format; guint i; /* if one format, that is the one */ if (G_VALUE_HOLDS_STRING (format_list)) return gst_video_format_from_string (g_value_get_string (format_list)); if (!GST_VALUE_HOLDS_LIST (format_list)) { GST_ERROR ("negotiated caps do not have a valid format"); return GST_VIDEO_FORMAT_UNKNOWN; } if (native_format == GST_VIDEO_FORMAT_UNKNOWN || native_format == GST_VIDEO_FORMAT_ENCODED) { native_format = GST_VIDEO_FORMAT_NV12; /* default VA format */ } /* search our native format in the list */ for (i = 0; i < gst_value_list_get_size (format_list); i++) { frmt = gst_value_list_get_value (format_list, i); out_format = gst_video_format_from_string (g_value_get_string (frmt)); /* GStreamer do not handle encoded formats nicely. Try the next * one. */ if (out_format == GST_VIDEO_FORMAT_ENCODED) continue; if (native_format == out_format) return out_format; } /* just pick the first valid format in the list */ i = 0; do { frmt = gst_value_list_get_value (format_list, i++); out_format = gst_video_format_from_string (g_value_get_string (frmt)); } while (out_format == GST_VIDEO_FORMAT_ENCODED); return out_format; }
static void gst_face_overlay_message_handler (GstBin * bin, GstMessage * message) { if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT && strcmp (gst_structure_get_name (message->structure), "facedetect") == 0) { GstFaceOverlay *filter = GST_FACEOVERLAY (bin); /* optionally draw the image once every two messages for better performance * filter->process_message = !filter->process_message; * if(!filter->process_message) * return; */ guint x, y, width, height; int delta_x, delta_y, svg_x, svg_y, svg_width, svg_height; const GstStructure *face; int face_count; face_count = gst_value_list_get_size (gst_structure_get_value (message->structure, "faces")); /* The last face in the list seems to be the right one, objects mistakenly * detected as faces for a couple of frames seem to be in the list * beginning. TODO: needs confirmation. */ face = gst_value_get_structure (gst_value_list_get_value (gst_structure_get_value (message->structure, "faces"), face_count - 1)); gst_structure_get_uint (face, "x", &x); gst_structure_get_uint (face, "y", &y); gst_structure_get_uint (face, "width", &width); gst_structure_get_uint (face, "height", &height); /* Apply x and y offsets relative to face position and size. * Set image width and height as a fraction of face width and height. * Cast to int since face position and size will never be bigger than * G_MAX_INT and we may have negative values as svg_x or svg_y */ delta_x = (int) (filter->x * (int) width); svg_x = (int) x + delta_x; delta_y = (int) (filter->y * (int) height); svg_y = (int) y + delta_y; svg_width = (int) width *filter->w; svg_height = (int) height *filter->h; g_object_set (filter->svg_overlay, "location", filter->location, "x", svg_x, "y", svg_y, "width", svg_width, "height", svg_height, NULL); } GST_BIN_CLASS (parent_class)->handle_message (bin, message); }
EXPORT_C #endif void gst_tag_merge_use_first (GValue * dest, const GValue * src) { const GValue *ret = gst_value_list_get_value (src, 0); g_value_init (dest, G_VALUE_TYPE (ret)); g_value_copy (ret, dest); }
static void gst_value_fraction_get_extremes (const GValue * v, gint * min_num, gint * min_denom, gint * max_num, gint * max_denom) { if (GST_VALUE_HOLDS_FRACTION (v)) { *min_num = *max_num = gst_value_get_fraction_numerator (v); *min_denom = *max_denom = gst_value_get_fraction_denominator (v); } else if (GST_VALUE_HOLDS_FRACTION_RANGE (v)) { const GValue *min, *max; min = gst_value_get_fraction_range_min (v); *min_num = gst_value_get_fraction_numerator (min); *min_denom = gst_value_get_fraction_denominator (min); max = gst_value_get_fraction_range_max (v); *max_num = gst_value_get_fraction_numerator (max); *max_denom = gst_value_get_fraction_denominator (max); } else if (GST_VALUE_HOLDS_LIST (v)) { gint min_n = G_MAXINT, min_d = 1, max_n = 0, max_d = 1; int i, n; *min_num = G_MAXINT; *min_denom = 1; *max_num = 0; *max_denom = 1; n = gst_value_list_get_size (v); g_assert (n > 0); for (i = 0; i < n; i++) { const GValue *t = gst_value_list_get_value (v, i); gst_value_fraction_get_extremes (t, &min_n, &min_d, &max_n, &max_d); if (gst_util_fraction_compare (min_n, min_d, *min_num, *min_denom) < 0) { *min_num = min_n; *min_denom = min_d; } if (gst_util_fraction_compare (max_n, max_d, *max_num, *max_denom) > 0) { *max_num = max_n; *max_denom = max_d; } } } else { g_warning ("Unknown type for framerate"); *min_num = 0; *min_denom = 1; *max_num = G_MAXINT; *max_denom = 1; } }
/* receive spectral data from element message */ static gboolean message_handler (GstBus * bus, GstMessage * message, gpointer data) { if (message->type == GST_MESSAGE_ELEMENT) { const GstStructure *s = gst_message_get_structure (message); const gchar *name = gst_structure_get_name (s); GstClockTime endtime; if (strcmp (name, "spectrum") == 0) { const GValue *magnitudes; const GValue *phases; const GValue *mag, *phase; gdouble freq; guint i; if (!gst_structure_get_clock_time (s, "endtime", &endtime)) endtime = GST_CLOCK_TIME_NONE; // g_print ("New spectrum message, endtime %" GST_TIME_FORMAT "\n", // GST_TIME_ARGS (endtime)); magnitudes = gst_structure_get_value (s, "magnitude"); phases = gst_structure_get_value (s, "phase"); for (i = 0; i < spect_bands; ++i) { freq = (gdouble) ((AUDIOFREQ / 2) * i + AUDIOFREQ / 4) / spect_bands; mag = gst_value_list_get_value (magnitudes, i); phase = gst_value_list_get_value (phases, i); if (mag != NULL && phase != NULL) { g_print ("%g %f\n", freq, g_value_get_float (mag)); } } //system(" perl rtgnuplotter.pl"); } } return TRUE; }
/* receive spectral data from element message */ gboolean AudioGrabber::message_handler (GstBus * bus, GstMessage * message, gpointer data) { if (message->type == GST_MESSAGE_ELEMENT) { const GstStructure *s = gst_message_get_structure (message); const gchar *name = gst_structure_get_name (s); GstClockTime endtime; if (strcmp (name, "spectrum") == 0) { const GValue *magnitudes; const GValue *phases; const GValue *mag, *phase; gdouble freq; int i; if (!gst_structure_get_clock_time (s, "endtime", &endtime)) endtime = GST_CLOCK_TIME_NONE; //g_print ("New spectrum message, endtime %" GST_TIME_FORMAT "\n", // GST_TIME_ARGS (endtime)); magnitudes = gst_structure_get_value (s, "magnitude"); phases = gst_structure_get_value (s, "phase"); for (i = 0; i < 20; ++i) { // TODO 20 = _num_bands freq = (gdouble) ((8000 / 2) * i + 8000 / 4) / 20; // TODO 8000=_freq 8000=_freq 20=_num_bands mag = gst_value_list_get_value (magnitudes, i); phase = gst_value_list_get_value (phases, i); if (mag != NULL && phase != NULL && g_value_get_float (mag) >-50 && freq>16) { g_print ("band %d (freq %g): magnitude %f dB phase %f\n", i, freq, g_value_get_float (mag), g_value_get_float (phase)); g_print ("\n"); } } } } return TRUE; }
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); }
EXPORT_C #endif void gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src) { GString *str; gint i, count; count = gst_value_list_get_size (src); str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0))); for (i = 1; i < count; i++) { /* seperator between two string */ str = g_string_append (str, _(", ")); str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1))); } g_value_init (dest, G_TYPE_STRING); g_value_set_string_take_ownership (dest, str->str); g_string_free (str, FALSE); }
static VALUE value_list_gvalue2rvalue(const GValue *value) { guint i, len; VALUE result; len = gst_value_list_get_size(value); result = rb_ary_new2(len); for (i = 0; i < len; i++) { rb_ary_push(result, GVAL2RVAL(gst_value_list_get_value(value, i))); } return result; }
static void check_pad_template (GstPadTemplate * tmpl) { const GValue *list_val, *fmt_val; GstStructure *s; gboolean *formats_supported; GstCaps *caps; guint i, num_formats; num_formats = get_num_formats (); formats_supported = g_new0 (gboolean, num_formats); caps = gst_pad_template_get_caps (tmpl); /* If this fails, we need to update this unit test */ fail_unless_equals_int (gst_caps_get_size (caps), 1); s = gst_caps_get_structure (caps, 0); fail_unless (gst_structure_has_name (s, "video/x-raw")); list_val = gst_structure_get_value (s, "format"); fail_unless (list_val != NULL); /* If this fails, we need to update this unit test */ fail_unless (GST_VALUE_HOLDS_LIST (list_val)); for (i = 0; i < gst_value_list_get_size (list_val); ++i) { GstVideoFormat fmt; const gchar *fmt_str; fmt_val = gst_value_list_get_value (list_val, i); fail_unless (G_VALUE_HOLDS_STRING (fmt_val)); fmt_str = g_value_get_string (fmt_val); GST_LOG ("format string: '%s'", fmt_str); fmt = gst_video_format_from_string (fmt_str); fail_unless (fmt != GST_VIDEO_FORMAT_UNKNOWN); formats_supported[(guint) fmt] = TRUE; } gst_caps_unref (caps); for (i = 2; i < num_formats; ++i) { if (!formats_supported[i]) { g_error ("videoconvert doesn't support format '%s'", gst_video_format_to_string ((GstVideoFormat) i)); } } g_free (formats_supported); }
/* 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); } } }
static gdouble gst_msg_db_to_percent(GstMessage *msg, gchar *value_name) { const GValue *list; const GValue *value; gdouble value_db; gdouble percent; list = gst_structure_get_value( gst_message_get_structure(msg), value_name); value = gst_value_list_get_value(list, 0); value_db = g_value_get_double(value); percent = pow(10, value_db / 20); return (percent > 1.0) ? 1.0 : percent; }
static void get_supported_framerates (ofGstVideoFormat &video_format, GstStructure &structure) { const GValue *framerates; ofGstFramerate framerate; framerates = gst_structure_get_value (&structure, "framerate"); if (GST_VALUE_HOLDS_FRACTION (framerates)){ framerate.numerator = gst_value_get_fraction_numerator (framerates); framerate.denominator = gst_value_get_fraction_denominator (framerates); video_format.framerates.push_back(framerate); ofLog(OF_LOG_NOTICE,"%d/%d ", framerate.numerator, framerate.denominator); }else if (GST_VALUE_HOLDS_LIST (framerates)){ int num_framerates = gst_value_list_get_size (framerates); for (int i = 0; i < num_framerates; i++){ const GValue *value = gst_value_list_get_value (framerates, i); framerate.numerator = gst_value_get_fraction_numerator (value); framerate.denominator = gst_value_get_fraction_denominator (value); video_format.framerates.push_back(framerate); ofLog(OF_LOG_NOTICE,"%d/%d ", framerate.numerator, framerate.denominator); } }else if (GST_VALUE_HOLDS_FRACTION_RANGE (framerates)){ int numerator_min, denominator_min, numerator_max, denominator_max; const GValue *fraction_range_min; const GValue *fraction_range_max; fraction_range_min = gst_value_get_fraction_range_min (framerates); numerator_min = gst_value_get_fraction_numerator (fraction_range_min); denominator_min = gst_value_get_fraction_denominator (fraction_range_min); fraction_range_max = gst_value_get_fraction_range_max (framerates); numerator_max = gst_value_get_fraction_numerator (fraction_range_max); denominator_max = gst_value_get_fraction_denominator (fraction_range_max); ofLog(OF_LOG_NOTICE,"from %d/%d to %d/%d", numerator_min, denominator_max, numerator_max, denominator_min); for (int i = numerator_min; i <= numerator_max; i++){ for (int j = denominator_min; j <= denominator_max; j++){ framerate.numerator = i; framerate.denominator = j; video_format.framerates.push_back(framerate); } } }else{ ofLog (OF_LOG_WARNING,"unknown GValue type %s for framerates", G_VALUE_TYPE_NAME (framerates)); } }
static void dvb_base_bin_pat_info_cb (DvbBaseBin * dvbbasebin, const GstStructure * pat_info) { DvbBaseBinProgram *program; DvbBaseBinStream *stream; const GValue *value; GstStructure *program_info; guint program_number; guint pid; guint old_pmt_pid; gint i; gboolean rebuild_filter = FALSE; const GValue *programs; programs = gst_structure_get_value (pat_info, "programs"); for (i = 0; i < gst_value_list_get_size (programs); ++i) { value = gst_value_list_get_value (programs, i); program_info = g_value_get_boxed (value); gst_structure_get_uint (program_info, "program-number", &program_number); gst_structure_get_uint (program_info, "pid", &pid); program = dvb_base_bin_get_program (dvbbasebin, program_number); if (program == NULL) program = dvb_base_bin_add_program (dvbbasebin, program_number); old_pmt_pid = program->pmt_pid; program->pmt_pid = pid; if (program->selected) { /* PAT update */ if (old_pmt_pid != G_MAXUINT16 && old_pmt_pid != program->pmt_pid) dvb_base_bin_get_stream (dvbbasebin, old_pmt_pid)->usecount -= 1; stream = dvb_base_bin_get_stream (dvbbasebin, program->pmt_pid); if (stream == NULL) stream = dvb_base_bin_add_stream (dvbbasebin, program->pmt_pid); stream->usecount += 1; rebuild_filter = TRUE; } } if (rebuild_filter) dvb_base_bin_rebuild_filter (dvbbasebin); }
/* receive spectral data from element message */ static gboolean message_handler (GstBus * bus, GstMessage * message, gpointer data) { if (message->type == GST_MESSAGE_ELEMENT) { const GstStructure *s = gst_message_get_structure (message); const gchar *name = gst_structure_get_name (s); if (strcmp (name, "spectrum") == 0) { GstElement *spectrum = GST_ELEMENT (GST_MESSAGE_SRC (message)); GstClockTime timestamp, duration; GstClockTime waittime = GST_CLOCK_TIME_NONE; if (gst_structure_get_clock_time (s, "running-time", ×tamp) && gst_structure_get_clock_time (s, "duration", &duration)) { /* wait for middle of buffer */ waittime = timestamp + duration / 2; } else if (gst_structure_get_clock_time (s, "endtime", ×tamp)) { waittime = timestamp; } if (GST_CLOCK_TIME_IS_VALID (waittime)) { GstClockID clock_id; GstClockTime basetime = gst_element_get_base_time (spectrum); gfloat *spect = g_new (gfloat, spect_bands); const GValue *list; const GValue *value; guint i; list = gst_structure_get_value (s, "magnitude"); for (i = 0; i < spect_bands; ++i) { value = gst_value_list_get_value (list, i); spect[i] = height_scale * g_value_get_float (value); } clock_id = gst_clock_new_single_shot_id (sync_clock, waittime + basetime); gst_clock_id_wait_async (clock_id, delayed_spectrum_update, (gpointer) spect); gst_clock_id_unref (clock_id); } } } return TRUE; }
static PyObject * gi_gst_list_from_value (const GValue * value) { PyObject *list, *value_list_type, *value_list; gint i; list = PyList_New (gst_value_list_get_size (value)); for (i = 0; i < gst_value_list_get_size (value); i++) { const GValue *v = gst_value_list_get_value (value, i); PyList_SET_ITEM (list, i, pyg_value_as_pyobject (v, TRUE)); } value_list_type = gi_gst_get_type ("ValueList"); value_list = PyObject_CallFunction (value_list_type, "N", list); Py_DECREF (value_list_type); return value_list; }
/** * gst_query_parse_formats_nth: * @query: a #GstQuery * @nth: the nth format to retrieve. * @format: a pointer to store the nth format * * Parse the format query and retrieve the @nth format from it into * @format. If the list contains less elements than @nth, @format will be * set to GST_FORMAT_UNDEFINED. * * Since: 0.10.4 */ void gst_query_parse_formats_nth (GstQuery * query, guint nth, GstFormat * format) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS); if (format) { const GValue *list; structure = gst_query_get_structure (query); list = gst_structure_get_value (structure, "formats"); if (list == NULL) { *format = GST_FORMAT_UNDEFINED; } else { if (nth < gst_value_list_get_size (list)) { *format = g_value_get_enum (gst_value_list_get_value (list, nth)); } else *format = GST_FORMAT_UNDEFINED; } } }
static void lgm_device_parse_structure (GstStructure * s, GHashTable * table) { gint width, height; const GValue *val; gchar *struct_str; struct_str = gst_structure_to_string (s); GST_DEBUG ("Parsing structure: %s\n", struct_str); g_free (struct_str); width = lgm_device_fixate_int_value (gst_structure_get_value (s, "width")); height = lgm_device_fixate_int_value (gst_structure_get_value (s, "height")); val = gst_structure_get_value (s, "framerate"); if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION) { lgm_device_add_format_from_fps_val (table, width, height, val); } else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE) { /* For sources returning template caps or ranges set framerate to 0/0 */ lgm_device_add_format (table, width, height, 0, 0); } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) { guint n, len; len = gst_value_array_get_size (val); for (n = 0; n < len; n++) { const GValue *kid = gst_value_array_get_value (val, n); lgm_device_add_format_from_fps_val (table, width, height, kid); } } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) { guint n, len; len = gst_value_list_get_size (val); for (n = 0; n < len; n++) { const GValue *kid = gst_value_list_get_value (val, n); lgm_device_add_format_from_fps_val (table, width, height, kid); } } }
/* 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); }
static int lgm_device_fixate_int_value (const GValue * val) { int ret; if (G_VALUE_TYPE (val) == GST_TYPE_INT_RANGE) { ret = gst_value_get_int_range_min (val); } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) { const GValue *kid = gst_value_array_get_value (val, 0); ret = g_value_get_int (kid); } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) { const GValue *kid = gst_value_list_get_value (val, 0); ret = g_value_get_int (kid); } else { ret = g_value_get_int (val); } /* For sources returning template caps set width and height to 0 */ if (ret == 1) { ret = 0; } return ret; }
/* receive spectral data from element message */ gboolean message_handler (GstBus * bus, GstMessage * message, gpointer data) { if (message->type == GST_MESSAGE_ELEMENT) { const GstStructure *s = gst_message_get_structure (message); const gchar *name = gst_structure_get_name (s); if (strcmp (name, "spectrum") == 0) { gfloat *spect = g_new (gfloat, spect_bands); const GValue *list; const GValue *value; guint i; list = gst_structure_get_value (s, "magnitude"); for (i = 0; i < spect_bands; ++i) { value = gst_value_list_get_value (list, i); spect[i] = height_scale * g_value_get_float (value); } draw_spectrum (spect); g_free (spect); } } return TRUE; }
/* * Selects one mode from the ones on the list */ const gchar *gst_sbc_get_mode_from_list(const GValue *list, gint channels) { unsigned int i; const GValue *value; const gchar *aux; gboolean joint, stereo, dual, mono; guint size = gst_value_list_get_size(list); joint = stereo = dual = mono = FALSE; for (i = 0; i < size; i++) { value = gst_value_list_get_value(list, i); aux = g_value_get_string(value); if (strcmp("joint", aux) == 0) joint = TRUE; else if (strcmp("stereo", aux) == 0) stereo = TRUE; else if (strcmp("dual", aux) == 0) dual = TRUE; else if (strcmp("mono", aux) == 0) mono = TRUE; } if (channels == 1 && mono) return "mono"; else if (channels == 2) { if (joint) return "joint"; else if (stereo) return "stereo"; else if (dual) return "dual"; } return NULL; }