Beispiel #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;
}
Beispiel #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;
}
Beispiel #3
0
static VALUE
rb_gst_index_set_resolver (VALUE self)
{
    gst_index_set_resolver (RGST_INDEX (self), __resolver,
                            (gpointer) rb_block_proc ());
    return self;
}
Beispiel #4
0
/* 
 * Method: set_certainty(certainty)
 * certainty: the certainty to set (see Gst::Index::Certainty).
 *
 * Sets the certainty of the index.
 *
 * Returns: self.
 */
static VALUE
rb_gst_index_set_certainty (VALUE self, VALUE certainty)
{
    gst_index_set_certainty (RGST_INDEX (self),
                             RVAL2GENUM (certainty, GST_TYPE_INDEX_CERTAINTY));
    return self;
}
/*
 * Method: set_index(index)
 * index: the index to set, as a Gst::Index.
 * 
 * Sets the specified index on the element.
 *
 * Returns: self. 
 */
static VALUE
rg_set_index(VALUE self, VALUE index)
{
    gst_element_set_index(SELF(self), RGST_INDEX(index));
    return self;
}
Beispiel #6
0
/*
 * Method: new_group
 *
 * Creates a new group for the given index.  It will be set as the current
 * group.
 *
 * Returns: the ID of the newly created group.
 */
static VALUE
rb_gst_index_new_group (VALUE self)
{
    return INT2FIX (gst_index_new_group (RGST_INDEX (self)));
}
Beispiel #7
0
/*
 * Method: commit(id)
 * id: the writer that committed the index.
 *
 * Tells the index that the writer with the given ID is done with 
 * this index and is not going to write any more entries to it.
 *
 * Returns: self.
 */
static VALUE
rb_gst_index_commit (VALUE self, VALUE id)
{
    gst_index_commit (RGST_INDEX (self), FIX2INT (id));
    return self;
}
Beispiel #8
0
/* Method: writable?
 * Returns: whether the index can be written.
 */
static VALUE
rb_gst_index_is_writable (VALUE self)
{
    return CBOOL2RVAL (GST_INDEX_IS_WRITABLE (RGST_INDEX (self)));
}
Beispiel #9
0
/* Method: readable?
 * Returns: whether the index can be read.
 */
static VALUE
rb_gst_index_is_readable (VALUE self)
{
    return CBOOL2RVAL (GST_INDEX_IS_READABLE (RGST_INDEX (self)));
}
Beispiel #10
0
/* Method: certainty
 * Returns: the certainty of the index (see Gst::Index::Certainty).
 */
static VALUE
rb_gst_index_get_certainty (VALUE self)
{
    return GENUM2RVAL (gst_index_get_certainty (RGST_INDEX (self)),
                       GST_TYPE_INDEX_CERTAINTY);
}
Beispiel #11
0
/*
 * Method: set_group(group)
 * group: the number of the group to set.
 *
 * Sets the current group number to the given argument.
 *
 * Returns: true if the operation succeeded, false if the group did not exist.
 */
static VALUE
rb_gst_index_set_group (VALUE self, VALUE group)
{
    return
        CBOOL2RVAL (gst_index_set_group (RGST_INDEX (self), FIX2INT (group)));
}