mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gst/: Added FractionRange type
Original commit message from CVS: * gst/pygstvalue.c: (pygst_value_as_pyobject), (pygst_value_init_for_pyobject), (pygst_value_from_pyobject), (pygst_value_init): * gst/__init__.py: Added FractionRange type * gst/gst-types.defs: * gst/gst.defs: * gst/gst.override: API updates
This commit is contained in:
parent
6592099266
commit
96256ac65c
6 changed files with 167 additions and 37 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-11-22 Edward Hervey <edward@fluendo.com>
|
||||
|
||||
* gst/pygstvalue.c: (pygst_value_as_pyobject),
|
||||
(pygst_value_init_for_pyobject), (pygst_value_from_pyobject),
|
||||
(pygst_value_init):
|
||||
* gst/__init__.py:
|
||||
Added FractionRange type
|
||||
* gst/gst-types.defs:
|
||||
* gst/gst.defs:
|
||||
* gst/gst.override:
|
||||
API updates
|
||||
|
||||
2005-11-22 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
* gst/gst.defs:
|
||||
|
|
|
@ -45,7 +45,7 @@ except ImportError:
|
|||
|
||||
class Value:
|
||||
def __init__(self, type):
|
||||
assert type in ('fourcc', 'intrange', 'doublerange', 'fraction')
|
||||
assert type in ('fourcc', 'intrange', 'doublerange', 'fractionrange', 'fraction')
|
||||
self.type = type
|
||||
|
||||
class Fourcc(Value):
|
||||
|
@ -71,6 +71,17 @@ class DoubleRange(Value):
|
|||
def __repr__(self):
|
||||
return '<gst.DoubleRange [%f, %f]>' % (self.low, self.high)
|
||||
|
||||
class FractionRange(Value):
|
||||
def __init__(self, low, high):
|
||||
Value.__init__(self, 'fractionrange')
|
||||
self.low = low
|
||||
self.high = high
|
||||
def __repr__(self):
|
||||
return '<gst.FractionRange [%d/%d, %d/%d]>' % (self.low.num,
|
||||
self.low.denom,
|
||||
self.high.num,
|
||||
self.high.denom)
|
||||
|
||||
class Fraction(Value):
|
||||
def __init__(self, num, denom):
|
||||
Value.__init__(self, 'fraction')
|
||||
|
|
|
@ -407,6 +407,7 @@
|
|||
'("seek" "GST_CORE_ERROR_SEEK")
|
||||
'("caps" "GST_CORE_ERROR_CAPS")
|
||||
'("tag" "GST_CORE_ERROR_TAG")
|
||||
'("missing-plugin" "GST_CORE_ERROR_MISSING_PLUGIN")
|
||||
'("num-errors" "GST_CORE_ERROR_NUM_ERRORS")
|
||||
)
|
||||
)
|
||||
|
|
135
gst/gst.defs
135
gst/gst.defs
|
@ -393,6 +393,15 @@
|
|||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method add_signal_watch_full
|
||||
(of-object "GstBus")
|
||||
(c-name "gst_bus_add_signal_watch_full")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gint" "priority")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method remove_signal_watch
|
||||
(of-object "GstBus")
|
||||
(c-name "gst_bus_remove_signal_watch")
|
||||
|
@ -1753,7 +1762,7 @@
|
|||
(caller-owns-return #t)
|
||||
)
|
||||
|
||||
(define-function event_new_newsegment
|
||||
(define-function event_new_new_segment
|
||||
(c-name "gst_event_new_new_segment")
|
||||
(return-type "GstEvent*")
|
||||
(caller-owns-return #t)
|
||||
|
@ -1767,7 +1776,7 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method parse_newsegment
|
||||
(define-method parse_new_segment
|
||||
(of-object "GstEvent")
|
||||
(c-name "gst_event_parse_new_segment")
|
||||
(return-type "none")
|
||||
|
@ -1799,7 +1808,7 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-function event_new_buffersize
|
||||
(define-function event_new_buffer_size
|
||||
(c-name "gst_event_new_buffer_size")
|
||||
(return-type "GstEvent*")
|
||||
(caller-owns-return #t)
|
||||
|
@ -1811,7 +1820,7 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method parse_buffersize
|
||||
(define-method parse_buffer_size
|
||||
(of-object "GstEvent")
|
||||
(c-name "gst_event_parse_buffer_size")
|
||||
(return-type "none")
|
||||
|
@ -4543,6 +4552,23 @@
|
|||
|
||||
;; From ../gstreamer/gst/gstsegment.h
|
||||
|
||||
(define-function gst_segment_get_type
|
||||
(c-name "gst_segment_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function gst_segment_new
|
||||
(c-name "gst_segment_new")
|
||||
(is-constructor-of "GstSegment")
|
||||
(return-type "GstSegment*")
|
||||
)
|
||||
|
||||
(define-method free
|
||||
(of-object "GstSegment")
|
||||
(c-name "gst_segment_free")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method init
|
||||
(of-object "GstSegment")
|
||||
(c-name "gst_segment_init")
|
||||
|
@ -5026,7 +5052,15 @@
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
(define-method fixate_field_nearest_fraction
|
||||
(of-object "GstStructure")
|
||||
(c-name "gst_structure_fixate_field_nearest_fraction")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-char*" "field_name")
|
||||
'("const-GValue*" "target")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; From ../gstreamer/gst/gstsystemclock.h
|
||||
|
@ -5572,9 +5606,9 @@
|
|||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method merge
|
||||
(define-method merge_tags
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_merge")
|
||||
(c-name "gst_tag_setter_merge_tags")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-GstTagList*" "list")
|
||||
|
@ -5582,9 +5616,9 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method add
|
||||
(define-method add_tags
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_add")
|
||||
(c-name "gst_tag_setter_add_tags")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagMergeMode" "mode")
|
||||
|
@ -5593,9 +5627,9 @@
|
|||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-method add_values
|
||||
(define-method add_tag_values
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_add_values")
|
||||
(c-name "gst_tag_setter_add_tag_values")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagMergeMode" "mode")
|
||||
|
@ -5604,9 +5638,9 @@
|
|||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-method add_valist
|
||||
(define-method add_tag_valist
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_add_valist")
|
||||
(c-name "gst_tag_setter_add_tag_valist")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagMergeMode" "mode")
|
||||
|
@ -5615,9 +5649,9 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method add_valist_values
|
||||
(define-method add_tag_valist_values
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_add_valist_values")
|
||||
(c-name "gst_tag_setter_add_tag_valist_values")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagMergeMode" "mode")
|
||||
|
@ -5626,24 +5660,24 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method get_list
|
||||
(define-method get_tag_list
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_get_list")
|
||||
(c-name "gst_tag_setter_get_tag_list")
|
||||
(return-type "const-GstTagList*")
|
||||
)
|
||||
|
||||
(define-method set_merge_mode
|
||||
(define-method set_tag_merge_mode
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_set_merge_mode")
|
||||
(c-name "gst_tag_setter_set_tag_merge_mode")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagMergeMode" "mode")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_merge_mode
|
||||
(define-method get_tag_merge_mode
|
||||
(of-object "GstTagSetter")
|
||||
(c-name "gst_tag_setter_get_merge_mode")
|
||||
(c-name "gst_tag_setter_get_tag_merge_mode")
|
||||
(return-type "GstTagMergeMode")
|
||||
)
|
||||
|
||||
|
@ -5968,17 +6002,6 @@
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From ../gstreamer/gst/gsturitype.h
|
||||
|
||||
(define-function uri_get_uri_type
|
||||
(c-name "gst_uri_get_uri_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From ../gstreamer/gst/gstutils.h
|
||||
|
||||
(define-function util_set_value_from_string
|
||||
|
@ -6618,6 +6641,54 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-function gst_value_fraction_subtract
|
||||
(c-name "gst_value_fraction_subtract")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GValue*" "dest")
|
||||
'("const-GValue*" "minuend")
|
||||
'("const-GValue*" "subtrahend")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_value_set_fraction_range
|
||||
(c-name "gst_value_set_fraction_range")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GValue*" "value")
|
||||
'("const-GValue*" "start")
|
||||
'("const-GValue*" "end")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_value_set_fraction_range_full
|
||||
(c-name "gst_value_set_fraction_range_full")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GValue*" "value")
|
||||
'("int" "numerator_start")
|
||||
'("int" "denominator_start")
|
||||
'("int" "numerator_end")
|
||||
'("int" "denominator_end")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_value_get_fraction_range_min
|
||||
(c-name "gst_value_get_fraction_range_min")
|
||||
(return-type "const-GValue*")
|
||||
(parameters
|
||||
'("const-GValue*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_value_get_fraction_range_max
|
||||
(c-name "gst_value_get_fraction_range_max")
|
||||
(return-type "const-GValue*")
|
||||
(parameters
|
||||
'("const-GValue*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function value_get_date
|
||||
(c-name "gst_value_get_date")
|
||||
(return-type "const-GDate*")
|
||||
|
|
|
@ -648,13 +648,13 @@ _wrap_gst_xml_parse_memory(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|||
return PyBool_FromLong(ret);
|
||||
}
|
||||
%%
|
||||
override gst_tag_setter_get_list noargs
|
||||
override gst_tag_setter_get_tag_list noargs
|
||||
static PyObject *
|
||||
_wrap_gst_tag_setter_get_list(PyGObject *self)
|
||||
_wrap_gst_tag_setter_get_tag_list(PyGObject *self)
|
||||
{
|
||||
GstTagList *ret;
|
||||
|
||||
ret = (GstTagList*)gst_tag_setter_get_list(GST_TAG_SETTER(self->obj));
|
||||
ret = (GstTagList*)gst_tag_setter_get_tag_list(GST_TAG_SETTER(self->obj));
|
||||
/* pyg_boxed_new handles NULL checking */
|
||||
return pyg_boxed_new(GST_TYPE_TAG_LIST, ret, TRUE, TRUE);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ static PyObject *gstfourcc_class = NULL;
|
|||
static PyObject *gstintrange_class = NULL;
|
||||
static PyObject *gstdoublerange_class = NULL;
|
||||
static PyObject *gstfraction_class = NULL;
|
||||
|
||||
static PyObject *gstfractionrange_class = NULL;
|
||||
|
||||
/**
|
||||
* pygst_value_as_pyobject:
|
||||
|
@ -93,6 +93,16 @@ pygst_value_as_pyobject(const GValue *value, gboolean copy_boxed)
|
|||
gst_value_get_fraction_numerator (value),
|
||||
gst_value_get_fraction_denominator (value)),
|
||||
NULL);
|
||||
} else if (GST_VALUE_HOLDS_FRACTION_RANGE (value)) {
|
||||
const GValue *min, *max;
|
||||
min = gst_value_get_fraction_range_min (value);
|
||||
max = gst_value_get_fraction_range_max (value);
|
||||
ret = PyObject_Call
|
||||
(gstfractionrange_class,
|
||||
Py_BuildValue ("OO",
|
||||
pygst_value_as_pyobject (min, copy_boxed),
|
||||
pygst_value_as_pyobject (max, copy_boxed)),
|
||||
NULL);
|
||||
} else {
|
||||
gchar buf[256];
|
||||
g_snprintf (buf, 256, "unknown type: %s", g_type_name (G_VALUE_TYPE (value)));
|
||||
|
@ -128,6 +138,8 @@ pygst_value_init_for_pyobject (GValue *value, PyObject *obj)
|
|||
t = GST_TYPE_DOUBLE_RANGE;
|
||||
else if (PyObject_IsInstance (obj, gstfraction_class))
|
||||
t = GST_TYPE_FRACTION;
|
||||
else if (PyObject_IsInstance (obj, gstfractionrange_class))
|
||||
t = GST_TYPE_FRACTION_RANGE;
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "Unexpected gst.Value instance");
|
||||
return FALSE;
|
||||
|
@ -219,6 +231,27 @@ pygst_value_from_pyobject (GValue *value, PyObject *obj)
|
|||
denom = PyInt_AsLong (pyval);
|
||||
g_assert (G_MININT <= denom && denom <= G_MAXINT);
|
||||
gst_value_set_fraction (value, (int)num, (int)denom);
|
||||
} else if (PyObject_IsInstance (obj, gstfractionrange_class)) {
|
||||
GValue low = {0, };
|
||||
GValue high = {0, };
|
||||
PyObject *pylow, *pyhigh;
|
||||
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_FRACTION_RANGE);
|
||||
if (!(pylow = PyObject_GetAttrString (obj, "low")))
|
||||
return -1;
|
||||
if (!pygst_value_init_for_pyobject (&low, pylow))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&low, pylow) != 0)
|
||||
return -1;
|
||||
|
||||
if (!(pyhigh = PyObject_GetAttrString (obj, "high")))
|
||||
return -1;
|
||||
if (!pygst_value_init_for_pyobject (&high, pyhigh))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&high, pyhigh) != 0)
|
||||
return -1;
|
||||
|
||||
gst_value_set_fraction_range (value, &low, &high);
|
||||
} else {
|
||||
gchar buf[256];
|
||||
gchar *str = PyString_AsString (PyObject_Repr(obj));
|
||||
|
@ -292,6 +325,8 @@ pygst_value_init(void)
|
|||
NULL_CHECK (gstdoublerange_class);
|
||||
gstfraction_class = (PyObject*)PyDict_GetItemString (dict, "Fraction");
|
||||
NULL_CHECK (gstfraction_class);
|
||||
gstfractionrange_class = (PyObject*)PyDict_GetItemString (dict, "FractionRange");
|
||||
NULL_CHECK (gstfractionrange_class);
|
||||
return TRUE;
|
||||
|
||||
err:
|
||||
|
|
Loading…
Reference in a new issue