/* * Method: data * * Gets the internal data stored in the entry. The data depends of the type * of the entry: * * Gst::IndexEntry::ID: the description of the ID, as a String. * * Gst::IndexEntry::ASSOCIATION: an Array that contains the number of associations, a Gst::Format, the value of the format and the association flags (see Gst::Index::AssocFlags). * * Gst::IndexEntry::FORMAT: an Array that contains a Gst::Format and its value. * * Gst::IndexEntry::OBJECt: not yet implemented. * * Returns: the internal data of the entry. */ static VALUE rg_data (VALUE self) { GstIndexEntry *entry; VALUE data; entry = RGST_INDEX_ENTRY (self); switch (entry->type) { case GST_INDEX_ENTRY_ID: data = CSTR2RVAL (entry->data.id.description); break; case GST_INDEX_ENTRY_ASSOCIATION: data = rb_ary_new (); rb_ary_push (data, INT2FIX (entry->data.assoc.nassocs)); rb_ary_push (data, RGST_FORMAT_NEW (entry->data.assoc.assocs->format)); rb_ary_push (data, ULL2NUM (entry->data.assoc.assocs->value)); rb_ary_push (data, GFLAGS2RVAL (entry->data.assoc.flags, GST_TYPE_ASSOC_FLAGS)); break; case GST_INDEX_ENTRY_FORMAT: data = rb_ary_new (); rb_ary_push (data, RGST_FORMAT_NEW (entry->data.format.format)); rb_ary_push (data, CSTR2RVAL (entry->data.format.key)); break; case GST_INDEX_ENTRY_OBJECT: /* TODO */ default: data = Qnil; } return data; }
/* * Class method: find(nick) * nick: the nick of an existing format. * * Returns: a reference to the Gst::Format object registered with the * given nick, or nil if this query was not registered. */ static VALUE rg_s_find (VALUE self, VALUE nick) { GstFormat format = gst_format_get_by_nick (RVAL2CSTR (nick)); return format != GST_FORMAT_UNDEFINED ? RGST_FORMAT_NEW (&format) : Qnil; }
/* * Class method: each { |format| ... } * * Calls the block for each registered format, passing a reference * to the Gst::Format object as parameter. * * Returns: always nil. */ static VALUE rg_s_each (VALUE self) { GstIterator *iter; gpointer value; iter = gst_format_iterate_definitions(); while (gst_iterator_next(iter, &value) == GST_ITERATOR_OK) { GstFormatDefinition *def = (GstFormatDefinition *)value; rb_yield(RGST_FORMAT_NEW(&(def->value))); } gst_iterator_free(iter); return Qnil; }