2008-01-01 13:22:21 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
|
|
|
/* gst-python
|
|
|
|
* Copyright (C) 2008 <edward.hervey@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
headers
|
2008-01-13 17:24:42 +00:00
|
|
|
|
2008-01-01 13:22:21 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2008-06-26 14:57:29 +00:00
|
|
|
#define NO_IMPORT_PYGOBJECT
|
2010-10-18 09:59:03 +00:00
|
|
|
#include "pygst.h"
|
2008-01-01 13:22:21 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#include <gst/pbutils/pbutils.h>
|
2008-01-11 16:30:45 +00:00
|
|
|
#include "pygstminiobject.h"
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
|
|
|
|
#define GST_CAT_DEFAULT pygst_debug
|
2008-01-01 13:22:21 +00:00
|
|
|
|
2008-01-15 11:41:51 +00:00
|
|
|
/* Boonky define that allows for backwards compatibility with Python 2.4 */
|
|
|
|
#if PY_VERSION_HEX < 0x02050000
|
|
|
|
#define Py_ssize_t int
|
|
|
|
#endif
|
|
|
|
|
2008-01-13 17:24:42 +00:00
|
|
|
static void
|
|
|
|
install_plugins_result_handler(GstInstallPluginsReturn result, gpointer user_data)
|
|
|
|
{
|
|
|
|
PyGILState_STATE state;
|
|
|
|
PyObject *callback, *args;
|
|
|
|
PyObject *py_user_data;
|
|
|
|
PyObject *py_result;
|
|
|
|
PyObject *ret;
|
|
|
|
gint i, len;
|
|
|
|
|
|
|
|
if (user_data == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
state = pyg_gil_state_ensure();
|
|
|
|
|
|
|
|
py_user_data = (PyObject*) user_data;
|
|
|
|
py_result = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, result);
|
|
|
|
|
|
|
|
callback = PyTuple_GetItem(py_user_data, 0);
|
|
|
|
args = Py_BuildValue("(N)", py_result);
|
|
|
|
|
|
|
|
len = PyTuple_Size(py_user_data);
|
|
|
|
for (i = 1; i < len; ++i) {
|
|
|
|
PyObject *tuple = args;
|
|
|
|
args = PySequence_Concat(tuple, PyTuple_GetItem(py_user_data, i));
|
|
|
|
Py_DECREF(tuple);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = PyObject_CallObject(callback, args);
|
|
|
|
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
PyErr_Print();
|
|
|
|
|
|
|
|
Py_DECREF(args);
|
|
|
|
pyg_gil_state_release(state);
|
|
|
|
|
|
|
|
}
|
2008-01-01 13:22:21 +00:00
|
|
|
%%
|
|
|
|
modulename gst.pbutils
|
|
|
|
%%
|
|
|
|
import gobject.GObject as PyGObject_Type
|
|
|
|
import gst.Object as PyGstObject_Type
|
|
|
|
import gst.Structure as PyGstStructure_Type
|
|
|
|
import gst.Element as PyGstElement_Type
|
|
|
|
import gst.Message as PyGstMessage_Type
|
2010-10-18 09:59:03 +00:00
|
|
|
import gst.MiniObject as PyGstMiniObject_Type
|
2008-01-01 13:22:21 +00:00
|
|
|
%%
|
|
|
|
include
|
|
|
|
gstversion.override
|
|
|
|
%%
|
|
|
|
ignore-glob
|
|
|
|
_*
|
|
|
|
*init
|
2008-01-11 16:30:45 +00:00
|
|
|
*_free
|
2008-01-01 13:22:21 +00:00
|
|
|
*_get_type
|
|
|
|
%%
|
2008-01-11 16:30:45 +00:00
|
|
|
override gst_install_plugins_sync kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_install_plugins_sync(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "details", "context", NULL };
|
|
|
|
PyObject *py_ctx;
|
|
|
|
GstInstallPluginsContext *ctx;
|
|
|
|
GstInstallPluginsReturn ret;
|
|
|
|
gchar **details;
|
|
|
|
gint len;
|
|
|
|
PyObject *py_ret;
|
|
|
|
PyObject *py_details;
|
|
|
|
Py_ssize_t i;
|
|
|
|
|
2008-01-13 17:24:42 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:install_plugins_sync",
|
2008-01-11 16:30:45 +00:00
|
|
|
kwlist, &py_details, &py_ctx))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!pyg_boxed_check(py_ctx, GST_TYPE_INSTALL_PLUGINS_CONTEXT)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument 2 must be a gst.pbutils.InstallPluginsContext");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = PySequence_Size(py_details);
|
|
|
|
if ((!PySequence_Check(py_details)) || (len < 1)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
details = g_new0(gchar*, len+1);
|
|
|
|
|
|
|
|
/* Check all items in py_details are strings */
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
PyObject *py_str = PySequence_GetItem(py_details, i);
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
if (!PyString_Check(py_str)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
Py_DECREF(py_details);
|
2009-03-05 12:45:07 +00:00
|
|
|
g_strfreev(details);
|
2008-01-11 16:30:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!(str = PyString_AsString(py_str))) {
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
Py_DECREF(py_details);
|
2009-03-05 12:45:07 +00:00
|
|
|
g_strfreev(details);
|
2008-01-11 16:30:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
details[i] = g_strdup(str);
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx = (GstInstallPluginsContext *) pyg_boxed_get(py_ctx, GstInstallPluginsContext);
|
2008-01-13 17:24:42 +00:00
|
|
|
|
|
|
|
pyg_begin_allow_threads;
|
2008-01-11 16:30:45 +00:00
|
|
|
ret = gst_install_plugins_sync(details, ctx);
|
2008-01-13 17:24:42 +00:00
|
|
|
pyg_end_allow_threads;
|
|
|
|
|
|
|
|
g_strfreev(details);
|
|
|
|
|
|
|
|
py_ret = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, ret);
|
|
|
|
return py_ret;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_install_plugins_async args
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_install_plugins_async(PyGObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
PyObject *py_ctx, *py_ret, *py_details, *callback, *cbargs, *data;
|
|
|
|
GstInstallPluginsContext *ctx;
|
|
|
|
GstInstallPluginsReturn ret;
|
|
|
|
gchar **details;
|
|
|
|
gint len;
|
|
|
|
Py_ssize_t i;
|
|
|
|
|
|
|
|
if (PyTuple_Size(args) < 3) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "install_plugins_async requires at least 3 arguments");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
py_ctx = PySequence_GetItem(args, 1);
|
|
|
|
|
|
|
|
if (!pyg_boxed_check(py_ctx, GST_TYPE_INSTALL_PLUGINS_CONTEXT)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Argument 2 must be a gst.pbutils.InstallPluginsContext");
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
py_details = PySequence_GetItem(args, 0);
|
|
|
|
if ((!PySequence_Check(py_details)) || (PySequence_Size(py_details) < 1)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = PySequence_Size(py_details);
|
|
|
|
details = g_new0(gchar*, len+1);
|
|
|
|
|
|
|
|
/* Check all items in py_details are strings */
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
PyObject *py_str = PySequence_GetItem(py_details, i);
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
if (!PyString_Check(py_str)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
g_strfreev(details);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!(str = PyString_AsString(py_str))) {
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
g_strfreev(details);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
details[i] = g_strdup(str);
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
callback = PySequence_GetItem(args, 2);
|
|
|
|
if (!PyCallable_Check(callback)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
|
|
|
Py_DECREF(callback);
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
g_strfreev(details);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(cbargs = PySequence_GetSlice(args, 3, PyTuple_Size(args)))) {
|
|
|
|
Py_DECREF(callback);
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
g_strfreev(details);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!(data = Py_BuildValue("(ON)", callback, cbargs))) {
|
|
|
|
Py_DECREF(py_details);
|
|
|
|
Py_DECREF(py_ctx);
|
|
|
|
Py_DECREF(callback);
|
|
|
|
Py_DECREF(cbargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx = (GstInstallPluginsContext *) pyg_boxed_get(py_ctx, GstInstallPluginsContext);
|
|
|
|
pyg_begin_allow_threads;
|
|
|
|
ret = gst_install_plugins_async(details, ctx,
|
|
|
|
(GstInstallPluginsResultFunc) install_plugins_result_handler,
|
|
|
|
data);
|
|
|
|
pyg_end_allow_threads;
|
2008-01-11 16:30:45 +00:00
|
|
|
|
|
|
|
g_strfreev(details);
|
|
|
|
|
|
|
|
py_ret = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, ret);
|
|
|
|
return py_ret;
|
|
|
|
}
|
2010-10-22 11:28:03 +00:00
|
|
|
%%
|
|
|
|
override gst_plugins_base_version noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_plugins_base_version (PyObject *self)
|
|
|
|
{
|
|
|
|
guint major, minor, micro, nano;
|
|
|
|
PyObject *py_tuple;
|
|
|
|
|
|
|
|
gst_plugins_base_version (&major, &minor, µ, &nano);
|
|
|
|
py_tuple = PyTuple_New(4);
|
|
|
|
PyTuple_SetItem(py_tuple, 0, PyInt_FromLong(major));
|
|
|
|
PyTuple_SetItem(py_tuple, 1, PyInt_FromLong(minor));
|
|
|
|
PyTuple_SetItem(py_tuple, 2, PyInt_FromLong(micro));
|
|
|
|
PyTuple_SetItem(py_tuple, 3, PyInt_FromLong(nano));
|
|
|
|
|
|
|
|
return py_tuple;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_info_get_stream_list noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_info_get_stream_list(PyGstMiniObject * self)
|
|
|
|
{
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres;
|
|
|
|
|
|
|
|
res = gst_discoverer_info_get_stream_list(GST_DISCOVERER_INFO (self->obj));
|
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_info_get_streams kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_info_get_streams(PyGstMiniObject * self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "type", NULL };
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres, *py_type;
|
|
|
|
GType ftype;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstDiscovererInfo.get_streams", kwlist, &py_type))
|
|
|
|
return NULL;
|
|
|
|
if ((ftype = pyg_type_from_object(py_type)) == 0)
|
|
|
|
return NULL;
|
|
|
|
res = gst_discoverer_info_get_streams(GST_DISCOVERER_INFO (self->obj), ftype);
|
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_info_get_audio_streams noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_info_get_audio_streams(PyGstMiniObject * self)
|
|
|
|
{
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres;
|
|
|
|
|
|
|
|
res = gst_discoverer_info_get_audio_streams(GST_DISCOVERER_INFO (self->obj));
|
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_info_get_video_streams noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_info_get_video_streams(PyGstMiniObject * self)
|
|
|
|
{
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres;
|
|
|
|
|
|
|
|
res = gst_discoverer_info_get_video_streams(GST_DISCOVERER_INFO (self->obj));
|
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_info_get_container_streams noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_info_get_container_streams(PyGstMiniObject * self)
|
|
|
|
{
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres;
|
|
|
|
|
|
|
|
res = gst_discoverer_info_get_container_streams(GST_DISCOVERER_INFO (self->obj));
|
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_discoverer_container_info_get_streams noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_discoverer_container_info_get_streams(PyGstMiniObject * self)
|
|
|
|
{
|
|
|
|
GList *res, *tmp;
|
|
|
|
PyObject *pyres;
|
|
|
|
|
2010-11-08 18:01:50 +00:00
|
|
|
res = gst_discoverer_container_info_get_streams(GST_DISCOVERER_CONTAINER_INFO (self->obj));
|
2010-10-22 11:28:03 +00:00
|
|
|
|
|
|
|
pyres = PyList_New(0);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
|
|
|
}
|
|
|
|
if (res)
|
|
|
|
gst_discoverer_stream_info_list_free(res);
|
|
|
|
return pyres;
|
|
|
|
}
|