summaryrefslogtreecommitdiffstats
path: root/beos
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 12:56:59 +0000
committerhandbrake <[email protected]>2006-01-14 12:56:59 +0000
commit452f36599a1ea52f3bd42361b534594568c428fd (patch)
tree7f53f79212cf524f0a13ed5ee2250992f21eabcb /beos
parenta9a84221af31ca7d11d1aa182d8b152270203f9f (diff)
HandBrake 0.4
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'beos')
-rw-r--r--beos/HandBrake.cpp47
-rw-r--r--beos/HandBrake.h10
-rw-r--r--beos/HandBrake.rsrcbin0 -> 4217 bytes
-rw-r--r--beos/MainWindow.cpp714
-rw-r--r--beos/MainWindow.h84
-rw-r--r--beos/RipView.cpp616
-rw-r--r--beos/RipView.h77
-rw-r--r--beos/ScanView.cpp280
-rw-r--r--beos/ScanView.h48
9 files changed, 1120 insertions, 756 deletions
diff --git a/beos/HandBrake.cpp b/beos/HandBrake.cpp
index b1b386a6d..b5f13196b 100644
--- a/beos/HandBrake.cpp
+++ b/beos/HandBrake.cpp
@@ -1,4 +1,4 @@
-/* $Id: HandBrake.cpp,v 1.6 2003/09/30 14:38:15 titer Exp $
+/* $Id: HandBrake.cpp,v 1.8 2003/10/13 22:23:02 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -11,42 +11,47 @@
void SigHandler( int signal )
{
+ /* Ugly way to exit cleanly when hitting Ctrl-C */
((HBApp*) be_app)->fWindow->PostMessage( B_QUIT_REQUESTED );
}
-int main( int argc, char ** argv )
+int main()
{
signal( SIGINT, SigHandler );
signal( SIGHUP, SigHandler );
signal( SIGQUIT, SigHandler );
- int c;
- bool debug = false;
- while( ( c = getopt( argc, argv, "v" ) ) != -1 )
- {
- switch( c )
- {
- case 'v':
- debug = true;
- break;
-
- default:
- break;
- }
- }
-
/* Run the BApplication */
- HBApp * app = new HBApp( debug );
+ HBApp * app = new HBApp();
app->Run();
delete app;
return 0;
}
/* Constructor */
-HBApp::HBApp( bool debug )
- : BApplication( "application/x-vnd.titer-handbrake" )
+HBApp::HBApp()
+ : BApplication("application/x-vnd.titer-handbrake" )
{
- fWindow = new HBWindow( debug );
+ fWindow = new MainWindow();
fWindow->Show();
}
+void HBApp::MessageReceived( BMessage * message )
+{
+ switch( message->what )
+ {
+ case B_SAVE_REQUESTED:
+ fWindow->PostMessage( message );
+ break;
+
+ default:
+ BApplication::MessageReceived( message );
+ break;
+ }
+}
+
+void HBApp::RefsReceived( BMessage * message )
+{
+ fWindow->PostMessage( message );
+}
+
diff --git a/beos/HandBrake.h b/beos/HandBrake.h
index 72234e195..7035b5487 100644
--- a/beos/HandBrake.h
+++ b/beos/HandBrake.h
@@ -1,4 +1,4 @@
-/* $Id: HandBrake.h,v 1.5 2003/09/30 14:38:15 titer Exp $
+/* $Id: HandBrake.h,v 1.7 2003/10/13 22:23:02 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -9,14 +9,16 @@
#include <Application.h>
-class HBWindow;
+class MainWindow;
class HBApp : public BApplication
{
public:
- HBApp( bool debug );
+ HBApp();
+ void MessageReceived( BMessage * message );
+ void RefsReceived( BMessage * message );
- HBWindow * fWindow;
+ MainWindow * fWindow;
};
#endif
diff --git a/beos/HandBrake.rsrc b/beos/HandBrake.rsrc
new file mode 100644
index 000000000..d9f87ee44
--- /dev/null
+++ b/beos/HandBrake.rsrc
Binary files differ
diff --git a/beos/MainWindow.cpp b/beos/MainWindow.cpp
index ca18537a5..613cf21df 100644
--- a/beos/MainWindow.cpp
+++ b/beos/MainWindow.cpp
@@ -1,248 +1,50 @@
-/* $Id: MainWindow.cpp,v 1.14 2003/10/05 14:56:38 titer Exp $
+/* $Id: MainWindow.cpp,v 1.19 2003/10/13 22:23:02 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
It may be used under the terms of the GNU General Public License. */
-#include <fs_info.h>
-#include <sys/ioctl.h>
#include <Alert.h>
#include <Application.h>
-#include <Box.h>
-#include <Button.h>
-#include <Directory.h>
-#include <Drivers.h>
-#include <MenuField.h>
-#include <Path.h>
-#include <Query.h>
-#include <PopUpMenu.h>
#include <Screen.h>
-#include <Slider.h>
-#include <StatusBar.h>
-#include <StringView.h>
-#include <TextControl.h>
-#include <VolumeRoster.h>
-#include "MainWindow.h"
#include "Manager.h"
-#include "PictureWin.h"
-
-#define DEFAULT_FILE "/boot/home/Desktop/Movie.avi"
-#define WINDOW_RECT BRect( 0,0,400,405 )
-
-#define BUTTON_ADVANCED 'badv'
-#define BUTTON_FILE 'bfil'
-#define BUTTON_PICTURE 'bpic'
-#define BUTTON_START 'bsta'
-#define BUTTON_CANCEL 'bcan'
-#define BUTTON_SUSPEND 'bsus'
-#define BUTTON_RESUME 'bres'
-#define POPUP_AUDIO 'paud'
-#define POPUP_TITLE 'ptit'
-#define POPUP_VOLUME 'pvol'
-#define SLIDER_AUDIO 'saud'
-#define SLIDER_VIDEO 'svid'
-
-/* HBBox : almost a simple BBox, unless we draw a horizontal line
- before the "Picture" and "Advanced" buttons. There must be a
- cleaner way to do this, but I'm not a expert GUI programmer. */
-
-/* Constructor */
-HBBox::HBBox( BRect rect )
- : BBox( rect, NULL )
-{
-}
-
-/* Draw */
-void HBBox::Draw( BRect rect )
-{
- /* Inherited method */
- BBox::Draw( rect );
-
- /* Draw the line */
- SetHighColor( 120, 120, 120 );
- SetLowColor( 255, 255, 255 );
- StrokeLine( BPoint( 10, 265 ),
- BPoint( Bounds().Width() - 10, 265 ),
- B_SOLID_HIGH );
- StrokeLine( BPoint( 11, 266 ),
- BPoint( Bounds().Width() - 10, 266 ),
- B_SOLID_LOW );
-}
-
-HBVolumeItem::HBVolumeItem( HBVolume * volume )
- : BMenuItem( "", new BMessage( POPUP_VOLUME ) )
-{
- fVolume = volume;
-
- SetLabel( fVolume->fName );
-}
-
-HBTitleItem::HBTitleItem( HBTitle * title )
- : BMenuItem( "", new BMessage( POPUP_TITLE) )
-{
- fTitle = title;
-
- char label[1024]; memset( label, 0, 1024 );
- sprintf( label, "%d (%02lld:%02lld:%02lld)", fTitle->fIndex,
- fTitle->fLength / 3600, ( fTitle->fLength % 3600 ) / 60,
- fTitle->fLength % 60 );
- SetLabel( label );
-}
-
-HBAudioItem::HBAudioItem( HBAudio * audio )
- : BMenuItem( "", new BMessage( POPUP_AUDIO ) )
-{
- fAudio = audio;
-
- SetLabel( fAudio ? fAudio->fDescription : "None" );
-}
+#include "MainWindow.h"
+#include "ScanView.h"
+#include "RipView.h"
-HBWindow::HBWindow( bool debug )
- : BWindow( WINDOW_RECT, "HandBrake " VERSION, B_TITLED_WINDOW,
+MainWindow::MainWindow()
+ : BWindow( BRect( 0,0,10,10 ), "HandBrake " VERSION, B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
{
- /* Center the window */
- BScreen screen;
- MoveTo( ( screen.Frame().Width() - Frame().Width() ) / 2,
- ( screen.Frame().Height() - Frame().Height() ) / 2 );
-
- /* -- GUI starts here -- */
-
- BRect r;
-
- /* Add a background view */
- BView * view;
- view = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
- view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
-
- /* Add the settings box */
- r = BRect( 10, 10, view->Bounds().Width() - 10,
- view->Bounds().Height() - 85 );
- fBox = new HBBox( r );
- fBox->SetLabel( "Settings" );
-
- /* Volume */
- r = BRect( 10, 15, fBox->Bounds().Width() - 10, 35 );
- fVolumePopUp = new BPopUpMenu( "" );
- fVolumeField = new BMenuField( r, NULL, "Volume :",
- fVolumePopUp, true );
- fBox->AddChild( fVolumeField );
-
- /* Title */
- r = BRect( 10, 45, fBox->Bounds().Width() - 10, 65 );
- fTitlePopUp = new BPopUpMenu( "" );
- fTitleField = new BMenuField( r, NULL, "Title :",
- fTitlePopUp, true );
- fBox->AddChild( fTitleField );
-
- /* Audio 1 */
- r = BRect( 10, 75, fBox->Bounds().Width() - 10, 95 );
- fAudio1PopUp = new BPopUpMenu( "" );
- fAudio1Field = new BMenuField( r, NULL, "Audio 1 :",
- fAudio1PopUp, true );
- fBox->AddChild( fAudio1Field );
-
- /* Audio 2 */
- r = BRect( 10, 105, fBox->Bounds().Width() - 10, 125 );
- fAudio2PopUp = new BPopUpMenu( "" );
- fAudio2Field = new BMenuField( r, NULL, "Audio 2 :",
- fAudio2PopUp, true );
- fBox->AddChild( fAudio2Field );
-
- /* Video bitrate */
- r = BRect( 10, 135, fBox->Bounds().Width() - 10, 165 );
- fVideoSlider = new BSlider( r, NULL, "Video bitrate : 1024 kbps",
- new BMessage( SLIDER_VIDEO ),
- 128, 4096, B_TRIANGLE_THUMB );
- fVideoSlider->SetValue( 1024 );
- fBox->AddChild( fVideoSlider );
-
- /* Audio bitrate */
- r = BRect( 10, 175, fBox->Bounds().Width() - 10, 205 );
- fAudioSlider = new BSlider( r, NULL, "Audio bitrate : 128 kbps",
- new BMessage( SLIDER_AUDIO ),
- 64, 384, B_TRIANGLE_THUMB );
- fAudioSlider->SetValue( 128 );
- fBox->AddChild( fAudioSlider );
-
- /* Destination file */
- r = BRect( 10, 215, fBox->Bounds().Width() - 10, 230 );
- fFileString = new BStringView( r, NULL, "Destination file :" );
- fBox->AddChild( fFileString );
- r = BRect( 10, 235, fBox->Bounds().Width() - 90, 255 );
- fFileControl = new BTextControl( r, NULL, "", DEFAULT_FILE,
- new BMessage() );
- fFileControl->SetDivider( 0 );
- fBox->AddChild( fFileControl );
- r = BRect( fBox->Bounds().Width() - 80, 230,
- fBox->Bounds().Width() - 10, 255 );
- fFileButton = new BButton( r, NULL, "Browse...",
- new BMessage( BUTTON_FILE ) );
- fBox->AddChild( fFileButton );
-
- /* Settings buttons */
- r = BRect( fBox->Bounds().Width() - 200, 275,
- fBox->Bounds().Width() - 100, 300 );
- fPictureButton = new BButton( r, NULL, "Picture settings...",
- new BMessage( BUTTON_PICTURE ) );
- fBox->AddChild( fPictureButton );
-
- r = BRect( fBox->Bounds().Width() - 90, 275,
- fBox->Bounds().Width() - 10, 300 );
- fAdvancedButton = new BButton( r, NULL, "Advanced...",
- new BMessage( BUTTON_ADVANCED ) );
- fBox->AddChild( fAdvancedButton );
-
- view->AddChild( fBox );
-
- /* Status bar */
- r = BRect( 10, view->Bounds().Height() - 75,
- view->Bounds().Width() - 10, view->Bounds().Height() - 45 );
- fStatusBar = new BStatusBar( r, NULL, NULL );
- fStatusBar->SetMaxValue( 1.0 );
- view->AddChild( fStatusBar );
-
- /* Buttons */
- r = BRect( view->Bounds().Width() - 240, view->Bounds().Height() - 35,
- view->Bounds().Width() - 170, view->Bounds().Height() - 10 );
- BButton * aboutButton;
- aboutButton = new BButton( r, NULL, "About...",
- new BMessage( B_ABOUT_REQUESTED ) );
- view->AddChild( aboutButton );
-
- r = BRect( view->Bounds().Width() - 160, view->Bounds().Height() - 35,
- view->Bounds().Width() - 90, view->Bounds().Height() - 10 );
- fSuspendButton = new BButton( r, NULL, "Suspend",
- new BMessage( BUTTON_SUSPEND ) );
- view->AddChild( fSuspendButton );
-
- r = BRect( view->Bounds().Width() - 80, view->Bounds().Height() - 35,
- view->Bounds().Width() - 10, view->Bounds().Height() - 10 );
- fStartButton = new BButton( r, NULL, "Start !",
- new BMessage( BUTTON_START ) );
- view->AddChild( fStartButton );
-
- AddChild( view );
-
- /* -- GUI ends here -- */
-
/* Init libhb & launch the manager thread */
- fManager = new HBManager( debug );
+ fManager = new HBManager( true );
- /* Detects DVD drives & VOB folders, then tell libhb to scan it */
- ScanVolumes();
+ /* Add the scan view */
+ fScanView = new ScanView( fManager );
+ fRipView = new RipView( fManager );
+ AddChild( fScanView );
+
+ /* Resize to fit */
+ ResizeTo( fScanView->Bounds().Width(), fScanView->Bounds().Height() );
+
+ BScreen screen;
+ MoveTo( ( screen.Frame().Width() - fRipView->Bounds().Width() ) / 2,
+ ( screen.Frame().Height() - fRipView->Bounds().Height() ) / 2 );
/* Update the interface */
+ fDie = false;
fUpdateThread = spawn_thread( (int32 (*)(void *)) UpdateInterface,
"interface", B_DISPLAY_PRIORITY, this );
resume_thread( fUpdateThread );
}
-bool HBWindow::QuitRequested()
+bool MainWindow::QuitRequested()
{
/* Clean up */
- kill_thread( fUpdateThread );
+ fDie = true;
+ long exit_value;
+ wait_for_thread( fUpdateThread, &exit_value );
delete fManager;
/* Stop the application */
@@ -250,7 +52,7 @@ bool HBWindow::QuitRequested()
return true;
}
-void HBWindow::MessageReceived( BMessage * message )
+void MainWindow::MessageReceived( BMessage * message )
{
switch( message->what )
{
@@ -269,209 +71,44 @@ void HBWindow::MessageReceived( BMessage * message )
break;
}
- case BUTTON_ADVANCED:
- break;
-
- case BUTTON_FILE:
- break;
-
- case BUTTON_PICTURE:
- {
- HBTitle * title =
- ((HBTitleItem*) fTitlePopUp->FindMarked())->fTitle;
- HBPictureWin * pictureWin = new HBPictureWin( fManager, title );
- pictureWin->Show();
+ case B_REFS_RECEIVED:
+ case SCAN_RADIO:
+ case SCAN_BROWSE_BUTTON:
+ case SCAN_OPEN:
+ fScanView->MessageReceived( message );
break;
- }
-
- case BUTTON_START:
- {
- HBTitle * title =
- ((HBTitleItem*) fTitlePopUp->FindMarked())->fTitle;
- HBAudio * audio1 =
- ((HBAudioItem*) fAudio1PopUp->FindMarked())->fAudio;
- HBAudio * audio2 =
- ((HBAudioItem*) fAudio2PopUp->FindMarked())->fAudio;
-
- title->fBitrate = fVideoSlider->Value();
- if( audio1 )
- {
- audio1->fOutBitrate = fAudioSlider->Value();
- }
- if( audio2 )
- {
- audio2->fOutBitrate = fAudioSlider->Value();
- }
- fManager->StartRip( title, audio1, audio2,
- (char*) fFileControl->Text() );
+ case B_SAVE_REQUESTED:
+ case RIP_TITLE_POPUP:
+ case RIP_BITRATE_RADIO:
+ case RIP_TARGET_CONTROL:
+ case RIP_CROP_BUTTON:
+ case RIP_BROWSE_BUTTON:
+ case RIP_SUSPEND_BUTTON:
+ case RIP_RIP_BUTTON:
+ fRipView->MessageReceived( message );
break;
- }
-
- case BUTTON_CANCEL:
- fManager->StopRip();
- break;
-
- case BUTTON_SUSPEND:
- fManager->SuspendRip();
- break;
-
- case BUTTON_RESUME:
- fManager->ResumeRip();
- break;
-
- case POPUP_AUDIO:
- break;
-
- case POPUP_TITLE:
- {
- HBTitle * title =
- ((HBTitleItem*) fTitlePopUp->FindMarked())->fTitle;
-
- /* Empty audio popups */
- HBAudioItem * audioItem;
- while( ( audioItem = (HBAudioItem*) fAudio1PopUp->ItemAt( 0 ) ) )
- {
- fAudio1PopUp->RemoveItem( audioItem );
- delete audioItem;
- }
- while( ( audioItem = (HBAudioItem*) fAudio2PopUp->ItemAt( 0 ) ) )
- {
- fAudio2PopUp->RemoveItem( audioItem );
- delete audioItem;
- }
-
- HBAudio * audio;
- for( uint32_t i = 0;
- i < title->fAudioList->CountItems();
- i++ )
- {
- audio = (HBAudio*) title->fAudioList->ItemAt( i );
- fAudio1PopUp->AddItem( new HBAudioItem( audio ) );
- fAudio2PopUp->AddItem( new HBAudioItem( audio ) );
- }
- fAudio1PopUp->AddItem( new HBAudioItem( NULL ) );
- fAudio2PopUp->AddItem( new HBAudioItem( NULL ) );
- ((HBAudioItem*) fAudio1PopUp->ItemAt( 0 ))->SetMarked( true );
- ((HBAudioItem*) fAudio2PopUp->ItemAt(
- fAudio2PopUp->CountItems() - 1 ))->SetMarked( true );
-
- break;
- }
-
- case POPUP_VOLUME:
- break;
-
- case SLIDER_AUDIO:
- {
- char label[64]; memset( label, 0, 64 );
- snprintf( label, 128, "Audio bitrate : %ld kbps",
- fAudioSlider->Value() );
- fAudioSlider->SetLabel( label );
- break;
- }
-
- case SLIDER_VIDEO:
- {
- char label[64]; memset( label, 0, 64 );
- snprintf( label, 128, "Video bitrate : %ld kbps",
- fVideoSlider->Value() );
- fVideoSlider->SetLabel( label );
- break;
- }
-
+
default:
BWindow::MessageReceived( message );
break;
}
}
-
-void HBWindow::ScanVolumes()
+void MainWindow::UpdateInterface( MainWindow * _this )
{
- BVolumeRoster * roster = new BVolumeRoster();
- BVolume * bVolume = new BVolume();
- fs_info info;
- int device;
- device_geometry geometry;
-
- HBVolume * volume;
- HBList * volumeList = new HBList();
+ uint64_t time;
- /* Parse mounted volumes */
- while( roster->GetNextVolume( bVolume ) == B_NO_ERROR )
- {
- /* open() and ioctl() for more informations */
- fs_stat_dev( bVolume->Device(), &info );
- if( ( device = open( info.device_name, O_RDONLY ) ) < 0 )
- {
- continue;
- }
-
- if( ioctl( device, B_GET_GEOMETRY, &geometry,
- sizeof( geometry ) ) < 0 )
-
- {
- continue;
- }
-
- /* Get the volume name */
- char volumeName[B_FILE_NAME_LENGTH];
- bVolume->GetName( volumeName );
-
- if( bVolume->IsReadOnly() && geometry.device_type == B_CD )
- {
- /* May be a DVD */
- volume = new HBVolume( info.device_name, volumeName );
- volumeList->AddItem( volume );
- }
- else if( geometry.device_type == B_DISK )
- {
- /* May be a hard drive. Look for VIDEO_TS folders on it */
- BQuery * query = new BQuery();
-
- if( query->SetVolume( bVolume ) != B_OK )
- {
- delete query;
- continue;
- }
-
- if( query->SetPredicate( "name = VIDEO_TS.BUP" ) != B_OK )
- {
- delete query;
- continue;
- }
-
- query->Fetch();
-
- BEntry entry, parentEntry;
- BPath path;
- while( query->GetNextEntry( &entry ) == B_OK )
- {
- entry.GetParent( &parentEntry );
- parentEntry.GetPath( &path );
-
- volume = new HBVolume( (char*) path.Path() );
- volumeList->AddItem( volume );
- }
-
- delete query;
- }
- }
-
- fManager->ScanVolumes( volumeList );
-}
-
-void HBWindow::UpdateInterface( HBWindow * _this )
-{
- for( ;; )
+ while( !_this->fDie )
{
+ /* Update every 0.1 sec */
+ time = system_time();
_this->_UpdateInterface();
- snooze( 10000 );
+ snooze( 100000 - ( system_time() - time ) );
}
}
-void HBWindow::_UpdateInterface()
+void MainWindow::_UpdateInterface()
{
if( !fManager->NeedUpdate() )
{
@@ -486,97 +123,31 @@ void HBWindow::_UpdateInterface()
return;
}
- EnableInterface( status.fMode );
-
switch( status.fMode )
{
case HB_MODE_UNDEF:
+ case HB_MODE_NEED_VOLUME:
break;
-
+
case HB_MODE_SCANNING:
- {
- char text[1024]; memset( text, 0, 1024 );
- sprintf( text, "Scanning %s, title %d...",
- status.fScannedVolume, status.fScannedTitle );
- fStatusBar->Update( - fStatusBar->CurrentValue(), text );
+ case HB_MODE_INVALID_VOLUME:
+ fScanView->UpdateIntf( status );
break;
- }
- case HB_MODE_SCANDONE:
- {
- HBVolume * volume;
- for( uint32_t i = 0;
- i < status.fVolumeList->CountItems();
- i++ )
- {
- volume = (HBVolume*) status.fVolumeList->ItemAt( i );
- fVolumePopUp->AddItem( new HBVolumeItem( volume ) );
- }
- ((HBVolumeItem*) fVolumePopUp->ItemAt( 0 ))->SetMarked( true );
-
- HBTitle * title;
- volume = (HBVolume*) status.fVolumeList->ItemAt( 0 );
- for( uint32_t i = 0;
- i < volume->fTitleList->CountItems();
- i++ )
- {
- title = (HBTitle*) volume->fTitleList->ItemAt( i );
- fTitlePopUp->AddItem( new HBTitleItem( title ) );
- }
- ((HBTitleItem*) fTitlePopUp->ItemAt( 0 ))->SetMarked( true );
-
- HBAudio * audio;
- title = (HBTitle*) volume->fTitleList->ItemAt( 0 );
- for( uint32_t i = 0;
- i < title->fAudioList->CountItems();
- i++ )
- {
- audio = (HBAudio*) title->fAudioList->ItemAt( i );
- fAudio1PopUp->AddItem( new HBAudioItem( audio ) );
- fAudio2PopUp->AddItem( new HBAudioItem( audio ) );
- }
- fAudio1PopUp->AddItem( new HBAudioItem( NULL ) );
- fAudio2PopUp->AddItem( new HBAudioItem( NULL ) );
- ((HBAudioItem*) fAudio1PopUp->ItemAt( 0 ))->SetMarked( true );
- ((HBAudioItem*) fAudio2PopUp->ItemAt(
- fAudio2PopUp->CountItems() - 1 ))->SetMarked( true );
-
- fStatusBar->Update( - fStatusBar->CurrentValue(),
- "Ready. Press 'Start' to rip." );
+ case HB_MODE_READY_TO_RIP:
+ RemoveChild( fScanView );
+ ResizeTo( fRipView->Bounds().Width(),
+ fRipView->Bounds().Height() );
+ AddChild( fRipView );
+ fRipView->UpdateIntf( status );
break;
- }
case HB_MODE_ENCODING:
- {
- char text[1024]; memset( text, 0, 1024 );
- sprintf( text,
- "Encoding : %.2f %%, %.2f fps (%02d:%02d:%02d remaining)",
- 100 * status.fPosition, status.fFrameRate,
- status.fRemainingTime / 3600,
- ( status.fRemainingTime % 3600 ) / 60,
- status.fRemainingTime % 60 );
- fStatusBar->Update( status.fPosition -
- fStatusBar->CurrentValue(), text );
- break;
- }
-
case HB_MODE_SUSPENDED:
- {
- char text[1024]; memset( text, 0, 1024 );
- sprintf( text, "Encoding : %.2f %%, %.2f fps (Paused)",
- 100 * status.fPosition, status.fFrameRate );
- fStatusBar->Update( status.fPosition -
- fStatusBar->CurrentValue(), text );
- break;
- }
-
case HB_MODE_DONE:
- break;
-
case HB_MODE_CANCELED:
- break;
-
case HB_MODE_ERROR:
+ fRipView->UpdateIntf( status );
break;
default:
@@ -586,174 +157,3 @@ void HBWindow::_UpdateInterface()
Unlock();
}
-void HBWindow::EnableInterface( HBMode mode )
-{
- if( mode == fOldMode && mode != HB_MODE_UNDEF )
- {
- return;
- }
-
- switch( mode )
- {
- case HB_MODE_UNDEF:
- {
- fAdvancedButton->SetEnabled( false );
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetEnabled( false );
- fSuspendButton->SetEnabled( false );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- case HB_MODE_SCANNING:
- {
- fAdvancedButton->SetEnabled( true );
- fFileButton->SetEnabled( true );
- fPictureButton->SetEnabled( false );
- fStartButton->SetEnabled( false );
- fSuspendButton->SetEnabled( false );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( true );
- fVideoSlider->SetEnabled( true );
- fFileString->SetHighColor( 0, 0, 0 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( true );
- break;
- }
-
- case HB_MODE_SCANDONE:
- {
- fAdvancedButton->SetEnabled( true );
- fFileButton->SetEnabled( true );
- fPictureButton->SetEnabled( true );
- fStartButton->SetLabel( "Start" );
- fStartButton->SetMessage( new BMessage( BUTTON_START ) );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetEnabled( false );
- fAudio1Field->SetEnabled( true );
- fAudio2Field->SetEnabled( true );
- fTitleField->SetEnabled( true );
- fVolumeField->SetEnabled( true );
- fAudioSlider->SetEnabled( true );
- fVideoSlider->SetEnabled( true );
- fFileString->SetHighColor( 0, 0, 0 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( true );
- break;
- }
-
- case HB_MODE_ENCODING:
- {
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetLabel( "Cancel" );
- fStartButton->SetMessage( new BMessage( BUTTON_CANCEL ) );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetLabel( "Suspend" );
- fSuspendButton->SetMessage( new BMessage( BUTTON_SUSPEND ) );
- fSuspendButton->SetEnabled( true );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- case HB_MODE_SUSPENDED:
- {
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetLabel( "Cancel" );
- fStartButton->SetMessage( new BMessage( BUTTON_CANCEL ) );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetLabel( "Resume" );
- fSuspendButton->SetMessage( new BMessage( BUTTON_RESUME ) );
- fSuspendButton->SetEnabled( true );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- case HB_MODE_DONE:
- {
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetEnabled( true );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- case HB_MODE_CANCELED:
- {
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetEnabled( true );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- case HB_MODE_ERROR:
- {
- fFileButton->SetEnabled( false );
- fPictureButton->SetEnabled( false );
- fStartButton->SetEnabled( true );
- fSuspendButton->SetEnabled( true );
- fAudio1Field->SetEnabled( false );
- fAudio2Field->SetEnabled( false );
- fTitleField->SetEnabled( false );
- fVolumeField->SetEnabled( false );
- fAudioSlider->SetEnabled( false );
- fVideoSlider->SetEnabled( false );
- fFileString->SetHighColor( 156, 156, 156 );
- fFileString->Invalidate();
- fFileControl->SetEnabled( false );
- break;
- }
-
- default:
- break;
- }
-}
-
diff --git a/beos/MainWindow.h b/beos/MainWindow.h
index e40c2587a..c4c32a711 100644
--- a/beos/MainWindow.h
+++ b/beos/MainWindow.h
@@ -1,4 +1,4 @@
-/* $Id: MainWindow.h,v 1.9 2003/09/30 14:38:15 titer Exp $
+/* $Id: MainWindow.h,v 1.10 2003/10/10 01:08:42 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -8,93 +8,29 @@
#ifndef HB_MAIN_WINDOW_H
#define HB_MAIN_WINDOW_H
-/* BeOS headers */
-#include <Box.h>
-#include <MenuItem.h>
#include <Window.h>
-class BButton;
-class BMenuField;
-class BPopUpMenu;
-class BSlider;
-class BStatusBar;
-class BStringView;
-class BTextControl;
+class ScanView;
+class RipView;
-/* libhb headers */
-#include "Manager.h"
+#include "Common.h"
-class HBVolumeItem : public BMenuItem
+class MainWindow : public BWindow
{
public:
- HBVolumeItem( HBVolume * volume );
-
- HBVolume * fVolume;
-};
-
-class HBTitleItem : public BMenuItem
-{
- public:
- HBTitleItem( HBTitle * title );
-
- HBTitle * fTitle;
-};
-
-class HBAudioItem : public BMenuItem
-{
- public:
- HBAudioItem( HBAudio * audio );
-
- HBAudio * fAudio;
-};
-
-class HBBox : public BBox
-{
- public:
- HBBox( BRect );
- void Draw( BRect );
-};
-
-class HBWindow : public BWindow
-{
- public:
- HBWindow( bool debug );
+ MainWindow();
virtual bool QuitRequested();
virtual void MessageReceived( BMessage * message );
- void ScanVolumes();
-
private:
- static void UpdateInterface( HBWindow * _this );
+ static void UpdateInterface( MainWindow * _this );
void _UpdateInterface();
- void EnableInterface( HBMode mode );
HBManager * fManager;
-
- /* GUI */
- HBBox * fBox;
- BButton * fAdvancedButton;
- BButton * fFileButton;
- BButton * fPictureButton;
- BButton * fStartButton;
- BButton * fSuspendButton;
- BMenuField * fAudio1Field;
- BMenuField * fAudio2Field;
- BMenuField * fTitleField;
- BMenuField * fVolumeField;
- BPopUpMenu * fAudio1PopUp;
- BPopUpMenu * fAudio2PopUp;
- BPopUpMenu * fTitlePopUp;
- BPopUpMenu * fVolumePopUp;
- BSlider * fAudioSlider;
- BSlider * fVideoSlider;
- BStatusBar * fStatusBar;
- BStringView * fFileString;
- BTextControl * fFileControl;
-
int fUpdateThread;
+ volatile bool fDie;
- /* Used to SetEnabled() GUI items only if needed */
- HBMode fOldMode;
+ ScanView * fScanView;
+ RipView * fRipView;
};
#endif
diff --git a/beos/RipView.cpp b/beos/RipView.cpp
new file mode 100644
index 000000000..180ba23ff
--- /dev/null
+++ b/beos/RipView.cpp
@@ -0,0 +1,616 @@
+/* $Id: RipView.cpp,v 1.6 2003/10/13 23:42:03 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://beos.titer.org/handbrake/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#include <Box.h>
+#include <Button.h>
+#include <CheckBox.h>
+#include <FilePanel.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <Path.h>
+#include <PopUpMenu.h>
+#include <RadioButton.h>
+#include <StatusBar.h>
+#include <String.h>
+#include <TextControl.h>
+
+#include "RipView.h"
+#include "PictureWin.h"
+#include "Manager.h"
+
+#define DEFAULT_FILE "/boot/home/Desktop/Movie.avi"
+
+RipView::RipView( HBManager * manager )
+ : BView( BRect( 0,0,400,480 ), NULL, B_FOLLOW_ALL, B_WILL_DRAW )
+{
+ fManager = manager;
+
+ BRect r;
+ SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+
+ /* Video box */
+ r = BRect( 10, 10, Bounds().Width() - 10, 160 );
+ fVideoBox = new BBox( r );
+ fVideoBox->SetLabel( "Video" );
+ AddChild( fVideoBox );
+
+ /* Title */
+ r = BRect( 10, 15, fVideoBox->Bounds().Width() - 10, 35 );
+ fTitlePopUp = new BPopUpMenu( "" );
+ fTitleField = new BMenuField( r, NULL, "Title:",
+ fTitlePopUp, true );
+ fVideoBox->AddChild( fTitleField );
+
+ /* Video codec */
+ r = BRect( 10, 40, fVideoBox->Bounds().Width() - 10, 60 );
+ fVideoCodecPopUp = new BPopUpMenu( "" );
+ fVideoCodecField = new BMenuField( r, NULL, "Codec:",
+ fVideoCodecPopUp, true );
+ fVideoBox->AddChild( fVideoCodecField );
+
+ /* Video bitrate */
+ r = BRect( 10, 65, fVideoBox->Bounds().Width() / 2, 85 );
+ fCustomBitrateRadio =
+ new BRadioButton( r, NULL, "Custom bitrate (kbps)",
+ new BMessage( RIP_BITRATE_RADIO ) );
+ fCustomBitrateRadio->SetValue( 1 );
+ fVideoBox->AddChild( fCustomBitrateRadio );
+ r = BRect( fVideoBox->Bounds().Width() - 80, 65,
+ fVideoBox->Bounds().Width() - 10, 85 );
+ fCustomBitrateControl = new BTextControl( r, NULL, NULL, "1024", NULL );
+ fCustomBitrateControl->SetDivider( 0 );
+ fVideoBox->AddChild( fCustomBitrateControl );
+ r = BRect( 10, 90, fVideoBox->Bounds().Width() / 2, 110 );
+ fTargetSizeRadio =
+ new BRadioButton( r, NULL, "Target size (MB)",
+ new BMessage( RIP_BITRATE_RADIO ) );
+ fVideoBox->AddChild( fTargetSizeRadio );
+ r = BRect( fVideoBox->Bounds().Width() - 80, 90,
+ fVideoBox->Bounds().Width() - 10, 110 );
+ fTargetSizeControl = new BTextControl( r, NULL, NULL, "700", NULL );
+ fTargetSizeControl->SetDivider( 0 );
+ fTargetSizeControl->SetEnabled( false );
+ fTargetSizeControl->SetModificationMessage(
+ new BMessage( RIP_TARGET_CONTROL ) );
+ fVideoBox->AddChild( fTargetSizeControl );
+
+ /* 2-pass */
+ r = BRect( 10, 125, fVideoBox->Bounds().Width() / 2, 140 );
+ fTwoPassCheck = new BCheckBox( r, NULL, "2-pass encoding", NULL );
+ fVideoBox->AddChild( fTwoPassCheck );
+
+ /* Crop */
+ r = BRect( fVideoBox->Bounds().Width() - 120, 120,
+ fVideoBox->Bounds().Width() - 10, 140 );
+ fCropButton = new BButton( r, NULL, "Crop & Resize...",
+ new BMessage( RIP_CROP_BUTTON ) );
+ fVideoBox->AddChild( fCropButton );
+
+ /* Audio box */
+ r = BRect( 10, 170, Bounds().Width() - 10, 290 );
+ fAudioBox = new BBox( r );
+ fAudioBox->SetLabel( "Audio" );
+ AddChild( fAudioBox );
+
+ /* Language */
+ r = BRect( 10, 15, fAudioBox->Bounds().Width() - 10, 35 );
+ fLanguagePopUp = new BPopUpMenu( "" );
+ fLanguageField = new BMenuField( r, NULL, "Language:",
+ fLanguagePopUp, true );
+ fAudioBox->AddChild( fLanguageField );
+
+ /* Secondary language */
+ r = BRect( 10, 40, fAudioBox->Bounds().Width() - 10, 60 );
+ fSecondaryLanguagePopUp = new BPopUpMenu( "" );
+ fSecondaryLanguageField = new BMenuField( r, NULL, "Secondary language:",
+ fSecondaryLanguagePopUp, true );
+ fAudioBox->AddChild( fSecondaryLanguageField );
+
+ /* Audio codec */
+ r = BRect( 10, 65, fAudioBox->Bounds().Width() - 10, 85 );
+ fAudioCodecPopUp = new BPopUpMenu( "" );
+ fAudioCodecField = new BMenuField( r, NULL, "Codec:",
+ fAudioCodecPopUp, true );
+ fAudioBox->AddChild( fAudioCodecField );
+
+ /* Audio bitrate */
+ r = BRect( 10, 90, fAudioBox->Bounds().Width() - 10, 110 );
+ fAudioBitratePopUp = new BPopUpMenu( "" );
+ fAudioBitrateField = new BMenuField( r, NULL, "Bitrate:",
+ fAudioBitratePopUp, true );
+ fAudioBox->AddChild( fAudioBitrateField );
+
+ /* Destination box */
+ r = BRect( 10, 300, Bounds().Width() - 10, 395 );
+ fDestinationBox = new BBox( r );
+ fDestinationBox->SetLabel( "Destination" );
+ AddChild( fDestinationBox );
+
+ /* File format */
+ r = BRect( 10, 15, fDestinationBox->Bounds().Width() - 10, 35 );
+ fFileFormatPopUp = new BPopUpMenu( "" );
+ fFileFormatField = new BMenuField( r, NULL, "File format:",
+ fFileFormatPopUp, true );
+ fDestinationBox->AddChild( fFileFormatField );
+
+ /* File location */
+ r = BRect( 10, 40, fDestinationBox->Bounds().Width() - 10, 60 );
+ fFileControl = new BTextControl( r, NULL, "Location:",
+ DEFAULT_FILE, NULL );
+ fFileControl->SetDivider( 100 );
+ fDestinationBox->AddChild( fFileControl );
+
+ /* Browse button */
+ r = BRect( fDestinationBox->Bounds().Width() - 80, 65,
+ fDestinationBox->Bounds().Width() - 10, 85 );
+ fFileButton = new BButton( r, NULL, "Browse...",
+ new BMessage( RIP_BROWSE_BUTTON ) );
+ fDestinationBox->AddChild( fFileButton );
+
+ fFilePanel = new BFilePanel( B_SAVE_PANEL, NULL, NULL, 0, false );
+
+ /* Status bar */
+ r = BRect( 10, 405, Bounds().Width() - 10, 435 );
+ fStatusBar = new BStatusBar( r, NULL );
+ AddChild( fStatusBar );
+
+ /* Suspend/Rip buttons */
+ r = BRect( Bounds().Width() - 180, 445,
+ Bounds().Width() - 100, 465 );
+ fSuspendButton = new BButton( r, NULL, "Suspend",
+ new BMessage( RIP_SUSPEND_BUTTON ) );
+ fSuspendButton->SetEnabled( false );
+ AddChild( fSuspendButton );
+ r = BRect( Bounds().Width() - 90, 445,
+ Bounds().Width() - 10, 465 );
+ fStartButton = new BButton( r, NULL, "Rip !",
+ new BMessage( RIP_RIP_BUTTON ) );
+ fStartButton->MakeDefault( true );
+ AddChild( fStartButton );
+
+ /* Fill popups */
+ fVideoCodecPopUp->AddItem( new BMenuItem( "MPEG-4", NULL ) );
+ fVideoCodecPopUp->ItemAt( 0 )->SetMarked( true );
+ fAudioCodecPopUp->AddItem( new BMenuItem( "MP3", NULL ) );
+ fAudioCodecPopUp->ItemAt( 0 )->SetMarked( true );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "32", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "64", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "96", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "128", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "160", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "192", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "224", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "256", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "288", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->AddItem(
+ new BMenuItem( "320", new BMessage( RIP_TARGET_CONTROL ) ) );
+ fAudioBitratePopUp->ItemAt( 3 )->SetMarked( true );
+ fFileFormatPopUp->AddItem( new BMenuItem( "AVI", NULL ) );
+ fFileFormatPopUp->ItemAt( 0 )->SetMarked( true );
+}
+
+void RipView::MessageReceived( BMessage * message )
+{
+ switch( message->what )
+ {
+ case RIP_TITLE_POPUP:
+ {
+ int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() );
+ HBTitle * title = (HBTitle*) fTitleList->ItemAt( index );
+
+ /* Empty current popups */
+ BMenuItem * item;
+ while( ( item = fLanguagePopUp->ItemAt( 0 ) ) )
+ {
+ fLanguagePopUp->RemoveItem( item );
+ delete item;
+ }
+ while( ( item = fSecondaryLanguagePopUp->ItemAt( 0 ) ) )
+ {
+ fSecondaryLanguagePopUp->RemoveItem( item );
+ delete item;
+ }
+
+ /* Show new languages */
+ HBAudio * audio;
+ for( uint32_t i = 0; i < title->fAudioList->CountItems(); i++ )
+ {
+ audio = (HBAudio*) title->fAudioList->ItemAt( i );
+ fLanguagePopUp->AddItem(
+ new BMenuItem( audio->fDescription, NULL ) );
+ fSecondaryLanguagePopUp->AddItem(
+ new BMenuItem( audio->fDescription,
+ new BMessage( RIP_TARGET_CONTROL ) ) );
+ }
+ fLanguagePopUp->ItemAt( 0 )->SetMarked( true );
+ fSecondaryLanguagePopUp->AddItem( new BMenuItem( "None",
+ new BMessage( RIP_TARGET_CONTROL ) ) );
+ fSecondaryLanguagePopUp->ItemAt(
+ fSecondaryLanguagePopUp->CountItems() - 1 )->SetMarked( true );
+
+ fSecondaryLanguageField->SetEnabled(
+ ( title->fAudioList->CountItems() > 1 ) );
+
+ break;
+ }
+
+ case RIP_BITRATE_RADIO:
+ {
+ if( fCustomBitrateRadio->Value() )
+ {
+ fCustomBitrateControl->SetEnabled( true );
+ fTargetSizeControl->SetEnabled( false );
+ }
+ else
+ {
+ fCustomBitrateControl->SetEnabled( false );
+ fTargetSizeControl->SetEnabled( true );
+ Window()->PostMessage( RIP_TARGET_CONTROL );
+ }
+ break;
+ }
+
+ case RIP_TARGET_CONTROL:
+ {
+ if( !fTargetSizeRadio->Value() )
+ {
+ break;
+ }
+
+ int64_t available;
+ int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() );
+ HBTitle * title = (HBTitle*) fTitleList->ItemAt( index );
+
+ available = (int64_t) 1024 * 1024 *
+ atoi( fTargetSizeControl->Text() );
+
+ /* AVI headers */
+ available -= 2048;
+
+ /* Video chunk headers (8 bytes / frame) and
+ and index (16 bytes / frame) */
+ available -= 24 * title->fLength * title->fRate /
+ title->fScale;
+
+ /* Audio tracks */
+ available -=
+ ( strcmp( fSecondaryLanguagePopUp->FindMarked()->Label(),
+ "None" ) ? 2 : 1 ) *
+ ( title->fLength *
+ atoi( fAudioBitratePopUp->FindMarked()->Label() ) * 128 +
+ 24 * title->fLength * 44100 / 1152 );
+
+ char string[1024]; memset( string, 0, 1024 );
+ if( available < 0 )
+ {
+ sprintf( string, "0" );
+ }
+ else
+ {
+ sprintf( string, "%lld", available /
+ ( 128 * title->fLength ) );
+ }
+ fCustomBitrateControl->SetText( string );
+ break;
+ }
+
+ case RIP_CROP_BUTTON:
+ {
+ int index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() );
+ HBTitle * title = (HBTitle*) fTitleList->ItemAt( index );
+
+ HBPictureWin * win;
+ win = new HBPictureWin( fManager, title );
+ win->Show();
+ break;
+ }
+
+ case RIP_BROWSE_BUTTON:
+ {
+ fFilePanel->Show();
+ }
+
+ case B_SAVE_REQUESTED:
+ {
+ entry_ref ref;
+ BString string;
+ if( message->FindRef( "directory", 0, &ref ) == B_OK &&
+ message->FindString( "name", &string ) == B_OK )
+ {
+ BPath * path = new BPath( &ref );
+ string.Prepend( "/" );
+ string.Prepend( path->Path() );
+ fFileControl->SetText( string.String() );
+ }
+ break;
+ }
+
+ case RIP_SUSPEND_BUTTON:
+ {
+ if( strcmp( fSuspendButton->Label(), "Suspend" ) )
+ {
+ fManager->ResumeRip();
+ }
+ else
+ {
+ fManager->SuspendRip();
+ }
+
+ break;
+ }
+
+ case RIP_RIP_BUTTON:
+ {
+ if( strcmp( fStartButton->Label(), "Rip !" ) )
+ {
+ fManager->StopRip();
+ }
+ else
+ {
+ int index;
+
+ /* Get asked title & languages */
+ index = fTitlePopUp->IndexOf( fTitlePopUp->FindMarked() );
+ HBTitle * title = (HBTitle*) fTitleList->ItemAt( index );
+ index = fLanguagePopUp->IndexOf( fLanguagePopUp->FindMarked() );
+ HBAudio * audio1 =
+ (HBAudio*) title->fAudioList->ItemAt( index );
+ index = fSecondaryLanguagePopUp->IndexOf(
+ fSecondaryLanguagePopUp->FindMarked() );
+ HBAudio * audio2 =
+ (HBAudio*) title->fAudioList->ItemAt( index );
+
+ /* Use user settings */
+ title->fBitrate = atoi( fCustomBitrateControl->Text() );
+ title->fTwoPass = ( fTwoPassCheck->Value() != 0 );
+ audio1->fOutBitrate =
+ atoi( fAudioBitratePopUp->FindMarked()->Label() );
+ if( audio2 )
+ {
+ audio2->fOutBitrate =
+ atoi( fAudioBitratePopUp->FindMarked()->Label() );
+ }
+
+ /* Let libhb do the job */
+ fManager->StartRip( title, audio1, audio2,
+ (char*) fFileControl->Text() );
+ }
+ break;
+ }
+
+ default:
+ BView::MessageReceived( message );
+ break;
+ }
+}
+
+void RipView::UpdateIntf( HBStatus status )
+{
+ switch( status.fMode )
+ {
+ case HB_MODE_READY_TO_RIP:
+ {
+ fTitleList = status.fTitleList;
+
+ HBTitle * title;
+ for( uint32_t i = 0; i < fTitleList->CountItems(); i++ )
+ {
+ title = (HBTitle*) fTitleList->ItemAt( i );
+ char string[1024]; memset( string, 0, 1024 );
+ sprintf( string, "%d (%02lld:%02lld:%02lld)",
+ title->fIndex, title->fLength / 3600,
+ ( title->fLength % 3600 ) / 60,
+ title->fLength % 60 );
+ fTitlePopUp->AddItem(
+ new BMenuItem( string, new BMessage( RIP_TITLE_POPUP ) ) );
+ }
+ fTitlePopUp->ItemAt( 0 )->SetMarked( true );
+ Window()->PostMessage( RIP_TITLE_POPUP );
+ break;
+ }
+
+ case HB_MODE_ENCODING:
+ {
+ fTitleField->SetEnabled( false );
+ fVideoCodecField->SetEnabled( false );
+ fCustomBitrateRadio->SetEnabled( false );
+ fCustomBitrateControl->SetEnabled( false );
+ fTargetSizeRadio->SetEnabled( false );
+ fTargetSizeControl->SetEnabled( false );
+ fTwoPassCheck->SetEnabled( false );
+ fCropButton->SetEnabled( false );
+ fLanguageField->SetEnabled( false );
+ fSecondaryLanguageField->SetEnabled( false );
+ fAudioCodecField->SetEnabled( false );
+ fAudioBitrateField->SetEnabled( false );
+ fFileFormatField->SetEnabled( false );
+ fFileControl->SetEnabled( false );
+ fFileButton->SetEnabled( false );
+
+ if( !status.fPosition )
+ {
+ fStatusBar->Update( - fStatusBar->CurrentValue(),
+ "Starting..." );
+ }
+ else
+ {
+ char string[1024]; memset( string, 0, 1024 );
+ sprintf( string, "Encoding: %.2f %% (%.2f fps, "
+ "%02d:%02d:%02d remaining)",
+ 100 * status.fPosition,
+ status.fFrameRate,
+ status.fRemainingTime / 3600,
+ ( status.fRemainingTime % 3600 ) / 60,
+ status.fRemainingTime % 60 );
+ fStatusBar->Update( 100 * status.fPosition -
+ fStatusBar->CurrentValue(),
+ string );
+ }
+
+ fSuspendButton->SetLabel( "Suspend" );
+ fSuspendButton->SetEnabled( true );
+ fStartButton->SetLabel( "Cancel" );
+ fStartButton->SetEnabled( true );
+ break;
+ }
+
+ case HB_MODE_SUSPENDED:
+ {
+ fTitleField->SetEnabled( false );
+ fVideoCodecField->SetEnabled( false );
+ fCustomBitrateRadio->SetEnabled( false );
+ fCustomBitrateControl->SetEnabled( false );
+ fTargetSizeRadio->SetEnabled( false );
+ fTargetSizeControl->SetEnabled( false );
+ fTwoPassCheck->SetEnabled( false );
+ fCropButton->SetEnabled( false );
+ fLanguageField->SetEnabled( false );
+ fSecondaryLanguageField->SetEnabled( false );
+ fAudioCodecField->SetEnabled( false );
+ fAudioBitrateField->SetEnabled( false );
+ fFileFormatField->SetEnabled( false );
+ fFileControl->SetEnabled( false );
+ fFileButton->SetEnabled( false );
+
+ fStatusBar->Update( 100 * status.fPosition -
+ fStatusBar->CurrentValue(), "Suspended" );
+
+ fSuspendButton->SetLabel( "Resume" );
+ fSuspendButton->SetEnabled( true );
+ fStartButton->SetLabel( "Cancel" );
+ fStartButton->SetEnabled( true );
+ break;
+ }
+
+ case HB_MODE_STOPPING:
+ {
+ fTitleField->SetEnabled( false );
+ fVideoCodecField->SetEnabled( false );
+ fCustomBitrateRadio->SetEnabled( false );
+ fCustomBitrateControl->SetEnabled( false );
+ fTargetSizeRadio->SetEnabled( false );
+ fTargetSizeControl->SetEnabled( false );
+ fTwoPassCheck->SetEnabled( false );
+ fCropButton->SetEnabled( false );
+ fLanguageField->SetEnabled( false );
+ fSecondaryLanguageField->SetEnabled( false );
+ fAudioCodecField->SetEnabled( false );
+ fAudioBitrateField->SetEnabled( false );
+ fFileFormatField->SetEnabled( false );
+ fFileControl->SetEnabled( false );
+ fFileButton->SetEnabled( false );
+
+ fStatusBar->Update( - fStatusBar->CurrentValue(),
+ "Stopping..." );
+
+ fSuspendButton->SetLabel( "Suspend" );
+ fSuspendButton->SetEnabled( false );
+ fStartButton->SetLabel( "Cancel" );
+ fStartButton->SetEnabled( false );
+ break;
+ }
+
+ case HB_MODE_DONE:
+ {
+ fTitleField->SetEnabled( true );
+ fVideoCodecField->SetEnabled( true );
+ fCustomBitrateRadio->SetEnabled( true );
+ fCustomBitrateControl->SetEnabled( fCustomBitrateRadio->Value() );
+ fTargetSizeRadio->SetEnabled( true );
+ fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() );
+ fTwoPassCheck->SetEnabled( true );
+ fCropButton->SetEnabled( true );
+ fLanguageField->SetEnabled( true );
+ fSecondaryLanguageField->SetEnabled(
+ ( fSecondaryLanguagePopUp->CountItems() > 2 ) );
+ fAudioCodecField->SetEnabled( true );
+ fAudioBitrateField->SetEnabled( true );
+ fFileFormatField->SetEnabled( true );
+ fFileControl->SetEnabled( true );
+ fFileButton->SetEnabled( true );
+
+ fStatusBar->Update( 100.0 - fStatusBar->CurrentValue(),
+ "Done." );
+
+ fSuspendButton->SetLabel( "Suspend" );
+ fSuspendButton->SetEnabled( false );
+ fStartButton->SetLabel( "Rip !" );
+ fStartButton->SetEnabled( true );
+ break;
+ }
+
+ case HB_MODE_CANCELED:
+ {
+ fTitleField->SetEnabled( true );
+ fVideoCodecField->SetEnabled( true );
+ fCustomBitrateRadio->SetEnabled( true );
+ fCustomBitrateControl->SetEnabled( fCustomBitrateRadio->Value() );
+ fTargetSizeRadio->SetEnabled( true );
+ fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() );
+ fTwoPassCheck->SetEnabled( true );
+ fCropButton->SetEnabled( true );
+ fLanguageField->SetEnabled( true );
+ fSecondaryLanguageField->SetEnabled(
+ ( fSecondaryLanguagePopUp->CountItems() > 2 ) );
+ fAudioCodecField->SetEnabled( true );
+ fAudioBitrateField->SetEnabled( true );
+ fFileFormatField->SetEnabled( true );
+ fFileControl->SetEnabled( true );
+ fFileButton->SetEnabled( true );
+
+ fStatusBar->Update( - fStatusBar->CurrentValue(),
+ "Canceled." );
+
+ fSuspendButton->SetLabel( "Suspend" );
+ fSuspendButton->SetEnabled( false );
+ fStartButton->SetLabel( "Rip !" );
+ fStartButton->SetEnabled( true );
+ break;
+ }
+
+ case HB_MODE_ERROR:
+ {
+ fTitleField->SetEnabled( true );
+ fVideoCodecField->SetEnabled( true );
+ fCustomBitrateRadio->SetEnabled( true );
+ fCustomBitrateControl->SetEnabled( fCustomBitrateRadio->Value() );
+ fTargetSizeRadio->SetEnabled( true );
+ fTargetSizeControl->SetEnabled( fTargetSizeRadio->Value() );
+ fTwoPassCheck->SetEnabled( true );
+ fCropButton->SetEnabled( true );
+ fLanguageField->SetEnabled( true );
+ fSecondaryLanguageField->SetEnabled(
+ ( fSecondaryLanguagePopUp->CountItems() > 2 ) );
+ fAudioCodecField->SetEnabled( true );
+ fAudioBitrateField->SetEnabled( true );
+ fFileFormatField->SetEnabled( true );
+ fFileControl->SetEnabled( true );
+ fFileButton->SetEnabled( true );
+
+ fStatusBar->Update( - fStatusBar->CurrentValue(),
+ "Error." );
+
+ fSuspendButton->SetLabel( "Suspend" );
+ fSuspendButton->SetEnabled( false );
+ fStartButton->SetLabel( "Rip !" );
+ fStartButton->SetEnabled( true );
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
diff --git a/beos/RipView.h b/beos/RipView.h
new file mode 100644
index 000000000..d487b2b99
--- /dev/null
+++ b/beos/RipView.h
@@ -0,0 +1,77 @@
+/* $Id: RipView.h,v 1.5 2003/10/13 22:23:02 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://beos.titer.org/handbrake/>.
+ It may be used under the terms of the GNU General Public License. */
+
+
+#ifndef HB_RIP_VIEW_H
+#define HB_RIP_VIEW_H
+
+#include <View.h>
+class BBox;
+class BButton;
+class BCheckBox;
+class BFilePanel;
+class BMenuField;
+class BPopUpMenu;
+class BRadioButton;
+class BStatusBar;
+class BTextControl;
+
+#include "Common.h"
+
+#define RIP_TITLE_POPUP 'rtip'
+#define RIP_BITRATE_RADIO 'rbir'
+#define RIP_TARGET_CONTROL 'rtac'
+#define RIP_CROP_BUTTON 'rcrb'
+#define RIP_BROWSE_BUTTON 'rbrb'
+#define RIP_SUSPEND_BUTTON 'rsub'
+#define RIP_RIP_BUTTON 'rrib'
+
+class RipView : public BView
+{
+ public:
+ RipView( HBManager * manager );
+ void MessageReceived( BMessage * message );
+ void UpdateIntf( HBStatus status );
+
+ private:
+ HBManager * fManager;
+ HBList * fTitleList;
+
+ BBox * fVideoBox;
+ BPopUpMenu * fTitlePopUp;
+ BMenuField * fTitleField;
+ BPopUpMenu * fVideoCodecPopUp;
+ BMenuField * fVideoCodecField;
+ BRadioButton * fCustomBitrateRadio;
+ BTextControl * fCustomBitrateControl;
+ BRadioButton * fTargetSizeRadio;
+ BTextControl * fTargetSizeControl;
+ BCheckBox * fTwoPassCheck;
+ BButton * fCropButton;
+
+ BBox * fAudioBox;
+ BPopUpMenu * fLanguagePopUp;
+ BMenuField * fLanguageField;
+ BPopUpMenu * fSecondaryLanguagePopUp;
+ BMenuField * fSecondaryLanguageField;
+ BPopUpMenu * fAudioCodecPopUp;
+ BMenuField * fAudioCodecField;
+ BPopUpMenu * fAudioBitratePopUp;
+ BMenuField * fAudioBitrateField;
+
+ BBox * fDestinationBox;
+ BPopUpMenu * fFileFormatPopUp;
+ BMenuField * fFileFormatField;
+ BTextControl * fFileControl;
+ BButton * fFileButton;
+ BFilePanel * fFilePanel;
+
+ BStatusBar * fStatusBar;
+ BButton * fSuspendButton;
+ BButton * fStartButton;
+};
+
+#endif
diff --git a/beos/ScanView.cpp b/beos/ScanView.cpp
new file mode 100644
index 000000000..fb5d722e8
--- /dev/null
+++ b/beos/ScanView.cpp
@@ -0,0 +1,280 @@
+/* $Id: ScanView.cpp,v 1.4 2003/10/13 23:42:03 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://beos.titer.org/handbrake/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#include <fs_info.h>
+#include <sys/ioctl.h>
+#include <Box.h>
+#include <Button.h>
+#include <Directory.h>
+#include <Drivers.h>
+#include <FilePanel.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <Path.h>
+#include <PopUpMenu.h>
+#include <Query.h>
+#include <RadioButton.h>
+#include <StringView.h>
+#include <TextControl.h>
+#include <VolumeRoster.h>
+
+#include "Manager.h"
+#include "ScanView.h"
+
+ScanView::ScanView( HBManager * manager )
+ : BView( BRect( 0,0,400,190 ), NULL, B_FOLLOW_ALL, B_WILL_DRAW )
+{
+ fManager = manager;
+
+ BRect r;
+ SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+
+ r = BRect( 10, 10, Bounds().Width() - 10, 115 );
+ BBox * box = new BBox( r );
+ box->SetLabel( "Select source:" );
+ AddChild( box );
+
+ r = BRect( 10, 15, box->Bounds().Width() / 2, 35 );
+ fRadioDetected = new BRadioButton( r, NULL, "Detected volume:",
+ new BMessage( SCAN_RADIO ) );
+ box->AddChild( fRadioDetected );
+
+ r = BRect( box->Bounds().Width() / 2, 15,
+ box->Bounds().Width() - 10, 35 );
+ fPopUp = new BPopUpMenu( "" );
+ fField = new BMenuField( r, NULL, NULL, fPopUp, true );
+ fField->SetDivider( 0 );
+ box->AddChild( fField );
+
+ r = BRect( 10, 45, box->Bounds().Width() / 3, 65 );
+ fRadioFolder = new BRadioButton( r, NULL, "DVD folder:",
+ new BMessage( SCAN_RADIO ) );
+ box->AddChild( fRadioFolder );
+
+ r = BRect( box->Bounds().Width() / 3, 45,
+ box->Bounds().Width() - 10, 65 );
+ fFolderControl = new BTextControl( r, NULL, NULL, NULL, NULL );
+ box->AddChild( fFolderControl );
+
+ r = BRect( box->Bounds().Width() - 80, 70,
+ box->Bounds().Width() - 10, 95 );
+ fBrowseButton = new BButton( r, NULL, "Browse...",
+ new BMessage( SCAN_BROWSE_BUTTON ) );
+ box->AddChild( fBrowseButton );
+
+ fFilePanel = new BFilePanel( B_OPEN_PANEL, NULL,
+ NULL, B_DIRECTORY_NODE );
+
+ r = BRect( 10, 125, Bounds().Width() - 10, 145 );
+ fStatusString = new BStringView( r, NULL, NULL );
+ AddChild( fStatusString );
+
+ r = BRect( Bounds().Width() - 70, 155,
+ Bounds().Width() - 10, 175 );
+ fOpenButton = new BButton( r, NULL, "Open", new BMessage( SCAN_OPEN ) );
+ fOpenButton->MakeDefault( true );
+ AddChild( fOpenButton );
+
+ DetectVolumes();
+}
+
+void ScanView::MessageReceived( BMessage * message )
+{
+ switch( message->what )
+ {
+ case SCAN_RADIO:
+ {
+ if( fRadioDetected->Value() )
+ {
+ fField->SetEnabled( true );
+ fFolderControl->SetEnabled( false );
+ fBrowseButton->SetEnabled( false );
+ fOpenButton->SetEnabled( fPopUp->CountItems() > 0 );
+ }
+ else
+ {
+ fField->SetEnabled( false );
+ fFolderControl->SetEnabled( true );
+ fBrowseButton->SetEnabled( true );
+ fOpenButton->SetEnabled( true );
+ }
+ break;
+ }
+
+ case SCAN_BROWSE_BUTTON:
+ {
+ fFilePanel->Show();
+ break;
+ }
+
+ case B_REFS_RECEIVED:
+ {
+ entry_ref ref;
+ if( message->FindRef( "refs", 0, &ref ) == B_OK )
+ {
+ BPath * path = new BPath( &ref );
+ fFolderControl->SetText( path->Path() );
+ }
+ break;
+ }
+
+ case SCAN_OPEN:
+ {
+ if( fRadioDetected->Value() )
+ {
+ fManager->ScanVolumes( (char*)
+ fPopUp->FindMarked()->Label() );
+ }
+ else
+ {
+ fManager->ScanVolumes( (char*) fFolderControl->Text() );
+ }
+ break;
+ }
+
+ default:
+ BView::MessageReceived( message );
+ }
+}
+
+void ScanView::UpdateIntf( HBStatus status )
+{
+ switch( status.fMode )
+ {
+ case HB_MODE_SCANNING:
+ {
+ fRadioDetected->SetEnabled( false );
+ fRadioFolder->SetEnabled( false );
+ fField->SetEnabled( false );
+ fFolderControl->SetEnabled( false );
+ fBrowseButton->SetEnabled( false );
+ fOpenButton->SetEnabled( false );
+
+ char string[1024]; memset( string, 0, 1024 );
+ if( !status.fScannedTitle )
+ {
+ sprintf( string, "Opening %s...",
+ status.fScannedVolume );
+ }
+ else
+ {
+ sprintf( string, "Scanning %s, title %d...",
+ status.fScannedVolume, status.fScannedTitle );
+ }
+ fStatusString->SetText( string );
+ break;
+ }
+
+ case HB_MODE_INVALID_VOLUME:
+ {
+ fRadioDetected->SetEnabled( true );
+ fRadioFolder->SetEnabled( true );
+
+ if( fRadioDetected->Value() )
+ {
+ fField->SetEnabled( true );
+ fFolderControl->SetEnabled( false );
+ fBrowseButton->SetEnabled( false );
+ fOpenButton->SetEnabled( fPopUp->CountItems() > 0 );
+ }
+ else
+ {
+ fField->SetEnabled( false );
+ fFolderControl->SetEnabled( true );
+ fBrowseButton->SetEnabled( true );
+ fOpenButton->SetEnabled( true );
+ }
+
+ fStatusString->SetText( "Invalid volume." );
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+void ScanView::DetectVolumes()
+{
+ BVolumeRoster * roster = new BVolumeRoster();
+ BVolume * volume = new BVolume();
+ fs_info info;
+ int device;
+ device_geometry geometry;
+
+ /* Parse mounted volumes */
+ while( roster->GetNextVolume( volume ) == B_NO_ERROR )
+ {
+ /* open() and ioctl() for more informations */
+ fs_stat_dev( volume->Device(), &info );
+ if( ( device = open( info.device_name, O_RDONLY ) ) < 0 )
+ {
+ continue;
+ }
+
+ if( ioctl( device, B_GET_GEOMETRY, &geometry,
+ sizeof( geometry ) ) < 0 )
+
+ {
+ continue;
+ }
+
+ /* Get the volume name */
+ char volumeName[B_FILE_NAME_LENGTH];
+ volume->GetName( volumeName );
+
+ if( volume->IsReadOnly() && geometry.device_type == B_CD )
+ {
+ /* May be a DVD */
+ fPopUp->AddItem( new BMenuItem( info.device_name, NULL ) );
+ }
+ else if( geometry.device_type == B_DISK )
+ {
+ /* May be a hard drive. Look for VIDEO_TS folders on it */
+ BQuery * query = new BQuery();
+
+ if( query->SetVolume( volume ) != B_OK )
+ {
+ delete query;
+ continue;
+ }
+
+ if( query->SetPredicate( "name = VIDEO_TS.BUP" ) != B_OK )
+ {
+ delete query;
+ continue;
+ }
+
+ query->Fetch();
+
+ BEntry entry, parentEntry;
+ BPath path;
+ while( query->GetNextEntry( &entry ) == B_OK )
+ {
+ entry.GetParent( &parentEntry );
+ parentEntry.GetPath( &path );
+
+ fPopUp->AddItem( new BMenuItem( path.Path(), NULL ) );
+ }
+
+ delete query;
+ }
+ }
+
+ if( fPopUp->CountItems() > 0 )
+ {
+ fPopUp->ItemAt( 0 )->SetMarked( true );
+ fRadioDetected->SetValue( true );
+ fFolderControl->SetEnabled( false );
+ fBrowseButton->SetEnabled( false );
+ }
+ else
+ {
+ fRadioFolder->SetValue( true );
+ fField->SetEnabled( false );
+ }
+}
+
diff --git a/beos/ScanView.h b/beos/ScanView.h
new file mode 100644
index 000000000..5e2514b54
--- /dev/null
+++ b/beos/ScanView.h
@@ -0,0 +1,48 @@
+/* $Id: ScanView.h,v 1.2 2003/10/13 22:23:02 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://beos.titer.org/handbrake/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#ifndef HB_SCAN_VIEW_H
+#define HB_SCAN_VIEW_H
+
+#include <View.h>
+class BButton;
+class BFilePanel;
+class BMenuField;
+class BPopUpMenu;
+class BRadioButton;
+class BStringView;
+class BTextControl;
+
+#include "Common.h"
+
+#define SCAN_RADIO 'scra'
+#define SCAN_BROWSE_BUTTON 'sbrb'
+#define SCAN_OPEN 'scop'
+
+class ScanView : public BView
+{
+ public:
+ ScanView( HBManager * manager );
+ void MessageReceived( BMessage * message );
+ void UpdateIntf( HBStatus status );
+
+ private:
+ void DetectVolumes();
+
+ HBManager * fManager;
+
+ BRadioButton * fRadioDetected;
+ BRadioButton * fRadioFolder;
+ BMenuField * fField;
+ BPopUpMenu * fPopUp;
+ BTextControl * fFolderControl;
+ BButton * fBrowseButton;
+ BFilePanel * fFilePanel;
+ BStringView * fStatusString;
+ BButton * fOpenButton;
+};
+
+#endif