VideoWindow.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:7k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * VideoWindow.h: BeOS video window class prototype
  3.  *****************************************************************************
  4.  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
  5.  * $Id: 4f874d31aeb0d77abeac6af209c3a8acfcd1135a $
  6.  *
  7.  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  8.  *          Tony Castley <tcastley@mail.powerup.com.au>
  9.  *          Richard Shepherd <richard@rshepherd.demon.co.uk>
  10.  *          Stephan Aßmus <stippi@yellowbites.com>
  11.  *
  12.  * This program is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2 of the License, or
  15.  * (at your option) any later version.
  16.  *
  17.  * This program is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with this program; if not, write to the Free Software
  24.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  25.  *****************************************************************************/
  26. #ifndef BEOS_VIDEO_WINDOW_H
  27. #define BEOS_VIDEO_WINDOW_H
  28. #include <View.h>
  29. #include <Window.h>
  30. #define BITMAP  0
  31. #define OVERLAY 1
  32. #define OPENGL  2
  33. typedef struct colorcombo
  34. {
  35.     color_space colspace;
  36.     const char *name;
  37.     uint32_t chroma;
  38.     int planes;
  39.     int pixel_bytes;
  40. } colorcombo;
  41. colorcombo colspace[]=
  42. {
  43.     {B_YCbCr420, "B_YCbCr420", VLC_FOURCC('I','4','2','0'), 3, 2},
  44.     {B_YUV422,   "B_YUV422",   VLC_FOURCC('Y','4','2','2'), 3, 2},
  45.     {B_YCbCr422, "B_YCbCr422", VLC_FOURCC('Y','U','Y','2'), 3, 2},
  46.     {B_RGB32,    "B_RGB32",    VLC_FOURCC('R','V','3','2'), 1, 4},
  47.     {B_RGB16,    "B_RGB16",    VLC_FOURCC('R','V','1','6'), 1, 2}
  48. };
  49. #define COLOR_COUNT 5
  50. #define DEFAULT_COL 3
  51. class VideoSettings
  52. {
  53.  public:
  54.                             VideoSettings( const VideoSettings& clone );
  55.     virtual                    ~VideoSettings();
  56.     static    VideoSettings*    DefaultSettings();
  57.     enum
  58.     {
  59.         SIZE_OTHER            = 0,
  60.         SIZE_50                = 1,
  61.         SIZE_100            = 2,
  62.         SIZE_200            = 3,
  63.     };
  64.             void            SetVideoSize( uint32_t mode );
  65.     inline    uint32_t            VideoSize() const
  66.                                 { return fVideoSize; }
  67.     enum
  68.     {
  69.         FLAG_CORRECT_RATIO    = 0x0001,
  70.         FLAG_SYNC_RETRACE    = 0x0002,
  71.         FLAG_ON_TOP_ALL        = 0x0004,
  72.         FLAG_FULL_SCREEN    = 0x0008,
  73.     };
  74.     inline    void            SetFlags( uint32_t flags )
  75.                                 { fFlags = flags; }
  76.     inline    void            AddFlags( uint32_t flags )
  77.                                 { fFlags |= flags; }
  78.     inline    void            ClearFlags( uint32_t flags )
  79.                                 { fFlags &= ~flags; }
  80.     inline    bool            HasFlags( uint32_t flags ) const
  81.                                 { return fFlags & flags; }
  82.     inline    uint32_t            Flags() const
  83.                                 { return fFlags; }
  84.  private:
  85.                             VideoSettings(); // reserved for default settings
  86.     static    VideoSettings    fDefaultSettings;
  87.             uint32_t            fVideoSize;
  88.             uint32_t            fFlags;
  89.             BMessage*        fSettings;
  90. };
  91. class VLCView : public BView
  92. {
  93.  public:
  94.                             VLCView( BRect bounds, vout_thread_t *p_vout );
  95.     virtual                    ~VLCView();
  96.     virtual    void            AttachedToWindow();
  97.     virtual    void            MouseDown(BPoint where);
  98.     virtual    void            MouseUp(BPoint where);
  99.     virtual    void            MouseMoved(BPoint where, uint32 transit,
  100.                                        const BMessage* dragMessage);
  101.     virtual    void            Pulse();
  102.     virtual    void            Draw(BRect updateRect);
  103.  private:
  104.             vout_thread_t   *p_vout;
  105.             bigtime_t        fLastMouseMovedTime;
  106.             int             fMouseHideTimeout;
  107.             bool            fCursorHidden;
  108.             bool            fCursorInside;
  109.             bool            fIgnoreDoubleClick;
  110. };
  111. class VideoWindow : public BWindow
  112. {
  113. public:
  114.                             VideoWindow(int v_width,
  115.                                         int v_height,
  116.                                         BRect frame,
  117.                                         vout_thread_t *p_vout);
  118.     virtual                    ~VideoWindow();
  119.                             // BWindow
  120.     virtual    void            MessageReceived(BMessage* message);
  121.     virtual    void            Zoom(BPoint origin,
  122.                                  float width, float height);
  123.     virtual    void            FrameResized(float width, float height);
  124.     virtual    void            FrameMoved(BPoint origin);
  125.     virtual    void            ScreenChanged(BRect frame,
  126.                                           color_space mode);
  127.     virtual    void            WindowActivated(bool active);
  128.                             // VideoWindow
  129.             void            drawBuffer(int bufferIndex);
  130.             void            ToggleInterfaceShowing();
  131.             void            SetInterfaceShowing(bool showIt);
  132.             void            SetCorrectAspectRatio(bool doIt);
  133.             bool            CorrectAspectRatio() const;
  134.             void            ToggleFullScreen();
  135.             void            SetFullScreen(bool doIt);
  136.             bool            IsFullScreen() const;
  137.             void            SetOnTop(bool doIt);
  138.             bool            IsOnTop() const;
  139.             void            SetSyncToRetrace(bool doIt);
  140.             bool            IsSyncedToRetrace() const;
  141.     inline    status_t        InitCheck() const
  142.                                 { return fInitStatus; }
  143.     // this is the hook controling direct screen connection
  144.     int32_t         i_width;     // aspect corrected bitmap size
  145.     int32_t         i_height;
  146.     BRect           winSize;     // current window size
  147.     BBitmap            *bitmap[3];
  148. //    BBitmap         *overlaybitmap;
  149.     VLCView            *view;
  150.     int             i_buffer;
  151.     volatile bool    teardownwindow;
  152.     thread_id       fDrawThreadID;
  153.     int             mode;
  154.     int             bitmap_count;
  155.     int             colspace_index;
  156. private:
  157.             status_t        _AllocateBuffers(int width,
  158.                                              int height,
  159.                                              int* mode);
  160.             void            _FreeBuffers();
  161.             void            _BlankBitmap(BBitmap* bitmap) const;
  162.             void            _SetVideoSize(uint32_t mode);
  163.             void            _SetToSettings();
  164.     vout_thread_t   *p_vout;
  165.     int32_t            fTrueWidth;     // incomming bitmap size
  166.     int32_t            fTrueHeight;
  167.     window_feel        fCachedFeel;
  168.     bool            fInterfaceShowing;
  169.     status_t        fInitStatus;
  170.     VideoSettings*    fSettings;
  171. };
  172. #endif    // BEOS_VIDEO_WINDOW_H