📄 videooutput.cpp
字号:
/***************************************************************************** * vout_beos.cpp: beos video output display method ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN * $Id: VideoOutput.cpp 10509 2005-04-01 22:01:24Z titer $ * * Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Samuel Hocevar <sam@zoy.org> * Tony Castley <tcastley@mail.powerup.com.au> * Richard Shepherd <richard@rshepherd.demon.co.uk> * Stephan Aßmus <stippi@yellowbites.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <errno.h> /* ENOMEM */#include <stdlib.h> /* free() */#include <stdio.h>#include <string.h> /* strerror() */#include <Application.h>#include <BitmapStream.h>#include <Bitmap.h>#include <Directory.h>#include <DirectWindow.h>#include <File.h>#include <InterfaceKit.h>#include <NodeInfo.h>#include <String.h>#include <TranslatorRoster.h>#include <WindowScreen.h>/* VLC headers */#include <vlc/vlc.h>#include <vlc/intf.h>#include <vlc/vout.h>#include <vlc_keys.h>#include "InterfaceWindow.h" // for load/save_settings()#include "DrawingTidbits.h"#include "MsgVals.h"#include "VideoWindow.h"/***************************************************************************** * vout_sys_t: BeOS video output method descriptor ***************************************************************************** * This structure is part of the video output thread descriptor. * It describes the BeOS specific properties of an output thread. *****************************************************************************/struct vout_sys_t{ VideoWindow * p_window; int32_t i_width; int32_t i_height;// uint8_t *pp_buffer[3]; uint32_t source_chroma; int i_index;};#define MOUSE_IDLE_TIMEOUT 2000000 // two seconds#define MIN_AUTO_VSYNC_REFRESH 61 // Hz/***************************************************************************** * beos_GetAppWindow : retrieve a BWindow pointer from the window name *****************************************************************************/BWindow*beos_GetAppWindow(char *name){ int32_t index; BWindow *window; for (index = 0 ; ; index++) { window = be_app->WindowAt(index); if (window == NULL) break; if (window->LockWithTimeout(20000) == B_OK) { if (strcmp(window->Name(), name) == 0) { window->Unlock(); break; } window->Unlock(); } } return window;}static const int beos_keys[][2] ={ { B_LEFT_ARROW, KEY_LEFT }, { B_RIGHT_ARROW, KEY_RIGHT }, { B_UP_ARROW, KEY_UP }, { B_DOWN_ARROW, KEY_DOWN }, { B_SPACE, KEY_SPACE }, { B_ENTER, KEY_ENTER }, { B_F1_KEY, KEY_F1 }, { B_F2_KEY, KEY_F2 }, { B_F3_KEY, KEY_F3 }, { B_F4_KEY, KEY_F4 }, { B_F5_KEY, KEY_F5 }, { B_F6_KEY, KEY_F6 }, { B_F7_KEY, KEY_F7 }, { B_F8_KEY, KEY_F8 }, { B_F9_KEY, KEY_F9 }, { B_F10_KEY, KEY_F10 }, { B_F11_KEY, KEY_F11 }, { B_F12_KEY, KEY_F12 }, { B_HOME, KEY_HOME }, { B_END, KEY_END }, { B_ESCAPE, KEY_ESC }, { B_PAGE_UP, KEY_PAGEUP }, { B_PAGE_DOWN, KEY_PAGEDOWN }, { B_TAB, KEY_TAB }, { B_BACKSPACE, KEY_BACKSPACE }};static int ConvertKeyFromVLC( int key ){ for( unsigned i = 0; i < sizeof( beos_keys ) / sizeof( int ) / 2; i++ ) { if( beos_keys[i][1] == key ) { return beos_keys[i][0]; } } return key;}static int ConvertKeyToVLC( int key ){ for( unsigned i = 0; i < sizeof( beos_keys ) / sizeof( int ) / 2; i++ ) { if( beos_keys[i][0] == key ) { return beos_keys[i][1]; } } return key;}/***************************************************************************** * get_interface_window *****************************************************************************/BWindow*get_interface_window(){ return beos_GetAppWindow( "VLC " PACKAGE_VERSION );}class BackgroundView : public BView{ public: BackgroundView(BRect frame, VLCView* view) : BView(frame, "background", B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE), fVideoView(view) { SetViewColor(kBlack); } virtual ~BackgroundView() {} virtual void MouseDown(BPoint where) { // convert coordinates where = fVideoView->ConvertFromParent(where); // let him handle it fVideoView->MouseDown(where); } virtual void MouseMoved(BPoint where, uint32_t transit, const BMessage* dragMessage) { // convert coordinates where = fVideoView->ConvertFromParent(where); // let him handle it fVideoView->MouseMoved(where, transit, dragMessage); // notice: It might look like transit should be // B_OUTSIDE_VIEW regardless, but leave it like this, // otherwise, unwanted things will happen! } private: VLCView* fVideoView;};/***************************************************************************** * VideoSettings constructor and destructor *****************************************************************************/VideoSettings::VideoSettings() : fVideoSize( SIZE_100 ), fFlags( FLAG_CORRECT_RATIO ), fSettings( new BMessage( 'sett' ) ){ // read settings from disk status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" ); if ( ret == B_OK ) { uint32_t flags; if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK ) SetFlags( flags ); uint32_t size; if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK ) SetVideoSize( size ); } else { // figure out if we should use vertical sync by default BScreen screen(B_MAIN_SCREEN_ID); if (screen.IsValid()) { display_mode mode; screen.GetMode(&mode); float refresh = (mode.timing.pixel_clock * 1000) / ((mode.timing.h_total)* (mode.timing.v_total)); if (refresh < MIN_AUTO_VSYNC_REFRESH) AddFlags(FLAG_SYNC_RETRACE); } }}VideoSettings::VideoSettings( const VideoSettings& clone ) : fVideoSize( clone.VideoSize() ), fFlags( clone.Flags() ), fSettings( NULL ){}VideoSettings::~VideoSettings(){ if ( fSettings ) { // we are the default settings // and write our settings to disk if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK) fSettings->AddInt32( "video size", VideoSize() ); if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK) fSettings->AddInt32( "flags", Flags() ); save_settings( fSettings, "video_settings", "VideoLAN Client" ); delete fSettings; } else { // we are just a clone of the default settings fDefaultSettings.SetVideoSize( VideoSize() ); fDefaultSettings.SetFlags( Flags() ); }}/***************************************************************************** * VideoSettings::DefaultSettings *****************************************************************************/VideoSettings*VideoSettings::DefaultSettings(){ return &fDefaultSettings;}/***************************************************************************** * VideoSettings::SetVideoSize *****************************************************************************/voidVideoSettings::SetVideoSize( uint32_t mode ){ fVideoSize = mode;}// static variable initializationVideoSettingsVideoSettings::fDefaultSettings;/***************************************************************************** * VideoWindow constructor and destructor *****************************************************************************/VideoWindow::VideoWindow(int v_width, int v_height, BRect frame, vout_thread_t *p_videoout) : BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE), i_width(frame.IntegerWidth()), i_height(frame.IntegerHeight()), winSize(frame), i_buffer(0), teardownwindow(false), fTrueWidth(v_width), fTrueHeight(v_height), fCachedFeel(B_NORMAL_WINDOW_FEEL), fInterfaceShowing(false), fInitStatus(B_ERROR), fSettings(new VideoSettings(*VideoSettings::DefaultSettings())){ p_vout = p_videoout; // create the view to do the display view = new VLCView( Bounds(), p_vout ); // create background view BView *mainView = new BackgroundView( Bounds(), view ); AddChild(mainView); mainView->AddChild(view); // allocate bitmap buffers for (int32_t i = 0; i < 3; i++) bitmap[i] = NULL; fInitStatus = _AllocateBuffers(v_width, v_height, &mode); // make sure we layout the view correctly FrameResized(i_width, i_height); if (fInitStatus >= B_OK && mode == OVERLAY) { overlay_restrictions r; bitmap[0]->GetOverlayRestrictions(&r); SetSizeLimits((i_width * r.min_width_scale), i_width * r.max_width_scale, (i_height * r.min_height_scale), i_height * r.max_height_scale); } // vlc settings override settings from disk if (config_GetInt(p_vout, "fullscreen")) fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN); _SetToSettings();}VideoWindow::~VideoWindow(){ int32 result; teardownwindow = true; wait_for_thread(fDrawThreadID, &result); _FreeBuffers(); delete fSettings;}/*****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -