]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/vlm/vlm_streampanel.cpp
s/vlc_object_yield/vlc_object_release/
[vlc] / modules / gui / wxwidgets / dialogs / vlm / vlm_streampanel.cpp
1 /*****************************************************************************
2  * vlm_streampanel:cpp
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 #if 0
25 #include "dialogs/vlm/vlm_streampanel.hpp"
26 #include "dialogs/vlm/vlm_stream.hpp"
27 #include "dialogs/vlm/vlm_slider_manager.hpp"
28
29 #include "dialogs/vlm/vlm_panel.hpp"
30
31 #include "bitmaps/play.xpm"
32 #include "bitmaps/pause.xpm"
33 #include "bitmaps/stop.xpm"
34 #include "bitmaps/trash.xpm"
35 #include "bitmaps/edit.xpm"
36
37 enum
38 {
39     BPlay_Event,
40     BStop_Event,
41     BSlider_Event,
42     BEdit_Event,
43     BTrash_Event,
44 };
45
46 BEGIN_EVENT_TABLE( VLMBroadcastStreamPanel, wxPanel )
47     EVT_BUTTON( BPlay_Event, VLMBroadcastStreamPanel::OnPlay )
48     EVT_BUTTON( BStop_Event, VLMBroadcastStreamPanel::OnStop )
49     EVT_BUTTON( BEdit_Event, VLMBroadcastStreamPanel::OnEdit )
50     EVT_BUTTON( BTrash_Event, VLMBroadcastStreamPanel::OnTrash )
51     EVT_COMMAND_SCROLL( BSlider_Event, VLMBroadcastStreamPanel::OnSliderUpdate )
52 END_EVENT_TABLE()
53
54 /***********************************************************************
55  * VLMStream
56  ***********************************************************************/
57 VLMStreamPanel::VLMStreamPanel( intf_thread_t * _p_intf, wxWindow * _p_parent ):
58          wxPanel( _p_parent, -1, wxDefaultPosition, wxDefaultSize )
59 {
60     p_intf = _p_intf;
61     p_slider = NULL;
62 }
63
64 VLMStreamPanel::~VLMStreamPanel()
65 {
66 }
67
68 /***********************************************************************
69  * VLMBroadcastStream
70  ***********************************************************************/
71 VLMBroadcastStreamPanel::VLMBroadcastStreamPanel( intf_thread_t* _p_intf,
72        wxWindow *_p_parent , VLMBroadcastStream *_stream ):
73        VLMStreamPanel( _p_intf, _p_parent ),
74        p_stream( _stream )
75 {
76     wxStaticBox *box = new wxStaticBox( this, -1,
77                     wxU( p_stream->p_media->psz_name ) );
78
79     wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( box, wxHORIZONTAL );
80
81     play_button = new wxBitmapButton( this, BPlay_Event,
82                                 wxBitmap( play_xpm ) );
83     play_button->SetToolTip( wxU(_("Play/Pause") ) );
84     box_sizer->Add( play_button, 0, wxEXPAND | wxALL, 5 );
85
86     wxBitmapButton *stop_button = new wxBitmapButton( this, BStop_Event,
87                                           wxBitmap( stop_xpm ) );
88     stop_button->SetToolTip( wxU(_("Stop") ) );
89     box_sizer->Add( stop_button, 0, wxEXPAND | wxALL, 5 );
90
91     p_slider = new wxSlider( this,  BSlider_Event, 0, 0,
92                             SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
93     p_slider->Disable();
94     box_sizer->Add( p_slider,    1, wxEXPAND | wxALL, 5 );
95
96     p_time = new wxStaticText( this, -1, wxU( "0:00:00 / 0:00:00") );
97     box_sizer->Add( p_time, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
98
99     wxBitmapButton *edit_button = new wxBitmapButton( this, BEdit_Event,
100                                     wxBitmap( edit_xpm ) );
101     edit_button->SetToolTip( wxU( _("Edit") ) );
102     box_sizer->Add( edit_button, 0, wxEXPAND | wxALL , 5 );
103
104     wxBitmapButton *trash_button = new wxBitmapButton( this, BTrash_Event,
105                                     wxBitmap( trash_xpm ) );
106     trash_button->SetToolTip( wxU( _("Delete" ) ) );
107     box_sizer->Add( trash_button, 0, wxEXPAND | wxALL , 5 );
108
109     box_sizer->Layout();
110     SetSizerAndFit( box_sizer );
111
112     p_sm = new VLMSliderManager( p_intf, this );
113 }
114
115 VLMBroadcastStreamPanel::~VLMBroadcastStreamPanel()
116 {
117 }
118
119 void VLMBroadcastStreamPanel::TogglePlayButton( int state )
120 {
121     if( state == PLAYING_S )
122     {
123         play_button->SetBitmapLabel( wxBitmap( pause_xpm ) );
124     }
125     if( state == PAUSE_S )
126     {
127         play_button->SetBitmapLabel( wxBitmap( play_xpm ) );
128     }
129 }
130
131 void VLMBroadcastStreamPanel::Update()
132 {
133     /* Update managed slider */
134     p_sm->Update();
135     p_time->SetLabel( p_sm->time_string );
136 }
137
138 void VLMBroadcastStreamPanel::OnPlay( wxCommandEvent &event )
139 {
140     /* FIXME: Factorize input / VLM code here */
141     /* Handle multiple instance */
142     if( p_stream->p_media->i_instance > 0 &&
143         p_stream->p_media->instance[0]->p_input )
144     {
145         vlc_value_t val;
146         vlc_object_hold( p_stream->p_media->instance[0]->p_input );
147         var_Get( p_stream->p_media->instance[0]->p_input, "state", &val );
148         if( val.i_int != PAUSE_S )
149         {
150             /* Pause */
151             val.i_int = PAUSE_S;
152         }
153         else
154         {
155             /* Resume */
156             val.i_int = PLAYING_S;
157         }
158         var_Set( p_stream->p_media->instance[0]->p_input, "state", val );
159         TogglePlayButton( val.i_int );
160         vlc_object_release( p_stream->p_media->instance[0]->p_input );
161     }
162     else
163     {
164          p_stream->Play();
165          TogglePlayButton( PLAYING_S );
166     }
167 }
168
169 void VLMBroadcastStreamPanel::OnStop( wxCommandEvent &event )
170 {
171     p_stream->Stop();
172 }
173
174 void VLMBroadcastStreamPanel::OnEdit( wxCommandEvent &event )
175 {
176      VLMEditStreamFrame *p_frame =
177            new  VLMEditStreamFrame( p_intf, this, p_stream->p_vlm, true,
178                                     p_stream );
179      p_frame->Show();
180 }
181
182 void VLMBroadcastStreamPanel::OnTrash( wxCommandEvent &event )
183 {
184     p_stream->Delete();
185 }
186
187 void VLMBroadcastStreamPanel::OnSliderUpdate( wxScrollEvent& event )
188 {
189     p_sm->ProcessUpdate( event );
190 }
191
192 /***********************************************************************
193  * VLMVODStream
194  ***********************************************************************/
195 VLMVODStreamPanel::VLMVODStreamPanel( intf_thread_t* _p_intf,
196        wxWindow *_p_parent , VLMVODStream *_stream ):
197        VLMStreamPanel( _p_intf, _p_parent ),
198        p_stream( _stream )
199 {
200 }
201
202 VLMVODStreamPanel::~VLMVODStreamPanel()
203 {
204 }
205 #endif