1 /*****************************************************************************
2 * vlc_wrapper.h: BeOS plugin for vlc (derived from MacOS X port )
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: VlcWrapper.cpp,v 1.2 2002/08/06 10:54:34 tcastley Exp $
7 * Authors: Florian G. Pflug <fgp@phlo.org>
8 * Jon Lech Johansen <jon-vl@nanocrew.net>
9 * Tony Casltey <tony@castley.net>
11 * This program is free software{} you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation{} either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY{} without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program{} if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 #include <SupportKit.h>
31 #include "VlcWrapper.h"
33 Intf_VLCWrapper *Intf_VLCWrapper::getVLCWrapper(intf_thread_t *p_if)
35 static Intf_VLCWrapper *one_wrapper;
36 if (one_wrapper == NULL )
38 one_wrapper = new Intf_VLCWrapper(p_if);
43 Intf_VLCWrapper::Intf_VLCWrapper(intf_thread_t *p_if)
48 Intf_VLCWrapper::~Intf_VLCWrapper()
52 //bool Intf_VLCWrapper::manage()
55 // p_intf->pf_manage( p_intf );
57 // if ( p_intf->b_die )
62 /* Update the input */
63 // if( p_intf->p_sys->p_input != NULL )
65 // if( p_intf->p_sys->p_input->b_dead )
67 // vlc_object_release( p_intf->p_sys->p_input );
68 // p_intf->p_sys->p_input = NULL;
72 // p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
75 // if ( p_intf->p_sys->p_input != NULL )
77 // vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
78 // if( !p_intf->p_sys->p_input->b_die )
80 // /* New input or stream map change */
81 // if( p_intf->p_sys->p_input->stream.b_changed ||
82 // p_intf->p_sys->i_part !=
83 // p_intf->p_sys->p_input->stream.p_selected_area->i_part )
86 // p_intf->p_sys->b_disabled_menus = 0;
89 // vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
91 // else if ( !p_intf->p_sys->b_disabled_menus )
94 // p_intf->p_sys->b_disabled_menus = 1;
99 void Intf_VLCWrapper::quit()
104 /* playlist control */
106 int Intf_VLCWrapper::inputGetStatus()
108 if( p_intf->p_sys->p_input != NULL )
110 return( p_intf->p_sys->p_input->stream.control.i_status );
118 bool Intf_VLCWrapper::playlistPlay()
120 playlist_t *p_playlist =
121 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
124 vlc_mutex_lock( &p_playlist->object_lock );
125 if( p_playlist->i_size )
127 vlc_mutex_unlock( &p_playlist->object_lock );
128 playlist_Play( p_playlist );
129 vlc_object_release( p_playlist );
133 vlc_mutex_unlock( &p_playlist->object_lock );
134 vlc_object_release( p_playlist );
141 void Intf_VLCWrapper::playlistPause()
144 playlist_t *p_playlist =
145 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
147 playlist_Pause( p_playlist );
148 vlc_object_release( p_playlist );
151 void Intf_VLCWrapper::playlistStop()
153 playlist_t *p_playlist =
154 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
157 playlist_Stop( p_playlist );
158 vlc_object_release( p_playlist );
162 void Intf_VLCWrapper::playlistNext()
164 playlist_t *p_playlist =
165 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
168 playlist_Next( p_playlist );
169 vlc_object_release( p_playlist );
172 void Intf_VLCWrapper::playlistPrev()
174 playlist_t *p_playlist =
175 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
178 playlist_Prev( p_playlist );
179 vlc_object_release( p_playlist );
182 void Intf_VLCWrapper::playlistSkip(int i)
184 playlist_t *p_playlist =
185 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
188 playlist_Skip( p_playlist, i );
189 vlc_object_release( p_playlist );
192 void Intf_VLCWrapper::playlistGoto(int i)
194 playlist_t *p_playlist =
195 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
198 playlist_Goto( p_playlist, i );
199 vlc_object_release( p_playlist );
202 /* playback control */
203 void Intf_VLCWrapper::playSlower()
205 if( p_intf->p_sys->p_input != NULL )
207 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
209 if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
219 void Intf_VLCWrapper::playFaster()
221 if( p_intf->p_sys->p_input != NULL )
223 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
225 if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
235 void Intf_VLCWrapper::toggleProgram(int i_program){}
237 void Intf_VLCWrapper::toggleTitle(int i_title)
239 if( p_intf->p_sys->p_input != NULL )
241 input_ChangeArea( p_intf->p_sys->p_input,
242 p_intf->p_sys->p_input->stream.pp_areas[i_title] );
244 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
247 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
251 void Intf_VLCWrapper::toggleChapter(int i_chapter)
253 if( p_intf->p_sys->p_input != NULL )
255 p_intf->p_sys->p_input->stream.p_selected_area->i_part = i_chapter;
256 input_ChangeArea( p_intf->p_sys->p_input,
257 p_intf->p_sys->p_input->stream.p_selected_area );
259 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
261 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
265 void Intf_VLCWrapper::toggleLanguage(int i_language)
269 int i_cat = AUDIO_ES;
271 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
272 for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
274 if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
280 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
282 msg_Info( p_intf, "Old: %d, New: %d", i_old, i_language);
283 if( i_language != -1 )
285 input_ToggleES( p_intf->p_sys->p_input,
286 p_intf->p_sys->p_input->stream.pp_selected_es[i_language],
290 if( (i_old != -1) && (i_old != i_language) )
292 input_ToggleES( p_intf->p_sys->p_input,
293 p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
298 void Intf_VLCWrapper::toggleSubtitle(int i_subtitle)
303 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
304 for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
306 if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
312 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
314 msg_Info( p_intf, "Old: %d, New: %d", i_old, i_subtitle);
315 if( i_subtitle != -1 )
317 input_ToggleES( p_intf->p_sys->p_input,
318 p_intf->p_sys->p_input->stream.pp_selected_es[i_subtitle],
322 if( (i_old != -1) && (i_old != i_subtitle) )
324 input_ToggleES( p_intf->p_sys->p_input,
325 p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
331 void Intf_VLCWrapper::channelNext()
335 void Intf_VLCWrapper::channelPrev()
339 void Intf_VLCWrapper::eject(){}
345 BString* Intf_VLCWrapper::getTimeAsString()
347 static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
349 if( p_intf->p_sys->p_input == NULL )
351 return (new BString("00:00:00"));
354 input_OffsetToTime( p_intf->p_sys->p_input,
356 p_intf->p_sys->p_input->stream.p_selected_area->i_tell );
358 return(new BString(psz_currenttime));
361 float Intf_VLCWrapper::getTimeAsFloat()
365 if( p_intf->p_sys->p_input != NULL )
367 f_time = (float)p_intf->p_sys->p_input->stream.p_selected_area->i_tell /
368 (float)p_intf->p_sys->p_input->stream.p_selected_area->i_size;
377 void Intf_VLCWrapper::setTimeAsFloat(float f_position)
379 if( p_intf->p_sys->p_input != NULL )
381 input_Seek( p_intf->p_sys->p_input,
382 (long long int)(p_intf->p_sys->p_input->stream.p_selected_area->i_size * f_position / 100),
387 BList *Intf_VLCWrapper::playlistAsArray()
390 playlist_t *p_playlist =
391 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
394 BList* p_list = new BList(p_playlist->i_size);
396 vlc_mutex_lock( &p_playlist->object_lock );
398 for( i = 0; i < p_playlist->i_size; i++ )
400 p_list->AddItem(new BString(p_playlist->pp_items[i]->psz_name));
403 vlc_mutex_unlock( &p_playlist->object_lock );
404 vlc_object_release( p_playlist );
408 /* open file/disc/network */
409 void Intf_VLCWrapper::openFiles(BList *o_files)
412 playlist_t *p_playlist =
413 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
416 while( ( o_file = (BString *)o_files->LastItem() ) )
418 o_files->RemoveItem(o_files->CountItems() - 1);
419 playlist_Add( p_playlist, o_file->String(),
420 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
424 vlc_object_release( p_playlist );
428 void Intf_VLCWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_chapter)
430 BString o_source("");
431 o_source << o_type << ":" << o_device ;
433 playlist_t *p_playlist =
434 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
436 playlist_Add( p_playlist, o_source.String(),
437 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
438 vlc_object_release( p_playlist );
441 void Intf_VLCWrapper::openNet(BString o_addr, int i_port)
445 void Intf_VLCWrapper::openNetChannel(BString o_addr, int i_port)
449 void Intf_VLCWrapper::openNetHTTP(BString o_addr)
453 void Intf_VLCWrapper::toggleMute( )
455 input_ToggleMute( p_intf->p_sys->p_input );
458 /* menus management */