1
/*****************************************************************************
2
* init.c: Core functions : init, playlist, stream management
3
*****************************************************************************
4
* Copyright (C) 2005 the VideoLAN team
5
* $Id: 6fdf33768a28ba4958ebe8a79885ef325005bd1f $
7
* Authors: Olivier Aubert <olivier.aubert@liris.univ-lyon1.fr>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22
*****************************************************************************/
25
#include <mediacontrol_internal.h>
26
#include <vlc/mediacontrol.h>
28
mediacontrol_Instance* mediacontrol_new( char** args, mediacontrol_Exception *exception )
30
mediacontrol_Instance* retval;
40
for ( p_tmp = args ; *p_tmp != NULL ; p_tmp++ )
44
ppsz_argv = malloc( ( i_count + 2 ) * sizeof( char * ) ) ;
47
exception->code = mediacontrol_InternalException;
48
exception->message = "out of memory";
52
for ( i_index = 0; i_index < i_count; i_index++ )
54
ppsz_argv[i_index + 1] = strdup( args[i_index] );
55
if( ! ppsz_argv[i_index + 1] )
57
exception->code = mediacontrol_InternalException;
58
exception->message = "out of memory";
63
ppsz_argv[i_count + 1] = NULL;
65
p_vlc_id = VLC_Create();
68
exception->code = mediacontrol_InternalException;
69
exception->message = strdup( "unable to create VLC" );
73
p_vlc = ( vlc_object_t* )vlc_current_object( p_vlc_id );
76
exception->code = mediacontrol_InternalException;
77
exception->message = strdup( "unable to find VLC object" );
80
retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
83
exception->code = mediacontrol_InternalException;
84
exception->message = strdup( "out of memory" );
88
if( VLC_Init( p_vlc_id, i_count + 1, ppsz_argv ) != VLC_SUCCESS )
90
exception->code = mediacontrol_InternalException;
91
exception->message = strdup( "cannot initialize VLC" );
95
retval->p_vlc = p_vlc;
96
retval->vlc_object_id = p_vlc_id;
98
/* We can keep references on these, which should not change. Is it true ? */
99
retval->p_playlist = vlc_object_find( p_vlc,
100
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
101
retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE );
103
if( ! retval->p_playlist || ! retval->p_intf )
105
exception->code = mediacontrol_InternalException;
106
exception->message = strdup( "no interface available" );
114
mediacontrol_exit( mediacontrol_Instance *self )
116
vlc_object_release( (vlc_object_t* )self->p_playlist );
117
vlc_object_release( (vlc_object_t* )self->p_intf );
118
vlc_object_release( (vlc_object_t*)self->p_vlc );
120
VLC_CleanUp( self->vlc_object_id );
121
VLC_Destroy( self->vlc_object_id );