]> git.sesse.net Git - vlc/blob - modules/gui/beos/VlcWrapper.cpp
- Added LCD info view from 0.4.x
[vlc] / modules / gui / beos / VlcWrapper.cpp
1 /*****************************************************************************
2  * intf_vlc_wrapper.h: BeOS plugin for vlc (derived from MacOS X port )
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: VlcWrapper.cpp,v 1.7 2002/10/28 19:42:24 titer Exp $
6  *
7  * Authors: Florian G. Pflug <fgp@phlo.org>
8  *          Jon Lech Johansen <jon-vl@nanocrew.net>
9  *          Tony Casltey <tony@castley.net>
10  *          Stephan Aßmus <stippi@yellowbites.com>
11  *
12  * This program is free software{} you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation{} either version 2 of the License, or
15  * (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY{} without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program{} if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26 /* VLC headers */
27 #include <SupportKit.h>
28
29 #include <vlc/vlc.h>
30 #include <vlc/intf.h>
31 #include <audio_output.h>
32 #include <aout_internal.h>
33
34 #include "VlcWrapper.h"
35
36 Intf_VLCWrapper *Intf_VLCWrapper::getVLCWrapper(intf_thread_t *p_interface)
37 {
38     static Intf_VLCWrapper *one_wrapper;
39     if (one_wrapper == NULL )
40     {
41        one_wrapper = new Intf_VLCWrapper(p_interface);
42     }
43     return one_wrapper;
44 }
45
46 Intf_VLCWrapper::Intf_VLCWrapper(intf_thread_t *p_interface)
47 {
48     p_intf = p_interface;
49 }
50
51 Intf_VLCWrapper::~Intf_VLCWrapper()
52 {
53 }
54
55 #if 0
56 bool Intf_VLCWrapper::manage()
57 {
58    /* p_main->p_intf->pf_manage( p_intf ); */
59    
60    if ( p_intf->b_die )
61    {
62        // exit the lot
63        return( 1 );
64    }
65    
66    if ( p_intf->p_sys->p_input != NULL )
67    {
68        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
69         if( !p_intf->p_sys->p_input->b_die )
70         {
71             /* New input or stream map change */
72             if( p_intf->p_sys->p_input->stream.b_changed ||
73                 p_intf->p_sys->i_part !=
74                     p_intf->p_sys->p_input->stream.p_selected_area->i_part )
75             {
76                 setupMenus();
77                 p_intf->p_sys->b_disabled_menus = 0;
78             }
79         }
80         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
81     }
82     else if ( !p_intf->p_sys->b_disabled_menus )
83     {
84         setupMenus();
85         p_intf->p_sys->b_disabled_menus = 1;
86     }
87     return( 0 );
88 }
89 #endif
90
91 void Intf_VLCWrapper::quit()
92 {
93     p_intf->b_die = 1;
94 }
95     
96 /* playlist control */
97 bool Intf_VLCWrapper::playlistPlay()
98 {
99     playlist_t *p_playlist = 
100                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
101                                                        FIND_ANYWHERE );
102
103     vlc_mutex_lock( &p_playlist->object_lock );
104     if( p_playlist->i_size )
105     {
106         vlc_mutex_unlock( &p_playlist->object_lock );
107         playlist_Play( p_playlist );
108         vlc_object_release( p_playlist );
109     }
110     else
111     {
112         vlc_mutex_unlock( &p_playlist->object_lock );
113         vlc_object_release( p_playlist );
114     }
115
116     return( true );
117 }
118
119 void Intf_VLCWrapper::playlistPause()
120 {
121     toggle_mute(  );
122     playlist_t *p_playlist = 
123                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
124                                                        FIND_ANYWHERE );
125     playlist_Pause( p_playlist );
126     vlc_object_release( p_playlist );
127 }
128
129 void Intf_VLCWrapper::playlistStop()
130 {
131     playlist_t *p_playlist = 
132                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
133                                                        FIND_ANYWHERE );
134
135     playlist_Stop( p_playlist );
136     vlc_object_release( p_playlist );
137 }
138
139 void Intf_VLCWrapper::playlistNext()
140 {
141     playlist_t *p_playlist = 
142                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
143                                                        FIND_ANYWHERE );
144
145     playlist_Next( p_playlist );
146     vlc_object_release( p_playlist );
147 }
148
149 void Intf_VLCWrapper::playlistPrev()
150 {
151     playlist_t *p_playlist = 
152                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
153                                                        FIND_ANYWHERE );
154
155     playlist_Prev( p_playlist );
156     vlc_object_release( p_playlist );
157 }
158
159 void Intf_VLCWrapper::playlistSkip(int i)
160 {
161     playlist_t *p_playlist = 
162                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
163                                                        FIND_ANYWHERE );
164
165     playlist_Skip( p_playlist, i );
166     vlc_object_release( p_playlist );
167 }
168
169 void Intf_VLCWrapper::playlistGoto(int i)
170 {
171     playlist_t *p_playlist = 
172                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
173                                                        FIND_ANYWHERE );
174
175     playlist_Goto( p_playlist, i );
176     vlc_object_release( p_playlist );
177 }
178
179 void Intf_VLCWrapper::playlistJumpTo( int pos )
180 {
181 #if 0
182         // sanity checks
183         if ( pos < 0 )
184                 pos = 0;
185         int size = playlistSize();
186         if (pos >= size)
187                 pos = size - 1;
188         // weird hack
189     if( p_input_bank->pp_input[0] != NULL )
190                 pos--;
191         // stop current stream
192         playlistStop();
193         // modify current position in playlist
194         playlistLock();
195         p_main->p_playlist->i_index = pos;
196         playlistUnlock();
197         // start playing
198         playlistPlay();
199 #endif
200 }
201
202 int Intf_VLCWrapper::playlistCurrentPos()
203 {
204         playlistLock();
205         int pos = p_intf->p_sys->p_playlist->i_index;
206         playlistUnlock();
207         return pos;
208 }
209
210 int Intf_VLCWrapper::playlistSize()
211 {
212         playlistLock();
213         int size = p_intf->p_sys->p_playlist->i_size;
214         playlistUnlock();
215         return size;
216 }
217
218 void Intf_VLCWrapper::playlistLock()
219 {
220         vlc_mutex_lock( &p_intf->p_sys->p_playlist->object_lock );
221 }
222
223 void Intf_VLCWrapper::playlistUnlock()
224 {
225         vlc_mutex_unlock( &p_intf->p_sys->p_playlist->object_lock );
226 }
227
228 void Intf_VLCWrapper::getNavCapabilities( bool* canSkipPrev,
229                                                                                   bool* canSkipNext )
230 {
231         if ( canSkipPrev && canSkipNext )
232         {
233                 // init the parameters
234                 *canSkipPrev = false;
235                 *canSkipNext = false;
236                 // get playlist info
237                 playlistLock();
238                 int pos = p_intf->p_sys->p_playlist->i_index;
239                 int size = p_intf->p_sys->p_playlist->i_size;
240                 playlistUnlock();
241
242                 /* input_thread_t* input = p_input_bank->pp_input[0]; */
243                 input_thread_t* input = p_intf->p_sys->p_input;
244                 // see if we have got a stream going            
245                 if ( input )
246                 {
247                         vlc_mutex_lock( &input->stream.stream_lock );
248
249                         bool hasTitles = input->stream.i_area_nb > 1;
250                         int numChapters = input->stream.p_selected_area->i_part_nb;
251                         bool hasChapters = numChapters > 1;
252                         // first, look for chapters
253                         if ( hasChapters )
254                         {
255                                 *canSkipPrev = input->stream.p_selected_area->i_part > 0;
256                                 *canSkipNext = input->stream.p_selected_area->i_part <
257                                                                          input->stream.p_selected_area->i_part_nb - 1;
258                         }
259                         // if one of the skip capabilities is false,
260                         // make it depend on titles instead
261                         if ( !*canSkipPrev && hasTitles )
262                                 *canSkipPrev = input->stream.p_selected_area->i_id > 1;
263                         if ( !*canSkipNext && hasTitles )
264                                 *canSkipNext = input->stream.p_selected_area->i_id < input->stream.i_area_nb - 1;
265
266                         vlc_mutex_unlock( &input->stream.stream_lock );
267                 }
268                 // last but not least, make capabilities depend on playlist
269                 if ( !*canSkipPrev )
270                         *canSkipPrev = pos > 0;
271                 if ( !*canSkipNext )
272                         *canSkipNext = pos < size - 1;
273         }
274 }
275
276 void Intf_VLCWrapper::navigatePrev()
277 {
278 #if 0
279         bool hasSkiped = false;
280
281         input_thread_t* input = p_input_bank->pp_input[0];
282         // see if we have got a stream going            
283         if ( input )
284         {
285                 // get information from stream (lock it while looking at it)
286                 vlc_mutex_lock( &input->stream.stream_lock );
287
288                 int currentTitle = input->stream.p_selected_area->i_id;
289                 int currentChapter = input->stream.p_selected_area->i_part;
290                 int numTitles = input->stream.i_area_nb;
291                 bool hasTitles = numTitles > 1;
292                 int numChapters = input->stream.p_selected_area->i_part_nb;
293                 bool hasChapters = numChapters > 1;
294
295                 vlc_mutex_unlock( &input->stream.stream_lock );
296
297                 // first, look for chapters
298                 if ( hasChapters )
299                 {
300                         // skip to the previous chapter
301                         currentChapter--;
302
303                         if ( currentChapter >= 0 )
304                         {
305                                 toggleChapter( currentChapter );
306                                 hasSkiped = true;
307                         }
308                 }
309                 // if we couldn't skip chapters, try titles instead
310                 if ( !hasSkiped && hasTitles )
311                 {
312                         // skip to the previous title
313                         currentTitle--;
314                         // disallow area 0 since it is used for video_ts.vob
315                         if( currentTitle > 0 )
316                         {
317                                 toggleTitle(currentTitle);
318                                 hasSkiped = true;
319                         }
320                 }
321
322         }
323         // last but not least, skip to previous file
324         if ( !hasSkiped )
325                 playlistPrev();
326 #endif
327 }
328
329 void Intf_VLCWrapper::navigateNext()
330 {
331 #if 0
332         bool hasSkiped = false;
333
334         input_thread_t* input = p_input_bank->pp_input[0];
335         // see if we have got a stream going            
336         if ( input )
337         {
338                 // get information from stream (lock it while looking at it)
339                 vlc_mutex_lock( &input->stream.stream_lock );
340
341                 int currentTitle = input->stream.p_selected_area->i_id;
342                 int currentChapter = input->stream.p_selected_area->i_part;
343                 int numTitles = input->stream.i_area_nb;
344                 bool hasTitles = numTitles > 1;
345                 int numChapters = input->stream.p_selected_area->i_part_nb;
346                 bool hasChapters = numChapters > 1;
347
348                 vlc_mutex_unlock( &input->stream.stream_lock );
349
350                 // first, look for chapters
351                 if ( hasChapters )
352                 {
353                         // skip to the next chapter
354                         currentChapter++;
355                         if ( currentChapter < numChapters )
356                         {
357                                 toggleChapter( currentChapter );
358                                 hasSkiped = true;
359                         }
360                 }
361                 // if we couldn't skip chapters, try titles instead
362                 if ( !hasSkiped && hasTitles )
363                 {
364                         // skip to the next title
365                         currentTitle++;
366                         // disallow area 0 since it is used for video_ts.vob
367                         if ( currentTitle < numTitles - 1 )
368                         {
369                                 toggleTitle(currentTitle);
370                                 hasSkiped = true;
371                         }
372                 }
373
374         }
375         // last but not least, skip to next file
376         if ( !hasSkiped )
377                 playlistNext();
378 #endif
379 }
380
381
382 //void Intf_VLCWrapper::channelNext()
383 //{
384 //    intf_thread_t * p_intf = p_main->p_intf;
385 //
386 //    p_intf->p_sys->i_channel++;
387 //
388 //    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
389 //
390 //    vlc_mutex_lock( &p_intf->change_lock );
391 //
392 //    network_ChannelJoin( p_intf->p_sys->i_channel );
393 //    p_intf->pf_manage( p_intf );
394 //
395 //    vlc_mutex_unlock( &p_intf->change_lock );
396 //}
397 //
398 //void Intf_VLCWrapper::channelPrev()
399 //{
400 //    intf_thread_t * p_intf = p_main->p_intf;
401 //
402 //    if ( p_intf->p_sys->i_channel )
403 //    {
404 //        p_intf->p_sys->i_channel--;
405 //    }
406 //
407 //    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
408 //
409 //    vlc_mutex_lock( &p_intf->change_lock );
410 //
411 //    network_ChannelJoin( p_intf->p_sys->i_channel );
412 //    p_intf->pf_manage( p_intf );
413 //
414 //    vlc_mutex_unlock( &p_intf->change_lock );
415 //
416 //}
417
418 void Intf_VLCWrapper::loop()
419 {
420     if ( p_intf->p_sys->b_loop )
421     {
422         playlist_Delete( p_intf->p_sys->p_playlist,
423                          p_intf->p_sys->p_playlist->i_size - 1 );
424     }
425     else
426     {
427         playlist_Add( p_intf->p_sys->p_playlist, "vlc:loop",
428                       PLAYLIST_APPEND | PLAYLIST_GO,
429                       PLAYLIST_END );
430     }
431     p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
432 }
433
434
435     /* playback control */
436 void Intf_VLCWrapper::playSlower()
437 {
438     if( p_intf->p_sys->p_input != NULL )
439     {
440         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
441     }
442     if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
443     {
444         toggle_mute(  );
445     }
446     else
447     {
448         toggle_mute ( );
449     }
450 }
451
452 void Intf_VLCWrapper::playFaster()
453 {
454     if( p_intf->p_sys->p_input != NULL )
455     {
456         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
457     }
458     if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
459     {
460         toggle_mute(  );
461     }
462     else
463     {
464         toggle_mute ( );
465     }
466 }
467
468 void Intf_VLCWrapper::volume_mute()
469 {
470     p_intf->p_sys->p_aout =
471         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
472                                            FIND_ANYWHERE );
473     if( p_intf->p_sys->p_aout != NULL )
474     {
475             if( !p_intf->p_sys->b_mute )
476                 {
477                     p_intf->p_sys->i_saved_volume = p_intf->p_sys->p_aout->output.i_volume;
478                     p_intf->p_sys->p_aout->output.i_volume = 0;
479                     p_intf->p_sys->b_mute = 1;
480                 }
481     }
482
483 }
484
485 void Intf_VLCWrapper::volume_restore()
486 {
487     p_intf->p_sys->p_aout =
488         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
489                                             FIND_ANYWHERE );
490     if( p_intf->p_sys->p_aout != NULL )
491     {
492             p_intf->p_sys->p_aout->output.i_volume = p_intf->p_sys->i_saved_volume;
493                 p_intf->p_sys->i_saved_volume = 0;
494             p_intf->p_sys->b_mute = 0;
495     }
496
497 }
498
499 void Intf_VLCWrapper::set_volume(int value)
500 {
501     p_intf->p_sys->p_aout =
502         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
503                                             FIND_ANYWHERE );
504     if( p_intf->p_sys->p_aout != NULL )
505     {
506                 // make sure value is within bounds
507                 if (value < 0)
508                         value = 0;
509                 if (value > AOUT_VOLUME_MAX)
510                         value = AOUT_VOLUME_MAX;
511                 vlc_mutex_lock( &p_intf->p_sys->p_aout->mixer_lock );
512                 // unmute volume if muted
513                 if ( p_intf->p_sys->b_mute )
514                 {
515                         p_intf->p_sys->b_mute = 0;
516             p_intf->p_sys->p_aout->output.i_volume = value;
517                 }
518                 vlc_mutex_unlock( &p_intf->p_sys->p_aout->mixer_lock );
519     }
520 }
521
522 void Intf_VLCWrapper::toggle_mute()
523 {
524     p_intf->p_sys->p_aout =
525         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
526                                             FIND_ANYWHERE );
527     if( p_intf->p_sys->p_aout != NULL )
528         {
529             if ( p_intf->p_sys->b_mute )
530             {
531                 volume_restore();
532             }
533             else
534             {
535                 volume_mute();
536             }
537         }
538 }
539
540 bool Intf_VLCWrapper::is_muted()
541 {
542         bool muted = true;
543         
544     p_intf->p_sys->p_aout =
545         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
546                                             FIND_ANYWHERE );
547     if( p_intf->p_sys->p_aout != NULL )
548         {
549                 vlc_mutex_lock( &p_intf->p_sys->p_aout->mixer_lock );
550                 if( p_intf->p_sys->p_aout->output.i_volume > 0 )
551                 {
552                         muted = false;
553                 }
554                 vlc_mutex_unlock( &p_intf->p_sys->p_aout->mixer_lock );
555 // unfortunately, this is not reliable!
556 //              return p_main->p_intf->p_sys->b_mute;
557         }
558         return muted;
559 }
560
561 bool Intf_VLCWrapper::is_playing()
562 {
563
564         bool playing = false;
565         if ( p_intf->p_sys->p_input )
566         {
567                 switch ( p_intf->p_sys->p_input->stream.control.i_status )
568                 {
569                         case PLAYING_S:
570                         case FORWARD_S:
571                         case BACKWARD_S:
572                         case START_S:
573                                 playing = true;
574                     break;
575                         case PAUSE_S:
576                         case UNDEF_S:
577                         case NOT_STARTED_S:
578                         default:
579                                 break;
580                 }
581         }
582         return playing;
583
584 }
585
586 void Intf_VLCWrapper::maxvolume()
587 {
588     p_intf->p_sys->p_aout =
589         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
590                                             FIND_ANYWHERE );
591     if( p_intf->p_sys->p_aout != NULL )
592     {
593             if( p_intf->p_sys->b_mute )
594             {
595                 p_intf->p_sys->i_saved_volume = AOUT_VOLUME_MAX;
596             }
597             else
598             {
599                 p_intf->p_sys->p_aout->output.i_volume = AOUT_VOLUME_MAX;
600             }
601     }
602 }
603
604 bool Intf_VLCWrapper::has_audio()
605 {
606     p_intf->p_sys->p_aout =
607         (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
608                                             FIND_ANYWHERE );
609     return( p_intf->p_sys->p_aout != NULL );
610 }
611
612 //void Intf_VLCWrapper::fullscreen()
613 //{
614 //    if( p_vout_bank->pp_vout[0] != NULL )
615 //    {
616 //        p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
617 //    }
618 //}
619
620 void Intf_VLCWrapper::eject(){}
621
622     /* playback info */
623
624 const char*  Intf_VLCWrapper::getTimeAsString()
625 {
626     static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
627         
628     if( p_intf->p_sys->p_input == NULL )
629     {
630         return ("-:--:--");
631     }     
632    
633     input_OffsetToTime( p_intf->p_sys->p_input, 
634                         psz_currenttime, 
635                         p_intf->p_sys->p_input->stream.p_selected_area->i_tell );        
636
637     return(psz_currenttime);
638 }
639
640 float  Intf_VLCWrapper::getTimeAsFloat()
641 {
642     float f_time = 0.0;
643
644     if( p_intf->p_sys->p_input != NULL )
645     {
646         f_time = (float)p_intf->p_sys->p_input->stream.p_selected_area->i_tell / 
647                  (float)p_intf->p_sys->p_input->stream.p_selected_area->i_size;
648     }    
649     else
650     {
651         f_time = 0.0;
652     }
653     return( f_time );
654 }
655
656 void   Intf_VLCWrapper::setTimeAsFloat(float f_position)
657 {
658     if( p_intf->p_sys->p_input != NULL )
659     {
660         input_Seek( p_intf->p_sys->p_input, 
661                    (long long int)(p_intf->p_sys->p_input->stream.p_selected_area->i_size
662                        * f_position / SEEKSLIDER_RANGE ), 
663                    INPUT_SEEK_SET);
664     }
665 }
666
667 /* bool   Intf_VLCWrapper::playlistPlaying()
668
669     return( !p_intf->p_sys->p_playlist->b_stopped );
670 } */
671
672 BList  *Intf_VLCWrapper::playlistAsArray()
673
674     int i;
675     playlist_t *p_playlist = 
676                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
677                                                        FIND_ANYWHERE );
678
679     BList* p_list = new BList(p_playlist->i_size);
680     
681     vlc_mutex_lock( &p_playlist->object_lock );
682
683     for( i = 0; i < p_playlist->i_size; i++ )
684     {
685         p_list->AddItem(new BString(p_playlist->pp_items[i]->psz_name));
686     }
687
688     vlc_mutex_unlock( &p_playlist->object_lock );
689     vlc_object_release( p_playlist );
690     return( p_list );
691 }
692
693 // getPlaylistInfo
694 void
695 Intf_VLCWrapper::getPlaylistInfo( int32& currentIndex, int32& maxIndex )
696 {
697         currentIndex = -1;
698         maxIndex = -1;
699         if ( playlist_t* list = (playlist_t*)p_intf->p_sys->p_playlist )
700         {
701                 maxIndex = list->i_size;
702                 if ( maxIndex > 0 )
703                         currentIndex = list->i_index + 1;
704                 else
705                         maxIndex = -1;
706         }
707 }
708
709 // getTitleInfo
710 void  
711 Intf_VLCWrapper::getTitleInfo( int32& currentIndex, int32& maxIndex )
712 {
713         currentIndex = -1;
714         maxIndex = -1;
715         if ( input_thread_t* input = p_intf->p_sys->p_input )
716         {
717                 vlc_mutex_lock( &input->stream.stream_lock );
718
719                 maxIndex = input->stream.i_area_nb - 1;
720                 if ( maxIndex > 0)
721                         currentIndex = input->stream.p_selected_area->i_id;
722                 else
723                         maxIndex = -1;
724
725                 vlc_mutex_unlock( &input->stream.stream_lock );
726         }
727 }
728
729 // getChapterInfo
730 void
731 Intf_VLCWrapper::getChapterInfo( int32& currentIndex, int32& maxIndex )
732 {
733         currentIndex = -1;
734         maxIndex = -1;
735         if ( input_thread_t* input = p_intf->p_sys->p_input )
736         {
737                 vlc_mutex_lock( &input->stream.stream_lock );
738
739                 maxIndex = input->stream.p_selected_area->i_part_nb - 1;
740                 if ( maxIndex > 0)
741                         currentIndex = input->stream.p_selected_area->i_part;
742                 else
743                         maxIndex = -1;
744
745                 vlc_mutex_unlock( &input->stream.stream_lock );
746         }
747 }
748
749     /* open file/disc/network */
750 void Intf_VLCWrapper::openFiles( BList* o_files, bool replace )
751 {
752     BString *o_file;
753     playlist_t *p_playlist = p_intf->p_sys->p_playlist;
754
755     while( ( o_file = (BString *)o_files->LastItem() ) )
756     {
757         o_files->RemoveItem(o_files->CountItems() - 1);
758         playlist_Add( p_playlist, o_file->String(),
759                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
760         delete o_file;
761     }
762
763     vlc_object_release( p_playlist );
764 }
765
766 void Intf_VLCWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_chapter)
767 {
768     BString o_source("");
769     o_source << o_type << ":" << o_device ;
770
771     playlist_t *p_playlist = 
772                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
773                                                       FIND_ANYWHERE );
774     playlist_Add( p_playlist, o_source.String(),
775                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
776     vlc_object_release( p_playlist );
777 }
778
779 void Intf_VLCWrapper::openNet(BString o_addr, int i_port)
780 {
781 }
782
783 void Intf_VLCWrapper::openNetChannel(BString o_addr, int i_port)
784 {
785 }
786
787 void Intf_VLCWrapper::openNetHTTP(BString o_addr)
788 {
789 }
790
791
792     /* menus management */
793 void Intf_VLCWrapper::toggleProgram(int i_program){}
794
795 void Intf_VLCWrapper::toggleTitle(int i_title)
796 {
797     if( p_intf->p_sys->p_input != NULL )
798     {
799         input_ChangeArea( p_intf->p_sys->p_input,
800                           p_intf->p_sys->p_input->stream.pp_areas[i_title] );
801
802         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
803         //setupMenus();
804
805         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
806     }
807 }
808
809 void Intf_VLCWrapper::toggleChapter(int i_chapter)
810 {
811     if( p_intf->p_sys->p_input != NULL )
812     {
813         p_intf->p_sys->p_input->stream.p_selected_area->i_part = i_chapter;
814         input_ChangeArea( p_intf->p_sys->p_input,
815                           p_intf->p_sys->p_input->stream.p_selected_area );
816
817         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
818 //        setupMenus();
819         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
820     }
821 }
822
823 void Intf_VLCWrapper::toggleLanguage(int i_language)
824 {
825
826     int32 i_old = -1;
827     int i_cat = AUDIO_ES;
828
829     vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
830     for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
831     {
832         if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
833         {
834             i_old = i;
835             break;
836         }
837     }
838     vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
839
840     msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_language);
841     if( i_language != -1 )
842     {
843         input_ToggleES( p_intf->p_sys->p_input, 
844                         p_intf->p_sys->p_input->stream.pp_selected_es[i_language],
845                         VLC_TRUE );
846     }
847
848     if( (i_old != -1) && (i_old != i_language) )
849     {
850         input_ToggleES( p_intf->p_sys->p_input, 
851                         p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
852                         VLC_FALSE );
853     }
854 }
855
856 void Intf_VLCWrapper::toggleSubtitle(int i_subtitle)
857 {
858     int32 i_old = -1;
859     int i_cat = SPU_ES;
860
861     vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
862     for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
863     {
864         if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
865         {
866             i_old = i;
867             break;
868         }
869     }
870     vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
871     
872     msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_subtitle);
873     if( i_subtitle != -1 )
874     {
875         input_ToggleES( p_intf->p_sys->p_input, 
876                         p_intf->p_sys->p_input->stream.pp_selected_es[i_subtitle],
877                         VLC_TRUE );
878     }
879
880     if( (i_old != -1) && (i_old != i_subtitle) )
881     {
882         input_ToggleES( p_intf->p_sys->p_input, 
883                         p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
884                         VLC_FALSE );
885     }
886 }
887
888
889 void Intf_VLCWrapper::setupMenus(){}
890 int  Intf_VLCWrapper::inputGetStatus() {}