* intf_beos.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: intf_beos.cpp,v 1.17 2001/03/06 01:26:06 richards Exp $
+ * $Id: intf_beos.cpp,v 1.27 2001/05/01 04:18:17 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
- * Tony Castley <tcastley@mail.powerup.com.au>
+ * Tony Castley <tony@castley.net>
* Richard Shepherd <richard@rshepherd.demon.co.uk>
*
* This program is free software; you can redistribute it and/or modify
#include <Screen.h>
#include <malloc.h>
#include <string.h>
+#include <Directory.h>
+#include <Entry.h>
+#include <Path.h>
+#include <StorageDefs.h>
+#include <scsi.h>
+#include <scsiprobe_driver.h>
extern "C"
{
#include "input_ext-intf.h"
#include "interface.h"
-#include "intf_plst.h"
+#include "intf_playlist.h"
#include "intf_msg.h"
#include "audio_output.h"
#include "MsgVals.h"
-
#include "main.h"
}
menu_bar = new BMenuBar(rect, "main menu");
AddChild( menu_bar );
- BMenu *m;
+ BMenu *mFile;
+ BMenu *mAudio;
+ CDMenu *cd_menu;
+
+ BMenuItem *mItem;
- menu_bar->AddItem( m = new BMenu("File") );
+ 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();
- m->AddItem( new BMenuItem("Open file...", new BMessage(OPEN_FILE), 'O'));
- m->AddItem( new BMenuItem("Open DVD...", new BMessage(OPEN_DVD), 'D'));
- m->AddSeparatorItem();
- m->AddItem( new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
+ mAudio->AddItem( new LanguageMenu("Language", AUDIO_ES, p_intf) );
+ mAudio->AddItem( new LanguageMenu("Subtitles", SPU_ES, p_intf) );
rect = Bounds();
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;
+
case OPEN_FILE:
if(file_panel)
{
break;
case OPEN_DVD:
- alert = new BAlert(VOUT_TITLE, "Play DVD from menu not yet supported", "Bummer");
- alert->Go();
- //intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, "dvd:/dev/disk/ide/atapi/1/master/0/raw" );
+ 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;
case STOP_PLAYBACK:
// silence the sound, otherwise very horrible
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = 0;
+ p_main->p_aout->i_vol = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_END);
// {
// if (p_main->p_aout != NULL)
// {
-// p_main->p_aout->vol = vol_val;
+// p_main->p_aout->i_vol = vol_val;
// }
// snooze(400000);
// input_SetStatus(p_intf->p_input, INPUT_STATUS_PLAY);
{
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = 0;
+ p_main->p_aout->i_vol = 0;
}
playback_status = PAUSED;
}
{
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = vol_val;
+ p_main->p_aout->i_vol = vol_val;
}
playback_status = PLAYING;
}
{
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = 0;
+ p_main->p_aout->i_vol = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_FASTER);
{
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = 0;
+ 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;
-/* if( p_intf->p_input != NULL )
- {
- float new_position;
- if (p_message->FindFloat("be:value", &new_position) == B_OK)
- {
- printf("%e\n", new_position);
- input_Seek( p_intf->p_input, new_position * 100 );
- }
- } */
break;
case VOLUME_CHG:
// adjust the volume
if (p_main->p_aout != NULL)
{
- p_main->p_aout->vol = vol_val;
+ p_main->p_aout->i_vol = vol_val;
}
break;
case VOLUME_MUTE:
// mute
if (p_main->p_aout != NULL)
{
- if (p_main->p_aout->vol == 0)
+ if (p_main->p_aout->i_vol == 0)
{
p_vol->SetEnabled(true);
- p_main->p_aout->vol = vol_val;
+ p_main->p_aout->i_vol = vol_val;
}
else
{
p_vol->SetEnabled(false);
- p_main->p_aout->vol = 0;
+ p_main->p_aout->i_vol = 0;
}
}
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:
+ {
+ int32 i = p_message->FindInt32("subtitle");
+ input_ChangeES(p_intf->p_input,
+ p_intf->p_input->stream.pp_es[i], 2);
+ }
break;
case B_REFS_RECEIVED:
case B_SIMPLE_DATA:
if( p_message->FindRef( "refs", &ref ) == B_OK )
{
BPath path( &ref );
- char * psz_name = strdup(path.Path());
- intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_name );
+ intf_PlaylistAdd( p_main->p_playlist,
+ PLAYLIST_END, path.Path() );
}
}
/*****************************************************************************
* InterfaceWindow::QuitRequested
*****************************************************************************/
-
bool InterfaceWindow::QuitRequested()
{
p_intf->b_die = 1;
return( false );
}
+
+/*****************************************************************************
+ * CDMenu::CDMenu
+ *****************************************************************************/
+CDMenu::CDMenu(const char *name)
+ : BMenu(name)
+{
+}
+
+/*****************************************************************************
+ * CDMenu::~CDMenu
+ *****************************************************************************/
+CDMenu::~CDMenu()
+{
+}
+
+/*****************************************************************************
+ * CDMenu::AttachedToWindow
+ *****************************************************************************/
+void CDMenu::AttachedToWindow(void)
+{
+ while (RemoveItem((long int)0) != NULL); // remove all items
+ GetCD("/dev/disk");
+ BMenu::AttachedToWindow();
+}
+
+/*****************************************************************************
+ * CDMenu::GetCD
+ *****************************************************************************/
+int CDMenu::GetCD(const char *directory)
+{
+ BDirectory dir;
+ dir.SetTo(directory);
+ if(dir.InitCheck() != B_NO_ERROR) {
+ return B_ERROR;
+ }
+ dir.Rewind();
+ BEntry entry;
+ while(dir.GetNextEntry(&entry) >= 0) {
+ BPath path;
+ const char *name;
+ entry_ref e;
+
+ if(entry.GetPath(&path) != B_NO_ERROR)
+ continue;
+ name = path.Path();
+
+
+ if(entry.GetRef(&e) != B_NO_ERROR)
+ continue;
+
+ if(entry.IsDirectory()) {
+ if(strcmp(e.name, "floppy") == 0)
+ continue; // ignore floppy (it is not silent)
+ int devfd = GetCD(name);
+ if(devfd >= 0)
+ {
+ return devfd;
+ }
+ }
+ else {
+ int devfd;
+ device_geometry g;
+ status_t m;
+
+ if(strcmp(e.name, "raw") != 0)
+ continue; // ignore partitions
+
+ devfd = open(name, O_RDONLY);
+ if(devfd < 0)
+ continue;
+
+ if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
+ if(g.device_type == B_CD) //ensure the drive is a CD-ROM
+ {
+ if(ioctl(devfd, B_GET_MEDIA_STATUS, &m, sizeof(m)) >= 0 )
+ if(m == B_NO_ERROR) //ensure media is present
+ {
+ BMessage *msg;
+ msg = new BMessage(OPEN_DVD);
+ msg->AddString("device", name);
+ BMenuItem *menu_item;
+ menu_item = new BMenuItem(name, msg);
+ AddItem(menu_item);
+ continue;
+ }
+ }
+ }
+ close(devfd);
+ }
+ }
+ return B_ERROR;
+}
+
+/*****************************************************************************
+ * LanguageMenu::LanguageMenu
+ *****************************************************************************/
+LanguageMenu::LanguageMenu(const char *name, int menu_kind, intf_thread_t *p_interface)
+ :BMenu(name)
+{
+ kind = menu_kind;
+ p_intf = p_interface;
+}
+
+/*****************************************************************************
+ * LanguageMenu::~LanguageMenu
+ *****************************************************************************/
+LanguageMenu::~LanguageMenu()
+{
+}
+
+/*****************************************************************************
+ * LanguageMenu::AttachedToWindow
+ *****************************************************************************/
+void LanguageMenu::AttachedToWindow(void)
+{
+ while (RemoveItem((long int)0) != NULL); // remove all items
+ SetRadioMode(true);
+ GetChannels();
+ BMenu::AttachedToWindow();
+}
+
+/*****************************************************************************
+ * LanguageMenu::GetChannels
+ *****************************************************************************/
+int LanguageMenu::GetChannels()
+{
+ char* psz_name;
+ bool b_active;
+ bool b_found;
+ int32 i;
+ es_descriptor_t *p_es;
+
+ if (p_intf->p_input == NULL)
+ return 1;
+
+ for (i = 0; i < p_intf->p_input->stream.i_selected_es_number; i++)
+ {
+ if (kind ==
+ p_intf->p_input->stream.pp_selected_es[i]->i_cat)
+ {
+ p_es = p_intf->p_input->stream.pp_selected_es[i];
+ }
+ }
+ for (i = 0; i < p_intf->p_input->stream.i_es_number; i++)
+ {
+ if (kind == p_intf->p_input->stream.pp_es[i]->i_cat)
+ {
+ psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
+ BMessage *msg;
+ if (kind == AUDIO_ES) //audio
+ {
+ msg = new BMessage(SELECT_CHANNEL);
+ msg->AddInt32("channel", i);
+ }
+ else
+ {
+ msg = new BMessage(SELECT_SUBTITLE);
+ msg->AddInt32("subtitle", i);
+ }
+ BMenuItem *menu_item;
+ menu_item = new BMenuItem(psz_name, msg);
+ AddItem(menu_item);
+ b_active = (p_es == p_intf->p_input->stream.pp_es[i]);
+ menu_item->SetMarked(b_active);
+ }
+ }
+}
+
+
/*****************************************************************************
* MediaSlider
*****************************************************************************/
v->SetHighColor(black);
else
v->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
- r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/6);
+ r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/(4 * r.IntegerWidth() / r.IntegerHeight()));
v->StrokeEllipse(r);
if(IsEnabled())
v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));