Commit 84a86ed7 authored by Sam Hocevar's avatar Sam Hocevar

  * Added support for some terribly braindead DVD subtitles in Kenshin
    which do not have a "stop display" command. Anime fans rejoice!
  * Fixed the BeOS interface to use p_aout_bank instead of p_main->p_aout.
  * Coding-style butchery (mostly tabs).
parent 58ab8de5
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.29 2001/03/21 13:42:33 sam Exp $
* $Id: video.h,v 1.30 2001/05/07 04:42:42 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -123,9 +123,10 @@ typedef struct subpicture_s
int i_size; /* data size */
struct subpicture_s * p_next; /* next subtitle to be displayed */
/* Other properties */
mtime_t begin_date; /* beginning of display date */
mtime_t end_date; /* end of display date */
/* Date properties */
mtime_t i_start; /* beginning of display date */
mtime_t i_stop; /* end of display date */
boolean_t b_ephemer; /* does the subtitle have a TTL ? */
/* Display properties - these properties are only indicative and may be
* changed by the video output thread, or simply ignored depending of the
......
......@@ -2,7 +2,7 @@
* intf_beos.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: intf_beos.cpp,v 1.27 2001/05/01 04:18:17 sam Exp $
* $Id: intf_beos.cpp,v 1.28 2001/05/07 04:42:42 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -13,7 +13,7 @@
* 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
......@@ -100,135 +100,140 @@ typedef struct intf_sys_s
/*****************************************************************************
* InterfaceWindow
*****************************************************************************/
InterfaceWindow::InterfaceWindow( BRect frame, const char *name , intf_thread_t *p_interface )
: BWindow(frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK |B_ASYNCHRONOUS_CONTROLS)
InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
intf_thread_t *p_interface )
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK
| B_ASYNCHRONOUS_CONTROLS )
{
file_panel = NULL;
p_intf = p_interface;
BRect ButtonRect;
float xStart = 5.0;
float yStart = 20.0;
BRect ButtonRect;
float xStart = 5.0;
float yStart = 20.0;
SetName( "interface" );
SetTitle(VOUT_TITLE " (BeOS interface)");
BRect rect(0, 0, 0, 0);
BMenuBar *menu_bar;
BMenuBar *menu_bar;
menu_bar = new BMenuBar(rect, "main menu");
AddChild( menu_bar );
BMenu *mFile;
BMenu *mAudio;
CDMenu *cd_menu;
BMenuItem *mItem;
menu_bar->AddItem( mFile = new BMenu("File") );
menu_bar->ResizeToPreferred();
mFile->AddItem(mItem = new BMenuItem("Open File" B_UTF8_ELLIPSIS, new BMessage(OPEN_FILE), 'O'));
cd_menu = new CDMenu("Open Disc");
mFile->AddItem(cd_menu);
mFile->AddSeparatorItem();
mFile->AddItem(mItem = new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED), 'A'));
mItem->SetTarget( be_app );
mFile->AddItem(mItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
menu_bar->AddItem ( mAudio = new BMenu("Audio") );
menu_bar->ResizeToPreferred();
mAudio->AddItem( new LanguageMenu("Language", AUDIO_ES, p_intf) );
mAudio->AddItem( new LanguageMenu("Subtitles", SPU_ES, p_intf) );
BMenu *mFile;
BMenu *mAudio;
CDMenu *cd_menu;
BMenuItem *mItem;
menu_bar->AddItem( mFile = new BMenu( "File" ) );
menu_bar->ResizeToPreferred();
mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
new BMessage(OPEN_FILE), 'O') );
cd_menu = new CDMenu( "Open Disc" );
mFile->AddItem( cd_menu );
mFile->AddSeparatorItem();
mFile->AddItem( mItem = new BMenuItem( "About" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED), 'A') );
mItem->SetTarget( be_app );
mFile->AddItem(mItem = new BMenuItem( "Quit",
new BMessage(B_QUIT_REQUESTED), 'Q') );
menu_bar->AddItem ( mAudio = new BMenu( "Audio" ) );
menu_bar->ResizeToPreferred();
mAudio->AddItem( new LanguageMenu( "Language", AUDIO_ES, p_intf ) );
mAudio->AddItem( new LanguageMenu( "Subtitles", SPU_ES, p_intf ) );
rect = Bounds();
rect.top += menu_bar->Bounds().IntegerHeight()+1;
rect.top += menu_bar->Bounds().IntegerHeight() + 1;
BBox* p_view;
p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER );
p_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
/* Buttons */
/* Slow play */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
TransportButton* p_slow = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSkipBackBitmapBits,
kPressedSkipBackBitmapBits,
kDisabledSkipBackBitmapBits,
new BMessage(SLOWER_PLAY));
p_view->AddChild( p_slow );
/* Play Pause */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kPlayButtonSize);
xStart += kPlayPauseBitmapWidth + 1.0;
PlayPauseButton* p_play = new PlayPauseButton(ButtonRect, B_EMPTY_STRING,
kPlayButtonBitmapBits,
kPressedPlayButtonBitmapBits,
kDisabledPlayButtonBitmapBits,
kPlayingPlayButtonBitmapBits,
kPressedPlayingPlayButtonBitmapBits,
kPausedPlayButtonBitmapBits,
kPressedPausedPlayButtonBitmapBits,
new BMessage(START_PLAYBACK));
p_view->AddChild( p_play );
p_play->SetPlaying();
/* Fast Foward */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
TransportButton* p_fast = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSkipForwardBitmapBits,
kPressedSkipForwardBitmapBits,
kDisabledSkipForwardBitmapBits,
new BMessage(FASTER_PLAY));
p_view->AddChild( p_fast );
/* Stop */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kStopButtonSize);
xStart += kStopBitmapWidth;
TransportButton* p_stop = new TransportButton(ButtonRect, B_EMPTY_STRING,
kStopButtonBitmapBits,
kPressedStopButtonBitmapBits,
kDisabledStopButtonBitmapBits,
new BMessage(STOP_PLAYBACK));
p_view->AddChild( p_stop );
ButtonRect.SetLeftTop(BPoint(xStart + 5, yStart + 6));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSpeakerButtonSize);
xStart += kSpeakerIconBitmapWidth;
TransportButton* p_mute = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSpeakerIconBits,
kPressedSpeakerIconBits,
kSpeakerIconBits,
new BMessage(VOLUME_MUTE));
p_view->AddChild( p_mute );
/* Seek Status */
p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER );
p_view->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
/* Buttons */
/* Slow play */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
TransportButton* p_slow = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSkipBackBitmapBits,
kPressedSkipBackBitmapBits,
kDisabledSkipBackBitmapBits,
new BMessage(SLOWER_PLAY));
p_view->AddChild( p_slow );
/* Play Pause */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kPlayButtonSize);
xStart += kPlayPauseBitmapWidth + 1.0;
PlayPauseButton* p_play = new PlayPauseButton(ButtonRect, B_EMPTY_STRING,
kPlayButtonBitmapBits,
kPressedPlayButtonBitmapBits,
kDisabledPlayButtonBitmapBits,
kPlayingPlayButtonBitmapBits,
kPressedPlayingPlayButtonBitmapBits,
kPausedPlayButtonBitmapBits,
kPressedPausedPlayButtonBitmapBits,
new BMessage(START_PLAYBACK));
p_view->AddChild( p_play );
p_play->SetPlaying();
/* Fast Foward */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
TransportButton* p_fast = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSkipForwardBitmapBits,
kPressedSkipForwardBitmapBits,
kDisabledSkipForwardBitmapBits,
new BMessage(FASTER_PLAY));
p_view->AddChild( p_fast );
/* Stop */
ButtonRect.SetLeftTop(BPoint(xStart, yStart));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kStopButtonSize);
xStart += kStopBitmapWidth;
TransportButton* p_stop = new TransportButton(ButtonRect, B_EMPTY_STRING,
kStopButtonBitmapBits,
kPressedStopButtonBitmapBits,
kDisabledStopButtonBitmapBits,
new BMessage(STOP_PLAYBACK));
p_view->AddChild( p_stop );
ButtonRect.SetLeftTop(BPoint(xStart + 5, yStart + 6));
ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSpeakerButtonSize);
xStart += kSpeakerIconBitmapWidth;
TransportButton* p_mute = new TransportButton(ButtonRect, B_EMPTY_STRING,
kSpeakerIconBits,
kPressedSpeakerIconBits,
kSpeakerIconBits,
new BMessage(VOLUME_MUTE));
p_view->AddChild( p_mute );
/* Seek Status */
rgb_color fill_color = {0,255,0};
p_seek = new SeekSlider(BRect(5,2,255,15), this, 0, 100,
B_TRIANGLE_THUMB);
p_seek->SetValue(0);
p_seek->UseFillColor(true, &fill_color);
p_seek = new SeekSlider(BRect(5,2,255,15), this, 0, 100,
B_TRIANGLE_THUMB);
p_seek->SetValue(0);
p_seek->UseFillColor(true, &fill_color);
p_view->AddChild( p_seek );
/* Volume Slider */
p_vol = new MediaSlider(BRect(xStart,20,255,30), new BMessage(VOLUME_CHG),
0, VOLUME_MAX);
p_vol->SetValue(VOLUME_DEFAULT);
p_vol->UseFillColor(true, &fill_color);
/* Volume Slider */
p_vol = new MediaSlider(BRect(xStart,20,255,30), new BMessage(VOLUME_CHG),
0, VOLUME_MAX);
p_vol->SetValue(VOLUME_DEFAULT);
p_vol->UseFillColor(true, &fill_color);
p_view->AddChild( p_vol );
/* Set size and Show */
/* Set size and Show */
AddChild( p_view );
ResizeTo(260,50 + menu_bar->Bounds().IntegerHeight()+1);
ResizeTo(260,50 + menu_bar->Bounds().IntegerHeight()+1);
Show();
}
......@@ -241,156 +246,208 @@ InterfaceWindow::~InterfaceWindow()
*****************************************************************************/
void InterfaceWindow::MessageReceived( BMessage * p_message )
{
int vol_val = p_vol->Value(); // remember the current volume
static int playback_status; // remember playback state
BAlert *alert;
Activate();
int vol_val = p_vol->Value(); // remember the current volume
static int playback_status; // remember playback state
int i_index;
BAlert *alert;
Activate();
switch( p_message->what )
{
// case B_ABOUT_REQUESTED:
// alert = new BAlert(VOUT_TITLE, "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
// alert->Go();
// break;
// alert = new BAlert(VOUT_TITLE, "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
// alert->Go();
// break;
case OPEN_FILE:
if(file_panel)
{
file_panel->Show();
break;
}
file_panel = new BFilePanel();
file_panel->SetTarget(this);
file_panel->Show();
break;
if( file_panel )
{
file_panel->Show();
break;
}
file_panel = new BFilePanel();
file_panel->SetTarget( this );
file_panel->Show();
break;
case OPEN_DVD:
const char **device;
char device_method_and_name[B_FILE_NAME_LENGTH + 4];
if(p_message->FindString("device", device) != B_ERROR)
{
sprintf(device_method_and_name, "dvd:%s", *device);
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, device_method_and_name );
}
break;
const char **ppsz_device;
char psz_method[ B_FILE_NAME_LENGTH + 4 ];
if( p_message->FindString("device", ppsz_device) != B_ERROR )
{
snprintf( psz_method, B_FILE_NAME_LENGTH + 4,
"dvd:%s", *ppsz_device );
psz_method[ B_FILE_NAME_LENGTH + 4 - 1 ] = '\0';
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_method );
}
break;
case STOP_PLAYBACK:
// this currently stops playback not nicely
if (p_intf->p_input != NULL )
{
// silence the sound, otherwise very horrible
if (p_main->p_aout != NULL)
{
p_main->p_aout->i_vol = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_END);
}
break;
case START_PLAYBACK:
// starts playing in normal mode
// if (p_intf->p_input != NULL )
// {
// if (p_main->p_aout != NULL)
// {
// p_main->p_aout->i_vol = vol_val;
// }
// snooze(400000);
// input_SetStatus(p_intf->p_input, INPUT_STATUS_PLAY);
// playback_status = PLAYING;
// }
// break;
case PAUSE_PLAYBACK:
// pause the playback
if (p_intf->p_input != NULL )
{
// mute the volume if currently playing
if (playback_status == PLAYING)
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->i_vol = 0;
}
playback_status = PAUSED;
}
else
// restore the volume
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->i_vol = vol_val;
}
playback_status = PLAYING;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_PAUSE);
}
break;
case FASTER_PLAY:
// cycle the fast playback modes
if (p_intf->p_input != NULL )
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->i_vol = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_FASTER);
}
break;
case SLOWER_PLAY:
// cycle the slow playback modes
if (p_intf->p_input != NULL )
{
if (p_main->p_aout != NULL)
{
p_main->p_aout->i_vol = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_SLOWER);
}
break;
case SEEK_PLAYBACK:
// handled by semaphores;
break;
case VOLUME_CHG:
// adjust the volume
if (p_main->p_aout != NULL)
// this currently stops playback not nicely
if( p_intf->p_input != NULL )
{
// silence the sound, otherwise very horrible
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume = p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_END );
}
break;
case START_PLAYBACK:
// starts playing in normal mode
// if (p_intf->p_input != NULL )
//
// if (p_main->p_aout != NULL)
// {
// p_main->p_aout->i_vol = vol_val;
// }
// snooze(400000);
// input_SetStatus(p_intf->p_input, INPUT_STATUS_PLAY);
// playback_status = PLAYING;
// }
// break;
case PAUSE_PLAYBACK:
// pause the playback
if( p_intf->p_input != NULL )
{
// mute the volume if currently playing
if( playback_status == PLAYING )
{
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
playback_status = PAUSED;
}
else
// restore the volume
{
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_aout_bank->pp_aout[i_index]->i_volume =
p_aout_bank->pp_aout[i_index]->i_savedvolume;
p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
playback_status = PLAYING;
}
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
}
break;
case FASTER_PLAY:
// cycle the fast playback modes
if( p_intf->p_input != NULL )
{
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
}
break;
case SLOWER_PLAY:
// cycle the slow playback modes
if (p_intf->p_input != NULL )
{
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
}
break;
case SEEK_PLAYBACK:
// handled by semaphores;
break;
case VOLUME_CHG:
// adjust the volume
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume = vol_val;
}
else
{
p_aout_bank->pp_aout[i_index]->i_volume = vol_val;
}
}
vlc_mutex_unlock( &p_aout_bank->lock );
break;
case VOLUME_MUTE:
// mute
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
{
p_aout_bank->pp_aout[i_index]->i_volume =
p_aout_bank->pp_aout[i_index]->i_savedvolume;
p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
}
else
{
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
}
vlc_mutex_unlock( &p_aout_bank->lock );
break;
case SELECT_CHANNEL:
{
int32 i = p_message->FindInt32( "channel" );
input_ChangeES( p_intf->p_input,
p_intf->p_input->stream.pp_es[i], 1 );
}
break;
case SELECT_SUBTITLE:
{
p_main->p_aout->i_vol = vol_val;
}
break;
case VOLUME_MUTE:
// mute
if (p_main->p_aout != NULL)
{
if (p_main->p_aout->i_vol == 0)
{
p_vol->SetEnabled(true);
p_main->p_aout->i_vol = vol_val;