Update of /cvsroot/freevo/kaa/xine/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15153
Modified Files:
__init__.py stream.c stream.h xine.c
Log Message:
Implement more of the API; add some default values in frame_output_callback
in case the python function fails; check for return value of False from
callback (assumes it's a WeakCallback whose referance is no longer
available)
Index: stream.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/stream.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** stream.c 19 Jul 2005 02:07:24 -0000 1.4
--- stream.c 19 Jul 2005 05:51:59 -0000 1.5
***************
*** 53,56 ****
--- 53,61 ----
Py_DECREF(tmp);
}
+ if (self->master) {
+ tmp = (PyObject *)self->master;
+ self->master= 0;
+ Py_DECREF(tmp);
+ }
return 0;
}
***************
*** 75,78 ****
--- 80,88 ----
return ret;
}
+ if (self->master) {
+ ret = visit((PyObject *)self->master, arg);
+ if (ret != 0)
+ return ret;
+ }
return 0;
}
***************
*** 116,120 ****
if (self->stream && self->xine_object_owner) {
Py_BEGIN_ALLOW_THREADS
! xine_close(self->stream);
xine_dispose(self->stream);
Py_END_ALLOW_THREADS
--- 126,130 ----
if (self->stream && self->xine_object_owner) {
Py_BEGIN_ALLOW_THREADS
! //xine_close(self->stream);
xine_dispose(self->stream);
Py_END_ALLOW_THREADS
***************
*** 163,166 ****
--- 173,194 ----
}
+ PyObject *
+ Xine_Stream_PyObject_stop(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ Py_BEGIN_ALLOW_THREADS
+ xine_stop(self->stream);
+ Py_END_ALLOW_THREADS
+ return Py_INCREF(Py_None), Py_None;
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_eject(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ int result;
+ Py_BEGIN_ALLOW_THREADS
+ result = xine_eject(self->stream);
+ Py_END_ALLOW_THREADS
+ return PyBool_FromLong(result);
+ }
PyObject *
***************
*** 186,196 ****
}
- // *INDENT-OFF*
PyMethodDef Xine_Stream_PyObject_methods[] = {
! {"open", (PyCFunction) Xine_Stream_PyObject_open, METH_VARARGS |
METH_KEYWORDS},
! {"play", (PyCFunction) Xine_Stream_PyObject_play, METH_VARARGS |
METH_KEYWORDS},
! {"get_source", (PyCFunction) Xine_Stream_PyObject_get_source,
METH_VARARGS | METH_KEYWORDS},
{NULL, NULL}
};
--- 214,347 ----
}
+ PyObject *
+ Xine_Stream_PyObject_slave(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ PyObject *tmp = NULL;
+ Xine_Stream_PyObject *slave;
+ int affection, result;
+
+ if (!PyArg_ParseTuple(args, "O!i", &Xine_Stream_PyObject_Type, &slave,
&affection))
+ return NULL;
+
+ if (slave->master)
+ tmp = slave->master;
+ slave->master = (PyObject *)self;
+ Py_INCREF(self);
+ if (tmp)
+ Py_DECREF(tmp);
+
+ Py_BEGIN_ALLOW_THREADS
+ result = xine_stream_master_slave(self->stream, slave->stream, affection);
+ Py_END_ALLOW_THREADS
+ return PyBool_FromLong(result);
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_set_trick_mode(Xine_Stream_PyObject *self, PyObject
*args, PyObject *kwargs)
+ {
+ int mode, value, result;
+
+ if (!PyArg_ParseTuple(args, "ii", &mode, &value))
+ return NULL;
+
+ result = xine_trick_mode(self->stream, mode, value);
+ return PyBool_FromLong(result);
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_get_current_vpts(Xine_Stream_PyObject *self, PyObject
*args, PyObject *kwargs)
+ {
+ return PyLong_FromLongLong(xine_get_current_vpts(self->stream));
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_get_error(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ return PyLong_FromLongLong(xine_get_error(self->stream));
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_get_status(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ return PyLong_FromLongLong(xine_get_status(self->stream));
+ }
+
+ PyObject *
+ Xine_Stream_PyObject_get_lang(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ int channel = -1, result;
+ char lang[XINE_LANG_MAX+1], *type;
+
+ if (!PyArg_ParseTuple(args, "si", &type, &channel))
+ return NULL;
+
+ if (!strcmp(type, "spu"))
+ result = xine_get_spu_lang(self->stream, channel, &lang[0]);
+ else
+ result = xine_get_audio_lang(self->stream, channel, &lang[0]);
+
+ if (!result) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return PyString_FromString(lang);
+ }
+
+
+ PyObject *
+ Xine_Stream_PyObject_get_pos_length(Xine_Stream_PyObject *self, PyObject
*args, PyObject *kwargs)
+ {
+ int pos_stream, pos_time, length_time, result;
+
+ result = xine_get_pos_length(self->stream, &pos_stream, &pos_time,
&length_time);
+ if (!result)
+ return Py_BuildValue("(sss)", NULL, NULL, NULL);
+
+ return Py_BuildValue("(iii)", pos_stream, pos_time, length_time);
+ }
+
+
+ PyObject *
+ Xine_Stream_PyObject_get_info(Xine_Stream_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ int info;
+
+ if (!PyArg_ParseTuple(args, "i", &info))
+ return NULL;
+
+ return PyLong_FromLong(xine_get_stream_info(self->stream, info));
+ }
+
+
+ PyObject *
+ Xine_Stream_PyObject_get_meta_info(Xine_Stream_PyObject *self, PyObject
*args, PyObject *kwargs)
+ {
+ int info;
+
+ if (!PyArg_ParseTuple(args, "i", &info))
+ return NULL;
+
+ return Py_BuildValue("s", (xine_get_meta_info(self->stream, info)));
+ }
PyMethodDef Xine_Stream_PyObject_methods[] = {
! {"open", (PyCFunction) Xine_Stream_PyObject_open, METH_VARARGS },
! {"play", (PyCFunction) Xine_Stream_PyObject_play, METH_VARARGS },
! {"stop", (PyCFunction) Xine_Stream_PyObject_stop, METH_VARARGS },
! {"eject", (PyCFunction) Xine_Stream_PyObject_eject, METH_VARARGS },
! {"get_source", (PyCFunction) Xine_Stream_PyObject_get_source,
METH_VARARGS },
! {"slave", (PyCFunction) Xine_Stream_PyObject_slave, METH_VARARGS },
! {"set_trick_mode", (PyCFunction) Xine_Stream_PyObject_set_trick_mode,
METH_VARARGS },
! {"get_current_vpts", (PyCFunction) Xine_Stream_PyObject_get_current_vpts,
METH_VARARGS },
! {"get_error", (PyCFunction) Xine_Stream_PyObject_get_error, METH_VARARGS
},
! {"get_status", (PyCFunction) Xine_Stream_PyObject_get_status,
METH_VARARGS },
! {"get_lang", (PyCFunction) Xine_Stream_PyObject_get_lang, METH_VARARGS },
! {"get_pos_length", (PyCFunction) Xine_Stream_PyObject_get_pos_length,
METH_VARARGS },
! {"get_info", (PyCFunction) Xine_Stream_PyObject_get_info, METH_VARARGS },
! {"get_meta_info", (PyCFunction) Xine_Stream_PyObject_get_meta_info,
METH_VARARGS },
!
! // TODO: xine_get_current_frame
{NULL, NULL}
};
Index: stream.h
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/stream.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** stream.h 18 Jul 2005 03:40:21 -0000 1.2
--- stream.h 19 Jul 2005 05:51:59 -0000 1.3
***************
*** 20,23 ****
--- 20,24 ----
xine_stream_t *stream;
int xine_object_owner;
+ PyObject *master;
PyObject *wrapper;
Index: xine.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/xine.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** xine.c 19 Jul 2005 04:17:08 -0000 1.5
--- xine.c 19 Jul 2005 05:51:59 -0000 1.6
***************
*** 173,179 ****
const char *const *list;
PyObject *pylist = NULL;
! int i;
! if (!PyArg_ParseTuple(args, "s", &type))
return NULL;
if (!strcmp(type, "video"))
--- 173,179 ----
const char *const *list;
PyObject *pylist = NULL;
! int i, post_types = -1;
! if (!PyArg_ParseTuple(args, "s|i", &type, &post_types))
return NULL;
if (!strcmp(type, "video"))
***************
*** 181,186 ****
else if (!strcmp(type, "audio"))
list = xine_list_audio_output_plugins(self->xine);
! else if (!strcmp(type, "post"))
! list = xine_list_post_plugins(self->xine);
else {
PyErr_Format(xine_error, "Unknown plugin type: %s", type);
--- 181,190 ----
else if (!strcmp(type, "audio"))
list = xine_list_audio_output_plugins(self->xine);
! else if (!strcmp(type, "post")) {
! if (post_types == -1)
! list = xine_list_post_plugins(self->xine);
! else
! list = xine_list_post_plugins_typed(self->xine, post_types);
! }
else {
PyErr_Format(xine_error, "Unknown plugin type: %s", type);
***************
*** 347,359 ****
}
PyMethodDef Xine_PyObject_methods[] = {
! {"list_plugins", (PyCFunction) Xine_PyObject_list_plugins, METH_VARARGS |
METH_KEYWORDS},
{"open_video_driver", (PyCFunction) Xine_PyObject_open_video_driver,
METH_VARARGS | METH_KEYWORDS},
{"open_audio_driver", (PyCFunction) Xine_PyObject_open_audio_driver,
METH_VARARGS | METH_KEYWORDS},
! {"stream_new", (PyCFunction) Xine_PyObject_stream_new, METH_VARARGS |
METH_KEYWORDS},
! {"post_init", (PyCFunction) Xine_PyObject_post_init, METH_VARARGS |
METH_KEYWORDS},
! {"get_log_names", (PyCFunction) Xine_PyObject_get_log_names, METH_VARARGS
| METH_KEYWORDS},
! {"get_log", (PyCFunction) Xine_PyObject_get_log, METH_VARARGS |
METH_KEYWORDS},
{NULL, NULL}
};
--- 351,507 ----
}
+ PyObject *
+ Xine_PyObject_set_engine_param(Xine_PyObject *self, PyObject *args, PyObject
*kwargs)
+ {
+ int param, value;
+
+ if (!PyArg_ParseTuple(args, "ii", ¶m, &value))
+ return NULL;
+ xine_engine_set_param(self->xine, param, value);
+ return Py_INCREF(Py_None), Py_None;
+ }
+
+ PyObject *
+ Xine_PyObject_get_engine_param(Xine_PyObject *self, PyObject *args, PyObject
*kwargs)
+ {
+ int param, value;
+
+ if (!PyArg_ParseTuple(args, "i", ¶m))
+ return NULL;
+ value = xine_engine_get_param(self->xine, param);
+ return PyInt_FromLong(value);
+ }
+
+ PyObject *
+ Xine_PyObject_get_input_plugin_ids(Xine_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ const char *const *list;
+ PyObject *pylist = NULL;
+ int i;
+ char *type;
+
+ if (!PyArg_ParseTuple(args, "s", &type))
+ return NULL;
+ if (!strcmp(type, "browsable"))
+ list = xine_get_browsable_input_plugin_ids(self->xine);
+ else
+ list = xine_get_autoplay_input_plugin_ids(self->xine);
+
+ pylist = PyList_New(0);
+ for (i = 0; list && list[i] != 0; i++) {
+ PyObject *str = PyString_FromString(list[i]);
+ PyList_Append(pylist, str);
+ Py_DECREF(str);
+ }
+ return pylist;
+ }
+
+ PyObject *
+ Xine_PyObject_get_browse_mrls(Xine_PyObject *self, PyObject *args, PyObject
*kwargs)
+ {
+ xine_mrl_t **mrls;
+ PyObject *pylist = NULL, *dict, *val;
+ char *plugin_id, *start_mrl;
+ int i, num;
+
+ if (!PyArg_ParseTuple(args, "sz", &plugin_id, &start_mrl))
+ return NULL;
+ mrls = xine_get_browse_mrls(self->xine, plugin_id, start_mrl, &num);
+ if (!mrls) {
+ PyErr_Format(xine_error, "Failed to get browse mrls -- unknown
plugin?");
+ return NULL;
+ }
+
+ pylist = PyList_New(0);
+ for (i = 0; i < num; i++) {
+ dict = PyDict_New();
+ val = Py_BuildValue("s", mrls[i]->origin);
+ PyDict_SetItemString(dict, "origin", val);
+ Py_DECREF(val);
+
+ val = Py_BuildValue("s", mrls[i]->link);
+ PyDict_SetItemString(dict, "link", val);
+ Py_DECREF(val);
+
+ val = Py_BuildValue("s", mrls[i]->mrl);
+ PyDict_SetItemString(dict, "mrl", val);
+ Py_DECREF(val);
+
+ val = Py_BuildValue("i", mrls[i]->type);
+ PyDict_SetItemString(dict, "type", val);
+ Py_DECREF(val);
+
+ val = Py_BuildValue("i", mrls[i]->size);
+ PyDict_SetItemString(dict, "size", val);
+ Py_DECREF(val);
+
+ PyList_Append(pylist, dict);
+ Py_DECREF(dict);
+ }
+ return pylist;
+ }
+
+
+ PyObject *
+ Xine_PyObject_get_autoplay_mrls(Xine_PyObject *self, PyObject *args, PyObject
*kwargs)
+ {
+ PyObject *pylist = NULL;
+ int i, num;
+ char *plugin, **mrls;
+
+ if (!PyArg_ParseTuple(args, "s", &plugin))
+ return NULL;
+
+ mrls = xine_get_autoplay_mrls(self->xine, plugin, &num);
+ if (!mrls) {
+ PyErr_Format(xine_error, "Failed to get autoplay mrls -- unknown
plugin?");
+ return NULL;
+ }
+
+ pylist = PyList_New(0);
+ for (i = 0; i < num; i++) {
+ PyObject *str = PyString_FromString(mrls[i]);
+ PyList_Append(pylist, str);
+ Py_DECREF(str);
+ }
+ return pylist;
+ }
+
+
+ PyObject *
+ Xine_PyObject_get_file_extensions(Xine_PyObject *self, PyObject *args,
PyObject *kwargs)
+ {
+ PyObject *o;
+ char *s = xine_get_file_extensions(self->xine);
+ o = Py_BuildValue("z", s);
+ free(s);
+ return o;
+ }
+
+ PyObject *
+ Xine_PyObject_get_mime_types(Xine_PyObject *self, PyObject *args, PyObject
*kwargs)
+ {
+ PyObject *o;
+ char *s = xine_get_mime_types(self->xine);
+ o = Py_BuildValue("z", s);
+ free(s);
+ return o;
+ }
PyMethodDef Xine_PyObject_methods[] = {
! {"list_plugins", (PyCFunction) Xine_PyObject_list_plugins, METH_VARARGS },
{"open_video_driver", (PyCFunction) Xine_PyObject_open_video_driver,
METH_VARARGS | METH_KEYWORDS},
{"open_audio_driver", (PyCFunction) Xine_PyObject_open_audio_driver,
METH_VARARGS | METH_KEYWORDS},
! {"stream_new", (PyCFunction) Xine_PyObject_stream_new, METH_VARARGS },
! {"post_init", (PyCFunction) Xine_PyObject_post_init, METH_VARARGS },
! {"get_log_names", (PyCFunction) Xine_PyObject_get_log_names, METH_VARARGS
},
! {"get_log", (PyCFunction) Xine_PyObject_get_log, METH_VARARGS },
! {"get_engine_param", (PyCFunction) Xine_PyObject_get_engine_param,
METH_VARARGS },
! {"set_engine_param", (PyCFunction) Xine_PyObject_set_engine_param,
METH_VARARGS },
! {"get_input_plugin_ids", (PyCFunction)
Xine_PyObject_get_input_plugin_ids, METH_VARARGS },
! {"get_browse_mrls", (PyCFunction) Xine_PyObject_get_browse_mrls,
METH_VARARGS },
! {"get_autoplay_mrls", (PyCFunction) Xine_PyObject_get_autoplay_mrls,
METH_VARARGS },
! {"get_file_extensions", (PyCFunction) Xine_PyObject_get_file_extensions,
METH_VARARGS },
! {"get_mime_types", (PyCFunction) Xine_PyObject_get_mime_types,
METH_VARARGS },
{NULL, NULL}
};
Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** __init__.py 19 Jul 2005 04:17:08 -0000 1.5
--- __init__.py 19 Jul 2005 05:51:59 -0000 1.6
***************
*** 34,38 ****
def __init__(self):
self._xine = _xine.Xine()
! self._xine.log_callback = self._log_callback
self.signals = {
"log": notifier.Signal()
--- 34,38 ----
def __init__(self):
self._xine = _xine.Xine()
! self._xine.log_callback = notifier.WeakCallback(self._log_callback)
self.signals = {
"log": notifier.Signal()
***************
*** 86,92 ****
return self._xine.list_plugins("audio")
! def list_post_plugins(self):
! return self._xine.list_plugins("post")
!
def post_init(self, name, inputs = 0, audio_targets = [], video_targets =
[]):
--- 86,91 ----
return self._xine.list_plugins("audio")
! def list_post_plugins(self, types = -1):
! return self._xine.list_plugins("post", types)
def post_init(self, name, inputs = 0, audio_targets = [], video_targets =
[]):
***************
*** 125,129 ****
print "LOG", section
self.signals["log"].emit(section)
!
class VideoPort(object):
--- 124,157 ----
print "LOG", section
self.signals["log"].emit(section)
!
! def get_engine_param(self, param):
! return self._xine.get_engine_param(param)
!
! def set_engine_param(self, param, value):
! return self._xine.set_engine_param(param, value)
!
! def get_browsable_input_plugin_ids(self):
! return self._xine.get_input_plugin_ids("browsable")
!
! def get_browse_mrls(self, plugin, start_mrl = None):
! return self._xine.get_browse_mrls(plugin, start_mrl)
!
! def get_autoplay_input_plugin_ids(self):
! return self._xine.get_input_plugin_ids("autoplay")
!
! def get_autoplay_mrls(self, plugin):
! return self._xine.get_autoplay_mrls(plugin)
!
! def get_file_extensions(self):
! return self._xine.get_file_extensions().split(" ")
!
! def get_mime_types(self):
! types = []
! for t in self._xine.get_mime_types().split(";"):
! vals = map(lambda x: x.strip(), t.split(":"))
! if len(vals) > 1:
! vals[1] = tuple(vals[1].split(","))
! types.append(tuple(vals))
! return types
class VideoPort(object):
***************
*** 153,157 ****
--- 181,221 ----
return _wrap_xine_object(self._stream.get_source("audio"))
+ def slave(self, slave, affection = 0xff):
+ assert(type(slave) == Stream)
+ assert(slave != self)
+ return self._stream.slave(slave._stream, affection)
+
+ def set_trick_mode(self, mode, value):
+ return self._stream.set_trick_mode(mode, value)
+ def stop(self):
+ return self._stream.stop()
+
+ def eject(self):
+ return self._stream.eject()
+
+ def get_current_vpts(self):
+ return self._stream.get_current_vpts()
+
+ def get_status(self):
+ return self._stream.get_status()
+
+ def get_error(self):
+ return self._stream.get_error()
+
+ def get_audio_lang(self, channel = -1):
+ return self._stream.get_lang("audio", channel)
+
+ def get_spu_lang(self, channel = -1):
+ return self._stream.get_lang("spu", channel)
+
+ def get_pos_length(self):
+ return self._stream.get_pos_length()
+
+ def get_info(self, info):
+ return self._stream.get_info(info)
+
+ def get_meta_info(self, info):
+ return self._stream.get_meta_info(info)
class Post(object):
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog