EXPORT_C #endif GstIndexEntry * gst_index_add_format (GstIndex * index, gint id, GstFormat format) { GstIndexEntry *entry; const GstFormatDefinition *def; g_return_val_if_fail (GST_IS_INDEX (index), NULL); g_return_val_if_fail (format != 0, NULL); if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; entry = g_new0 (GstIndexEntry, 1); entry->type = GST_INDEX_ENTRY_FORMAT; entry->id = id; entry->data.format.format = format; def = gst_format_get_details (format); entry->data.format.key = def->nick; gst_index_add_entry (index, entry); return entry; }
static void _file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers) { const gint bufsize = 16; gchar buf[16]; xmlNodePtr writer; xmlNodePtr formats; gint xx; if (!ii->array) { GST_INFO ("Index for %s is empty", ii->id_desc); return; } writer = xmlNewChild (writers, NULL, (xmlChar *) "writer", NULL); xmlSetProp (writer, (xmlChar *) "id", (xmlChar *) ii->id_desc); g_snprintf (buf, bufsize, "%d", ii->array->len); xmlSetProp (writer, (xmlChar *) "entries", (xmlChar *) buf); g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ xmlSetProp (writer, (xmlChar *) "datafile", (xmlChar *) buf); formats = xmlNewChild (writer, NULL, (xmlChar *) "formats", NULL); g_snprintf (buf, bufsize, "%d", ii->nformats); xmlSetProp (formats, (xmlChar *) "count", (xmlChar *) buf); for (xx = 0; xx < ii->nformats; xx++) { xmlNodePtr format = xmlNewChild (formats, NULL, (xmlChar *) "format", NULL); const GstFormatDefinition *def = gst_format_get_details (ii->format[xx]); xmlSetProp (format, (xmlChar *) "nick", (xmlChar *) def->nick); } }
/* * Method: ==(format) * format: a Gst::Format. * * Checks if two Gst::Format objects are registered under the * same nick. * * Returns: true on success, false on failure. */ static VALUE rg_operator_is_equal (VALUE self, VALUE other_format) { GstFormat *f1, *f2; const gchar *n1, *n2; if (NIL_P (other_format)) return Qfalse; f1 = RGST_FORMAT (self); f2 = RGST_FORMAT (other_format); n1 = gst_format_get_details (*f1)->nick; n2 = gst_format_get_details (*f2)->nick; return CBOOL2RVAL (strcmp (n1, n2) == 0); }
/** * gst_format_get_name: * @format: a #GstFormat * * Get a printable name for the given format. Do not modify or free. * * Returns: (nullable): a reference to the static name of the format * or %NULL if the format is unknown. */ const gchar * gst_format_get_name (GstFormat format) { const GstFormatDefinition *def; const gchar *result; if ((def = gst_format_get_details (format)) != NULL) result = def->nick; else result = NULL; return result; }
/** * gst_format_to_quark: * @format: a #GstFormat * * Get the unique quark for the given format. * * Returns: the quark associated with the format or 0 if the format * is unknown. */ GQuark gst_format_to_quark (GstFormat format) { const GstFormatDefinition *def; GQuark result; if ((def = gst_format_get_details (format)) != NULL) result = def->quark; else result = 0; return result; }
static void print_formats (const GstFormat * formats, gint pfx) { while (formats && *formats) { const GstFormatDefinition *definition; definition = gst_format_get_details (*formats); if (definition) PUT_STRING (pfx, "<format id=\"%d\" nick=\"%s\">%s</format>", *formats, definition->nick, definition->description); else PUT_STRING (pfx, "<format id=\"%d\">unknown</format>", *formats); formats++; } }
static void print_formats (const GstFormat * formats) { while (formats && *formats) { const GstFormatDefinition *definition; definition = gst_format_get_details (*formats); if (definition) n_print ("\t\t(%d):\t%s (%s)\n", *formats, definition->nick, definition->description); else n_print ("\t\t(%d):\tUnknown format\n", *formats); formats++; } }
/* Method: description * Returns: a longer description of the format. */ static VALUE rg_description (VALUE self) { GstFormat *format = RGST_FORMAT (self); return CSTR2RVAL (gst_format_get_details (*format)->description); }
/* Method: nick * Returns: the short nick of the format. */ static VALUE rg_nick (VALUE self) { GstFormat *format = RGST_FORMAT (self); return CSTR2RVAL (gst_format_get_details (*format)->nick); }
static gboolean gst_progress_report_do_query (GstProgressReport * filter, GstFormat format, gint hh, gint mm, gint ss, GstBuffer * buf) { const gchar *format_name = NULL; GstPad *sink_pad; gint64 cur, total; sink_pad = GST_BASE_TRANSFORM (filter)->sinkpad; GST_LOG_OBJECT (filter, "querying using format %d (%s)", format, gst_format_get_name (format)); if (filter->do_query || !buf) { GST_LOG_OBJECT (filter, "using upstream query"); if (!gst_pad_peer_query_position (sink_pad, format, &cur) || !gst_pad_peer_query_duration (sink_pad, format, &total)) { return FALSE; } } else { GstBaseTransform *base = GST_BASE_TRANSFORM (filter); GST_LOG_OBJECT (filter, "using buffer metadata"); if (format == GST_FORMAT_TIME && base->segment.format == GST_FORMAT_TIME) { cur = gst_segment_to_stream_time (&base->segment, format, GST_BUFFER_TIMESTAMP (buf)); total = base->segment.duration; } else { return FALSE; } } switch (format) { case GST_FORMAT_BYTES: format_name = "bytes"; break; case GST_FORMAT_BUFFERS: format_name = "buffers"; break; case GST_FORMAT_PERCENT: format_name = "percent"; break; case GST_FORMAT_TIME: format_name = "seconds"; cur /= GST_SECOND; total /= GST_SECOND; break; case GST_FORMAT_DEFAULT:{ GstCaps *caps; format_name = "bogounits"; caps = gst_pad_get_current_caps (GST_BASE_TRANSFORM (filter)->sinkpad); if (caps) { if (gst_caps_is_fixed (caps) && !gst_caps_is_any (caps)) { GstStructure *s = gst_caps_get_structure (caps, 0); const gchar *mime_type = gst_structure_get_name (s); if (g_str_has_prefix (mime_type, "video/") || g_str_has_prefix (mime_type, "image/")) { format_name = "frames"; } else if (g_str_has_prefix (mime_type, "audio/")) { format_name = "samples"; } } gst_caps_unref (caps); } break; } default:{ const GstFormatDefinition *details; details = gst_format_get_details (format); if (details) { format_name = details->nick; } else { format_name = "unknown"; } break; } } if (!filter->silent) { if (total > 0) { g_print ("%s (%02d:%02d:%02d): %" G_GINT64_FORMAT " / %" G_GINT64_FORMAT " %s (%4.1f %%)\n", GST_OBJECT_NAME (filter), hh, mm, ss, cur, total, format_name, (gdouble) cur / total * 100.0); } else { g_print ("%s (%02d:%02d:%02d): %" G_GINT64_FORMAT " %s\n", GST_OBJECT_NAME (filter), hh, mm, ss, cur, format_name); } } gst_progress_report_post_progress (filter, format, cur, total); return TRUE; }