vlcglue.h 5.01 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * vlcglue.h: Main header for the Python binding
 *****************************************************************************
 * Copyright (C) 1998-2004 the VideoLAN team
5
 * $Id: vlcglue.h 16752 2006-09-20 11:10:44Z oaubert $
6
7
 *
 * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
8
 *          Clément Stenac <zorglub@videolan.org>
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
 *****************************************************************************/
24
25
#ifndef _VLCGLUE_H
#define _VLCGLUE_H 1
26
27
28
29
30

#include <Python.h>
#include "structmember.h"

#include <stdio.h>
31
#include <vlc/vlc.h>
32
#include <vlc/libvlc.h>
zorglub's avatar
zorglub committed
33
34
#include <vlc/mediacontrol_structures.h>
#include <vlc/mediacontrol.h>
35

Olivier Aubert's avatar
Olivier Aubert committed
36
37
38
39
40
41
42
/* Python 2.5 64-bit support compatibility define */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif

43
44
45
46
47
48
#define SELF ((MediaControl*)self)

/**********************************************************************
 * Exceptions handling
 **********************************************************************/

49
#define MC_TRY exception=mediacontrol_exception_create( )
50
51

#define MC_EXCEPT  \
52
  if( exception && exception->code ) { \
53
    PyObject *py_exc = MediaControl_InternalException; \
54
    switch( exception->code ) { \
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    case mediacontrol_InternalException: \
      py_exc = MediaControl_InternalException; \
      break; \
    case mediacontrol_PlaylistException: \
      py_exc = MediaControl_PlaylistException; \
      break; \
    case mediacontrol_InvalidPosition: \
      py_exc = MediaControl_InvalidPosition; \
      break; \
    case mediacontrol_PositionKeyNotSupported: \
      py_exc = MediaControl_PositionKeyNotSupported; \
      break; \
    case mediacontrol_PositionOriginNotSupported: \
      py_exc = MediaControl_PositionOriginNotSupported; \
      break; \
    } \
71
72
    PyErr_SetString( py_exc, exception->message ); \
    mediacontrol_exception_free( exception ); \
73
    return NULL; \
74
  } else if( exception ) { mediacontrol_exception_free( exception ); }
75
76
77
78
79
80

PyObject *MediaControl_InternalException;
PyObject *MediaControl_PositionKeyNotSupported;
PyObject *MediaControl_PositionOriginNotSupported;
PyObject *MediaControl_InvalidPosition;
PyObject *MediaControl_PlaylistException;
81
PyObject *vlcInstance_Exception;
82

83
84
85
86
87
88
89
90
91
92
93
/**********************************************************************
 * vlc.Instance Object
 **********************************************************************/
typedef struct
{
    PyObject_HEAD
    libvlc_instance_t* p_instance;
} vlcInstance;

#define LIBVLC_INSTANCE ((vlcInstance*)self)

94
95
96
97
98
99
100
/**********************************************************************
 * MediaControl Object
 **********************************************************************/
typedef struct
{
    PyObject_HEAD
    mediacontrol_Instance* mc;
101
    vlcInstance *vlc_instance;
102
} MediaControl;
103
104
105
106
107
108
109
110
111

/**********************************************************************
 * Position Object
 **********************************************************************/
typedef struct
{
    PyObject_HEAD
    int origin;
    int key;
112
    PY_LONG_LONG value;
113
114
} PyPosition;

115
116
117
118
119
120
121
122
123
124
125
/**********************************************************************
 * vlc.Input Object
 **********************************************************************/
typedef struct
{
    PyObject_HEAD
    libvlc_input_t* p_input;
} vlcInput;

/* Forward declarations */
staticforward PyTypeObject MediaControl_Type;
126
staticforward PyTypeObject PyPosition_Type;
127
128
129
130
131
132
133
134
135
136
137
138
staticforward PyTypeObject vlcInstance_Type;
staticforward PyTypeObject vlcInput_Type;

#define LIBVLC_INPUT ((vlcInput*)self)

#define LIBVLC_TRY libvlc_exception_init( &ex );

#define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \
    PyObject *py_exc = vlcInstance_Exception; \
    PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \
    return NULL; \
  }
139
140
141

mediacontrol_PositionKey positionKey_py_to_c( PyObject * py_key );
mediacontrol_PositionOrigin positionOrigin_py_to_c( PyObject * py_origin );
142
143
mediacontrol_Position * position_py_to_c( PyObject * py_position );
PyPosition * position_c_to_py( mediacontrol_Position * position );
144
145
146
147
148
149
150
151

/* Long long conversion on Mac os X/ppc */
#if defined (__ppc__) || defined(__ppc64__)
#define ntohll(x) ((long long) x >> 64)
#else
#define ntohll(x) (x)
#endif

152
#endif