mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
gst/: Proper wrapping of GstController
Original commit message from CVS: * gst/gst.override: * gst/gstlibs.override: Proper wrapping of GstController * examples/Makefile.am: * examples/audio-controller.py: Example to show how to use gst.Controller
This commit is contained in:
parent
6e384e2e97
commit
fbd17dd797
5 changed files with 83 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2005-09-29 Edward Hervey <edward@fluendo.com>
|
||||
|
||||
* gst/gst.override:
|
||||
* gst/gstlibs.override:
|
||||
Proper wrapping of GstController
|
||||
* examples/Makefile.am:
|
||||
* examples/audio-controller.py:
|
||||
Example to show how to use gst.Controller
|
||||
|
||||
2005-09-29 Edward Hervey <edward@fluendo.com>
|
||||
|
||||
* examples/gstfile.py:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
examplesdir = $(pkgdatadir)/examples
|
||||
examples_DATA = \
|
||||
audio-controller.py \
|
||||
bps.py \
|
||||
cp.py \
|
||||
debugslider.py \
|
||||
|
|
36
examples/audio-controller.py
Normal file
36
examples/audio-controller.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# audio-controller.py
|
||||
# (c) 2005 Edward Hervey <edward at fluendo dot com>
|
||||
# Test case for the GstController on sinesrc -> alsasink
|
||||
# Inspired from ensonic's examples/controller/audio-controller.c
|
||||
|
||||
import gst
|
||||
import time
|
||||
|
||||
def main():
|
||||
pipeline = gst.Pipeline("audiocontroller")
|
||||
src = gst.element_factory_make("sinesrc", "src")
|
||||
sink = gst.element_factory_make("alsasink", "sink")
|
||||
pipeline.add_many(src, sink)
|
||||
src.link(sink)
|
||||
|
||||
control = gst.Controller(src, "freq", "volume")
|
||||
control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
|
||||
control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
|
||||
|
||||
control.set("volume", 0, 0.0)
|
||||
control.set("volume", 2 * gst.SECOND, 1.0)
|
||||
control.set("volume", 4 * gst.SECOND, 0.0)
|
||||
control.set("volume", 6 * gst.SECOND, 1.0)
|
||||
|
||||
control.set("freq", 0, 440.0)
|
||||
control.set("freq", 3 * gst.SECOND, 3000.0)
|
||||
control.set("freq", 6 * gst.SECOND, 880.0)
|
||||
|
||||
pipeline.set_state(gst.STATE_PLAYING)
|
||||
|
||||
time.sleep(7)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -274,6 +274,7 @@ init
|
|||
if (!pygst_value_init())
|
||||
return;
|
||||
pygst_miniobject_init();
|
||||
gst_controller_init(NULL, NULL);
|
||||
}
|
||||
%%
|
||||
modulename gst
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* -*- Mode: C; ; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
|
@ -66,3 +66,38 @@ _wrap_gst_controller_set (PyGObject *self, PyObject *args)
|
|||
Py_INCREF (Py_False);
|
||||
return Py_False;
|
||||
}
|
||||
%%
|
||||
override gst_controller_new_list args
|
||||
static int
|
||||
_wrap_gst_controller_new_list(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyGObject *target;
|
||||
gint len;
|
||||
GList *list = NULL;
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "Controller requires at least a target object");
|
||||
return -1;
|
||||
}
|
||||
target = (PyGObject *) PyTuple_GetItem(args, 0);
|
||||
if (len > 1)
|
||||
while (len-- > 1) {
|
||||
PyObject *temp;
|
||||
gchar *str;
|
||||
|
||||
temp = PyTuple_GetItem(args, len);
|
||||
str = PyString_AsString(temp);
|
||||
GST_INFO("prepending %s [%d]", str, len);
|
||||
list = g_list_prepend(list, PyString_AsString(temp));
|
||||
}
|
||||
|
||||
self->obj = (GObject *) gst_controller_new_list(target->obj, list);
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstController object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pygobject_register_wrapper((PyObject *) self);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue