Exemplo n.º 1
0
/*
 * Method: get_assoc_entry(id, method, flags, format, value) { ... }
 * id: the ID of the index writer.
 * method: the lookup method to use (see Gst::Index::LookupMethod).
 * flags: flags for the entry (see Gst::Index::AssocFlags).
 * format: a Gst::Format object.
 * value: the value to find.
 * 
 * Finds the given format/value in the index.  If a block is given, it will be
 * called as a compare function, passing references to 2 Gst::IndexEntry objects,
 * and waiting for a boolean as the return value.
 *
 * Returns: the entry associated with the value (as a Gst::IndexEntry object), or nil 
 * if the value is not found.
 */
static VALUE
rb_gst_index_get_assoc_entry (VALUE self, VALUE id, VALUE method, VALUE flags,
                              VALUE format, VALUE value)
{
    GstIndexEntry *index_entry;

    if (rb_block_given_p () == Qfalse)
        index_entry =
            gst_index_get_assoc_entry (RGST_INDEX (self), FIX2INT (id),
                                       RVAL2GENUM (method,
                                                   GST_TYPE_INDEX_LOOKUP_METHOD),
                                       RVAL2GFLAGS (flags,
                                                    GST_TYPE_ASSOC_FLAGS),
                                       *RGST_FORMAT (format), NUM2ULL (value));
    else
        index_entry =
            gst_index_get_assoc_entry_full (RGST_INDEX (self), FIX2INT (id),
                                            RVAL2GENUM (method,
                                                        GST_TYPE_INDEX_LOOKUP_METHOD),
                                            RVAL2GFLAGS (flags,
                                                         GST_TYPE_ASSOC_FLAGS),
                                            *RGST_FORMAT (format),
                                            NUM2ULL (value), __compare,
                                            (gpointer) rb_block_proc ());

    return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
        : Qnil;
}
Exemplo n.º 2
0
/*
 * Method: add(id, *args)
 * id: the ID of the index writer.
 * args: additional parameters, see below.
 *
 * Adds an entry into the index.  The type of the entry depends of
 * the number and kind of additional parameters.
 *
 *	* For an ID type, args must be a String.
 *	* For a FORMAT type, args must be a Gst::Format.
 *	* For an ASSOCIATION type, args must contains an association flag (see Gst::Index::AssocFlags), a Gst::Format and a value for the format.
 *	* For an OBJECT type, well you must wait, because it is not yet implemented.
 *
 * Returns: a reference to the newly allocated entry in the index, as a Gst::EntryIndex object.
 */
static VALUE
rb_gst_index_add (int argc, VALUE * argv, VALUE self)
{
    GstIndexEntry *index_entry;
    VALUE id;

    if (argc == 2) {
        VALUE var;

        rb_scan_args (argc, argv, "2", &id, &var);

        index_entry = CLASS2GTYPE (CLASS_OF (var)) == GST_TYPE_FORMAT2
            ? gst_index_add_format (RGST_INDEX (self), FIX2INT (id),
                                    *RGST_FORMAT (var))
            : gst_index_add_id (RGST_INDEX (self), FIX2INT (id),
                                RVAL2CSTR (var));

    } else {
        VALUE flags, format, value;

        rb_scan_args (argc, argv, "4", &id, &flags, &format, &value);

        index_entry =
            gst_index_add_association (RGST_INDEX (self), FIX2INT (id),
                                       RVAL2GFLAGS (flags,
                                                    GST_TYPE_ASSOC_FLAGS),
                                       *RGST_FORMAT (format), NUM2ULL (value));
    }

    return index_entry != NULL ? RGST_INDEX_ENTRY_NEW (index_entry)
        : Qnil;
}
Exemplo n.º 3
0
/*
 * 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);
}
Exemplo n.º 4
0
/* Method: type_id
 * Returns: the type id of this format (see Gst::Format::Type).
 */
static VALUE
rg_type_id (VALUE self)
{
    GstFormat *format = RGST_FORMAT (self);
    return GENUM2RVAL (*format, GST_TYPE_FORMAT);
}
Exemplo n.º 5
0
/* 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);
}
Exemplo n.º 6
0
/* 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);
}