⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videooutput.cpp

📁 VLC媒体播放程序
💻 CPP
📖 第 1 页 / 共 4 页
字号:
				        new BMenuItem( _("Show Interface"), new BMessage(SHOW_INTERFACE) );				    menu->AddItem( intfItem );				}				// Resize to 50%				BMenuItem *halfItem = new BMenuItem(_("50%"), new BMessage(RESIZE_50));				menu->AddItem(halfItem);				// Resize to 100%				BMenuItem *origItem = new BMenuItem(_("100%"), new BMessage(RESIZE_100));				menu->AddItem(origItem);				// Resize to 200%				BMenuItem *doubleItem = new BMenuItem(_("200%"), new BMessage(RESIZE_200));				menu->AddItem(doubleItem);				// Toggle FullScreen				BMenuItem *zoomItem = new BMenuItem(_("Fullscreen"), new BMessage(TOGGLE_FULL_SCREEN));				zoomItem->SetMarked(videoWindow->IsFullScreen());				menu->AddItem(zoomItem);					menu->AddSeparatorItem();					// Toggle vSync				BMenuItem *vsyncItem = new BMenuItem(_("Vertical Sync"), new BMessage(VERT_SYNC));				vsyncItem->SetMarked(videoWindow->IsSyncedToRetrace());				menu->AddItem(vsyncItem);				// Correct Aspect Ratio				BMenuItem *aspectItem = new BMenuItem(_("Correct Aspect Ratio"), new BMessage(ASPECT_CORRECT));				aspectItem->SetMarked(videoWindow->CorrectAspectRatio());				menu->AddItem(aspectItem);					menu->AddSeparatorItem();					// Window Feel Items/*				BMessage *winNormFeel = new BMessage(WINDOW_FEEL);				winNormFeel->AddInt32("WinFeel", (int32_t)B_NORMAL_WINDOW_FEEL);				BMenuItem *normWindItem = new BMenuItem("Normal Window", winNormFeel);				normWindItem->SetMarked(videoWindow->Feel() == B_NORMAL_WINDOW_FEEL);				menu->AddItem(normWindItem);								BMessage *winFloatFeel = new BMessage(WINDOW_FEEL);				winFloatFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_APP_WINDOW_FEEL);				BMenuItem *onTopWindItem = new BMenuItem("App Top", winFloatFeel);				onTopWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_APP_WINDOW_FEEL);				menu->AddItem(onTopWindItem);								BMessage *winAllFeel = new BMessage(WINDOW_FEEL);				winAllFeel->AddInt32("WinFeel", (int32_t)B_FLOATING_ALL_WINDOW_FEEL);				BMenuItem *allSpacesWindItem = new BMenuItem("On Top All Workspaces", winAllFeel);				allSpacesWindItem->SetMarked(videoWindow->Feel() == B_FLOATING_ALL_WINDOW_FEEL);				menu->AddItem(allSpacesWindItem);*/				BMessage *windowFeelMsg = new BMessage( WINDOW_FEEL );				bool onTop = videoWindow->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 );				BMenuItem *windowFeelItem = new BMenuItem( _("Stay On Top"), windowFeelMsg );				windowFeelItem->SetMarked( onTop );				menu->AddItem( windowFeelItem );				menu->AddSeparatorItem();				BMenuItem* screenShotItem = new BMenuItem( _("Take Screen Shot"),														   new BMessage( SCREEN_SHOT ) );				menu->AddItem( screenShotItem );				menu->SetTargetForItems( this );				ConvertToScreen( &where );				BRect mouseRect( where.x - 5, where.y - 5,				                 where.x + 5, where.y + 5 );				menu->Go( where, true, false, mouseRect, true );	        }		}	}	fLastMouseMovedTime = system_time();	fCursorHidden = false;}/***************************************************************************** * VLCVIew::MouseUp *****************************************************************************/voidVLCView::MouseUp( BPoint where ){    vlc_value_t val;    val.b_bool = VLC_TRUE;    var_Set( p_vout, "mouse-clicked", val );}/***************************************************************************** * VLCVIew::MouseMoved *****************************************************************************/voidVLCView::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage){	fLastMouseMovedTime = system_time();	fCursorHidden = false;	fCursorInside = (transit == B_INSIDE_VIEW || transit == B_ENTERED_VIEW);	/* DVD navigation */	unsigned int i_width, i_height, i_x, i_y;    vout_PlacePicture( p_vout, (unsigned int)Bounds().Width(),                       (unsigned int)Bounds().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;	var_Set( p_vout, "mouse-x", val );	val.i_int = ( (int)point.y - i_y ) * p_vout->render.i_height / i_height;	var_Set( p_vout, "mouse-y", val );	val.b_bool = VLC_TRUE;    var_Set( p_vout, "mouse-moved", val );}/***************************************************************************** * VLCVIew::Pulse *****************************************************************************/voidVLCView::Pulse(){	// 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	// even if it is not.	VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window());	if (!fCursorHidden)	{		if (fCursorInside			&& system_time() - fLastMouseMovedTime > MOUSE_IDLE_TIMEOUT)		{			be_app->ObscureCursor();			fCursorHidden = true;						// hide the interface window as well if full screen			if (videoWindow && videoWindow->IsFullScreen())				videoWindow->SetInterfaceShowing(false);		}	}    // Workaround to disable the screensaver in full screen:    // we simulate an activity every 29 seconds		if( videoWindow && videoWindow->IsFullScreen() &&	    system_time() - fLastMouseMovedTime > 29000000 )	{	    BPoint where;		uint32 buttons;		GetMouse(&where, &buttons, false);		ConvertToScreen(&where);		set_mouse_position((int32_t) where.x, (int32_t) where.y);	}}/***************************************************************************** * VLCVIew::KeyUp *****************************************************************************/void VLCView::KeyUp( const char *bytes, int32 numBytes ){    if( numBytes < 1 )    {        return;    }    uint32_t mods = modifiers();    vlc_value_t val;    val.i_int = ConvertKeyToVLC( *bytes );    if( mods & B_COMMAND_KEY )    {        val.i_int |= KEY_MODIFIER_ALT;    }    if( mods & B_SHIFT_KEY )    {        val.i_int |= KEY_MODIFIER_SHIFT;    }    if( mods & B_CONTROL_KEY )    {        val.i_int |= KEY_MODIFIER_CTRL;    }    var_Set( p_vout->p_vlc, "key-pressed", val );}/***************************************************************************** * VLCVIew::Draw *****************************************************************************/voidVLCView::Draw(BRect updateRect){	VideoWindow* window = dynamic_cast<VideoWindow*>( Window() );	if ( window && window->mode == BITMAP )		FillRect( updateRect );}/***************************************************************************** * Local prototypes *****************************************************************************/static int  Init       ( vout_thread_t * );static void End        ( vout_thread_t * );static int  Manage     ( vout_thread_t * );static void Display    ( vout_thread_t *, picture_t * );static int  BeosOpenDisplay ( vout_thread_t *p_vout );static void BeosCloseDisplay( vout_thread_t *p_vout );/***************************************************************************** * OpenVideo: allocates BeOS video thread output method ***************************************************************************** * This function allocates and initializes a BeOS vout method. *****************************************************************************/int E_(OpenVideo) ( vlc_object_t *p_this ){    vout_thread_t * p_vout = (vout_thread_t *)p_this;    /* Allocate structure */    p_vout->p_sys = (vout_sys_t*) malloc( sizeof( vout_sys_t ) );    if( p_vout->p_sys == NULL )    {        msg_Err( p_vout, "out of memory" );        return( 1 );    }    p_vout->p_sys->i_width = p_vout->render.i_width;    p_vout->p_sys->i_height = p_vout->render.i_height;    p_vout->p_sys->source_chroma = p_vout->render.i_chroma;    p_vout->pf_init = Init;    p_vout->pf_end = End;    p_vout->pf_manage = Manage;    p_vout->pf_render = NULL;    p_vout->pf_display = Display;    return( 0 );}/***************************************************************************** * Init: initialize BeOS video thread output method *****************************************************************************/int Init( vout_thread_t *p_vout ){    int i_index;    picture_t *p_pic;    I_OUTPUTPICTURES = 0;    /* Open and initialize device */    if( BeosOpenDisplay( p_vout ) )    {        msg_Err(p_vout, "vout error: can't open display");        return 0;    }    p_vout->output.i_width  = p_vout->render.i_width;    p_vout->output.i_height = p_vout->render.i_height;    /* Assume we have square pixels */    p_vout->output.i_aspect = p_vout->p_sys->i_width                               * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height;    p_vout->output.i_chroma = colspace[p_vout->p_sys->p_window->colspace_index].chroma;    p_vout->p_sys->i_index = 0;    p_vout->b_direct = 1;    p_vout->output.i_rmask  = 0x00ff0000;    p_vout->output.i_gmask  = 0x0000ff00;    p_vout->output.i_bmask  = 0x000000ff;    for (int buffer_index = 0 ; buffer_index < 3; buffer_index++)    {       p_pic = NULL;       /* Find an empty picture slot */       for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )       {           p_pic = NULL;           if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )           {               p_pic = p_vout->p_picture + i_index;               break;           }       }       if( p_pic == NULL )       {           return 0;       }       p_pic->p->p_pixels = (uint8_t*)p_vout->p_sys->p_window->bitmap[buffer_index]->Bits();       p_pic->p->i_lines = p_vout->p_sys->i_height;       p_pic->p->i_pixel_pitch = colspace[p_vout->p_sys->p_window->colspace_index].pixel_bytes;       p_pic->i_planes = colspace[p_vout->p_sys->p_window->colspace_index].planes;       p_pic->p->i_pitch = p_vout->p_sys->p_window->bitmap[buffer_index]->BytesPerRow();       p_pic->p->i_visible_pitch = p_pic->p->i_pixel_pitch * ( p_vout->p_sys->p_window->bitmap[buffer_index]->Bounds().IntegerWidth() + 1 );       p_pic->i_status = DESTROYED_PICTURE;       p_pic->i_type   = DIRECT_PICTURE;       PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;       I_OUTPUTPICTURES++;    }    return( 0 );}/***************************************************************************** * End: terminate BeOS video thread output method *****************************************************************************/void End( vout_thread_t *p_vout ){    BeosCloseDisplay( p_vout );}/***************************************************************************** * Manage *****************************************************************************/static int Manage( vout_thread_t * p_vout ){    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )    {        p_vout->p_sys->p_window->PostMessage( TOGGLE_FULL_SCREEN );        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;    }    return 0;}/***************************************************************************** * CloseVideo: destroy BeOS video thread output method ***************************************************************************** * Terminate an output method created by DummyCreateOutputMethod *****************************************************************************/void E_(CloseVideo) ( vlc_object_t *p_this ){    vout_thread_t * p_vout = (vout_thread_t *)p_this;    free( p_vout->p_sys );}/***************************************************************************** * Display: displays previously rendered output ***************************************************************************** * This function send the currently rendered image to BeOS image, waits until * it is displayed and switch the two rendering buffers, preparing next frame. *****************************************************************************/void Display( vout_thread_t *p_vout, picture_t *p_pic ){    VideoWindow * p_win = p_vout->p_sys->p_window;    /* draw buffer if required */    if (!p_win->teardownwindow)    {       p_win->drawBuffer(p_vout->p_sys->i_index);    }    /* change buffer */    p_vout->p_sys->i_index = ++p_vout->p_sys->i_index % 3;    p_pic->p->p_pixels = (uint8_t*)p_vout->p_sys->p_window->bitmap[p_vout->p_sys->i_index]->Bits();}/* following functions are local *//***************************************************************************** * BeosOpenDisplay: open and initialize BeOS device *****************************************************************************/static int BeosOpenDisplay( vout_thread_t *p_vout ){    p_vout->p_sys->p_window = new VideoWindow( p_vout->p_sys->i_width - 1,                                               p_vout->p_sys->i_height - 1,                                               BRect( 20, 50,                                                      20 + p_vout->i_window_width - 1,                                                      50 + p_vout->i_window_height - 1 ),                                               p_vout );    if( p_vout->p_sys->p_window == NULL )    {        msg_Err( p_vout, "cannot allocate VideoWindow" );        return( 1 );    }    else    {        p_vout->p_sys->p_window->Show();    }    return( 0 );}/***************************************************************************** * BeosDisplay: close and reset BeOS device ***************************************************************************** * Returns all resources allocated by BeosOpenDisplay and restore the original * state of the device. *****************************************************************************/static void BeosCloseDisplay( vout_thread_t *p_vout ){    VideoWindow * p_win = p_vout->p_sys->p_window;    /* Destroy the video window */    if( p_win != NULL && !p_win->teardownwindow)    {        p_win->Lock();        p_win->teardownwindow = true;        p_win->Hide();        p_win->Quit();    }    p_win = NULL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -