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

📄 vout_beos.cpp

📁 vlc stand 0.1.99 ist sehr einfach
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        }        fNumClipRects = info->clip_list_count;        fClipList = (clipping_rect*) malloc(fNumClipRects*sizeof(clipping_rect));        for( i=0 ; i<info->clip_list_count ; i++ )        {            fClipList[i].top = info->clip_list[i].top - info->window_bounds.top;            fClipList[i].left = info->clip_list[i].left - info->window_bounds.left;            fClipList[i].bottom = info->clip_list[i].bottom - info->window_bounds.top;            fClipList[i].right = info->clip_list[i].right - info->window_bounds.left;        }        break;    case B_DIRECT_STOP:        fConnected = false;        break;    }    locker->Unlock();}/***************************************************************************** * VideoWindow::MessageReceived *****************************************************************************/void VideoWindow::MessageReceived( BMessage * p_message ){    BWindow * p_win;        switch( p_message->what )    {    case B_KEY_DOWN:        // post the message to the interface window which will handle it        p_win = beos_GetAppWindow( "interface" );        if( p_win != NULL )        {            p_win->PostMessage( p_message );        }        break;        default:        BWindow::MessageReceived( p_message );        break;    }}/***************************************************************************** * VideoWindow::QuitRequested *****************************************************************************/bool VideoWindow::QuitRequested(){    return( true );}extern "C"{/***************************************************************************** * Local prototypes *****************************************************************************/static int     BeosOpenDisplay   ( vout_thread_t *p_vout );static void    BeosCloseDisplay  ( vout_thread_t *p_vout );/***************************************************************************** * vout_SysCreate: allocates dummy video thread output method ***************************************************************************** * This function allocates and initializes a dummy vout method. *****************************************************************************/int vout_SysCreate( vout_thread_t *p_vout, char *psz_display,                    int i_root_window, void *p_data ){    /* Allocate structure */    p_vout->p_sys = (vout_sys_t*) malloc( sizeof( vout_sys_t ) );    if( p_vout->p_sys == NULL )    {        intf_ErrMsg( "error: %s\n", strerror(ENOMEM) );        return( 1 );    }        /* Set video window's size */    p_vout->i_width =  main_GetIntVariable( VOUT_WIDTH_VAR, VOUT_WIDTH_DEFAULT );    p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR, VOUT_HEIGHT_DEFAULT );    /* Open and initialize device */    if( BeosOpenDisplay( p_vout ) )    {        intf_ErrMsg("vout error: can't open display\n");        free( p_vout->p_sys );        return( 1 );    }    return( 0 );}/***************************************************************************** * vout_SysInit: initialize dummy video thread output method *****************************************************************************/int vout_SysInit( vout_thread_t *p_vout ){    VideoWindow * p_win = p_vout->p_sys->p_window;    u32 i_page_size;    p_win->locker->Lock();    i_page_size =   p_vout->i_width * p_vout->i_height * p_vout->i_bytes_per_pixel;        p_vout->p_sys->i_width =         p_vout->i_width;    p_vout->p_sys->i_height =        p_vout->i_height;        /* Allocate memory for the 2 display buffers */    p_vout->p_sys->pp_buffer[0] = (byte_t*) malloc( i_page_size );    p_vout->p_sys->pp_buffer[1] = (byte_t*) malloc( i_page_size );    if( p_vout->p_sys->pp_buffer[0] == NULL  || p_vout->p_sys->pp_buffer[0] == NULL )    {        intf_ErrMsg("vout error: can't allocate video memory (%s)\n", strerror(errno) );        if( p_vout->p_sys->pp_buffer[0] != NULL ) free( p_vout->p_sys->pp_buffer[0] );        if( p_vout->p_sys->pp_buffer[1] != NULL ) free( p_vout->p_sys->pp_buffer[1] );        p_win->locker->Unlock();        return( 1 );    }    /* Set and initialize buffers */    vout_SetBuffers( p_vout, p_vout->p_sys->pp_buffer[0],                     p_vout->p_sys->pp_buffer[1] );    p_win->locker->Unlock();    return( 0 );}/***************************************************************************** * vout_SysEnd: terminate dummy video thread output method *****************************************************************************/void vout_SysEnd( vout_thread_t *p_vout ){   VideoWindow * p_win = p_vout->p_sys->p_window;      p_win->Lock();      free( p_vout->p_sys->pp_buffer[0] );   free( p_vout->p_sys->pp_buffer[1] );   p_win->fReady = false;   p_win->Unlock();   }/***************************************************************************** * vout_SysDestroy: destroy dummy video thread output method ***************************************************************************** * Terminate an output method created by DummyCreateOutputMethod *****************************************************************************/void vout_SysDestroy( vout_thread_t *p_vout ){    BeosCloseDisplay( p_vout );        free( p_vout->p_sys );}/***************************************************************************** * vout_SysManage: handle dummy events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/int vout_SysManage( vout_thread_t *p_vout ){    if( p_vout->i_changes & VOUT_SIZE_CHANGE )    {        intf_DbgMsg("resizing window\n");        p_vout->i_changes &= ~VOUT_SIZE_CHANGE;        /* Resize window */        p_vout->p_sys->p_window->ResizeTo( p_vout->i_width, p_vout->i_height );        /* Destroy XImages to change their size */        vout_SysEnd( p_vout );        /* Recreate XImages. If SysInit failed, the thread can't go on. */        if( vout_SysInit( p_vout ) )        {            intf_ErrMsg("error: can't resize display\n");            return( 1 );        }        /* Tell the video output thread that it will need to rebuild YUV         * tables. This is needed since convertion buffer size may have changed */        p_vout->i_changes |= VOUT_YUV_CHANGE;        intf_Msg("Video display resized (%dx%d)\n", p_vout->i_width, p_vout->i_height);    }    return( 0 );}/***************************************************************************** * vout_SysDisplay: displays previously rendered output ***************************************************************************** * This function send the currently rendered image to dummy image, waits until * it is displayed and switch the two rendering buffers, preparing next frame. *****************************************************************************/void vout_SysDisplay( vout_thread_t *p_vout ){    VideoWindow * p_win = p_vout->p_sys->p_window;        p_win->locker->Lock();    p_vout->i_buffer_index = ++p_vout->i_buffer_index & 1;    p_win->fReady = true;    p_win->fDirty = true;    p_win->locker->Unlock();}/* following functions are local *//***************************************************************************** * BeosOpenDisplay: open and initialize dummy device ***************************************************************************** * XXX?? The framebuffer mode is only provided as a fast and efficient way to * display video, providing the card is configured and the mode ok. It is * not portable, and is not supposed to work with many cards. Use at your * own risk ! *****************************************************************************/static int BeosOpenDisplay( vout_thread_t *p_vout ){     /* Create the DirectDraw video window */    p_vout->p_sys->p_window =        new VideoWindow(  BRect( 100, 100, 100+p_vout->i_width, 100+p_vout->i_height ), "VideoLAN", p_vout );    if( p_vout->p_sys->p_window == 0 )    {        free( p_vout->p_sys );        intf_ErrMsg( "error: cannot allocate memory for VideoWindow\n" );        return( 1 );    }       VideoWindow * p_win = p_vout->p_sys->p_window;        /* Wait until DirectConnected has been called */    while( !p_win->fConnected )        snooze( 50000 );    p_vout->i_screen_depth =         p_win->i_screen_depth;    p_vout->i_bytes_per_pixel =      p_win->i_bytes_per_pixel;    p_vout->i_bytes_per_line =       p_vout->i_width*p_win->i_bytes_per_pixel;        switch( p_vout->i_screen_depth )    {    case 8:        intf_ErrMsg( "vout error: 8 bit mode not fully supported\n" );        break;    case 15:        p_vout->i_red_mask =        0x7c00;        p_vout->i_green_mask =      0x03e0;        p_vout->i_blue_mask =       0x001f;        break;    case 16:        p_vout->i_red_mask =        0xf800;        p_vout->i_green_mask =      0x07e0;        p_vout->i_blue_mask =       0x001f;        break;    case 24:    case 32:    default:        p_vout->i_red_mask =        0xff0000;        p_vout->i_green_mask =      0x00ff00;        p_vout->i_blue_mask =       0x0000ff;        break;    }    return( 0 );}/***************************************************************************** * BeosDisplay: close and reset dummy device ***************************************************************************** * Returns all resources allocated by BeosOpenDisplay and restore the original * state of the device. *****************************************************************************/static void BeosCloseDisplay( vout_thread_t *p_vout ){        /* Destroy the video window */    p_vout->p_sys->p_window->Lock();    p_vout->p_sys->p_window->Quit();}} /* extern "C" */

⌨️ 快捷键说明

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