* VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: VlcWrapper.cpp,v 1.27 2003/04/22 16:36:16 titer Exp $
+ * $Id: VlcWrapper.cpp,v 1.42 2004/01/17 12:28:57 gbazin Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
#include <vlc/vout.h>
extern "C"
{
- #include <input_ext-plugins.h> // needed here when compiling without plugins
+ #include <input_ext-plugins.h> // needed here when compiling without plugins
#include <audio_output.h>
#include <aout_internal.h>
}
const char * _AddEllipsis( char * string )
{
- BString newString( string );
- newString << B_UTF8_ELLIPSIS;
- return newString.String();
+ char * temp;
+ temp = (char*) calloc( strlen( string ) + 4, 1 );
+ sprintf( temp, "%s%s", string, B_UTF8_ELLIPSIS );
+ return temp;
}
/* constructor */
VlcWrapper::~VlcWrapper()
{
if( p_input )
- {
vlc_object_release( p_input );
- }
+
if( p_playlist )
- {
vlc_object_release( p_playlist );
- }
}
-/* UpdateInput: updates p_input, returns true if the interface needs to
- be updated */
-bool VlcWrapper::UpdateInput()
+/* UpdateInput: updates p_input */
+void VlcWrapper::UpdateInput()
{
- if( p_input == NULL )
- {
+ if( !p_input )
p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
- }
- if( p_input != NULL )
- {
+ if( p_input )
if( p_input->b_dead )
{
vlc_object_release( p_input );
p_input = NULL;
}
- return true;
- }
- return false;
}
{
return UNDEF_S;
}
- return p_input->stream.control.i_status;
+
+ vlc_value_t state;
+ var_Get( p_input, "state", &state );
+ return state.i_int;
}
int VlcWrapper::InputRate()
{
return DEFAULT_RATE;
}
+
return p_input->stream.control.i_rate;
}
-void VlcWrapper::InputSlower()
+void VlcWrapper::InputSetRate( int rate )
{
- if( p_input != NULL )
+ if( !p_input )
{
- input_SetStatus( p_input, INPUT_STATUS_SLOWER );
+ return;
}
-}
-void VlcWrapper::InputFaster()
-{
- if( p_input != NULL )
- {
- input_SetStatus( p_input, INPUT_STATUS_FASTER );
- }
+ input_SetRate( p_input, rate );
}
BList * VlcWrapper::GetChannels( int i_cat )
{
message = new BMessage( what );
message->AddInt32( fieldName, i );
- if( strlen( p_input->stream.pp_es[i]->psz_desc ) )
- trackName = strdup( p_input->stream.pp_es[i]->psz_desc );
- else
+ if( !p_input->stream.pp_es[i]->psz_desc ||
+ !*p_input->stream.pp_es[i]->psz_desc )
trackName = _("<unknown>");
+ else
+ trackName = strdup( p_input->stream.pp_es[i]->psz_desc );
menuItem = new BMenuItem( trackName, message );
if( p_input->stream.pp_es[i] == p_es )
menuItem->SetMarked( true );
const char * VlcWrapper::GetTimeAsString()
{
- static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
+ static char psz_time[ MSTRTIME_MAX_SIZE ];
- if( p_input == NULL )
+ if( !p_input )
{
return ("-:--:--");
}
- input_OffsetToTime( p_input,
- psz_currenttime,
- p_input->stream.p_selected_area->i_tell );
+ vlc_value_t time;
+ var_Get( p_input, "time", &time );
+
+ mtime_t seconds = time.i_time / 1000000;
+ sprintf( psz_time, "%d:%02d:%02d",
+ (int) ( seconds / (60 * 60 ) ),
+ (int) ( ( seconds / 60 ) % 60 ),
+ (int) ( seconds % 60 ) );
- return(psz_currenttime);
+ return psz_time;
}
float VlcWrapper::GetTimeAsFloat()
{
- float f_time = 0.0;
-
- if( p_input != NULL )
- {
- f_time = (float)p_input->stream.p_selected_area->i_tell /
- (float)p_input->stream.p_selected_area->i_size;
- }
- else
+ if( !p_input )
{
- f_time = 0.0;
+ return 0.0;
}
- return( f_time );
+
+ vlc_value_t pos;
+ var_Get( p_input, "position", &pos );
+ return pos.f_float;
}
void VlcWrapper::SetTimeAsFloat( float f_position )
{
- if( p_input != NULL )
+ if( !p_input )
{
- input_Seek( p_input,
- (long long int)(p_input->stream.p_selected_area->i_size
- * f_position / SEEKSLIDER_RANGE ),
- INPUT_SEEK_SET);
+ return;
}
+
+ vlc_value_t pos;
+ pos.f_float = f_position / SEEKSLIDER_RANGE;
+ var_Set( p_input, "position", pos );
}
bool VlcWrapper::IsPlaying()
{
-
bool playing = false;
- if ( p_input )
+ if( p_input )
{
- switch ( p_input->stream.control.i_status )
+ switch( p_input->stream.control.i_status )
{
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;
}
if ( BString* o_file = (BString *)o_files->RemoveItem( i ) )
{
playlist_Add( p_playlist, o_file->String(),
- mode, index );
+ o_file->String(), mode, index );
if ( mode == PLAYLIST_INSERT )
index++;
delete o_file;
void VlcWrapper::OpenDisc(BString o_type, BString o_device, int i_title, int i_chapter)
{
- if( p_intf->p_sys->b_dvdmenus )
- o_device.Prepend( "dvd:" );
+ if( config_GetInt( p_intf, "beos-dvdmenus" ) )
+ o_device.Prepend( "dvdplay:" );
else
o_device.Prepend( "dvdold:" );
- playlist_Add( p_playlist, o_device.String(),
+ playlist_Add( p_playlist, o_device.String(), o_device.String(),
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
if ( copy )
{
// make a copy of the item at index
+ *copy = *item;
copy->psz_name = strdup( item->psz_name );
copy->psz_uri = strdup( item->psz_uri );
- copy->i_type = item->i_type;
- copy->i_status = item->i_status;
- copy->b_autodeletion = item->b_autodeletion;
}
}
return (void*)copy;
void VlcWrapper::VolumeMute()
{
- aout_VolumeGet( p_intf, &p_intf->p_sys->i_saved_volume );
aout_VolumeMute( p_intf, NULL );
p_intf->p_sys->b_mute = 1;
}
void VlcWrapper::VolumeRestore()
{
- aout_VolumeSet( p_intf, p_intf->p_sys->i_saved_volume );
+ audio_volume_t dummy;
+ aout_VolumeMute( p_intf, &dummy );
p_intf->p_sys->b_mute = 0;
}
* DVD *
*******/
-bool VlcWrapper::HasTitles()
+bool VlcWrapper::IsUsingMenus()
{
if( !p_input )
+ return false;
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+ if( p_playlist->i_index < 0 )
{
+ vlc_mutex_unlock( &p_playlist->object_lock );
return false;
}
+
+ char * psz_name = p_playlist->pp_items[p_playlist->i_index]->psz_name;
+ if( !strncmp( psz_name, "dvdplay:", 8 ) )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ return true;
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ return false;
+}
+
+bool VlcWrapper::HasTitles()
+{
+ if( !p_input )
+ return false;
+
return ( p_input->stream.i_area_nb > 1 );
}
for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ )
{
if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) &&
- ( p_input->stream.pp_es[i]->p_decoder_fifo != NULL ) )
+ ( p_input->stream.pp_es[i]->p_dec != NULL ) )
{
input_UnselectES( p_input, p_input->stream.pp_es[i] );
input_SelectES( p_input, p_input->stream.pp_es[i] );