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

📄 videooutput.cpp

📁 video linux conference
💻 CPP
📖 第 1 页 / 共 4 页
字号:
 * VideoWindow::MessageReceived *****************************************************************************/voidVideoWindow::MessageReceived( BMessage *p_message ){    switch( p_message->what )    {        case SHOW_INTERFACE:            SetInterfaceShowing( true );            break;        case TOGGLE_FULL_SCREEN:            BWindow::Zoom();            break;        case RESIZE_50:        case RESIZE_100:        case RESIZE_200:            if (IsFullScreen())                BWindow::Zoom();            _SetVideoSize(p_message->what);            break;        case VERT_SYNC:            SetSyncToRetrace(!IsSyncedToRetrace());            break;        case WINDOW_FEEL:            {                window_feel winFeel;                if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK)                {                    SetFeel(winFeel);                    fCachedFeel = winFeel;                    if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)                        fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);                    else                        fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);                }            }            break;        case ASPECT_CORRECT:            SetCorrectAspectRatio(!CorrectAspectRatio());            break;        case B_KEY_DOWN:        case B_UNMAPPED_KEY_DOWN:        case B_KEY_UP:        case B_UNMAPPED_KEY_UP:        {            key_map * keys;            char    * chars;            int32     key, modifiers;            if( p_message->FindInt32( "key", &key ) != B_OK ||                p_message->FindInt32( "modifiers", &modifiers ) != B_OK )            {                /* Shouldn't happen */                break;            }            if( ( p_message->what == B_KEY_UP ||                  p_message->what == B_UNMAPPED_KEY_UP ) &&                !( modifiers & B_COMMAND_KEY ) )            {                /* We only use the KEY_UP messages to detect Alt+X                   shortcuts (because the KEY_DOWN messages aren't                   sent when Alt is pressed) */                break;            }            /* Special case for Alt+1, Alt+2 and Alt+3 shortcuts: since               the character depends on the keymap, we use the key codes               directly (18, 19, 20) */            if( ( modifiers & B_COMMAND_KEY ) &&                key >= 18 && key <= 20 )            {                if( key == 18 )                    PostMessage( RESIZE_50 );                else if( key == 19 )                    PostMessage( RESIZE_100 );                else                    PostMessage( RESIZE_200 );                break;            }            /* Get the current keymap */            get_key_map( &keys, &chars );            if( key >= 128 || chars[keys->normal_map[key]] != 1 )            {                /* Weird key or Unicode character */                free( keys );                free( chars );                break;            }            vlc_value_t val;            val.i_int = ConvertKeyToVLC( chars[keys->normal_map[key]+1] );            if( modifiers & B_COMMAND_KEY )            {                val.i_int |= KEY_MODIFIER_ALT;            }            if( modifiers & B_SHIFT_KEY )            {                val.i_int |= KEY_MODIFIER_SHIFT;            }            if( modifiers & B_CONTROL_KEY )            {                val.i_int |= KEY_MODIFIER_CTRL;            }            var_Set( p_vout->p_vlc, "key-pressed", val );            free( keys );            free( chars );            break;        }        default:            BWindow::MessageReceived( p_message );            break;    }}/***************************************************************************** * VideoWindow::Zoom *****************************************************************************/voidVideoWindow::Zoom(BPoint origin, float width, float height ){    ToggleFullScreen();}/***************************************************************************** * VideoWindow::FrameMoved *****************************************************************************/voidVideoWindow::FrameMoved(BPoint origin){    if (IsFullScreen())        return ;    winSize = Frame();}/***************************************************************************** * VideoWindow::FrameResized *****************************************************************************/voidVideoWindow::FrameResized( float width, float height ){    int32_t useWidth = CorrectAspectRatio() ? i_width : fTrueWidth;    int32_t useHeight = CorrectAspectRatio() ? i_height : fTrueHeight;    float out_width, out_height;    float out_left, out_top;    float width_scale = width / useWidth;    float height_scale = height / useHeight;    if (width_scale <= height_scale)    {        out_width = (useWidth * width_scale);        out_height = (useHeight * width_scale);        out_left = 0;        out_top = (height - out_height) / 2;    }    else   /* if the height is proportionally smaller */    {        out_width = (useWidth * height_scale);        out_height = (useHeight * height_scale);        out_top = 0;        out_left = (width - out_width) / 2;    }    view->MoveTo(out_left,out_top);    view->ResizeTo(out_width, out_height);    if (!IsFullScreen())        winSize = Frame();}/***************************************************************************** * VideoWindow::ScreenChanged *****************************************************************************/voidVideoWindow::ScreenChanged(BRect frame, color_space format){    BScreen screen(this);    display_mode mode;    screen.GetMode(&mode);    float refresh = (mode.timing.pixel_clock * 1000)                    / ((mode.timing.h_total) * (mode.timing.v_total));    SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);}/***************************************************************************** * VideoWindow::Activate *****************************************************************************/voidVideoWindow::WindowActivated(bool active){}/***************************************************************************** * VideoWindow::drawBuffer *****************************************************************************/voidVideoWindow::drawBuffer(int bufferIndex){    i_buffer = bufferIndex;    // sync to the screen if required    if (IsSyncedToRetrace())    {        BScreen screen(this);        screen.WaitForRetrace(22000);    }    if (fInitStatus >= B_OK && LockLooper())    {       // switch the overlay bitmap       if (mode == OVERLAY)       {          rgb_color key;          view->SetViewOverlay(bitmap[i_buffer],                            bitmap[i_buffer]->Bounds() ,                            view->Bounds(),                            &key, B_FOLLOW_ALL,                            B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL|                            B_OVERLAY_TRANSFER_CHANNEL);           view->SetViewColor(key);       }       else       {         // switch the bitmap         view->DrawBitmap(bitmap[i_buffer], view->Bounds() );       }       UnlockLooper();    }}/***************************************************************************** * VideoWindow::SetInterfaceShowing *****************************************************************************/voidVideoWindow::ToggleInterfaceShowing(){    SetInterfaceShowing(!fInterfaceShowing);}/***************************************************************************** * VideoWindow::SetInterfaceShowing *****************************************************************************/voidVideoWindow::SetInterfaceShowing(bool showIt){    BWindow* window = get_interface_window();    if (window)    {        if (showIt)        {            if (fCachedFeel != B_NORMAL_WINDOW_FEEL)                SetFeel(B_NORMAL_WINDOW_FEEL);            window->Activate(true);            SendBehind(window);        }        else        {            SetFeel(fCachedFeel);            Activate(true);            window->SendBehind(this);        }        fInterfaceShowing = showIt;    }}/***************************************************************************** * VideoWindow::SetCorrectAspectRatio *****************************************************************************/voidVideoWindow::SetCorrectAspectRatio(bool doIt){    if (CorrectAspectRatio() != doIt)    {        if (doIt)            fSettings->AddFlags(VideoSettings::FLAG_CORRECT_RATIO);        else            fSettings->ClearFlags(VideoSettings::FLAG_CORRECT_RATIO);        FrameResized(Bounds().Width(), Bounds().Height());    }}/***************************************************************************** * VideoWindow::CorrectAspectRatio *****************************************************************************/boolVideoWindow::CorrectAspectRatio() const{    return fSettings->HasFlags(VideoSettings::FLAG_CORRECT_RATIO);}/***************************************************************************** * VideoWindow::ToggleFullScreen *****************************************************************************/voidVideoWindow::ToggleFullScreen(){    SetFullScreen(!IsFullScreen());}/***************************************************************************** * VideoWindow::SetFullScreen *****************************************************************************/voidVideoWindow::SetFullScreen(bool doIt){    if (doIt)    {        SetLook( B_NO_BORDER_WINDOW_LOOK );        BScreen screen( this );        BRect rect = screen.Frame();        Activate();        MoveTo(0.0, 0.0);        ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());        be_app->ObscureCursor();        fInterfaceShowing = false;        fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);    }    else    {        SetLook( B_TITLED_WINDOW_LOOK );        MoveTo(winSize.left, winSize.top);        ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());        be_app->ShowCursor();        fInterfaceShowing = true;        fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);    }}/***************************************************************************** * VideoWindow::IsFullScreen *****************************************************************************/boolVideoWindow::IsFullScreen() const{    return fSettings->HasFlags(VideoSettings::FLAG_FULL_SCREEN);}/***************************************************************************** * VideoWindow::SetSyncToRetrace *****************************************************************************/voidVideoWindow::SetSyncToRetrace(bool doIt){    if (doIt)        fSettings->AddFlags(VideoSettings::FLAG_SYNC_RETRACE);    else        fSettings->ClearFlags(VideoSettings::FLAG_SYNC_RETRACE);}/***************************************************************************** * VideoWindow::IsSyncedToRetrace *****************************************************************************/

⌨️ 快捷键说明

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