/*****************************************************************************
* vlc_position.c: vlc.Position binding
*****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006,2007,2008,2009 the VideoLAN team
* $Id$
*
- * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
+ * Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
*
* 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
{
PyPosition *self;
static char *kwlist[] = { "value", "origin", "key", NULL};
-
+
self = PyObject_New( PyPosition, &PyPosition_Type );
self->value=0;
self->origin=mediacontrol_AbsolutePosition;
self->key=mediacontrol_MediaTime;
- /* We do not care about the return value, since it will leave the fields
- with their default value. */
if(! PyArg_ParseTupleAndKeywords( args, kwds, "|lii", kwlist,
&(self->value),
&(self->origin),
&(self->key) ) )
{
- return NULL;
+ return NULL;
+ }
+
+ if( self->key != mediacontrol_MediaTime
+ && self->key != mediacontrol_ByteCount
+ && self->key != mediacontrol_SampleCount )
+ {
+ PyErr_SetString ( MediaControl_InternalException, "Invalid key value" );
+ return NULL;
+ }
+
+ if( self->origin != mediacontrol_AbsolutePosition
+ && self->origin != mediacontrol_RelativePosition
+ && self->origin != mediacontrol_ModuloPosition )
+ {
+ PyErr_SetString ( MediaControl_InternalException, "Invalid origin value" );
+ return NULL;
}
-
+
Py_INCREF( self );
- return ( PyObject * )self;
+ return ( PyObject * )self;
}
mediacontrol_PositionKey