Commit 9d3b03de authored by Eric Petit's avatar Eric Petit

+ input/decoder.c: detach decoder after vout_Request(...,0,0,0,0)ing

     so AttachSPU can still reach p_input
 + src/video_output/*: init mouse variable before attaching p_vout so
     dvdnav can't add callbacks on those before there're created
 + beos/VideoOutput.cpp: removed tabs, sanity check
parent 2c6dfafb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method * vout_beos.cpp: beos video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: VideoOutput.cpp,v 1.29 2003/12/28 01:49:12 titer Exp $ * $Id$
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc_keys.h> #include <vlc_keys.h>
#include "InterfaceWindow.h" // for load/save_settings() #include "InterfaceWindow.h" // for load/save_settings()
#include "DrawingTidbits.h" #include "DrawingTidbits.h"
#include "MsgVals.h" #include "MsgVals.h"
...@@ -76,8 +76,8 @@ struct vout_sys_t ...@@ -76,8 +76,8 @@ struct vout_sys_t
}; };
#define MOUSE_IDLE_TIMEOUT 2000000 // two seconds #define MOUSE_IDLE_TIMEOUT 2000000 // two seconds
#define MIN_AUTO_VSYNC_REFRESH 61 // Hz #define MIN_AUTO_VSYNC_REFRESH 61 // Hz
#define DEFAULT_SCREEN_SHOT_FORMAT 'PNG ' #define DEFAULT_SCREEN_SHOT_FORMAT 'PNG '
#define DEFAULT_SCREEN_SHOT_PATH "/boot/home/vlc screenshot" #define DEFAULT_SCREEN_SHOT_PATH "/boot/home/vlc screenshot"
...@@ -167,42 +167,42 @@ static int ConvertKeyToVLC( int key ) ...@@ -167,42 +167,42 @@ static int ConvertKeyToVLC( int key )
BWindow* BWindow*
get_interface_window() get_interface_window()
{ {
return beos_GetAppWindow( "VLC " PACKAGE_VERSION ); return beos_GetAppWindow( "VLC " PACKAGE_VERSION );
} }
class BackgroundView : public BView class BackgroundView : public BView
{ {
public: public:
BackgroundView(BRect frame, VLCView* view) BackgroundView(BRect frame, VLCView* view)
: BView(frame, "background", : BView(frame, "background",
B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE), B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE),
fVideoView(view) fVideoView(view)
{ {
SetViewColor(kBlack); SetViewColor(kBlack);
} }
virtual ~BackgroundView() {} virtual ~BackgroundView() {}
virtual void MouseDown(BPoint where) virtual void MouseDown(BPoint where)
{ {
// convert coordinates // convert coordinates
where = fVideoView->ConvertFromParent(where); where = fVideoView->ConvertFromParent(where);
// let him handle it // let him handle it
fVideoView->MouseDown(where); fVideoView->MouseDown(where);
} }
virtual void MouseMoved(BPoint where, uint32_t transit, virtual void MouseMoved(BPoint where, uint32_t transit,
const BMessage* dragMessage) const BMessage* dragMessage)
{ {
// convert coordinates // convert coordinates
where = fVideoView->ConvertFromParent(where); where = fVideoView->ConvertFromParent(where);
// let him handle it // let him handle it
fVideoView->MouseMoved(where, transit, dragMessage); fVideoView->MouseMoved(where, transit, dragMessage);
// notice: It might look like transit should be // notice: It might look like transit should be
// B_OUTSIDE_VIEW regardless, but leave it like this, // B_OUTSIDE_VIEW regardless, but leave it like this,
// otherwise, unwanted things will happen! // otherwise, unwanted things will happen!
} }
private: private:
VLCView* fVideoView; VLCView* fVideoView;
}; };
...@@ -210,65 +210,65 @@ class BackgroundView : public BView ...@@ -210,65 +210,65 @@ class BackgroundView : public BView
* VideoSettings constructor and destructor * VideoSettings constructor and destructor
*****************************************************************************/ *****************************************************************************/
VideoSettings::VideoSettings() VideoSettings::VideoSettings()
: fVideoSize( SIZE_100 ), : fVideoSize( SIZE_100 ),
fFlags( FLAG_CORRECT_RATIO ), fFlags( FLAG_CORRECT_RATIO ),
fSettings( new BMessage( 'sett' ) ) fSettings( new BMessage( 'sett' ) )
{ {
// read settings from disk // read settings from disk
status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" ); status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" );
if ( ret == B_OK ) if ( ret == B_OK )
{ {
uint32_t flags; uint32_t flags;
if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK ) if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK )
SetFlags( flags ); SetFlags( flags );
uint32_t size; uint32_t size;
if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK ) if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK )
SetVideoSize( size ); SetVideoSize( size );
} }
else else
{ {
// figure out if we should use vertical sync by default // figure out if we should use vertical sync by default
BScreen screen(B_MAIN_SCREEN_ID); BScreen screen(B_MAIN_SCREEN_ID);
if (screen.IsValid()) if (screen.IsValid())
{ {
display_mode mode; display_mode mode;
screen.GetMode(&mode); screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000) float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total)* (mode.timing.v_total)); / ((mode.timing.h_total)* (mode.timing.v_total));
if (refresh < MIN_AUTO_VSYNC_REFRESH) if (refresh < MIN_AUTO_VSYNC_REFRESH)
AddFlags(FLAG_SYNC_RETRACE); AddFlags(FLAG_SYNC_RETRACE);
} }
} }
} }
VideoSettings::VideoSettings( const VideoSettings& clone ) VideoSettings::VideoSettings( const VideoSettings& clone )
: fVideoSize( clone.VideoSize() ), : fVideoSize( clone.VideoSize() ),
fFlags( clone.Flags() ), fFlags( clone.Flags() ),
fSettings( NULL ) fSettings( NULL )
{ {
} }
VideoSettings::~VideoSettings() VideoSettings::~VideoSettings()
{ {
if ( fSettings ) if ( fSettings )
{ {
// we are the default settings // we are the default settings
// and write our settings to disk // and write our settings to disk
if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK) if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK)
fSettings->AddInt32( "video size", VideoSize() ); fSettings->AddInt32( "video size", VideoSize() );
if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK) if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK)
fSettings->AddInt32( "flags", Flags() ); fSettings->AddInt32( "flags", Flags() );
save_settings( fSettings, "video_settings", "VideoLAN Client" ); save_settings( fSettings, "video_settings", "VideoLAN Client" );
delete fSettings; delete fSettings;
} }
else else
{ {
// we are just a clone of the default settings // we are just a clone of the default settings
fDefaultSettings.SetVideoSize( VideoSize() ); fDefaultSettings.SetVideoSize( VideoSize() );
fDefaultSettings.SetFlags( Flags() ); fDefaultSettings.SetFlags( Flags() );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -277,7 +277,7 @@ VideoSettings::~VideoSettings() ...@@ -277,7 +277,7 @@ VideoSettings::~VideoSettings()
VideoSettings* VideoSettings*
VideoSettings::DefaultSettings() VideoSettings::DefaultSettings()
{ {
return &fDefaultSettings; return &fDefaultSettings;
} }
/***************************************************************************** /*****************************************************************************
...@@ -286,7 +286,7 @@ VideoSettings::DefaultSettings() ...@@ -286,7 +286,7 @@ VideoSettings::DefaultSettings()
void void
VideoSettings::SetVideoSize( uint32_t mode ) VideoSettings::SetVideoSize( uint32_t mode )
{ {
fVideoSize = mode; fVideoSize = mode;
} }
// static variable initialization // static variable initialization
...@@ -299,35 +299,35 @@ VideoSettings::fDefaultSettings; ...@@ -299,35 +299,35 @@ VideoSettings::fDefaultSettings;
*****************************************************************************/ *****************************************************************************/
VideoWindow::VideoWindow(int v_width, int v_height, BRect frame, VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
vout_thread_t *p_videoout) vout_thread_t *p_videoout)
: BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE), : BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
i_width(frame.IntegerWidth()), i_width(frame.IntegerWidth()),
i_height(frame.IntegerHeight()), i_height(frame.IntegerHeight()),
winSize(frame), winSize(frame),
i_buffer(0), i_buffer(0),
teardownwindow(false), teardownwindow(false),
fTrueWidth(v_width), fTrueWidth(v_width),
fTrueHeight(v_height), fTrueHeight(v_height),
fCachedFeel(B_NORMAL_WINDOW_FEEL), fCachedFeel(B_NORMAL_WINDOW_FEEL),
fInterfaceShowing(false), fInterfaceShowing(false),
fInitStatus(B_ERROR), fInitStatus(B_ERROR),
fSettings(new VideoSettings(*VideoSettings::DefaultSettings())) fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
{ {
p_vout = p_videoout; p_vout = p_videoout;
// create the view to do the display // create the view to do the display
view = new VLCView( Bounds(), p_vout ); view = new VLCView( Bounds(), p_vout );
// create background view // create background view
BView *mainView = new BackgroundView( Bounds(), view ); BView *mainView = new BackgroundView( Bounds(), view );
AddChild(mainView); AddChild(mainView);
mainView->AddChild(view); mainView->AddChild(view);
// allocate bitmap buffers // allocate bitmap buffers
for (int32_t i = 0; i < 3; i++) for (int32_t i = 0; i < 3; i++)
bitmap[i] = NULL; bitmap[i] = NULL;
fInitStatus = _AllocateBuffers(v_width, v_height, &mode); fInitStatus = _AllocateBuffers(v_width, v_height, &mode);
// make sure we layout the view correctly // make sure we layout the view correctly
FrameResized(i_width, i_height); FrameResized(i_width, i_height);
if (fInitStatus >= B_OK && mode == OVERLAY) if (fInitStatus >= B_OK && mode == OVERLAY)
...@@ -339,9 +339,9 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame, ...@@ -339,9 +339,9 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
(i_height * r.min_height_scale), i_height * r.max_height_scale); (i_height * r.min_height_scale), i_height * r.max_height_scale);
} }
// vlc settings override settings from disk // vlc settings override settings from disk
if (config_GetInt(p_vout, "fullscreen")) if (config_GetInt(p_vout, "fullscreen"))
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN); fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
// add a few useful shortcuts // add a few useful shortcuts
// XXX works only with US keymap // XXX works only with US keymap
...@@ -359,7 +359,7 @@ VideoWindow::~VideoWindow() ...@@ -359,7 +359,7 @@ VideoWindow::~VideoWindow()
teardownwindow = true; teardownwindow = true;
wait_for_thread(fDrawThreadID, &result); wait_for_thread(fDrawThreadID, &result);
_FreeBuffers(); _FreeBuffers();
delete fSettings; delete fSettings;
} }
/***************************************************************************** /*****************************************************************************
...@@ -368,90 +368,90 @@ VideoWindow::~VideoWindow() ...@@ -368,90 +368,90 @@ VideoWindow::~VideoWindow()
void void
VideoWindow::MessageReceived( BMessage *p_message ) VideoWindow::MessageReceived( BMessage *p_message )
{ {
switch( p_message->what ) switch( p_message->what )
{ {
case SHOW_INTERFACE: case SHOW_INTERFACE:
SetInterfaceShowing( true ); SetInterfaceShowing( true );
break; break;
case TOGGLE_FULL_SCREEN: case TOGGLE_FULL_SCREEN:
BWindow::Zoom(); BWindow::Zoom();
break; break;
case RESIZE_50: case RESIZE_50:
case RESIZE_100: case RESIZE_100:
case RESIZE_200: case RESIZE_200:
if (IsFullScreen()) if (IsFullScreen())
BWindow::Zoom(); BWindow::Zoom();
_SetVideoSize(p_message->what); _SetVideoSize(p_message->what);
break; break;
case VERT_SYNC: case VERT_SYNC:
SetSyncToRetrace(!IsSyncedToRetrace()); SetSyncToRetrace(!IsSyncedToRetrace());
break; break;
case WINDOW_FEEL: case WINDOW_FEEL:
{ {
window_feel winFeel; window_feel winFeel;
if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK) if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK)
{ {
SetFeel(winFeel); SetFeel(winFeel);
fCachedFeel = winFeel; fCachedFeel = winFeel;
if (winFeel == B_FLOATING_ALL_WINDOW_FEEL) if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)
fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL); fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);
else else
fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL); fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);
} }
} }
break; break;
case ASPECT_CORRECT: case ASPECT_CORRECT:
SetCorrectAspectRatio(!CorrectAspectRatio()); SetCorrectAspectRatio(!CorrectAspectRatio());
break; break;
case SCREEN_SHOT: case SCREEN_SHOT:
// save a screen shot // save a screen shot
if ( BBitmap* current = bitmap[i_buffer] ) if ( BBitmap* current = bitmap[i_buffer] )
{ {
// the following line might be tempting, but does not work for some overlay bitmaps!!! // the following line might be tempting, but does not work for some overlay bitmaps!!!
// BBitmap* temp = new BBitmap( current ); // BBitmap* temp = new BBitmap( current );
// so we clone the bitmap ourselves // so we clone the bitmap ourselves
// however, we need to take care of potentially different padding! // however, we need to take care of potentially different padding!
// memcpy() is slow when reading from grafix memory, but what the heck... // memcpy() is slow when reading from grafix memory, but what the heck...
BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() ); BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() );
if ( temp && temp->IsValid() ) if ( temp && temp->IsValid() )
{ {
int32_t height = (int32_t)current->Bounds().Height(); int32_t height = (int32_t)current->Bounds().Height();
uint8_t* dst = (uint8_t*)temp->Bits(); uint8_t* dst = (uint8_t*)temp->Bits();
uint8_t* src = (uint8_t*)current->Bits(); uint8_t* src = (uint8_t*)current->Bits();
int32_t dstBpr = temp->BytesPerRow(); int32_t dstBpr = temp->BytesPerRow();
int32_t srcBpr = current->BytesPerRow(); int32_t srcBpr = current->BytesPerRow();
int32_t validBytes = dstBpr > srcBpr ? srcBpr : dstBpr; int32_t validBytes = dstBpr > srcBpr ? srcBpr : dstBpr;
for ( int32_t y = 0; y < height; y++ ) for ( int32_t y = 0; y < height; y++ )
{ {
memcpy( dst, src, validBytes ); memcpy( dst, src, validBytes );
dst += dstBpr; dst += dstBpr;
src += srcBpr; src += srcBpr;
} }
char * path = config_GetPsz( p_vout, "beos-screenshotpath" ); char * path = config_GetPsz( p_vout, "beos-screenshotpath" );
if ( !path ) if ( !path )
path = strdup( DEFAULT_SCREEN_SHOT_PATH ); path = strdup( DEFAULT_SCREEN_SHOT_PATH );
/* FIXME - we should check which translators are /* FIXME - we should check which translators are
actually available */ actually available */
char * psz_format = config_GetPsz( p_vout, "beos-screenshotformat" ); char * psz_format = config_GetPsz( p_vout, "beos-screenshotformat" );
int32_t format = DEFAULT_SCREEN_SHOT_FORMAT; int32_t format = DEFAULT_SCREEN_SHOT_FORMAT;
if( !strcmp( psz_format, "TGA" ) ) if( !strcmp( psz_format, "TGA" ) )
format = 'TGA '; format = 'TGA ';
else if( !strcmp( psz_format, "PPM" ) ) else if( !strcmp( psz_format, "PPM" ) )
format = 'PPM '; format = 'PPM ';
else if( !strcmp( psz_format, "JPEG" ) ) else if( !strcmp( psz_format, "JPEG" ) )
format = 'JPEG'; format = 'JPEG';
else if( !strcmp( psz_format, "BMP" ) ) else if( !strcmp( psz_format, "BMP" ) )
format = 'BMP '; format = 'BMP ';
_SaveScreenShot( temp, path, format ); _SaveScreenShot( temp, path, format );
} }
else else
{ {
delete temp; delete temp;
} }
} }
break; break;
case SHORTCUT: case SHORTCUT:
{ {
vlc_value_t val; vlc_value_t val;
...@@ -459,10 +459,10 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -459,10 +459,10 @@ VideoWindow::MessageReceived( BMessage *p_message )
var_Set( p_vout->p_vlc, "key-pressed", val ); var_Set( p_vout->p_vlc, "key-pressed", val );
break; break;
} }
default: default:
BWindow::MessageReceived( p_message ); BWindow::MessageReceived( p_message );
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -471,7 +471,7 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -471,7 +471,7 @@ VideoWindow::MessageReceived( BMessage *p_message )
void void
VideoWindow::Zoom(BPoint origin, float width, float height ) VideoWindow::Zoom(BPoint origin, float width, float height )
{ {
ToggleFullScreen(); ToggleFullScreen();
} }
/***************************************************************************** /*****************************************************************************
...@@ -480,9 +480,9 @@ VideoWindow::Zoom(BPoint origin, float width, float height ) ...@@ -480,9 +480,9 @@ VideoWindow::Zoom(BPoint origin, float width, float height )
void void
VideoWindow::FrameMoved(BPoint origin) VideoWindow::FrameMoved(BPoint origin)
{ {
if (IsFullScreen()) if (IsFullScreen())
return ; return ;
winSize = Frame(); winSize = Frame();
} }
/***************************************************************************** /*****************************************************************************
...@@ -515,7 +515,7 @@ VideoWindow::FrameResized( float width, float height ) ...@@ -515,7 +515,7 @@ VideoWindow::FrameResized( float width, float height )
view->MoveTo(out_left,out_top); view->MoveTo(out_left,out_top);
view->ResizeTo(out_width, out_height); view->ResizeTo(out_width, out_height);
if (!IsFullScreen()) if (!IsFullScreen())
winSize = Frame(); winSize = Frame();
} }
...@@ -525,12 +525,12 @@ VideoWindow::FrameResized( float width, float height ) ...@@ -525,12 +525,12 @@ VideoWindow::FrameResized( float width, float height )
void void
VideoWindow::ScreenChanged(BRect frame, color_space format) VideoWindow::ScreenChanged(BRect frame, color_space format)
{ {
BScreen screen(this); BScreen screen(this);
display_mode mode; display_mode mode;
screen.GetMode(&mode); screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000) float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total) * (mode.timing.v_total)); / ((mode.timing.h_total) * (mode.timing.v_total));
SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH); SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);
} }
/***************************************************************************** /*****************************************************************************
...@@ -565,10 +565,10 @@ VideoWindow::drawBuffer(int bufferIndex) ...@@ -565,10 +565,10 @@ VideoWindow::drawBuffer(int bufferIndex)
bitmap[i_buffer]->Bounds() , bitmap[i_buffer]->Bounds() ,
view->Bounds(), view->Bounds(),
&key, B_FOLLOW_ALL, &key, B_FOLLOW_ALL,
B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL| B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL|
B_OVERLAY_TRANSFER_CHANNEL); B_OVERLAY_TRANSFER_CHANNEL);
view->SetViewColor(key); view->SetViewColor(key);
} }
else else
{ {
// switch the bitmap // switch the bitmap
...@@ -584,7 +584,7 @@ VideoWindow::drawBuffer(int bufferIndex) ...@@ -584,7 +584,7 @@ VideoWindow::drawBuffer(int bufferIndex)
void void
VideoWindow::ToggleInterfaceShowing() VideoWindow::ToggleInterfaceShowing()
{ {
SetInterfaceShowing(!fInterfaceShowing); SetInterfaceShowing(!fInterfaceShowing);
} }
/***************************************************************************** /*****************************************************************************
...@@ -593,24 +593,24 @@ VideoWindow::ToggleInterfaceShowing() ...@@ -593,24 +593,24 @@ VideoWindow::ToggleInterfaceShowing()
void void
VideoWindow::SetInterfaceShowing(bool showIt) VideoWindow::SetInterfaceShowing(bool showIt)
{ {
BWindow* window = get_interface_window(); BWindow* window = get_interface_window();
if (window) if (window)
{ {
if (showIt) if (showIt)
{ {
if (fCachedFeel != B_NORMAL_WINDOW_FEEL) if (fCachedFeel != B_NORMAL_WINDOW_FEEL)
SetFeel(B_NORMAL_WINDOW_FEEL); SetFeel(B_NORMAL_WINDOW_FEEL);
window->Activate(true); window->Activate(true);
SendBehind(window); SendBehind(window);
} }
else else
{ {
SetFeel(fCachedFeel); SetFeel(fCachedFeel);
Activate(true); Activate(true);
window->SendBehind(this); window->SendBehind(this);
} }
fInterfaceShowing = showIt; fInterfaceShowing = showIt;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -619,14 +619,14 @@ VideoWindow::SetInterfaceShowing(bool showIt) ...@@ -619,14 +619,14 @@ VideoWindow::SetInterfaceShowing(bool showIt)
void void
VideoWindow::SetCorrectAspectRatio(bool doIt) VideoWindow::SetCorrectAspectRatio(bool doIt)
{ {
if (CorrectAspectRatio() != doIt) if (CorrectAspectRatio() != doIt)
{ {
if (doIt) if (doIt)
fSettings->AddFlags(VideoSettings::FLAG_CORRECT_RATIO); fSettings->AddFlags(VideoSettings::FLAG_CORRECT_RATIO);
else else
fSettings->ClearFlags(VideoSettings::FLAG_CORRECT_RATIO); fSettings->ClearFlags(VideoSettings::FLAG_CORRECT_RATIO);
FrameResized(Bounds().Width(), Bounds().Height()); FrameResized(Bounds().Width(), Bounds().Height());
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -635,7 +635,7 @@ VideoWindow::SetCorrectAspectRatio(bool doIt) ...@@ -635,7 +635,7 @@ VideoWindow::SetCorrectAspectRatio(bool doIt)
bool bool
VideoWindow::CorrectAspectRatio() const VideoWindow::CorrectAspectRatio() const
{ {
return fSettings->HasFlags(VideoSettings::FLAG_CORRECT_RATIO); return fSettings->HasFlags(VideoSettings::FLAG_CORRECT_RATIO);
} }
/***************************************************************************** /*****************************************************************************
...@@ -644,7 +644,7 @@ VideoWindow::CorrectAspectRatio() const ...@@ -644,7 +644,7 @@ VideoWindow::CorrectAspectRatio() const
void void
VideoWindow::ToggleFullScreen() VideoWindow::ToggleFullScreen()
{ {
SetFullScreen(!IsFullScreen()); SetFullScreen(!IsFullScreen());
} }
/***************************************************************************** /*****************************************************************************
...@@ -653,27 +653,27 @@ VideoWindow::ToggleFullScreen() ...@@ -653,27 +653,27 @@ VideoWindow::ToggleFullScreen()
void void
VideoWindow::SetFullScreen(bool doIt) VideoWindow::SetFullScreen(bool doIt)
{ {
if (doIt) if (doIt)
{ {
SetLook( B_NO_BORDER_WINDOW_LOOK ); SetLook( B_NO_BORDER_WINDOW_LOOK );
BScreen screen( this ); BScreen screen( this );
BRect rect = screen.Frame(); BRect rect = screen.Frame();
Activate(); Activate();
MoveTo(0.0, 0.0); MoveTo(0.0, 0.0);
ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
be_app->ObscureCursor(); be_app->ObscureCursor();
fInterfaceShowing = false; fInterfaceShowing = false;
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN); fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
} }
else else
{ {
SetLook( B_TITLED_WINDOW_LOOK ); SetLook( B_TITLED_WINDOW_LOOK );
MoveTo(winSize.left, winSize.top); MoveTo(winSize.left, winSize.top);
ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight()); ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());
be_app->ShowCursor(); be_app->ShowCursor();
fInterfaceShowing = true; fInterfaceShowing = true;
fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN); fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -682,7 +682,7 @@ VideoWindow::SetFullScreen(bool doIt) ...@@ -682,7 +682,7 @@ VideoWindow::SetFullScreen(bool doIt)
bool bool
VideoWindow::IsFullScreen() const VideoWindow::IsFullScreen() const
{ {
return fSettings->HasFlags(VideoSettings::FLAG_FULL_SCREEN); return fSettings->HasFlags(VideoSettings::FLAG_FULL_SCREEN);
} }
/***************************************************************************** /*****************************************************************************
...@@ -691,10 +691,10 @@ VideoWindow::IsFullScreen() const ...@@ -691,10 +691,10 @@ VideoWindow::IsFullScreen() const
void void
VideoWindow::SetSyncToRetrace(bool doIt) VideoWindow::SetSyncToRetrace(bool doIt)
{ {
if (doIt) if (doIt)
fSettings->AddFlags(VideoSettings::FLAG_SYNC_RETRACE); fSettings->AddFlags(VideoSettings::FLAG_SYNC_RETRACE);
else else
fSettings->ClearFlags(VideoSettings::FLAG_SYNC_RETRACE); fSettings->ClearFlags(VideoSettings::FLAG_SYNC_RETRACE);
} }
/***************************************************************************** /*****************************************************************************
...@@ -703,7 +703,7 @@ VideoWindow::SetSyncToRetrace(bool doIt) ...@@ -703,7 +703,7 @@ VideoWindow::SetSyncToRetrace(bool doIt)
bool bool
VideoWindow::IsSyncedToRetrace() const VideoWindow::IsSyncedToRetrace() const
{ {
return fSettings->HasFlags(VideoSettings::FLAG_SYNC_RETRACE); return fSettings->HasFlags(VideoSettings::FLAG_SYNC_RETRACE);
} }
...@@ -713,15 +713,15 @@ VideoWindow::IsSyncedToRetrace() const ...@@ -713,15 +713,15 @@ VideoWindow::IsSyncedToRetrace() const
status_t status_t
VideoWindow::_AllocateBuffers(int width, int height, int* mode) VideoWindow::_AllocateBuffers(int width, int height, int* mode)
{ {
// clear any old buffers // clear any old buffers
_FreeBuffers(); _FreeBuffers();
// set default mode // set default mode
*mode = BITMAP; *mode = BITMAP;
BRect bitmapFrame( 0, 0, width, height ); BRect bitmapFrame( 0, 0, width, height );
// read from config, if we are supposed to use overlay at all // read from config, if we are supposed to use overlay at all
int noOverlay = !config_GetInt( p_vout, "overlay" ); int noOverlay = !config_GetInt( p_vout, "overlay" );
// test for overlay capability // test for overlay capability
for (int i = 0; i < COLOR_COUNT; i++) for (int i = 0; i < COLOR_COUNT; i++)
{ {
if (noOverlay) break; if (noOverlay) break;
...@@ -746,8 +746,8 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -746,8 +746,8 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
bitmap[0]->Bounds() , bitmap[0]->Bounds() ,
view->Bounds(), view->Bounds(),
&key, B_FOLLOW_ALL, &key, B_FOLLOW_ALL,
B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL); B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL);
view->SetViewColor(key); view->SetViewColor(key);
SetTitle("VLC " PACKAGE_VERSION " (Overlay)"); SetTitle("VLC " PACKAGE_VERSION " (Overlay)");
break; break;
} }
...@@ -759,12 +759,12 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -759,12 +759,12 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
} }
else else
delete bitmap[0]; delete bitmap[0];
} }
if (*mode == BITMAP) if (*mode == BITMAP)
{ {
// fallback to RGB // fallback to RGB
colspace_index = DEFAULT_COL; // B_RGB32 colspace_index = DEFAULT_COL; // B_RGB32
SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" ); SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" );
bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace );
bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace );
...@@ -774,16 +774,16 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -774,16 +774,16 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
status_t status = B_ERROR; status_t status = B_ERROR;
for (int32_t i = 0; i < 3; i++) for (int32_t i = 0; i < 3; i++)
{ {
if (bitmap[i]) if (bitmap[i])
status = bitmap[i]->InitCheck(); status = bitmap[i]->InitCheck();
if (status < B_OK) if (status < B_OK)
break; break;
} }
if (status >= B_OK) if (status >= B_OK)
{ {
// clear bitmaps to black // clear bitmaps to black
for (int32_t i = 0; i < 3; i++) for (int32_t i = 0; i < 3; i++)
_BlankBitmap(bitmap[i]); _BlankBitmap(bitmap[i]);
} }
return status; return status;
} }
...@@ -794,13 +794,13 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -794,13 +794,13 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
void void
VideoWindow::_FreeBuffers() VideoWindow::_FreeBuffers()
{ {
delete bitmap[0]; delete bitmap[0];
bitmap[0] = NULL; bitmap[0] = NULL;
delete bitmap[1]; delete bitmap[1];
bitmap[1] = NULL; bitmap[1] = NULL;
delete bitmap[2]; delete bitmap[2];
bitmap[2] = NULL; bitmap[2] = NULL;
fInitStatus = B_ERROR; fInitStatus = B_ERROR;
} }
/***************************************************************************** /*****************************************************************************
...@@ -809,75 +809,75 @@ VideoWindow::_FreeBuffers() ...@@ -809,75 +809,75 @@ VideoWindow::_FreeBuffers()
void void
VideoWindow::_BlankBitmap(BBitmap* bitmap) const VideoWindow::_BlankBitmap(BBitmap* bitmap) const
{ {
// no error checking (we do that earlier on and since it's a private function... // no error checking (we do that earlier on and since it's a private function...
// YCbCr: // YCbCr:
// Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128) // Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
// YUV: // YUV:
// Extrema points are Y 0 - 207 (absolute) U -91 - 91 (offset 128) V -127 - 127 (offset 128) // Extrema points are Y 0 - 207 (absolute) U -91 - 91 (offset 128) V -127 - 127 (offset 128)
// we only handle weird colorspaces with special care // we only handle weird colorspaces with special care
switch (bitmap->ColorSpace()) { switch (bitmap->ColorSpace()) {
case B_YCbCr422: { case B_YCbCr422: {
// Y0[7:0] Cb0[7:0] Y1[7:0] Cr0[7:0] Y2[7:0] Cb2[7:0] Y3[7:0] Cr2[7:0] // Y0[7:0] Cb0[7:0] Y1[7:0] Cr0[7:0] Y2[7:0] Cb2[7:0] Y3[7:0] Cr2[7:0]
int32_t height = bitmap->Bounds().IntegerHeight() + 1; int32_t height = bitmap->Bounds().IntegerHeight() + 1;
uint8_t* bits = (uint8_t*)bitmap->Bits(); uint8_t* bits = (uint8_t*)bitmap->Bits();
int32_t bpr = bitmap->BytesPerRow(); int32_t bpr = bitmap->BytesPerRow();
for (int32_t y = 0; y < height; y++) { for (int32_t y = 0; y < height; y++) {
// handle 2 bytes at a time // handle 2 bytes at a time
for (int32_t i = 0; i < bpr; i += 2) { for (int32_t i = 0; i < bpr; i += 2) {
// offset into line // offset into line
bits[i] = 16; bits[i] = 16;
bits[i + 1] = 128; bits[i + 1] = 128;
} }
// next line // next line
bits += bpr; bits += bpr;
} }
break; break;
} }
case B_YCbCr420: { case B_YCbCr420: {
// TODO: untested!! // TODO: untested!!
// Non-interlaced only, Cb0 Y0 Y1 Cb2 Y2 Y3 on even scan lines ... // Non-interlaced only, Cb0 Y0 Y1 Cb2 Y2 Y3 on even scan lines ...
// Cr0 Y0 Y1 Cr2 Y2 Y3 on odd scan lines // Cr0 Y0 Y1 Cr2 Y2 Y3 on odd scan lines
int32_t height = bitmap->Bounds().IntegerHeight() + 1; int32_t height = bitmap->Bounds().IntegerHeight() + 1;
uint8_t* bits = (uint8_t*)bitmap->Bits(); uint8_t* bits = (uint8_t*)bitmap->Bits();
int32_t bpr = bitmap->BytesPerRow(); int32_t bpr = bitmap->BytesPerRow();
for (int32_t y = 0; y < height; y += 1) { for (int32_t y = 0; y < height; y += 1) {
// handle 3 bytes at a time // handle 3 bytes at a time
for (int32_t i = 0; i < bpr; i += 3) { for (int32_t i = 0; i < bpr; i += 3) {
// offset into line // offset into line
bits[i] = 128; bits[i] = 128;
bits[i + 1] = 16; bits[i + 1] = 16;
bits[i + 2] = 16; bits[i + 2] = 16;
} }
// next line // next line
bits += bpr; bits += bpr;
} }
break; break;
} }
case B_YUV422: { case B_YUV422: {
// TODO: untested!! // TODO: untested!!
// U0[7:0] Y0[7:0] V0[7:0] Y1[7:0] U2[7:0] Y2[7:0] V2[7:0] Y3[7:0] // U0[7:0] Y0[7:0] V0[7:0] Y1[7:0] U2[7:0] Y2[7:0] V2[7:0] Y3[7:0]
int32_t height = bitmap->Bounds().IntegerHeight() + 1; int32_t height = bitmap->Bounds().IntegerHeight() + 1;
uint8_t* bits = (uint8_t*)bitmap->Bits(); uint8_t* bits = (uint8_t*)bitmap->Bits();
int32_t bpr = bitmap->BytesPerRow(); int32_t bpr = bitmap->BytesPerRow();
for (int32_t y = 0; y < height; y += 1) { for (int32_t y = 0; y < height; y += 1) {
// handle 2 bytes at a time // handle 2 bytes at a time
for (int32_t i = 0; i < bpr; i += 2) { for (int32_t i = 0; i < bpr; i += 2) {
// offset into line // offset into line
bits[i] = 128; bits[i] = 128;
bits[i + 1] = 0; bits[i + 1] = 0;
} }
// next line // next line
bits += bpr; bits += bpr;
} }
break; break;
} }
default: default:
memset(bitmap->Bits(), 0, bitmap->BitsLength()); memset(bitmap->Bits(), 0, bitmap->BitsLength());
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -886,25 +886,25 @@ VideoWindow::_BlankBitmap(BBitmap* bitmap) const ...@@ -886,25 +886,25 @@ VideoWindow::_BlankBitmap(BBitmap* bitmap) const
void void
VideoWindow::_SetVideoSize(uint32_t mode) VideoWindow::_SetVideoSize(uint32_t mode)
{ {
// let size depend on aspect correction // let size depend on aspect correction
int32_t width = CorrectAspectRatio() ? i_width : fTrueWidth; int32_t width = CorrectAspectRatio() ? i_width : fTrueWidth;
int32_t height = CorrectAspectRatio() ? i_height : fTrueHeight; int32_t height = CorrectAspectRatio() ? i_height : fTrueHeight;
switch (mode) switch (mode)
{ {
case RESIZE_50: case RESIZE_50:
width /= 2; width /= 2;
height /= 2; height /= 2;
break; break;
case RESIZE_200: case RESIZE_200:
width *= 2; width *= 2;
height *= 2; height *= 2;
break; break;
case RESIZE_100: case RESIZE_100:
default: default:
break; break;
} }
fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN); fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
ResizeTo(width, height); ResizeTo(width, height);
} }
/***************************************************************************** /*****************************************************************************
...@@ -913,32 +913,32 @@ VideoWindow::_SetVideoSize(uint32_t mode) ...@@ -913,32 +913,32 @@ VideoWindow::_SetVideoSize(uint32_t mode)
void void
VideoWindow::_SetToSettings() VideoWindow::_SetToSettings()
{ {
// adjust dimensions // adjust dimensions
uint32_t mode = RESIZE_100; uint32_t mode = RESIZE_100;
switch (fSettings->VideoSize()) switch (fSettings->VideoSize())
{ {
case VideoSettings::SIZE_50: case VideoSettings::SIZE_50:
mode = RESIZE_50; mode = RESIZE_50;
break; break;
case VideoSettings::SIZE_200: case VideoSettings::SIZE_200:
mode = RESIZE_200; mode = RESIZE_200;
break; break;
case VideoSettings::SIZE_100: case VideoSettings::SIZE_100:
case VideoSettings::SIZE_OTHER: case VideoSettings::SIZE_OTHER:
default: default:
break; break;
} }
bool fullscreen = IsFullScreen(); // remember settings bool fullscreen = IsFullScreen(); // remember settings
_SetVideoSize(mode); // because this will reset settings _SetVideoSize(mode); // because this will reset settings
// the fullscreen status is reflected in the settings, // the fullscreen status is reflected in the settings,
// but not yet in the windows state // but not yet in the windows state
if (fullscreen) if (fullscreen)
SetFullScreen(true); SetFullScreen(true);
if (fSettings->HasFlags(VideoSettings::FLAG_ON_TOP_ALL)) if (fSettings->HasFlags(VideoSettings::FLAG_ON_TOP_ALL))
fCachedFeel = B_FLOATING_ALL_WINDOW_FEEL; fCachedFeel = B_FLOATING_ALL_WINDOW_FEEL;
else else
fCachedFeel = B_NORMAL_WINDOW_FEEL; fCachedFeel = B_NORMAL_WINDOW_FEEL;
SetFeel(fCachedFeel); SetFeel(fCachedFeel);
} }
/***************************************************************************** /*****************************************************************************
...@@ -946,22 +946,22 @@ VideoWindow::_SetToSettings() ...@@ -946,22 +946,22 @@ VideoWindow::_SetToSettings()
*****************************************************************************/ *****************************************************************************/
void void
VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path, VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path,
uint32_t translatorID ) const uint32_t translatorID ) const
{ {
// make the info object from the parameters // make the info object from the parameters
screen_shot_info* info = new screen_shot_info; screen_shot_info* info = new screen_shot_info;
info->bitmap = bitmap; info->bitmap = bitmap;
info->path = path; info->path = path;
info->translatorID = translatorID; info->translatorID = translatorID;
info->width = CorrectAspectRatio() ? i_width : fTrueWidth; info->width = CorrectAspectRatio() ? i_width : fTrueWidth;
info->height = CorrectAspectRatio() ? i_height : fTrueHeight; info->height = CorrectAspectRatio() ? i_height : fTrueHeight;
// spawn a new thread to take care of the actual saving to disk // spawn a new thread to take care of the actual saving to disk
thread_id thread = spawn_thread( _save_screen_shot, thread_id thread = spawn_thread( _save_screen_shot,
"screen shot saver", "screen shot saver",
B_LOW_PRIORITY, (void*)info ); B_LOW_PRIORITY, (void*)info );
// start thread or do the job ourself if something went wrong // start thread or do the job ourself if something went wrong
if ( thread < B_OK || resume_thread( thread ) < B_OK ) if ( thread < B_OK || resume_thread( thread ) < B_OK )
_save_screen_shot( (void*)info ); _save_screen_shot( (void*)info );
} }
/***************************************************************************** /*****************************************************************************
...@@ -970,148 +970,148 @@ VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path, ...@@ -970,148 +970,148 @@ VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path,
int32 int32
VideoWindow::_save_screen_shot( void* cookie ) VideoWindow::_save_screen_shot( void* cookie )
{ {
screen_shot_info* info = (screen_shot_info*)cookie; screen_shot_info* info = (screen_shot_info*)cookie;
if ( info && info->bitmap && info->bitmap->IsValid() && info->path ) if ( info && info->bitmap && info->bitmap->IsValid() && info->path )
{ {
// try to be as quick as possible creating the file (the user might have // try to be as quick as possible creating the file (the user might have
// taken the next screen shot already!) // taken the next screen shot already!)
// make sure we have a unique name for the screen shot // make sure we have a unique name for the screen shot
BString path( info->path ); BString path( info->path );
// create the folder if it doesn't exist // create the folder if it doesn't exist
BString folder( info->path ); BString folder( info->path );
create_directory( folder.String(), 0777 ); create_directory( folder.String(), 0777 );
path << "/vlc screenshot"; path << "/vlc screenshot";
BEntry entry( path.String() ); BEntry entry( path.String() );
int32_t appendedNumber = 0; int32_t appendedNumber = 0;
if ( entry.Exists() && !entry.IsSymLink() ) if ( entry.Exists() && !entry.IsSymLink() )
{ {
// we would clobber an existing entry // we would clobber an existing entry
bool foundUniqueName = false; bool foundUniqueName = false;
appendedNumber = 1; appendedNumber = 1;
while ( !foundUniqueName ) { while ( !foundUniqueName ) {
BString newName( path.String() ); BString newName( path.String() );
newName << " " << appendedNumber; newName << " " << appendedNumber;
BEntry possiblyClobberedEntry( newName.String() ); BEntry possiblyClobberedEntry( newName.String() );
if ( possiblyClobberedEntry.Exists() if ( possiblyClobberedEntry.Exists()
&& !possiblyClobberedEntry.IsSymLink() ) && !possiblyClobberedEntry.IsSymLink() )
appendedNumber++; appendedNumber++;
else else
foundUniqueName = true; foundUniqueName = true;
} }
} }
if ( appendedNumber > 0 ) if ( appendedNumber > 0 )
path << " " << appendedNumber; path << " " << appendedNumber;
// there is still a slight chance to clobber an existing // there is still a slight chance to clobber an existing
// file (if it was created in the "meantime"), but we take it... // file (if it was created in the "meantime"), but we take it...
BFile outFile( path.String(), BFile outFile( path.String(),
B_CREATE_FILE | B_WRITE_ONLY | B_ERASE_FILE ); B_CREATE_FILE | B_WRITE_ONLY | B_ERASE_FILE );
// make colorspace converted copy of bitmap // make colorspace converted copy of bitmap
BBitmap* converted = new BBitmap( BRect( 0.0, 0.0, info->width, info->height ), BBitmap* converted = new BBitmap( BRect( 0.0, 0.0, info->width, info->height ),
B_RGB32 ); B_RGB32 );
status_t status = convert_bitmap( info->bitmap, converted ); status_t status = convert_bitmap( info->bitmap, converted );
if ( status == B_OK ) if ( status == B_OK )
{ {
BTranslatorRoster* roster = BTranslatorRoster::Default(); BTranslatorRoster* roster = BTranslatorRoster::Default();
uint32_t imageFormat = 0; uint32_t imageFormat = 0;
translator_id translator = 0; translator_id translator = 0;
bool found = false; bool found = false;
// find suitable translator // find suitable translator
translator_id* ids = NULL; translator_id* ids = NULL;
int32 count = 0; int32 count = 0;
status = roster->GetAllTranslators( &ids, &count ); status = roster->GetAllTranslators( &ids, &count );
if ( status >= B_OK ) if ( status >= B_OK )
{ {
for ( int tix = 0; tix < count; tix++ ) for ( int tix = 0; tix < count; tix++ )
{ {
const translation_format *formats = NULL; const translation_format *formats = NULL;
int32 num_formats = 0; int32 num_formats = 0;
bool ok = false; bool ok = false;
status = roster->GetInputFormats( ids[tix], status = roster->GetInputFormats( ids[tix],
&formats, &num_formats ); &formats, &num_formats );
if (status >= B_OK) if (status >= B_OK)
{ {
for ( int iix = 0; iix < num_formats; iix++ ) for ( int iix = 0; iix < num_formats; iix++ )
{ {
if ( formats[iix].type == B_TRANSLATOR_BITMAP ) if ( formats[iix].type == B_TRANSLATOR_BITMAP )
{ {
ok = true; ok = true;
break; break;
} }
} }
} }
if ( !ok ) if ( !ok )
continue; continue;
status = roster->GetOutputFormats( ids[tix], status = roster->GetOutputFormats( ids[tix],
&formats, &num_formats); &formats, &num_formats);
if ( status >= B_OK ) if ( status >= B_OK )
{ {
for ( int32_t oix = 0; oix < num_formats; oix++ ) for ( int32_t oix = 0; oix < num_formats; oix++ )
{ {
if ( formats[oix].type != B_TRANSLATOR_BITMAP ) if ( formats[oix].type != B_TRANSLATOR_BITMAP )
{ {
if ( formats[oix].type == info->translatorID ) if ( formats[oix].type == info->translatorID )
{ {
found = true; found = true;
imageFormat = formats[oix].type; imageFormat = formats[oix].type;
translator = ids[tix]; translator = ids[tix];
break; break;
} }
} }
} }
} }
} }
} }
delete[] ids; delete[] ids;
if ( found ) if ( found )
{ {
// make bitmap stream // make bitmap stream
BBitmapStream outStream( converted ); BBitmapStream outStream( converted );
status = outFile.InitCheck(); status = outFile.InitCheck();
if (status == B_OK) { if (status == B_OK) {
status = roster->Translate( &outStream, NULL, NULL, status = roster->Translate( &outStream, NULL, NULL,
&outFile, imageFormat ); &outFile, imageFormat );
if ( status == B_OK ) if ( status == B_OK )
{ {
BNodeInfo nodeInfo( &outFile ); BNodeInfo nodeInfo( &outFile );
if ( nodeInfo.InitCheck() == B_OK ) if ( nodeInfo.InitCheck() == B_OK )
{ {
translation_format* formats; translation_format* formats;
int32 count; int32 count;
status = roster->GetOutputFormats( translator, status = roster->GetOutputFormats( translator,
(const translation_format **) &formats, (const translation_format **) &formats,
&count); &count);
if ( status >= B_OK ) if ( status >= B_OK )
{ {
const char * mime = NULL; const char * mime = NULL;
for ( int ix = 0; ix < count; ix++ ) { for ( int ix = 0; ix < count; ix++ ) {
if ( formats[ix].type == imageFormat ) { if ( formats[ix].type == imageFormat ) {
mime = formats[ix].MIME; mime = formats[ix].MIME;
break; break;
} }
} }
if ( mime ) if ( mime )
nodeInfo.SetType( mime ); nodeInfo.SetType( mime );
} }
} }
} }
} }
outStream.DetachBitmap( &converted ); outStream.DetachBitmap( &converted );
outFile.Unset(); outFile.Unset();
} }
} }
delete converted; delete converted;
} }
if ( info ) if ( info )
{ {
delete info->bitmap; delete info->bitmap;
free( info->path ); free( info->path );
} }
delete info; delete info;
return B_OK; return B_OK;
} }
...@@ -1119,11 +1119,11 @@ VideoWindow::_save_screen_shot( void* cookie ) ...@@ -1119,11 +1119,11 @@ VideoWindow::_save_screen_shot( void* cookie )
* VLCView::VLCView * VLCView::VLCView
*****************************************************************************/ *****************************************************************************/
VLCView::VLCView(BRect bounds, vout_thread_t *p_vout_instance ) VLCView::VLCView(BRect bounds, vout_thread_t *p_vout_instance )
: BView(bounds, "video view", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED), : BView(bounds, "video view", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED),
fLastMouseMovedTime(system_time()), fLastMouseMovedTime(mdate()),
fCursorHidden(false), fCursorHidden(false),
fCursorInside(false), fCursorInside(false),
fIgnoreDoubleClick(false) fIgnoreDoubleClick(false)
{ {
p_vout = p_vout_instance; p_vout = p_vout_instance;
SetViewColor(B_TRANSPARENT_32_BIT); SetViewColor(B_TRANSPARENT_32_BIT);
...@@ -1142,10 +1142,10 @@ VLCView::~VLCView() ...@@ -1142,10 +1142,10 @@ VLCView::~VLCView()
void void
VLCView::AttachedToWindow() VLCView::AttachedToWindow()
{ {
// in order to get keyboard events // in order to get keyboard events
MakeFocus(true); MakeFocus(true);
// periodically check if we want to hide the pointer // periodically check if we want to hide the pointer
Window()->SetPulseRate(1000000); Window()->SetPulseRate(1000000);
} }
/***************************************************************************** /*****************************************************************************
...@@ -1154,111 +1154,111 @@ VLCView::AttachedToWindow() ...@@ -1154,111 +1154,111 @@ VLCView::AttachedToWindow()
void void
VLCView::MouseDown(BPoint where) VLCView::MouseDown(BPoint where)
{ {
VideoWindow* videoWindow = dynamic_cast<VideoWindow*>(Window()); VideoWindow* videoWindow = dynamic_cast<VideoWindow*>(Window());
BMessage* msg = Window()->CurrentMessage(); BMessage* msg = Window()->CurrentMessage();
int32 clicks; int32 clicks;
uint32_t buttons; uint32_t buttons;
msg->FindInt32("clicks", &clicks); msg->FindInt32("clicks", &clicks);
msg->FindInt32("buttons", (int32*)&buttons); msg->FindInt32("buttons", (int32*)&buttons);
if (videoWindow) if (videoWindow)
{ {
if (buttons & B_PRIMARY_MOUSE_BUTTON) if (buttons & B_PRIMARY_MOUSE_BUTTON)
{ {
if (clicks == 2 && !fIgnoreDoubleClick) if (clicks == 2 && !fIgnoreDoubleClick)
Window()->Zoom(); Window()->Zoom();
/* else /* else
videoWindow->ToggleInterfaceShowing(); */ videoWindow->ToggleInterfaceShowing(); */
fIgnoreDoubleClick = false; fIgnoreDoubleClick = false;
} }
else else
{ {
if (buttons & B_SECONDARY_MOUSE_BUTTON) if (buttons & B_SECONDARY_MOUSE_BUTTON)
{ {
// clicks will be 2 next time (if interval short enough) // clicks will be 2 next time (if interval short enough)
// even if the first click and the second // even if the first click and the second
// have not been made with the same mouse button // have not been made with the same mouse button
fIgnoreDoubleClick = true; fIgnoreDoubleClick = true;
// launch popup menu // launch popup menu
BPopUpMenu *menu = new BPopUpMenu("context menu"); BPopUpMenu *menu = new BPopUpMenu("context menu");
menu->SetRadioMode(false); menu->SetRadioMode(false);
// In full screen, add an item to show/hide the interface // In full screen, add an item to show/hide the interface
if( videoWindow->IsFullScreen() ) if( videoWindow->IsFullScreen() )
{ {
BMenuItem *intfItem = BMenuItem *intfItem =
new BMenuItem( _("Show Interface"), new BMessage(SHOW_INTERFACE) ); new BMenuItem( _("Show Interface"), new BMessage(SHOW_INTERFACE) );
menu->AddItem( intfItem ); menu->AddItem( intfItem );
} }
// Resize to 50% // Resize to 50%
BMenuItem *halfItem = new BMenuItem(_("50%"), new BMessage(RESIZE_50)); BMenuItem *halfItem = new BMenuItem(_("50%"), new BMessage(RESIZE_50));
menu->AddItem(halfItem); menu->AddItem(halfItem);
// Resize to 100% // Resize to 100%
BMenuItem *origItem = new BMenuItem(_("100%"), new BMessage(RESIZE_100)); BMenuItem *origItem = new BMenuItem(_("100%"), new BMessage(RESIZE_100));
menu->AddItem(origItem); menu->AddItem(origItem);
// Resize to 200% // Resize to 200%
BMenuItem *doubleItem = new BMenuItem(_("200%"), new BMessage(RESIZE_200)); BMenuItem *doubleItem = new BMenuItem(_("200%"), new BMessage(RESIZE_200));
menu->AddItem(doubleItem); menu->AddItem(doubleItem);
// Toggle FullScreen // Toggle FullScreen
BMenuItem *zoomItem = new BMenuItem(_("Fullscreen"), new BMessage(TOGGLE_FULL_SCREEN)); BMenuItem *zoomItem = new BMenuItem(_("Fullscreen"), new BMessage(TOGGLE_FULL_SCREEN));
zoomItem->SetMarked(videoWindow->IsFullScreen()); zoomItem->SetMarked(videoWindow->IsFullScreen());
menu->AddItem(zoomItem); menu->AddItem(zoomItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
// Toggle vSync // Toggle vSync
BMenuItem *vsyncItem = new BMenuItem(_("Vertical Sync"), new BMessage(VERT_SYNC)); BMenuItem *vsyncItem = new BMenuItem(_("Vertical Sync"), new BMessage(VERT_SYNC));
vsyncItem->SetMarked(videoWindow->IsSyncedToRetrace()); vsyncItem->SetMarked(videoWindow->IsSyncedToRetrace());
menu->AddItem(vsyncItem); menu->AddItem(vsyncItem);
// Correct Aspect Ratio // Correct Aspect Ratio
BMenuItem *aspectItem = new BMenuItem(_("Correct Aspect Ratio"), new BMessage(ASPECT_CORRECT)); BMenuItem *aspectItem = new BMenuItem(_("Correct Aspect Ratio"), new BMessage(ASPECT_CORRECT));
aspectItem->SetMarked(videoWindow->CorrectAspectRatio()); aspectItem->SetMarked(videoWindow->CorrectAspectRatio());
menu->AddItem(aspectItem); menu->AddItem(aspectItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
// Window Feel Items // Window Feel Items
/* BMessage *winNormFeel = new BMessage(WINDOW_FEEL); /* BMessage *winNormFeel = new BMessage(WINDOW_FEEL);
winNormFeel->AddInt32("WinFeel", (int32_t)B_NORMAL_WINDOW_FEEL); winNormFeel->AddInt32("WinFeel", (int32_t)B_NORMAL_WINDOW_FEEL);
BMenuItem *normWindItem = new BMenuItem("Normal Window", winNormFeel); BMenuItem *normWindItem = new BMenuItem("Normal Window", winNormFeel);
normWindItem->SetMarked(videoWindow->Feel() == B_NORMAL_WINDOW_FEEL); normWindItem->SetMarked(videoWindow->Feel() == B_NORMAL_WINDOW_FEEL);
menu->AddItem(normWindItem); menu->AddItem(normWindItem);
BMessage *winFloatFeel = new BMessage(WINDOW_FEEL); BMessage *winFloatFeel = new BMessage(WINDOW_FEEL);
winFloatFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_APP_WINDOW_FEEL); winFloatFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_APP_WINDOW_FEEL);
BMenuItem *onTopWindItem = new BMenuItem("App Top", winFloatFeel); BMenuItem *onTopWindItem = new BMenuItem("App Top", winFloatFeel);
onTopWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_APP_WINDOW_FEEL); onTopWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_APP_WINDOW_FEEL);
menu->AddItem(onTopWindItem); menu->AddItem(onTopWindItem);
BMessage *winAllFeel = new BMessage(WINDOW_FEEL); BMessage *winAllFeel = new BMessage(WINDOW_FEEL);
winAllFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_ALL_WINDOW_FEEL); winAllFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_ALL_WINDOW_FEEL);
BMenuItem *allSpacesWindItem = new BMenuItem("On Top All Workspaces", winAllFeel); BMenuItem *allSpacesWindItem = new BMenuItem("On Top All Workspaces", winAllFeel);
allSpacesWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_ALL_WINDOW_FEEL); allSpacesWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_ALL_WINDOW_FEEL);
menu->AddItem(allSpacesWindItem);*/ menu->AddItem(allSpacesWindItem);*/
BMessage *windowFeelMsg = new BMessage( WINDOW_FEEL ); BMessage *windowFeelMsg = new BMessage( WINDOW_FEEL );
bool onTop = videoWindow->Feel() == B_FLOATING_ALL_WINDOW_FEEL; bool onTop = videoWindow->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
window_feel feel = onTop ? B_NORMAL_WINDOW_FEEL : B_FLOATING_ALL_WINDOW_FEEL; window_feel feel = onTop ? B_NORMAL_WINDOW_FEEL : B_FLOATING_ALL_WINDOW_FEEL;
windowFeelMsg->AddInt32( "WinFeel", (int32_t)feel ); windowFeelMsg->AddInt32( "WinFeel", (int32_t)feel );
BMenuItem *windowFeelItem = new BMenuItem( _("Stay On Top"), windowFeelMsg ); BMenuItem *windowFeelItem = new BMenuItem( _("Stay On Top"), windowFeelMsg );
windowFeelItem->SetMarked( onTop ); windowFeelItem->SetMarked( onTop );
menu->AddItem( windowFeelItem ); menu->AddItem( windowFeelItem );
menu->AddSeparatorItem(); menu->AddSeparatorItem();
BMenuItem* screenShotItem = new BMenuItem( _("Take Screen Shot"), BMenuItem* screenShotItem = new BMenuItem( _("Take Screen Shot"),
new BMessage( SCREEN_SHOT ) ); new BMessage( SCREEN_SHOT ) );
menu->AddItem( screenShotItem ); menu->AddItem( screenShotItem );
menu->SetTargetForItems( this ); menu->SetTargetForItems( this );
ConvertToScreen( &where ); ConvertToScreen( &where );
BRect mouseRect( where.x - 5, where.y - 5, BRect mouseRect( where.x - 5, where.y - 5,
where.x + 5, where.y + 5 ); where.x + 5, where.y + 5 );
menu->Go( where, true, false, mouseRect, true ); menu->Go( where, true, false, mouseRect, true );
} }
} }
} }
fLastMouseMovedTime = system_time(); fLastMouseMovedTime = mdate();
fCursorHidden = false; fCursorHidden = false;
} }
/***************************************************************************** /*****************************************************************************
...@@ -1278,20 +1278,25 @@ VLCView::MouseUp( BPoint where ) ...@@ -1278,20 +1278,25 @@ VLCView::MouseUp( BPoint where )
void void
VLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage) VLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage)
{ {
fLastMouseMovedTime = system_time(); fLastMouseMovedTime = mdate();
fCursorHidden = false; fCursorHidden = false;
fCursorInside = (transit == B_INSIDE_VIEW || transit == B_ENTERED_VIEW); fCursorInside = ( transit == B_INSIDE_VIEW || transit == B_ENTERED_VIEW );
/* DVD navigation */
unsigned int i_width, i_height, i_x, i_y; if( !fCursorInside )
{
return;
}
vlc_value_t val;
unsigned int i_width, i_height, i_x, i_y;
vout_PlacePicture( p_vout, (unsigned int)Bounds().Width(), vout_PlacePicture( p_vout, (unsigned int)Bounds().Width(),
(unsigned int)Bounds().Height(), (unsigned int)Bounds().Height(),
&i_x, &i_y, &i_width, &i_height ); &i_x, &i_y, &i_width, &i_height );
vlc_value_t val; val.i_int = ( (int)point.x - i_x ) * p_vout->render.i_width / i_width;
val.i_int = ( (int)point.x - i_x ) * p_vout->render.i_width / i_width; var_Set( p_vout, "mouse-x", val );
var_Set( p_vout, "mouse-x", val ); val.i_int = ( (int)point.y - i_y ) * p_vout->render.i_height / i_height;
val.i_int = ( (int)point.y - i_y ) * p_vout->render.i_height / i_height; var_Set( p_vout, "mouse-y", val );
var_Set( p_vout, "mouse-y", val ); val.b_bool = VLC_TRUE;
val.b_bool = VLC_TRUE;
var_Set( p_vout, "mouse-moved", val ); var_Set( p_vout, "mouse-moved", val );
} }
...@@ -1301,35 +1306,35 @@ VLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage) ...@@ -1301,35 +1306,35 @@ VLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage)
void void
VLCView::Pulse() VLCView::Pulse()
{ {
// We are getting the pulse messages no matter if the mouse is over // We are getting the pulse messages no matter if the mouse is over
// this view. If we are in full screen mode, we want to hide the cursor // this view. If we are in full screen mode, we want to hide the cursor
// even if it is not. // even if it is not.
VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window()); VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window());
if (!fCursorHidden) if (!fCursorHidden)
{ {
if (fCursorInside if (fCursorInside
&& system_time() - fLastMouseMovedTime > MOUSE_IDLE_TIMEOUT) && mdate() - fLastMouseMovedTime > MOUSE_IDLE_TIMEOUT)
{ {
be_app->ObscureCursor(); be_app->ObscureCursor();
fCursorHidden = true; fCursorHidden = true;
// hide the interface window as well if full screen // hide the interface window as well if full screen
if (videoWindow && videoWindow->IsFullScreen()) if (videoWindow && videoWindow->IsFullScreen())
videoWindow->SetInterfaceShowing(false); videoWindow->SetInterfaceShowing(false);
} }
} }
// Workaround to disable the screensaver in full screen: // Workaround to disable the screensaver in full screen:
// we simulate an activity every 29 seconds // we simulate an activity every 29 seconds
if( videoWindow && videoWindow->IsFullScreen() && if( videoWindow && videoWindow->IsFullScreen() &&
system_time() - fLastMouseMovedTime > 29000000 ) mdate() - fLastMouseMovedTime > 29000000 )
{ {
BPoint where; BPoint where;
uint32 buttons; uint32 buttons;
GetMouse(&where, &buttons, false); GetMouse(&where, &buttons, false);
ConvertToScreen(&where); ConvertToScreen(&where);
set_mouse_position((int32_t) where.x, (int32_t) where.y); set_mouse_position((int32_t) where.x, (int32_t) where.y);
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -1367,9 +1372,9 @@ void VLCView::KeyUp( const char *bytes, int32 numBytes ) ...@@ -1367,9 +1372,9 @@ void VLCView::KeyUp( const char *bytes, int32 numBytes )
void void
VLCView::Draw(BRect updateRect) VLCView::Draw(BRect updateRect)
{ {
VideoWindow* window = dynamic_cast<VideoWindow*>( Window() ); VideoWindow* window = dynamic_cast<VideoWindow*>( Window() );
if ( window && window->mode == BITMAP ) if ( window && window->mode == BITMAP )
FillRect( updateRect ); FillRect( updateRect );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -674,8 +674,6 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) ...@@ -674,8 +674,6 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
*/ */
static void DeleteDecoder( decoder_t * p_dec ) static void DeleteDecoder( decoder_t * p_dec )
{ {
vlc_object_detach( p_dec );
msg_Dbg( p_dec, "killing decoder fourcc `%4.4s', %d PES in FIFO", msg_Dbg( p_dec, "killing decoder fourcc `%4.4s', %d PES in FIFO",
(char*)&p_dec->fmt_in.i_codec, (char*)&p_dec->fmt_in.i_codec,
p_dec->p_owner->p_fifo->i_depth ); p_dec->p_owner->p_fifo->i_depth );
...@@ -684,7 +682,7 @@ static void DeleteDecoder( decoder_t * p_dec ) ...@@ -684,7 +682,7 @@ static void DeleteDecoder( decoder_t * p_dec )
block_FifoEmpty( p_dec->p_owner->p_fifo ); block_FifoEmpty( p_dec->p_owner->p_fifo );
block_FifoRelease( p_dec->p_owner->p_fifo ); block_FifoRelease( p_dec->p_owner->p_fifo );
/* Cleanup */ /* Cleanup */
if( p_dec->p_owner->p_aout_input ) if( p_dec->p_owner->p_aout_input )
aout_DecDelete( p_dec->p_owner->p_aout, p_dec->p_owner->p_aout_input ); aout_DecDelete( p_dec->p_owner->p_aout, p_dec->p_owner->p_aout_input );
...@@ -739,6 +737,8 @@ static void DeleteDecoder( decoder_t * p_dec ) ...@@ -739,6 +737,8 @@ static void DeleteDecoder( decoder_t * p_dec )
vlc_object_destroy( p_dec->p_owner->p_packetizer ); vlc_object_destroy( p_dec->p_owner->p_packetizer );
} }
vlc_object_detach( p_dec );
free( p_dec->p_owner ); free( p_dec->p_owner );
} }
......
...@@ -297,6 +297,13 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -297,6 +297,13 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
vlc_mutex_init( p_vout, &p_vout->subpicture_lock ); vlc_mutex_init( p_vout, &p_vout->subpicture_lock );
vlc_mutex_init( p_vout, &p_vout->change_lock ); vlc_mutex_init( p_vout, &p_vout->change_lock );
/* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER );
/* Attach the new object now so we can use var inheritance below */ /* Attach the new object now so we can use var inheritance below */
vlc_object_attach( p_vout, p_parent ); vlc_object_attach( p_vout, p_parent );
......
...@@ -223,13 +223,6 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -223,13 +223,6 @@ void vout_IntfInit( vout_thread_t *p_vout )
} }
var_AddCallback( p_vout, "fullscreen", FullscreenCallback, NULL ); var_AddCallback( p_vout, "fullscreen", FullscreenCallback, NULL );
/* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER );
var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); var_Create( p_vout, "intf-change", VLC_VAR_BOOL );
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
var_Set( p_vout, "intf-change", val ); var_Set( p_vout, "intf-change", val );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment