]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/vlm/vlm_wrapper.cpp
Uniformize source files encoding
[vlc] / modules / gui / wxwidgets / dialogs / vlm / vlm_wrapper.cpp
1 /*****************************************************************************
2  * vlm_wrapper.cpp : Wrapper around VLM
3  *****************************************************************************
4  * Copyright (C) 2000-2005 the VideoLAN team
5  * $Id$
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 /* FIXME: This is not wx-specific */
25
26 #include "dialogs/vlm/vlm_wrapper.hpp"
27
28 VLMWrapper::VLMWrapper( intf_thread_t *_p_intf )
29 {
30     p_intf = _p_intf;
31     p_vlm = NULL;
32 }
33
34 VLMWrapper::~VLMWrapper()
35 {
36    /* FIXME :you have to destroy vlm here to close
37     * but we shouldn't destroy vlm here in case somebody else wants it */
38    if( p_vlm )
39         vlm_Delete( p_vlm );
40 }
41
42 vlc_bool_t VLMWrapper::AttachVLM()
43 {
44     p_vlm = vlm_New( p_intf );
45     return p_vlm ? VLC_TRUE: VLC_FALSE ;
46 }
47
48 void VLMWrapper::LockVLM()
49 {
50     vlc_mutex_lock( &p_vlm->object_lock );
51 }
52
53 void VLMWrapper::UnlockVLM()
54 {
55     vlc_mutex_unlock( &p_vlm->object_lock );
56 }
57
58 void VLMWrapper::AddBroadcast( const char* name, const char* input,
59                                const char* output,
60                                vlc_bool_t b_enabled, vlc_bool_t b_loop  )
61 {
62     vlm_message_t *message;
63     string command = "new " + string(name) + " broadcast";
64     vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
65     vlm_MessageDelete( message );
66     EditBroadcast( name, input, output, b_enabled, b_loop );
67 }
68
69 void VLMWrapper::EditBroadcast( const char* name, const char* input,
70                                const char* output,
71                                vlc_bool_t b_enabled, vlc_bool_t b_loop  )
72 {
73     vlm_message_t *message;
74     string command;
75     command = "setup " + string(name) + " inputdel all";
76     vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
77     vlm_MessageDelete( message );
78     command = "setup " + string(name) + " input " + string(input);
79     vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
80     vlm_MessageDelete( message );
81     if( strlen(output) > 0 )
82     {
83         command = "setup " + string(name) + " output " + string(output);
84         vlm_ExecuteCommand( p_vlm, (char*)command.c_str(), &message );
85         vlm_MessageDelete( message );
86     }
87     if( b_enabled )
88     {
89         command = "setup " + string(name) + " enabled";
90         vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
91         vlm_MessageDelete( message );
92     }
93     if( b_loop )
94     {
95         command = "setup " + string(name) + " loop";
96         vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
97         vlm_MessageDelete( message );
98     }
99 }
100
101 void VLMWrapper::AddVod( const char* name, const char* input,
102                          const char* output,
103                          vlc_bool_t b_enabled, vlc_bool_t b_loop  )
104 {
105     vlm_message_t *message;
106     string command = "new " + string(name) + " vod";
107     vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
108     vlm_MessageDelete( message );
109     EditVod( name, input, output, b_enabled, b_loop );
110 }
111
112 void VLMWrapper::EditVod( const char* name, const char* input,
113                           const char* output,
114                           vlc_bool_t b_enabled, vlc_bool_t b_loop  )
115 {
116     vlm_message_t *message;
117     string command;
118     command = "setup " + string(name) + " input " + string(input);
119     vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
120     vlm_MessageDelete( message );
121     if( strlen(output) > 0 )
122     {
123         command = "setup " + string(name) + " output " + string(output);
124         vlm_ExecuteCommand( p_vlm, (char*)command.c_str(), &message );
125         vlm_MessageDelete( message );
126     }
127     if( b_enabled )
128     {
129         command = "setup " + string(name) + " enabled";
130         vlm_ExecuteCommand( p_vlm, command.c_str(), &message );
131         vlm_MessageDelete( message );
132     }
133 }