]> git.sesse.net Git - vlc/blob - src/control/vlm.c
Missing file
[vlc] / src / control / vlm.c
1 /*****************************************************************************
2  * vlm.c: libvlc new API VLM handling functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id: playlist.c 14265 2006-02-12 17:31:39Z zorglub $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include <libvlc_internal.h>
25 #include <vlc/libvlc.h>
26
27 #include <vlc/vlc.h>
28 #include <vlc_input.h>
29 #include <vlc_vlm.h>
30
31 void InitVLM( libvlc_instance_t *p_instance )
32 {
33     if( p_instance->p_vlm ) return;
34     p_instance->p_vlm = vlm_New( p_instance->p_vlc );
35 }
36
37 #define CHECK_VLM { if( !p_instance->p_vlm ) InitVLM( p_instance ); \
38                     if( !p_instance->p_vlm ) {\
39                       libvlc_exception_raise( p_exception, \
40                                          "Unable to create VLM" ); return; } }
41
42 void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
43                                char *psz_input, char *psz_output,
44                                int i_options, char **ppsz_options,
45                                int b_enabled, int b_loop,
46                                libvlc_exception_t *p_exception )
47 {
48     vlm_media_t *p_media;
49     CHECK_VLM;
50
51     p_media = vlm_MediaNew( p_instance->p_vlm, psz_name, BROADCAST_TYPE );
52     if( !p_media )
53     {
54         libvlc_exception_raise( p_exception, "Media %s creation failed",
55                                 psz_name );
56         return;
57     }
58     libvlc_vlm_change_media( p_instance, psz_name, psz_input, psz_output,
59                              i_options, ppsz_options, b_enabled, b_loop,
60                              p_exception );
61
62 }
63
64 void libvlc_vlm_del_media( libvlc_instance_t *p_instance, char *psz_name,
65                            libvlc_exception_t *p_exception )
66 {
67     char *psz_message;
68     vlm_message_t *answer;
69     CHECK_VLM;
70     asprintf( &psz_message, "del %s", psz_name );
71     vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
72     if( answer->psz_value )
73     {
74         libvlc_exception_raise( p_exception, "Unable to delete %s",
75                                 psz_name );
76     }
77     free( psz_message);
78 }
79
80 void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, char *psz_name,
81                              int b_enabled, libvlc_exception_t *p_exception )
82 {
83     vlm_media_t *p_media;
84     CHECK_VLM;
85
86     if( b_enabled != 0 ) b_enabled = 1;
87
88     p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );
89     if( !p_media )
90     {
91         libvlc_exception_raise( p_exception, "Media %s does not exist",
92                                 psz_name );
93         return;
94     }
95     p_media->b_enabled = b_enabled;
96 }
97
98 void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name,
99                               char *psz_input, char *psz_output, int i_options,
100                               char **ppsz_options, int b_enabled, int b_loop,
101                               libvlc_exception_t *p_exception )
102 {
103     vlm_media_t *p_media;
104     CHECK_VLM;
105     if( b_enabled != 0 ) b_enabled = 1;
106     if( b_loop != 0 ) b_loop = 1;
107
108     p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );
109     if( !p_media )
110     {
111         libvlc_exception_raise( p_exception, "Media %s does not exist",
112                                 psz_name );
113         return;
114     }
115     p_media->b_enabled = b_enabled;
116     p_media->b_loop = b_loop;
117 }