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

📄 directx.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 5 页
字号:
        msg_Err( p_vout, "cannot initialize DirectDraw" );        return VLC_EGENERIC;    }    /* Create the directx display */    if( !p_vout->p_sys->p_display &&        DirectXCreateDisplay( p_vout ) != VLC_SUCCESS )    {        msg_Err( p_vout, "cannot initialize DirectDraw" );        return VLC_EGENERIC;    }    /* Initialize the output structure.     * Since DirectDraw can do rescaling for us, stick to the default     * coordinates and aspect. */    p_vout->output.i_width  = p_vout->render.i_width;    p_vout->output.i_height = p_vout->render.i_height;    p_vout->output.i_aspect = p_vout->render.i_aspect;#define MAX_DIRECTBUFFERS 1    /* Right now we use only 1 directbuffer because we don't want the     * video decoder to decode directly into direct buffers as they are     * created into video memory and video memory is _really_ slow */    /* Choose the chroma we will try first. */    switch( p_vout->render.i_chroma )    {        case VLC_FOURCC('Y','U','Y','2'):        case VLC_FOURCC('Y','U','N','V'):            p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');            break;        case VLC_FOURCC('U','Y','V','Y'):        case VLC_FOURCC('U','Y','N','V'):        case VLC_FOURCC('Y','4','2','2'):            p_vout->output.i_chroma = VLC_FOURCC('U','Y','V','Y');            break;        case VLC_FOURCC('Y','V','Y','U'):            p_vout->output.i_chroma = VLC_FOURCC('Y','V','Y','U');            break;        default:            p_vout->output.i_chroma = VLC_FOURCC('Y','V','1','2');            break;    }    NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );    i_chroma_backup = p_vout->output.i_chroma;    if( !I_OUTPUTPICTURES )    {        /* hmmm, it didn't work! Let's try commonly supported chromas */        if( p_vout->output.i_chroma != VLC_FOURCC('I','4','2','0') )        {            p_vout->output.i_chroma = VLC_FOURCC('Y','V','1','2');            NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );        }        if( !I_OUTPUTPICTURES )        {            /* hmmm, it still didn't work! Let's try another one */            p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');            NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );        }    }    if( !I_OUTPUTPICTURES )    {        /* If it still didn't work then don't try to use an overlay */        p_vout->output.i_chroma = i_chroma_backup;        p_vout->p_sys->b_using_overlay = 0;        NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );    }    /* Change the window title bar text */    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );    return VLC_SUCCESS;}/***************************************************************************** * End: terminate Sys video thread output method ***************************************************************************** * Terminate an output method created by Create. * It is called at the end of the thread. *****************************************************************************/static void End( vout_thread_t *p_vout ){    FreePictureVec( p_vout, p_vout->p_picture, I_OUTPUTPICTURES );    DirectXCloseDisplay( p_vout );    DirectXCloseDDraw( p_vout );    return;}/***************************************************************************** * CloseVideo: destroy Sys video thread output method ***************************************************************************** * Terminate an output method created by Create *****************************************************************************/static void CloseVideo( vlc_object_t *p_this ){    vout_thread_t * p_vout = (vout_thread_t *)p_this;    msg_Dbg( p_vout, "CloseVideo" );    if( p_vout->p_sys->p_event )    {        vlc_object_detach( p_vout->p_sys->p_event );        /* Kill DirectXEventThread */        p_vout->p_sys->p_event->b_die = VLC_TRUE;        /* we need to be sure DirectXEventThread won't stay stuck in         * GetMessage, so we send a fake message */        if( p_vout->p_sys->hwnd )        {            PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0);        }        vlc_thread_join( p_vout->p_sys->p_event );        vlc_object_destroy( p_vout->p_sys->p_event );    }    vlc_mutex_destroy( &p_vout->p_sys->lock );    /* Make sure the wallpaper is restored */    SwitchWallpaperMode( p_vout, VLC_FALSE );    if( p_vout->p_sys )    {        free( p_vout->p_sys );        p_vout->p_sys = NULL;    }}/***************************************************************************** * Manage: handle Sys events ***************************************************************************** * This function should be called regularly by the video output thread. * It returns a non null value if an error occurred. *****************************************************************************/static int Manage( vout_thread_t *p_vout ){    WINDOWPLACEMENT window_placement;    /* If we do not control our window, we check for geometry changes     * ourselves because the parent might not send us its events. */    vlc_mutex_lock( &p_vout->p_sys->lock );    if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )    {        RECT rect_parent;        POINT point;        vlc_mutex_unlock( &p_vout->p_sys->lock );        GetClientRect( p_vout->p_sys->hparent, &rect_parent );        point.x = point.y = 0;        ClientToScreen( p_vout->p_sys->hparent, &point );        OffsetRect( &rect_parent, point.x, point.y );        if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )        {            p_vout->p_sys->rect_parent = rect_parent;            /* This one is to force the update even if only             * the position has changed */            SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,                          rect_parent.right - rect_parent.left,                          rect_parent.bottom - rect_parent.top, 0 );            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,                          rect_parent.right - rect_parent.left,                          rect_parent.bottom - rect_parent.top, 0 );        }    }    else    {        vlc_mutex_unlock( &p_vout->p_sys->lock );    }    /*     * Position Change     */    if( p_vout->p_sys->i_changes & DX_POSITION_CHANGE )    {        p_vout->p_sys->i_changes &= ~DX_POSITION_CHANGE;        /* Check if we are still on the same monitor */        if( p_vout->p_sys->MonitorFromWindow &&            p_vout->p_sys->hmonitor !=                p_vout->p_sys->MonitorFromWindow( p_vout->p_sys->hwnd,                                                  MONITOR_DEFAULTTONEAREST ) )        {            /* This will force the vout core to recreate the picture buffers */            p_vout->i_changes |= VOUT_PICTURE_BUFFERS_CHANGE;        }    }    /* We used to call the Win32 PeekMessage function here to read the window     * messages. But since window can stay blocked into this function for a     * long time (for example when you move your window on the screen), I     * decided to isolate PeekMessage in another thread. */    if( p_vout->p_sys->i_changes & DX_WALLPAPER_CHANGE )    {        SwitchWallpaperMode( p_vout, !p_vout->p_sys->b_wallpaper );        p_vout->p_sys->i_changes &= ~DX_WALLPAPER_CHANGE;        E_(DirectXUpdateOverlay)( p_vout );    }    /*     * Fullscreen change     */    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE        || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )    {        vlc_value_t val;        HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?            p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;        p_vout->b_fullscreen = ! p_vout->b_fullscreen;        /* We need to switch between Maximized and Normal sized window */        window_placement.length = sizeof(WINDOWPLACEMENT);        GetWindowPlacement( hwnd, &window_placement );        if( p_vout->b_fullscreen )        {            /* Change window style, no borders and no title bar */            int i_style = WS_CLIPCHILDREN | WS_VISIBLE;            SetWindowLong( hwnd, GWL_STYLE, i_style );            if( p_vout->p_sys->hparent )            {                /* Retrieve current window position so fullscreen will happen                 * on the right screen */                POINT point = {0,0};                RECT rect;                ClientToScreen( p_vout->p_sys->hwnd, &point );                GetClientRect( p_vout->p_sys->hwnd, &rect );                SetWindowPos( hwnd, 0, point.x, point.y,                              rect.right, rect.bottom,                              SWP_NOZORDER|SWP_FRAMECHANGED );                GetWindowPlacement( hwnd, &window_placement );            }            /* Maximize window */            window_placement.showCmd = SW_SHOWMAXIMIZED;            SetWindowPlacement( hwnd, &window_placement );            SetWindowPos( hwnd, 0, 0, 0, 0, 0,                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);            if( p_vout->p_sys->hparent )            {                RECT rect;                GetClientRect( hwnd, &rect );                SetParent( p_vout->p_sys->hwnd, hwnd );                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,                              rect.right, rect.bottom,                              SWP_NOZORDER|SWP_FRAMECHANGED );            }            SetForegroundWindow( hwnd );        }        else        {            /* Change window style, no borders and no title bar */            SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );            /* Normal window */            window_placement.showCmd = SW_SHOWNORMAL;            SetWindowPlacement( hwnd, &window_placement );            SetWindowPos( hwnd, 0, 0, 0, 0, 0,                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);            if( p_vout->p_sys->hparent )            {                RECT rect;                GetClientRect( p_vout->p_sys->hparent, &rect );                SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,                              rect.right, rect.bottom,                              SWP_NOZORDER|SWP_FRAMECHANGED );                ShowWindow( hwnd, SW_HIDE );                SetForegroundWindow( p_vout->p_sys->hparent );            }            /* Make sure the mouse cursor is displayed */            PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );        }        /* Update the object variable and trigger callback */        val.b_bool = p_vout->b_fullscreen;        var_Set( p_vout, "fullscreen", val );        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;        p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;    }    /*     * Pointer change     */    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&        (mdate() - p_vout->p_sys->i_lastmoved) > 5000000 )    {        POINT point;        HWND hwnd;        /* Hide the cursor only if it is inside our window */        GetCursorPos( &point );        hwnd = WindowFromPoint(point);        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )        {            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );        }        else        {            p_vout->p_sys->i_lastmoved = mdate();        }    }    /*     * "Always on top" status change     */    if( p_vout->p_sys->b_on_top_change )    {        vlc_value_t val;        HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );        var_Get( p_vout, "video-on-top", &val );        /* Set the window on top if necessary */        if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )                           & WS_EX_TOPMOST ) )        {            CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,                           MF_BYCOMMAND | MFS_CHECKED );            SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,                          SWP_NOSIZE | SWP_NOMOVE );        }

⌨️ 快捷键说明

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