]> git.sesse.net Git - vlc/blob - modules/gui/beos/VlcWrapper.cpp
enabled changing filters on the fly
[vlc] / modules / gui / beos / VlcWrapper.cpp
1 /*****************************************************************************
2  * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: VlcWrapper.cpp,v 1.23 2003/01/29 00:02:09 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  *          Eric Petit <titer@videolan.org>
12  *
13  * This program is free software{} you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation{} either version 2 of the License, or
16  * (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY{} without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program{} if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
26  *****************************************************************************/
27 #include <AppKit.h>
28 #include <InterfaceKit.h>
29 #include <SupportKit.h>
30
31 #include <vlc/vlc.h>
32 #include <vlc/intf.h>
33 #include <vlc/vout.h>
34 extern "C"
35 {
36   #include <audio_output.h>
37   #include <aout_internal.h>
38 }
39
40 #include "VlcWrapper.h"
41 #include "MsgVals.h"
42
43 /* constructor */
44 VlcWrapper::VlcWrapper( intf_thread_t *p_interface )
45 {
46     p_intf = p_interface;
47     p_input = NULL;
48     p_aout = NULL;
49     p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
50                                                 FIND_ANYWHERE );
51 }
52
53 /* destructor */
54 VlcWrapper::~VlcWrapper()
55 {
56     if( p_input )
57     {
58         vlc_object_release( p_input );
59     }
60     if( p_playlist )
61     {
62         vlc_object_release( p_playlist );
63     }
64     if( p_aout )
65     {
66         vlc_object_release( p_aout );
67     }
68 }
69
70 /* UpdateInputAndAOut: updates p_input and p_aout, returns true if the
71    interface needs to be updated */
72 bool VlcWrapper::UpdateInputAndAOut()
73 {
74     if( p_input == NULL )
75     {
76         p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
77                                                      FIND_ANYWHERE );
78     }
79     if( p_aout == NULL )
80     {
81         p_aout = (aout_instance_t*)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
82                                                     FIND_ANYWHERE );
83     }
84         
85     if( p_input != NULL )
86     {
87         if( p_input->b_dead )
88         {
89             vlc_object_release( p_input );
90             p_input = NULL;
91             
92             if( p_aout )
93             {
94                 vlc_object_release( p_aout );
95                 p_aout = NULL;
96             }
97         }
98         return true;
99     }
100     return false;
101 }
102
103
104 /***************************
105  * input infos and control *
106  ***************************/
107
108 bool VlcWrapper::HasInput()
109 {
110     return ( p_input != NULL );
111 }
112
113 int VlcWrapper::InputStatus()
114 {
115     if( !p_input )
116     {
117         return UNDEF_S;
118     }
119     return p_input->stream.control.i_status;
120 }
121
122 int VlcWrapper::InputRate()
123 {
124     if( !p_input )
125     {
126         return DEFAULT_RATE;
127     }
128     return p_input->stream.control.i_rate;
129 }
130
131 void VlcWrapper::InputSlower()
132 {
133     if( p_input != NULL )
134     {
135         input_SetStatus( p_input, INPUT_STATUS_SLOWER );
136     }
137 }
138
139 void VlcWrapper::InputFaster()
140 {
141     if( p_input != NULL )
142     {
143         input_SetStatus( p_input, INPUT_STATUS_FASTER );
144     }
145 }
146
147 BList * VlcWrapper::GetChannels( int i_cat )
148 {
149     if( p_input )
150     {
151         unsigned int i;
152         uint32 what;
153         const char* fieldName;
154
155         switch( i_cat )
156         {
157             case AUDIO_ES:
158             {
159                 what = SELECT_CHANNEL;
160                 fieldName = "channel";
161                 break;
162             }
163             case SPU_ES:
164             {
165                 what = SELECT_SUBTITLE;
166                 fieldName = "subtitle";
167                 break;
168             }
169             default:
170             return NULL;
171        }
172
173         vlc_mutex_lock( &p_input->stream.stream_lock );
174       
175         /* find which track is currently playing */
176         es_descriptor_t *p_es = NULL;
177         for( i = 0; i < p_input->stream.i_selected_es_number; i++ )
178         {
179             if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
180                 p_es = p_input->stream.pp_selected_es[i];
181         }
182         
183         /* build a list of all tracks */
184         BList *list = new BList( p_input->stream.i_es_number );
185         BMenuItem *menuItem;
186         BMessage *message;
187         char *trackName;
188         
189         /* "None" */
190         message = new BMessage( what );
191         message->AddInt32( fieldName, -1 );
192         menuItem = new BMenuItem( "None", message );
193         if( !p_es )
194             menuItem->SetMarked( true );
195         list->AddItem( menuItem );
196         
197         for( i = 0; i < p_input->stream.i_es_number; i++ )
198         {
199             if( p_input->stream.pp_es[i]->i_cat == i_cat )
200             {
201                 message = new BMessage( what );
202                 message->AddInt32( fieldName, i );
203                 if( strlen( p_input->stream.pp_es[i]->psz_desc ) )
204                     trackName = strdup( p_input->stream.pp_es[i]->psz_desc );
205                 else
206                     trackName = "<unknown>";
207                 menuItem = new BMenuItem( trackName, message );
208                 if( p_input->stream.pp_es[i] == p_es )
209                     menuItem->SetMarked( true );
210                 list->AddItem( menuItem );
211             }
212         }
213         
214         vlc_mutex_unlock( &p_input->stream.stream_lock );
215
216         return list;
217     }
218     return NULL;
219 }
220
221 void VlcWrapper::ToggleLanguage( int i_language )
222 {
223     es_descriptor_t * p_es = NULL;
224     es_descriptor_t * p_es_old = NULL;
225
226     vlc_mutex_lock( &p_input->stream.stream_lock );
227     for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
228     {
229         if( p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
230         {
231             p_es_old = p_input->stream.pp_selected_es[i];
232             break;
233         }
234     }
235     vlc_mutex_unlock( &p_input->stream.stream_lock );
236     
237     if( i_language != -1 )
238     {
239         p_es = p_input->stream.pp_es[i_language];
240     }
241     if( p_es == p_es_old )
242     {
243         return;
244     }
245     if( p_es_old )
246     {
247         input_ToggleES( p_input, p_es_old, VLC_FALSE );
248     }
249     if( p_es )
250     {
251         input_ToggleES( p_input, p_es, VLC_TRUE );
252     }
253 }
254
255 void VlcWrapper::ToggleSubtitle( int i_subtitle )
256 {
257     es_descriptor_t * p_es = NULL;
258     es_descriptor_t * p_es_old = NULL;
259
260     vlc_mutex_lock( &p_input->stream.stream_lock );
261     for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
262     {
263         if( p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
264         {
265             p_es_old = p_input->stream.pp_selected_es[i];
266             break;
267         }
268     }
269     vlc_mutex_unlock( &p_input->stream.stream_lock );
270     
271     if( i_subtitle != -1 )
272     {
273         p_es = p_input->stream.pp_es[i_subtitle];
274     }
275     if( p_es == p_es_old )
276     {
277         return;
278     }
279     if( p_es_old )
280     {
281         input_ToggleES( p_input, p_es_old, VLC_FALSE );
282     }
283     if( p_es )
284     {
285         input_ToggleES( p_input, p_es, VLC_TRUE );
286     }
287 }
288
289 const char * VlcWrapper::GetTimeAsString()
290 {
291     static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
292         
293     if( p_input == NULL )
294     {
295         return ("-:--:--");
296     }     
297    
298     input_OffsetToTime( p_input, 
299                         psz_currenttime, 
300                         p_input->stream.p_selected_area->i_tell );        
301
302     return(psz_currenttime);
303 }
304
305 float VlcWrapper::GetTimeAsFloat()
306 {
307     float f_time = 0.0;
308
309     if( p_input != NULL )
310     {
311         f_time = (float)p_input->stream.p_selected_area->i_tell / 
312                  (float)p_input->stream.p_selected_area->i_size;
313     }    
314     else
315     {
316         f_time = 0.0;
317     }
318     return( f_time );
319 }
320
321 void VlcWrapper::SetTimeAsFloat( float f_position )
322 {
323     if( p_input != NULL )
324     {
325         input_Seek( p_input, 
326                    (long long int)(p_input->stream.p_selected_area->i_size
327                        * f_position / SEEKSLIDER_RANGE ), 
328                    INPUT_SEEK_SET);
329     }
330 }
331
332 bool VlcWrapper::IsPlaying()
333 {
334
335         bool playing = false;
336         if ( p_input )
337         {
338                 switch ( p_input->stream.control.i_status )
339                 {
340                         case PLAYING_S:
341                         case FORWARD_S:
342                         case BACKWARD_S:
343                         case START_S:
344                                 playing = true;
345                     break;
346                         case PAUSE_S:
347                         case UNDEF_S:
348                         case NOT_STARTED_S:
349                         default:
350                                 break;
351                 }
352         }
353         return playing;
354
355 }
356
357 /************
358  * playlist *
359  ************/
360
361 void VlcWrapper::OpenFiles( BList* o_files, bool replace )
362 {
363     BString *o_file;
364     int size = PlaylistSize();
365         bool wasEmpty = ( size < 1 );
366
367     /* delete current playlist */
368     if( replace )
369     {
370         for( int i = 0; i < size; i++ )
371         {
372             playlist_Delete( p_playlist, 0 );
373         }
374     }
375
376     /* append files */
377     while( ( o_file = (BString *)o_files->LastItem() ) )
378     {
379         playlist_Add( p_playlist, o_file->String(),
380                       PLAYLIST_APPEND, PLAYLIST_END );
381         o_files->RemoveItem(o_files->CountItems() - 1);
382     }
383     
384     /* eventually restart playing */
385     if( replace || wasEmpty )
386     {
387         playlist_Stop( p_playlist );
388         playlist_Play( p_playlist );
389     }
390 }
391  
392 void VlcWrapper::OpenDisc(BString o_type, BString o_device, int i_title, int i_chapter)
393 {
394     if( p_intf->p_sys->b_dvdmenus )
395         o_device.Prepend( "dvd:" );
396     else
397         o_device.Prepend( "dvdold:" );
398     playlist_Add( p_playlist, o_device.String(),
399                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
400 }
401
402 int VlcWrapper::PlaylistSize()
403 {
404     vlc_mutex_lock( &p_playlist->object_lock );
405     int i_size = p_playlist->i_size;
406     vlc_mutex_unlock( &p_playlist->object_lock );
407     return i_size;
408 }
409
410 char * VlcWrapper::PlaylistItemName( int i )
411 {
412    return p_playlist->pp_items[i]->psz_name;
413 }
414
415 int VlcWrapper::PlaylistCurrent()
416 {
417     return p_playlist->i_index;
418 }
419
420 bool VlcWrapper::PlaylistPlay()
421 {
422     if( PlaylistSize() )
423     {
424         playlist_Play( p_playlist );
425     }
426     return( true );
427 }
428
429 void VlcWrapper::PlaylistPause()
430 {
431     if( p_input )
432     {
433         input_SetStatus( p_input, INPUT_STATUS_PAUSE );
434     }
435 }
436
437 void VlcWrapper::PlaylistStop()
438 {
439     playlist_Stop( p_playlist );
440 }
441
442 void VlcWrapper::PlaylistNext()
443 {
444     playlist_Next( p_playlist );
445 }
446
447 void VlcWrapper::PlaylistPrev()
448 {
449     playlist_Prev( p_playlist );
450 }
451
452 void VlcWrapper::GetPlaylistInfo( int32& currentIndex, int32& maxIndex )
453 {
454         currentIndex = -1;
455         maxIndex = -1;
456         if ( p_playlist )
457         {
458                 maxIndex = p_playlist->i_size;
459                 if ( maxIndex > 0 )
460                         currentIndex = p_playlist->i_index + 1;
461                 else
462                         maxIndex = -1;
463         }
464 }
465
466 void VlcWrapper::PlaylistJumpTo( int pos )
467 {
468     playlist_Goto( p_playlist, pos );
469 }
470
471 void VlcWrapper::GetNavCapabilities( bool *canSkipPrev, bool *canSkipNext )
472 {
473         if ( canSkipPrev && canSkipNext )
474         {
475                 // init the parameters
476                 *canSkipPrev = false;
477                 *canSkipNext = false;
478                 // get playlist info
479                 int pos = PlaylistCurrent();
480                 int size = PlaylistSize();
481
482                 // see if we have got a stream going            
483                 if ( p_input )
484                 {
485                         vlc_mutex_lock( &p_input->stream.stream_lock );
486
487                         bool hasTitles = p_input->stream.i_area_nb > 1;
488                         int numChapters = p_input->stream.p_selected_area->i_part_nb;
489                         bool hasChapters = numChapters > 1;
490                         // first, look for chapters
491                         if ( hasChapters )
492                         {
493                                 *canSkipPrev = p_input->stream.p_selected_area->i_part > 0;
494                                 *canSkipNext = p_input->stream.p_selected_area->i_part <
495                                                                          p_input->stream.p_selected_area->i_part_nb - 1;
496                         }
497                         // if one of the skip capabilities is false,
498                         // make it depend on titles instead
499                         if ( !*canSkipPrev && hasTitles )
500                                 *canSkipPrev = p_input->stream.p_selected_area->i_id > 1;
501                         if ( !*canSkipNext && hasTitles )
502                                 *canSkipNext = p_input->stream.p_selected_area->i_id <
503                                                    p_input->stream.i_area_nb - 1;
504
505                         vlc_mutex_unlock( &p_input->stream.stream_lock );
506                 }
507                 // last but not least, make capabilities depend on playlist
508                 if ( !*canSkipPrev )
509                         *canSkipPrev = pos > 0;
510                 if ( !*canSkipNext )
511                         *canSkipNext = pos < size - 1;
512         }
513 }
514
515 void VlcWrapper::NavigatePrev()
516 {
517         bool hasSkiped = false;
518
519         // see if we have got a stream going            
520         if ( p_input )
521         {
522                 // get information from stream (lock it while looking at it)
523                 vlc_mutex_lock( &p_input->stream.stream_lock );
524
525                 int currentTitle = p_input->stream.p_selected_area->i_id;
526                 int currentChapter = p_input->stream.p_selected_area->i_part;
527                 int numTitles = p_input->stream.i_area_nb;
528                 bool hasTitles = numTitles > 1;
529                 int numChapters = p_input->stream.p_selected_area->i_part_nb;
530                 bool hasChapters = numChapters > 1;
531
532                 vlc_mutex_unlock( &p_input->stream.stream_lock );
533
534                 // first, look for chapters
535                 if ( hasChapters )
536                 {
537                         // skip to the previous chapter
538                         currentChapter--;
539
540                         if ( currentChapter >= 0 )
541                         {
542                                 ToggleChapter( currentChapter );
543                                 hasSkiped = true;
544                         }
545                 }
546                 // if we couldn't skip chapters, try titles instead
547                 if ( !hasSkiped && hasTitles )
548                 {
549                         // skip to the previous title
550                         currentTitle--;
551                         // disallow area 0 since it is used for video_ts.vob
552                         if( currentTitle > 0 )
553                         {
554                                 ToggleTitle(currentTitle);
555                                 hasSkiped = true;
556                         }
557                 }
558
559         }
560         // last but not least, skip to previous file
561         if ( !hasSkiped )
562                 PlaylistPrev();
563 }
564
565 void VlcWrapper::NavigateNext()
566 {
567         bool hasSkiped = false;
568
569         // see if we have got a stream going            
570         if ( p_input )
571         {
572                 // get information from stream (lock it while looking at it)
573                 vlc_mutex_lock( &p_input->stream.stream_lock );
574
575                 int currentTitle = p_input->stream.p_selected_area->i_id;
576                 int currentChapter = p_input->stream.p_selected_area->i_part;
577                 int numTitles = p_input->stream.i_area_nb;
578                 bool hasTitles = numTitles > 1;
579                 int numChapters = p_input->stream.p_selected_area->i_part_nb;
580                 bool hasChapters = numChapters > 1;
581
582                 vlc_mutex_unlock( &p_input->stream.stream_lock );
583
584                 // first, look for chapters
585                 if ( hasChapters )
586                 {
587                         // skip to the next chapter
588                         currentChapter++;
589                         if ( currentChapter < numChapters )
590                         {
591                                 ToggleChapter( currentChapter );
592                                 hasSkiped = true;
593                         }
594                 }
595                 // if we couldn't skip chapters, try titles instead
596                 if ( !hasSkiped && hasTitles )
597                 {
598                         // skip to the next title
599                         currentTitle++;
600                         // disallow area 0 since it is used for video_ts.vob
601                         if ( currentTitle < numTitles - 1 )
602                         {
603                                 ToggleTitle(currentTitle);
604                                 hasSkiped = true;
605                         }
606                 }
607
608         }
609         // last but not least, skip to next file
610         if ( !hasSkiped )
611                 PlaylistNext();
612 }
613
614
615 /*********
616  * audio *
617  *********/
618
619 bool VlcWrapper::HasAudio()
620 {
621     return( p_aout != NULL );
622 }
623
624 unsigned short VlcWrapper::GetVolume()
625 {
626     if( p_aout != NULL )
627     {
628         unsigned short i_volume;
629         aout_VolumeGet( p_aout, (audio_volume_t*)&i_volume );
630         return i_volume;
631     }
632     return 0;
633 }
634
635 void VlcWrapper::SetVolume(int value)
636 {
637     if( p_aout != NULL )
638     {
639                 if ( p_intf->p_sys->b_mute )
640                 {
641                         p_intf->p_sys->b_mute = 0;
642                 }
643         aout_VolumeSet( p_aout, value );
644     }
645 }
646
647 void VlcWrapper::VolumeMute()
648 {
649     if( p_aout != NULL )
650         {
651             aout_VolumeGet( p_aout, &p_intf->p_sys->i_saved_volume );
652             aout_VolumeMute( p_aout, NULL );
653             p_intf->p_sys->b_mute = 1;
654         }
655 }
656
657 void VlcWrapper::VolumeRestore()
658 {
659     if( p_aout != NULL )
660         {
661         aout_VolumeSet( p_aout, p_intf->p_sys->i_saved_volume );
662         p_intf->p_sys->b_mute = 0;
663         }
664 }
665
666 bool VlcWrapper::IsMuted()
667 {
668     return p_intf->p_sys->b_mute;
669 }
670
671 /*******
672  * DVD *
673  *******/
674
675 bool VlcWrapper::HasTitles()
676 {
677     if( !p_input )
678     {
679         return false;
680     }
681     return ( p_input->stream.i_area_nb > 1 );
682 }
683
684 BList * VlcWrapper::GetTitles()
685 {
686     if( p_input )
687     {
688         vlc_mutex_lock( &p_input->stream.stream_lock );
689       
690         BList *list = new BList( p_input->stream.i_area_nb );
691         BMenuItem *menuItem;
692         BMessage *message;
693         
694         for( unsigned int i = 1; i < p_input->stream.i_area_nb; i++ )
695         {
696             message = new BMessage( TOGGLE_TITLE );
697             message->AddInt32( "index", i );
698             BString helper( "" );
699             helper << i;
700             menuItem = new BMenuItem( helper.String(), message );
701             menuItem->SetMarked( p_input->stream.p_selected_area->i_id == i );
702             list->AddItem( menuItem );
703         }
704         
705         vlc_mutex_unlock( &p_input->stream.stream_lock );
706
707         return list;
708     }
709     return NULL;
710 }
711
712 void VlcWrapper::PrevTitle()
713 {
714     int i_id;
715     i_id = p_input->stream.p_selected_area->i_id - 1;
716     if( i_id > 0 )
717     {
718         ToggleTitle(i_id);
719     }
720 }
721
722 void VlcWrapper::NextTitle()
723 {
724     unsigned int i_id;
725     i_id = p_input->stream.p_selected_area->i_id + 1;
726     if( i_id < p_input->stream.i_area_nb )
727     {
728         ToggleTitle(i_id);
729     }
730 }
731
732 void VlcWrapper::ToggleTitle(int i_title)
733 {
734     if( p_input != NULL )
735     {
736         input_ChangeArea( p_input,
737                           p_input->stream.pp_areas[i_title] );
738
739         vlc_mutex_lock( &p_input->stream.stream_lock );
740
741         vlc_mutex_unlock( &p_input->stream.stream_lock );
742     }
743 }
744
745 void VlcWrapper::TitleInfo( int32 &currentIndex, int32 &maxIndex )
746 {
747         currentIndex = -1;
748         maxIndex = -1;
749         if ( p_input )
750         {
751                 vlc_mutex_lock( &p_input->stream.stream_lock );
752
753                 maxIndex = p_input->stream.i_area_nb - 1;
754                 if ( maxIndex > 0)
755                         currentIndex = p_input->stream.p_selected_area->i_id;
756                 else
757                         maxIndex = -1;
758
759                 vlc_mutex_unlock( &p_input->stream.stream_lock );
760         }
761 }
762
763 bool VlcWrapper::HasChapters()
764 {
765     if( !p_input )
766     {
767         return false;
768     }
769     return ( p_input->stream.p_selected_area->i_part_nb > 1 );
770 }
771
772 BList * VlcWrapper::GetChapters()
773 {
774     if( p_input )
775     {
776         vlc_mutex_lock( &p_input->stream.stream_lock );
777       
778         BList *list = new BList( p_input->stream.p_selected_area->i_part_nb );
779         BMenuItem *menuItem;
780         BMessage *message;
781         
782         for( unsigned int i = 1;
783              i < p_input->stream.p_selected_area->i_part_nb + 1; i++ )
784         {
785             message = new BMessage( TOGGLE_CHAPTER );
786             message->AddInt32( "index", i );
787             BString helper( "" );
788             helper << i;
789             menuItem = new BMenuItem( helper.String(), message );
790             menuItem->SetMarked( p_input->stream.p_selected_area->i_part == i );
791             list->AddItem( menuItem );
792         }
793         
794         vlc_mutex_unlock( &p_input->stream.stream_lock );
795
796         return list;
797     }
798     return NULL;
799 }
800
801 void VlcWrapper::PrevChapter()
802 {
803     int i_id;
804     i_id = p_input->stream.p_selected_area->i_part - 1;
805     if( i_id >= 0 )
806     {
807         ToggleChapter(i_id);
808     }
809 }
810
811 void VlcWrapper::NextChapter()
812 {
813     int i_id;
814     i_id = p_input->stream.p_selected_area->i_part + 1;
815     if( i_id >= 0 )
816     {
817         ToggleChapter(i_id);
818     }
819 }
820
821 void VlcWrapper::ToggleChapter(int i_chapter)
822 {
823     if( p_input != NULL )
824     {
825         p_input->stream.p_selected_area->i_part = i_chapter;
826         input_ChangeArea( p_input,
827                           p_input->stream.p_selected_area );
828
829         vlc_mutex_lock( &p_input->stream.stream_lock );
830         vlc_mutex_unlock( &p_input->stream.stream_lock );
831     }
832 }
833
834 void VlcWrapper::ChapterInfo( int32 &currentIndex, int32 &maxIndex )
835 {
836         currentIndex = -1;
837         maxIndex = -1;
838         if ( p_input )
839         {
840                 vlc_mutex_lock( &p_input->stream.stream_lock );
841
842                 maxIndex = p_input->stream.p_selected_area->i_part_nb - 1;
843                 if ( maxIndex > 0)
844                         currentIndex = p_input->stream.p_selected_area->i_part;
845                 else
846                         maxIndex = -1;
847
848                 vlc_mutex_unlock( &p_input->stream.stream_lock );
849         }
850 }
851
852 /****************
853  * Miscellanous *
854  ****************/
855  
856 void VlcWrapper::LoadSubFile( char * psz_file )
857 {
858     config_PutPsz( p_intf, "sub-file", strdup( psz_file ) );
859 }
860
861 void VlcWrapper::FilterChange()
862 {
863     if( !p_input )
864         return;
865     
866     vout_thread_t * p_vout;
867     vlc_mutex_lock( &p_input->stream.stream_lock );
868
869     /* Warn the vout we are about to change the filter chain */
870     p_vout = (vout_thread_t*)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
871                                               FIND_ANYWHERE );
872     if( p_vout )
873     {
874         p_vout->b_filter_change = VLC_TRUE;
875         vlc_object_release( p_vout );
876     }
877
878     /* restart all video stream */
879     for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ )
880     {
881         if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) &&
882             ( p_input->stream.pp_es[i]->p_decoder_fifo != NULL ) )
883         {
884             input_UnselectES( p_input, p_input->stream.pp_es[i] );
885             input_SelectES( p_input, p_input->stream.pp_es[i] );
886         }
887     }
888     vlc_mutex_unlock( &p_input->stream.stream_lock );
889 }