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

📄 qte.cpp

📁 video linux conference
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        }        p.drawImage( x, y, rotatedFrame, 0, 0, rw, rh );#else        QDirectPainter p(p_vout->p_sys->p_VideoWidget);        p.transformOrientation();        // just copy the image to the frame buffer...        memcpy(p.frameBuffer(), (p_pic->p_sys->pQImage->jumpTable())[0], h * p.lineStep());#endif    }}/***************************************************************************** * Manage: handle Qte events ***************************************************************************** * This function should be called regularly by video output thread. It manages * Qte events and allows window resizing. It returns a non null value on * error. *****************************************************************************/static int Manage( vout_thread_t *p_vout ){//    msg_Dbg( p_vout, "Manage" );    /* Fullscreen change */    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )    {        p_vout->b_fullscreen = ! p_vout->b_fullscreen;//        p_vout->p_sys->b_cursor_autohidden = 0;//        SDL_ShowCursor( p_vout->p_sys->b_cursor &&//                        ! p_vout->p_sys->b_cursor_autohidden );        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;        p_vout->i_changes |= VOUT_SIZE_CHANGE;    }    /*     * Size change     */    if( p_vout->i_changes & VOUT_SIZE_CHANGE )    {        msg_Dbg( p_vout, "video display resized (%dx%d)",                 p_vout->p_sys->i_width, p_vout->p_sys->i_height );        CloseDisplay( p_vout );        OpenDisplay( p_vout );        /* We don't need to signal the vout thread about the size change if         * we can handle rescaling ourselves */        p_vout->i_changes &= ~VOUT_SIZE_CHANGE;    }    /* Pointer change *///    if( ! p_vout->p_sys->b_cursor_autohidden &&//        ( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) )//    {//        /* Hide the mouse automatically *///        p_vout->p_sys->b_cursor_autohidden = 1;//        SDL_ShowCursor( 0 );//    }////    if( p_vout->p_vlc->b_die )//        p_vout->p_sys->bRunning = FALSE;    return 0;}/***************************************************************************** * End: terminate video thread output method ***************************************************************************** * Destroy the buffers created by vout_Init. It is called at the end of * the thread, but also each time the window is resized. *****************************************************************************/static void End( vout_thread_t *p_vout ){    int i_index;    /* Free the direct buffers we allocated */    for( i_index = I_OUTPUTPICTURES ; i_index ; )    {        i_index--;        FreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );    }}/***************************************************************************** * NewPicture: allocate a picture ***************************************************************************** * Returns 0 on success, -1 otherwise *****************************************************************************/static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ){    int dd = QPixmap::defaultDepth();    p_pic->p_sys = (picture_sys_t*) malloc( sizeof( picture_sys_t ) );    if( p_pic->p_sys == NULL )    {        return -1;    }    /* Create the display */    p_pic->p_sys->pQImage = new QImage(p_vout->output.i_width,                                       p_vout->output.i_height, dd );    if(p_pic->p_sys->pQImage == NULL)    {        return -1;    }    switch( dd )    {        case 8:            p_pic->p->i_pixel_pitch = 1;            break;        case 15:        case 16:            p_pic->p->i_pixel_pitch = 2;            break;        case 24:        case 32:            p_pic->p->i_pixel_pitch = 4;            break;        default:            return( -1 );    }    p_pic->p->p_pixels = (p_pic->p_sys->pQImage->jumpTable())[0];    p_pic->p->i_pitch = p_pic->p_sys->pQImage->bytesPerLine();    p_pic->p->i_lines = p_vout->output.i_height;    p_pic->p->i_visible_lines = p_vout->output.i_height;    p_pic->p->i_visible_pitch =            p_pic->p->i_pixel_pitch * p_vout->output.i_width;    p_pic->i_planes = 1;    return 0;}/***************************************************************************** * FreePicture: destroy a picture allocated with NewPicture *****************************************************************************/static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic ){    delete p_pic->p_sys->pQImage;}/***************************************************************************** * ToggleFullScreen: Enable or disable full screen mode ***************************************************************************** * This function will switch between fullscreen and window mode. * *****************************************************************************/static void ToggleFullScreen ( vout_thread_t *p_vout ){    if ( p_vout->b_fullscreen )       p_vout->p_sys->p_VideoWidget->showFullScreen();    else       p_vout->p_sys->p_VideoWidget->showNormal();    p_vout->b_fullscreen = !p_vout->b_fullscreen;}/***************************************************************************** * OpenDisplay: create qte applicaton / window ***************************************************************************** * Create a window according to video output given size, and set other * properties according to the display properties. *****************************************************************************/static int OpenDisplay( vout_thread_t *p_vout ){    /* for displaying the vout in a qt window we need the QtApplication */    p_vout->p_sys->p_QApplication = NULL;    p_vout->p_sys->p_VideoWidget = NULL;    p_vout->p_sys->p_event = (event_thread_t*) vlc_object_create( p_vout, sizeof(event_thread_t) );    p_vout->p_sys->p_event->p_vout = p_vout;    /* Initializations */#if 1 /* FIXME: I need an event queue to handle video output size changes. */    p_vout->b_fullscreen = VLC_TRUE;#endif    /* Set main window's size */    QWidget *desktop = p_vout->p_sys->p_QApplication->desktop();    p_vout->p_sys->i_width = p_vout->b_fullscreen ? desktop->height() :                                                    p_vout->i_window_width;    p_vout->p_sys->i_height = p_vout->b_fullscreen ? desktop->width() :                                                     p_vout->i_window_height;#if 0 /* FIXME: I need an event queue to handle video output size changes. */    /* Update dimensions */    p_vout->i_changes |= VOUT_SIZE_CHANGE;    p_vout->i_window_width = p_vout->p_sys->i_width;    p_vout->i_window_height = p_vout->p_sys->i_height;#endif    msg_Dbg( p_vout, "OpenDisplay (h=%d,w=%d)",p_vout->p_sys->i_height,p_vout->p_sys->i_width);    /* create thread to exec the qpe application */    if ( vlc_thread_create( p_vout->p_sys->p_event, "QT Embedded Thread",                            RunQtThread,                            VLC_THREAD_PRIORITY_OUTPUT, VLC_TRUE) )    {        msg_Err( p_vout, "cannot create QT Embedded Thread" );        vlc_object_destroy( p_vout->p_sys->p_event );        p_vout->p_sys->p_event = NULL;        return -1;    }    if( p_vout->p_sys->p_event->b_error )    {        msg_Err( p_vout, "RunQtThread failed" );        return -1;    }    vlc_object_attach( p_vout->p_sys->p_event, p_vout );    msg_Dbg( p_vout, "RunQtThread running" );    // just wait until the crew is complete...    while(p_vout->p_sys->p_VideoWidget == NULL)    {        msleep(1);    }    return VLC_SUCCESS;}/***************************************************************************** * CloseDisplay: destroy the window *****************************************************************************/static void CloseDisplay( vout_thread_t *p_vout ){    // quit qt application loop    msg_Dbg( p_vout, "destroying Qt Window" );#ifdef NEED_QTE_MAIN    if(p_vout->p_sys->p_QApplication)    {        p_vout->p_sys->bRunning = FALSE;        while(p_vout->p_sys->p_VideoWidget)        {            msleep(1);        }    }#else    if (p_vout->p_sys->p_QApplication)       p_vout->p_sys->p_QApplication->quit();#endif}/***************************************************************************** * main loop of qtapplication *****************************************************************************/static void RunQtThread(event_thread_t *p_event){    msg_Dbg( p_event->p_vout, "RunQtThread Starting" );#ifdef NEED_QTE_MAIN    if (qApp)    {        p_event->p_vout->p_sys->p_QApplication = qApp;        p_event->p_vout->p_sys->bOwnsQApp = FALSE;        p_event->p_vout->p_sys->p_VideoWidget = qApp->mainWidget();        msg_Dbg( p_event->p_vout, "RunQtThread applicaton attached" );    }#else    if (qApp==NULL)    {        int argc = 0;        QApplication* pApp = new QApplication(argc, NULL);        if(pApp)        {            p_event->p_vout->p_sys->p_QApplication = pApp;            p_event->p_vout->p_sys->bOwnsQApp = TRUE;        }        QWidget* pWidget = new QWidget();        if (pWidget)            {            p_event->p_vout->p_sys->p_VideoWidget = pWidget;        }    }#endif    /* signal the creation of the window */    vlc_thread_ready( p_event );    msg_Dbg( p_event->p_vout, "RunQtThread ready" );    if (p_event->p_vout->p_sys->p_QApplication)    {        /* Set default window width and heigh to exactly preferred size. */            QWidget *desktop = p_event->p_vout->p_sys->p_QApplication->desktop();            p_event->p_vout->p_sys->p_VideoWidget->setMinimumWidth( 10 );             p_event->p_vout->p_sys->p_VideoWidget->setMinimumHeight( 10 );            p_event->p_vout->p_sys->p_VideoWidget->setBaseSize( p_event->p_vout->p_sys->i_width,            p_event->p_vout->p_sys->i_height );        p_event->p_vout->p_sys->p_VideoWidget->setMaximumWidth( desktop->width() );        p_event->p_vout->p_sys->p_VideoWidget->setMaximumHeight( desktop->height() );        /* Check on fullscreen */        if (p_event->p_vout->b_fullscreen)                  p_event->p_vout->p_sys->p_VideoWidget->showFullScreen();        else                p_event->p_vout->p_sys->p_VideoWidget->showNormal();        p_event->p_vout->p_sys->p_VideoWidget->show();        p_event->p_vout->p_sys->bRunning = TRUE;#ifdef NEED_QTE_MAIN        while(!p_event->b_die && p_event->p_vout->p_sys->bRunning)              {               /* Check if we are asked to exit */           if( p_event->b_die )               break;               msleep(100);            }#else        // run the main loop of qtapplication until someone says: 'quit'        p_event->p_vout->p_sys->pcQApplication->exec();#endif    }#ifndef NEED_QTE_MAIN    if(p_event->p_vout->p_sys->p_QApplication)    {        delete p_event->p_vout->p_sys->p_VideoWidget;        p_event->p_vout->p_sys->p_VideoWidget = NULL;        delete p_event->p_vout->p_sys->p_QApplication;        p_event->p_vout->p_sys->p_QApplication = NULL;    }#else    p_event->p_vout->p_sys->p_VideoWidget = NULL;#endif    msg_Dbg( p_event->p_vout, "RunQtThread terminating" );}

⌨️ 快捷键说明

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