- mediacontrol_Instance* retval;
- vlc_object_t *p_vlc;
- vlc_object_t *p_object;
-
- p_object = ( vlc_object_t* )vlc_current_object( vlc_object_id );
- if( ! p_object )
- {
- RAISE( mediacontrol_InternalException, "Unable to find vlc object" );
- return NULL;
- }
-
- p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT );
- if( ! p_vlc )
- {
- RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );
- return NULL;
- }
- retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
- retval->p_vlc = p_vlc;
- retval->vlc_object_id = p_vlc->i_object_id;
-
- /* We can keep references on these, which should not change. Is it true ? */
- retval->p_playlist = vlc_object_find( p_vlc,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
-
- if( ! retval->p_playlist || ! retval->p_intf )
- {
- RAISE( mediacontrol_InternalException, "No available interface" );
- return NULL;
- }
- return retval;
-};
-
-
-/**************************************************************************
- * Playback management
- **************************************************************************/
-mediacontrol_Position*
-mediacontrol_get_media_position( mediacontrol_Instance *self,
- const mediacontrol_PositionOrigin an_origin,
- const mediacontrol_PositionKey a_key,
- mediacontrol_Exception *exception )
-{
- mediacontrol_Position* retval;
- vlc_value_t val;
- input_thread_t * p_input = self->p_playlist->p_input;
-
- exception = mediacontrol_exception_init( exception );
-
- retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
- retval->origin = an_origin;
- retval->key = a_key;
-
- if( ! p_input )
- {
- RAISE( mediacontrol_InternalException, "No input thread." );
- return NULL;
- }
-
- if( an_origin != mediacontrol_AbsolutePosition )
- {
- /* Relative or ModuloPosition make no sense */
- RAISE( mediacontrol_PositionOriginNotSupported, "Only absolute position is valid." );
- return NULL;
- }
-
- /* We are asked for an AbsolutePosition. */
- val.i_time = 0;
- var_Get( p_input, "time", &val );
- /* FIXME: check val.i_time > 0 */
-
- retval->value = mediacontrol_unit_convert( p_input,
- mediacontrol_MediaTime,
- a_key,
- val.i_time / 1000 );
- return retval;
-}
-
-/* Sets the media position */
-void
-mediacontrol_set_media_position( mediacontrol_Instance *self,
- const mediacontrol_Position * a_position,
- mediacontrol_Exception *exception )
-{
- vlc_value_t val;
- input_thread_t * p_input = self->p_playlist->p_input;
-
- exception=mediacontrol_exception_init( exception );
- if( ! p_input )
- {
- RAISE( mediacontrol_InternalException, "No input thread." );
- return;
- }
-
- if( !var_GetBool( p_input, "seekable" ) )
- {
- RAISE( mediacontrol_InvalidPosition, "Stream not seekable" );
- return;
- }
-
- val.i_time = mediacontrol_position2microsecond( p_input, a_position );
- var_Set( p_input, "time", val );
- return;