]> git.sesse.net Git - vlc/blob - python/vlcmodule.c
* backport 11374
[vlc] / python / vlcmodule.c
1 #include <Python.h>
2 #include <vlc/vlc.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6
7
8 static PyObject *vlc_create(PyObject *self, PyObject *args)
9 {
10     int iRc;
11
12     iRc = VLC_Create();
13     return Py_BuildValue("i", iRc);
14 }
15
16
17 static PyObject *vlc_init(PyObject *self, PyObject *args)
18 {
19     int iVlc;
20     char *pArgv[] = { "vlc", "--sout", NULL };
21     int iRc;
22
23     if (!PyArg_ParseTuple(args, "is", &iVlc, &pArgv[2]))
24         return NULL;
25     iRc = VLC_Init(iVlc, 3, pArgv);
26     return Py_BuildValue("i", iRc);
27 }
28
29
30 static PyObject *vlc_addTarget(PyObject *self, PyObject *args)
31 {
32     int iVlc;
33     char *file;
34     int iRc;
35
36     if (!PyArg_ParseTuple(args, "is", &iVlc, &file))
37         return NULL;
38     iRc = VLC_AddTarget(iVlc, file, 0, 0, PLAYLIST_APPEND, PLAYLIST_END);
39     return Py_BuildValue("i", iRc);
40 }
41
42
43 static PyObject *vlc_play(PyObject *self, PyObject *args)
44 {
45     int iVlc;
46     int iRc;
47
48     if (!PyArg_ParseTuple(args, "i", &iVlc))
49         return NULL;
50     iRc = VLC_Play(iVlc);
51     return Py_BuildValue("i", iRc);
52 }
53
54
55 static PyObject *vlc_stop(PyObject *self, PyObject *args)
56 {
57     int iVlc;
58     int iRc;
59
60     if (!PyArg_ParseTuple(args, "i", &iVlc))
61         return NULL;
62     iRc = VLC_CleanUp(iVlc);
63     return Py_BuildValue("i", iRc);
64 }
65
66
67 static PyObject *vlc_pause(PyObject *self, PyObject *args)
68 {
69     int iVlc;
70     int iRc;
71
72     if (!PyArg_ParseTuple(args, "i", &iVlc))
73         return NULL;
74     iRc = VLC_Pause(iVlc);
75     return Py_BuildValue("i", iRc);
76 }
77
78
79 static PyMethodDef VlcMethods[] = {
80     {"create", vlc_create, METH_VARARGS, _("Create a vlc thread.")},
81     {"init", vlc_init, METH_VARARGS, _("Initialize a vlc thread.")},
82     {"addTarget", vlc_addTarget, METH_VARARGS, _("Add a target in the playlist.")},
83     {"play", vlc_play, METH_VARARGS, _("Play")},
84     {"stop", vlc_stop, METH_VARARGS, _("Stop")},
85     {"pause", vlc_pause, METH_VARARGS, _("Pause")},
86     {NULL, NULL, 0, NULL}        /* Sentinel */
87 };
88
89
90 void initvlc(void)
91 {
92     Py_InitModule("vlc", VlcMethods);
93 }
94