VlcWrapper.cpp 22.5 KB
Newer Older
1
/*****************************************************************************
2
 * intf_vlc_wrapper.h: BeOS plugin for vlc (derived from MacOS X port )
3
4
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
Eric Petit's avatar
Eric Petit committed
5
 * $Id: VlcWrapper.cpp,v 1.7 2002/10/28 19:42:24 titer Exp $
6
7
8
9
 *
 * Authors: Florian G. Pflug <fgp@phlo.org>
 *          Jon Lech Johansen <jon-vl@nanocrew.net>
 *          Tony Casltey <tony@castley.net>
10
 *          Stephan Aßmus <stippi@yellowbites.com>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 *
 * This program is free software{} you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation{} either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY{} without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program{} if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/
/* VLC headers */
#include <SupportKit.h>

#include <vlc/vlc.h>
#include <vlc/intf.h>
31
32
#include <audio_output.h>
#include <aout_internal.h>
33

34
#include "VlcWrapper.h"
35

36
Intf_VLCWrapper *Intf_VLCWrapper::getVLCWrapper(intf_thread_t *p_interface)
37
38
39
40
{
    static Intf_VLCWrapper *one_wrapper;
    if (one_wrapper == NULL )
    {
41
       one_wrapper = new Intf_VLCWrapper(p_interface);
42
43
44
45
    }
    return one_wrapper;
}

46
Intf_VLCWrapper::Intf_VLCWrapper(intf_thread_t *p_interface)
47
{
48
    p_intf = p_interface;
49
50
51
52
53
54
}

Intf_VLCWrapper::~Intf_VLCWrapper()
{
}

55
56
57
#if 0
bool Intf_VLCWrapper::manage()
{
58
   /* p_main->p_intf->pf_manage( p_intf ); */
59
   
60
   if ( p_intf->b_die )
61
62
63
64
65
   {
       // exit the lot
       return( 1 );
   }
   
66
   if ( p_intf->p_sys->p_input != NULL )
67
   {
68
69
       vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
        if( !p_intf->p_sys->p_input->b_die )
70
71
        {
            /* New input or stream map change */
72
73
74
            if( p_intf->p_sys->p_input->stream.b_changed ||
                p_intf->p_sys->i_part !=
                    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
88
89
    }
    return( 0 );
}
#endif
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

void Intf_VLCWrapper::quit()
{
    p_intf->b_die = 1;
}
    
/* playlist control */
bool Intf_VLCWrapper::playlistPlay()
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_playlist->i_size )
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        playlist_Play( p_playlist );
        vlc_object_release( p_playlist );
    }
    else
    {
        vlc_mutex_unlock( &p_playlist->object_lock );
        vlc_object_release( p_playlist );
    }

    return( true );
}

void Intf_VLCWrapper::playlistPause()
{
121
    toggle_mute(  );
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );
    playlist_Pause( p_playlist );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::playlistStop()
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    playlist_Stop( p_playlist );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::playlistNext()
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    playlist_Next( p_playlist );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::playlistPrev()
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    playlist_Prev( p_playlist );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::playlistSkip(int i)
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    playlist_Skip( p_playlist, i );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::playlistGoto(int i)
{
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    playlist_Goto( p_playlist, i );
    vlc_object_release( p_playlist );
}

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
void Intf_VLCWrapper::playlistJumpTo( int pos )
{
#if 0
	// sanity checks
	if ( pos < 0 )
		pos = 0;
	int size = playlistSize();
	if (pos >= size)
		pos = size - 1;
	// weird hack
    if( p_input_bank->pp_input[0] != NULL )
		pos--;
	// stop current stream
	playlistStop();
	// modify current position in playlist
	playlistLock();
	p_main->p_playlist->i_index = pos;
	playlistUnlock();
	// start playing
	playlistPlay();
#endif
}

int Intf_VLCWrapper::playlistCurrentPos()
{
204
205
	playlistLock();
	int pos = p_intf->p_sys->p_playlist->i_index;
206
	playlistUnlock();
207
	return pos;
208
209
210
211
}

int Intf_VLCWrapper::playlistSize()
{
212
213
	playlistLock();
	int size = p_intf->p_sys->p_playlist->i_size;
214
	playlistUnlock();
215
	return size;
216
217
218
219
}

void Intf_VLCWrapper::playlistLock()
{
220
	vlc_mutex_lock( &p_intf->p_sys->p_playlist->object_lock );
221
222
223
224
}

void Intf_VLCWrapper::playlistUnlock()
{
225
	vlc_mutex_unlock( &p_intf->p_sys->p_playlist->object_lock );
226
227
228
229
230
231
232
233
234
235
236
237
}

void Intf_VLCWrapper::getNavCapabilities( bool* canSkipPrev,
										  bool* canSkipNext )
{
	if ( canSkipPrev && canSkipNext )
	{
		// init the parameters
		*canSkipPrev = false;
		*canSkipNext = false;
		// get playlist info
		playlistLock();
238
239
		int pos = p_intf->p_sys->p_playlist->i_index;
		int size = p_intf->p_sys->p_playlist->i_size;
240
241
		playlistUnlock();

242
243
		/* input_thread_t* input = p_input_bank->pp_input[0]; */
		input_thread_t* input = p_intf->p_sys->p_input;
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
		// see if we have got a stream going		
		if ( input )
		{
			vlc_mutex_lock( &input->stream.stream_lock );

			bool hasTitles = input->stream.i_area_nb > 1;
			int numChapters = input->stream.p_selected_area->i_part_nb;
			bool hasChapters = numChapters > 1;
			// first, look for chapters
			if ( hasChapters )
			{
				*canSkipPrev = input->stream.p_selected_area->i_part > 0;
				*canSkipNext = input->stream.p_selected_area->i_part <
									 input->stream.p_selected_area->i_part_nb - 1;
			}
			// if one of the skip capabilities is false,
			// make it depend on titles instead
			if ( !*canSkipPrev && hasTitles )
				*canSkipPrev = input->stream.p_selected_area->i_id > 1;
			if ( !*canSkipNext && hasTitles )
				*canSkipNext = input->stream.p_selected_area->i_id < input->stream.i_area_nb - 1;

			vlc_mutex_unlock( &input->stream.stream_lock );
		}
		// last but not least, make capabilities depend on playlist
		if ( !*canSkipPrev )
			*canSkipPrev = pos > 0;
		if ( !*canSkipNext )
			*canSkipNext = pos < size - 1;
	}
}

void Intf_VLCWrapper::navigatePrev()
{
#if 0
	bool hasSkiped = false;

	input_thread_t* input = p_input_bank->pp_input[0];
	// see if we have got a stream going		
	if ( input )
	{
		// get information from stream (lock it while looking at it)
		vlc_mutex_lock( &input->stream.stream_lock );

		int currentTitle = input->stream.p_selected_area->i_id;
		int currentChapter = input->stream.p_selected_area->i_part;
		int numTitles = input->stream.i_area_nb;
		bool hasTitles = numTitles > 1;
		int numChapters = input->stream.p_selected_area->i_part_nb;
		bool hasChapters = numChapters > 1;

		vlc_mutex_unlock( &input->stream.stream_lock );

		// first, look for chapters
		if ( hasChapters )
		{
			// skip to the previous chapter
			currentChapter--;

			if ( currentChapter >= 0 )
			{
				toggleChapter( currentChapter );
				hasSkiped = true;
			}
		}
		// if we couldn't skip chapters, try titles instead
		if ( !hasSkiped && hasTitles )
		{
			// skip to the previous title
			currentTitle--;
			// disallow area 0 since it is used for video_ts.vob
			if( currentTitle > 0 )
			{
				toggleTitle(currentTitle);
				hasSkiped = true;
			}
		}

	}
	// last but not least, skip to previous file
	if ( !hasSkiped )
		playlistPrev();
#endif
}

void Intf_VLCWrapper::navigateNext()
{
#if 0
	bool hasSkiped = false;

	input_thread_t* input = p_input_bank->pp_input[0];
	// see if we have got a stream going		
	if ( input )
	{
		// get information from stream (lock it while looking at it)
		vlc_mutex_lock( &input->stream.stream_lock );

		int currentTitle = input->stream.p_selected_area->i_id;
		int currentChapter = input->stream.p_selected_area->i_part;
		int numTitles = input->stream.i_area_nb;
		bool hasTitles = numTitles > 1;
		int numChapters = input->stream.p_selected_area->i_part_nb;
		bool hasChapters = numChapters > 1;

		vlc_mutex_unlock( &input->stream.stream_lock );

		// first, look for chapters
		if ( hasChapters )
		{
			// skip to the next chapter
			currentChapter++;
			if ( currentChapter < numChapters )
			{
				toggleChapter( currentChapter );
				hasSkiped = true;
			}
		}
		// if we couldn't skip chapters, try titles instead
		if ( !hasSkiped && hasTitles )
		{
			// skip to the next title
			currentTitle++;
			// disallow area 0 since it is used for video_ts.vob
			if ( currentTitle < numTitles - 1 )
			{
				toggleTitle(currentTitle);
				hasSkiped = true;
			}
		}

	}
	// last but not least, skip to next file
	if ( !hasSkiped )
		playlistNext();
#endif
}


//void Intf_VLCWrapper::channelNext()
//{
//    intf_thread_t * p_intf = p_main->p_intf;
//
//    p_intf->p_sys->i_channel++;
//
//    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
//
//    vlc_mutex_lock( &p_intf->change_lock );
//
//    network_ChannelJoin( p_intf->p_sys->i_channel );
//    p_intf->pf_manage( p_intf );
//
//    vlc_mutex_unlock( &p_intf->change_lock );
//}
//
//void Intf_VLCWrapper::channelPrev()
//{
//    intf_thread_t * p_intf = p_main->p_intf;
//
//    if ( p_intf->p_sys->i_channel )
//    {
//        p_intf->p_sys->i_channel--;
//    }
//
//    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
//
//    vlc_mutex_lock( &p_intf->change_lock );
//
//    network_ChannelJoin( p_intf->p_sys->i_channel );
//    p_intf->pf_manage( p_intf );
//
//    vlc_mutex_unlock( &p_intf->change_lock );
//
//}

void Intf_VLCWrapper::loop()
{
    if ( p_intf->p_sys->b_loop )
    {
422
423
        playlist_Delete( p_intf->p_sys->p_playlist,
                         p_intf->p_sys->p_playlist->i_size - 1 );
424
425
426
    }
    else
    {
427
428
429
        playlist_Add( p_intf->p_sys->p_playlist, "vlc:loop",
                      PLAYLIST_APPEND | PLAYLIST_GO,
                      PLAYLIST_END );
430
431
432
433
434
    }
    p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
}


435
436
437
438
439
440
441
442
443
    /* playback control */
void Intf_VLCWrapper::playSlower()
{
    if( p_intf->p_sys->p_input != NULL )
    {
        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
    }
    if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
    {
444
        toggle_mute(  );
445
446
447
    }
    else
    {
448
        toggle_mute ( );
449
450
451
452
453
454
455
456
457
458
459
    }
}

void Intf_VLCWrapper::playFaster()
{
    if( p_intf->p_sys->p_input != NULL )
    {
        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
    }
    if (p_intf->p_sys->p_input->stream.control.i_rate == DEFAULT_RATE)
    {
460
        toggle_mute(  );
461
462
463
    }
    else
    {
464
        toggle_mute ( );
465
466
467
    }
}

468
void Intf_VLCWrapper::volume_mute()
469
{
470
471
472
473
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                           FIND_ANYWHERE );
    if( p_intf->p_sys->p_aout != NULL )
474
    {
475
	    if( !p_intf->p_sys->b_mute )
476
		{
477
478
479
		    p_intf->p_sys->i_saved_volume = p_intf->p_sys->p_aout->output.i_volume;
		    p_intf->p_sys->p_aout->output.i_volume = 0;
		    p_intf->p_sys->b_mute = 1;
480
		}
481
    }
482

483
484
}

485
void Intf_VLCWrapper::volume_restore()
486
{
487
488
489
490
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    if( p_intf->p_sys->p_aout != NULL )
491
    {
492
493
494
	    p_intf->p_sys->p_aout->output.i_volume = p_intf->p_sys->i_saved_volume;
		p_intf->p_sys->i_saved_volume = 0;
	    p_intf->p_sys->b_mute = 0;
495
    }
496

497
498
}

499
void Intf_VLCWrapper::set_volume(int value)
500
{
501
502
503
504
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    if( p_intf->p_sys->p_aout != NULL )
505
    {
506
507
508
509
510
		// make sure value is within bounds
		if (value < 0)
			value = 0;
		if (value > AOUT_VOLUME_MAX)
			value = AOUT_VOLUME_MAX;
511
512
513
514
515
516
517
518
		vlc_mutex_lock( &p_intf->p_sys->p_aout->mixer_lock );
		// unmute volume if muted
		if ( p_intf->p_sys->b_mute )
		{
			p_intf->p_sys->b_mute = 0;
            p_intf->p_sys->p_aout->output.i_volume = value;
		}
		vlc_mutex_unlock( &p_intf->p_sys->p_aout->mixer_lock );
519
    }
520
}
521

522
523
void Intf_VLCWrapper::toggle_mute()
{
524
525
526
527
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    if( p_intf->p_sys->p_aout != NULL )
528
   	{
529
	    if ( p_intf->p_sys->b_mute )
530
	    {
531
	        volume_restore();
532
533
534
	    }
	    else
	    {
535
	        volume_mute();
536
537
	    }
	}
538
539
}

540
bool Intf_VLCWrapper::is_muted()
541
{
542
	bool muted = true;
543
544
545
546
547
	
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    if( p_intf->p_sys->p_aout != NULL )
548
	{
549
550
551
552
553
554
		vlc_mutex_lock( &p_intf->p_sys->p_aout->mixer_lock );
		if( p_intf->p_sys->p_aout->output.i_volume > 0 )
		{
			muted = false;
		}
		vlc_mutex_unlock( &p_intf->p_sys->p_aout->mixer_lock );
555
556
557
558
559
// unfortunately, this is not reliable!
//		return p_main->p_intf->p_sys->b_mute;
	}
	return muted;
}
560

561
562
bool Intf_VLCWrapper::is_playing()
{
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
570
571
572
573
574
575
576
577
578
579
580
581
582
		{
			case PLAYING_S:
			case FORWARD_S:
			case BACKWARD_S:
			case START_S:
				playing = true;
	            break;
			case PAUSE_S:
			case UNDEF_S:
			case NOT_STARTED_S:
			default:
				break;
		}
	}
	return playing;
583

584
}
585

586
587
void Intf_VLCWrapper::maxvolume()
{
588
589
590
591
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    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
598
	    }
	    else
	    {
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
607
608
609
    p_intf->p_sys->p_aout =
        (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
                                            FIND_ANYWHERE );
    return( p_intf->p_sys->p_aout != NULL );
610
611
}

612
613
614
615
616
617
618
//void Intf_VLCWrapper::fullscreen()
//{
//    if( p_vout_bank->pp_vout[0] != NULL )
//    {
//        p_vout_bank->pp_vout[0]->i_changes |= VOUT_FULLSCREEN_CHANGE;
//    }
//}
619
620
621

void Intf_VLCWrapper::eject(){}

622
    /* playback info */
623

Eric Petit's avatar
Eric Petit committed
624
const char*  Intf_VLCWrapper::getTimeAsString()
625
626
627
628
629
{
    static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
        
    if( p_intf->p_sys->p_input == NULL )
    {
Eric Petit's avatar
Eric Petit committed
630
        return ("-:--:--");
631
632
633
634
635
636
    }     
   
    input_OffsetToTime( p_intf->p_sys->p_input, 
                        psz_currenttime, 
                        p_intf->p_sys->p_input->stream.p_selected_area->i_tell );        

Eric Petit's avatar
Eric Petit committed
637
    return(psz_currenttime);
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
}

float  Intf_VLCWrapper::getTimeAsFloat()
{
    float f_time = 0.0;

    if( p_intf->p_sys->p_input != NULL )
    {
        f_time = (float)p_intf->p_sys->p_input->stream.p_selected_area->i_tell / 
                 (float)p_intf->p_sys->p_input->stream.p_selected_area->i_size;
    }    
    else
    {
        f_time = 0.0;
    }
    return( f_time );
}

void   Intf_VLCWrapper::setTimeAsFloat(float f_position)
{
    if( p_intf->p_sys->p_input != NULL )
    {
        input_Seek( p_intf->p_sys->p_input, 
Eric Petit's avatar
Eric Petit committed
661
662
                   (long long int)(p_intf->p_sys->p_input->stream.p_selected_area->i_size
                       * f_position / SEEKSLIDER_RANGE ), 
663
664
665
666
                   INPUT_SEEK_SET);
    }
}

667
/* bool   Intf_VLCWrapper::playlistPlaying()
668
{ 
669
670
    return( !p_intf->p_sys->p_playlist->b_stopped );
} */
671

672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
BList  *Intf_VLCWrapper::playlistAsArray()
{ 
    int i;
    playlist_t *p_playlist = 
                (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                       FIND_ANYWHERE );

    BList* p_list = new BList(p_playlist->i_size);
    
    vlc_mutex_lock( &p_playlist->object_lock );

    for( i = 0; i < p_playlist->i_size; i++ )
    {
        p_list->AddItem(new BString(p_playlist->pp_items[i]->psz_name));
    }

    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
    return( p_list );
}

Eric Petit's avatar
Eric Petit committed
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
// getPlaylistInfo
void
Intf_VLCWrapper::getPlaylistInfo( int32& currentIndex, int32& maxIndex )
{
	currentIndex = -1;
	maxIndex = -1;
	if ( playlist_t* list = (playlist_t*)p_intf->p_sys->p_playlist )
	{
		maxIndex = list->i_size;
		if ( maxIndex > 0 )
			currentIndex = list->i_index + 1;
		else
			maxIndex = -1;
	}
}

// getTitleInfo
void  
Intf_VLCWrapper::getTitleInfo( int32& currentIndex, int32& maxIndex )
{
	currentIndex = -1;
	maxIndex = -1;
	if ( input_thread_t* input = p_intf->p_sys->p_input )
	{
		vlc_mutex_lock( &input->stream.stream_lock );

		maxIndex = input->stream.i_area_nb - 1;
		if ( maxIndex > 0)
			currentIndex = input->stream.p_selected_area->i_id;
		else
			maxIndex = -1;

		vlc_mutex_unlock( &input->stream.stream_lock );
	}
}

// getChapterInfo
void
Intf_VLCWrapper::getChapterInfo( int32& currentIndex, int32& maxIndex )
{
	currentIndex = -1;
	maxIndex = -1;
	if ( input_thread_t* input = p_intf->p_sys->p_input )
	{
		vlc_mutex_lock( &input->stream.stream_lock );

		maxIndex = input->stream.p_selected_area->i_part_nb - 1;
		if ( maxIndex > 0)
			currentIndex = input->stream.p_selected_area->i_part;
		else
			maxIndex = -1;

		vlc_mutex_unlock( &input->stream.stream_lock );
	}
}

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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790

    while( ( o_file = (BString *)o_files->LastItem() ) )
    {
        o_files->RemoveItem(o_files->CountItems() - 1);
        playlist_Add( p_playlist, o_file->String(),
                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
        delete o_file;
    }

    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_chapter)
{
    BString o_source("");
    o_source << o_type << ":" << o_device ;

    playlist_t *p_playlist = 
               (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                      FIND_ANYWHERE );
    playlist_Add( p_playlist, o_source.String(),
                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
    vlc_object_release( p_playlist );
}

void Intf_VLCWrapper::openNet(BString o_addr, int i_port)
{
}

void Intf_VLCWrapper::openNetChannel(BString o_addr, int i_port)
{
}

void Intf_VLCWrapper::openNetHTTP(BString o_addr)
{
}

791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823

    /* menus management */
void Intf_VLCWrapper::toggleProgram(int i_program){}

void Intf_VLCWrapper::toggleTitle(int i_title)
{
    if( p_intf->p_sys->p_input != NULL )
    {
        input_ChangeArea( p_intf->p_sys->p_input,
                          p_intf->p_sys->p_input->stream.pp_areas[i_title] );

        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
        //setupMenus();

        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
    }
}

void Intf_VLCWrapper::toggleChapter(int i_chapter)
{
    if( p_intf->p_sys->p_input != NULL )
    {
        p_intf->p_sys->p_input->stream.p_selected_area->i_part = i_chapter;
        input_ChangeArea( p_intf->p_sys->p_input,
                          p_intf->p_sys->p_input->stream.p_selected_area );

        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
//        setupMenus();
        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
    }
}

void Intf_VLCWrapper::toggleLanguage(int i_language)
824
{
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853

    int32 i_old = -1;
    int i_cat = AUDIO_ES;

    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
    for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
    {
        if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
        {
            i_old = i;
            break;
        }
    }
    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );

    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_language);
    if( i_language != -1 )
    {
        input_ToggleES( p_intf->p_sys->p_input, 
                        p_intf->p_sys->p_input->stream.pp_selected_es[i_language],
                        VLC_TRUE );
    }

    if( (i_old != -1) && (i_old != i_language) )
    {
        input_ToggleES( p_intf->p_sys->p_input, 
                        p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
                        VLC_FALSE );
    }
854
855
}

856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
void Intf_VLCWrapper::toggleSubtitle(int i_subtitle)
{
    int32 i_old = -1;
    int i_cat = SPU_ES;

    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
    for( int i = 0; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
    {
        if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == i_cat )
        {
            i_old = i;
            break;
        }
    }
    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
871
    
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_subtitle);
    if( i_subtitle != -1 )
    {
        input_ToggleES( p_intf->p_sys->p_input, 
                        p_intf->p_sys->p_input->stream.pp_selected_es[i_subtitle],
                        VLC_TRUE );
    }

    if( (i_old != -1) && (i_old != i_subtitle) )
    {
        input_ToggleES( p_intf->p_sys->p_input, 
                        p_intf->p_sys->p_input->stream.pp_selected_es[i_old],
                        VLC_FALSE );
    }
}


void Intf_VLCWrapper::setupMenus(){}
int  Intf_VLCWrapper::inputGetStatus() {}