video.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef _VIDEO_H
  2. #define _VIDEO_H
  3. #include <windows.h>
  4. #include <ddraw.h>
  5. #include <multimon.h>
  6. #include "main.h"
  7. #define NUM_WIDGETS 11
  8. class VideoOutput;
  9. class SubsItem;
  10. class VideoOutputChild {
  11. public:
  12. VideoOutputChild() { m_mon_x=m_mon_y=0; }
  13. virtual ~VideoOutputChild() { }
  14. virtual int create(VideoOutput *parent, int w, int h, unsigned int type, int flipit, double aspectratio)=0; //return 1 if ok
  15. virtual int needChange()=0; //return 1 if need to renegociate video output
  16. virtual int onPaint(HWND hwnd, HDC hdc) { return 0; } //return 1 if override
  17. virtual void displayFrame(const char *buf, int size, int time)=0;
  18. virtual void goFullScreen()=0;
  19. virtual void removeFullScreen()=0;
  20. virtual int showOSD() { return 0; }
  21. virtual void hideOSD() { }
  22. virtual void timerCallback() { }
  23. virtual void setPalette(RGBQUAD *pal) { }
  24. virtual void drawSubtitle(SubsItem *item) { }
  25. virtual void resetSubtitle() { }
  26. char m_szTest[512];
  27. void update_monitor_coords(VideoOutput *parent);
  28. int m_mon_x;
  29. int m_mon_y;
  30. int m_found_devguid;
  31. GUID m_devguid;
  32. HMONITOR m_monitor_to_find;
  33. };
  34. #include "vid_overlay.h"
  35. #include "vid_ddraw.h"
  36. class VideoOutput : public IVideoOutput {
  37. public:
  38. VideoOutput(HWND parent_hwnd=NULL, int initxpos=CW_USEDEFAULT, int initypos=CW_USEDEFAULT);
  39. ~VideoOutput();
  40. int open(int w, int h, int vflip, double aspectratio, unsigned int fmt);
  41. void close();
  42. void draw(void *frame);
  43. void drawSubtitle(SubsItem *item);
  44. void showStatusMsg(const char *text);
  45. void notifyBufferState(int bufferstate); /* 0-255*/
  46. int get_latency();
  47. void setcallback(LRESULT (*msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), void *token) { m_msgcallback_tok=token; m_msgcallback=msgcallback; }
  48. void setNSVDecoder(NSVDecoder *nsv_decoder) { decoder = nsv_decoder; }
  49. void fullscreen();
  50. void remove_fullscreen();
  51. int is_fullscreen();
  52. HWND getHwnd() { return video_hwnd; }
  53. void adjustAspect(RECT &rd);
  54. int vid_vsync;
  55. int vid_aspectadj;
  56. int vid_overlays;
  57. int vid_ddraw;
  58. void getViewport(RECT *r, HWND wnd, int full);
  59. void setOutputSize(int w, int h);
  60. void getOutputSize(int *w, int *h);
  61. int osdShowing() { return show_osd; }
  62. int osdReady() { return ctrlrects_ready; }
  63. void showOSD();
  64. void hideOSD();
  65. void drawOSD(HDC hdc, RECT *r);
  66. int getOSDbarHeight() { return (show_osd && ctrlrects_ready) ? (ctrlrect_all.bottom - ctrlrect_all.top) : 0; };
  67. private:
  68. LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  69. static int class_refcnt;
  70. static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  71. HWND video_hwnd, video_parent_hwnd;
  72. NSVDecoder *decoder;
  73. double aspect;
  74. int width, height, flip;
  75. unsigned int type;
  76. int uyvy_output,yuy2_output;
  77. int i420_output;
  78. int is_fs;
  79. int ignore_mousemove_count;
  80. int show_osd;
  81. HWND oldfsparent;
  82. RECT oldfsrect; // the old window rect, BEFORE fullscreen mode was entered
  83. RECT lastfsrect; // the most recent bounding rect when in fullscreen mode
  84. LONG oldfsstyle;
  85. int m_bufferstate;
  86. void resetSubtitle();
  87. SubsItem *curSubtitle;
  88. // ONSCREEN DISPLAY (osd):
  89. HFONT osdFontText;
  90. HFONT osdFontSymbol;
  91. HGDIOBJ osdProgressBrushBg;
  92. HGDIOBJ osdProgressBrushFg;
  93. HGDIOBJ osdProgressPenBg;
  94. HGDIOBJ osdProgressPenFg;
  95. HGDIOBJ osdProgressPenBgHilite;
  96. HGDIOBJ osdBlackBrush;
  97. void osdHitTest(int x, int y, int dragging);
  98. int osdLastClickItem;
  99. HDC osdMemDC; // memory device context
  100. HBITMAP osdMemBM; // memory bitmap (for memDC)
  101. HBITMAP osdOldBM; // old bitmap (from memDC)
  102. int osdMemBMW; // width of memory bitmap
  103. int osdMemBMH; // height of memory bitmap
  104. int osdLastMouseX; // for WM_MOUSEMOVE thresholding, so osd isn't spastic
  105. int osdLastMouseY; // for WM_MOUSEMOVE thresholding, so osd isn't spastic
  106. RECT ctrlrect[NUM_WIDGETS]; // relative to [i.e. (0,0) is] upper left corner of the black strip @ the bottom
  107. RECT ctrlrect_all; // relative to [i.e. (0,0) is] upper left corner of the black strip @ the bottom
  108. int ctrlrects_ready;
  109. LRESULT (*m_msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  110. void *m_msgcallback_tok;
  111. VideoOutputChild *m_video_output;
  112. VideoOutputChild *createVideoOutput(int n);
  113. CRITICAL_SECTION m_cs;
  114. char *m_statusmsg;
  115. int m_need_change;
  116. HBITMAP m_logo;
  117. int m_logo_w, m_logo_h;
  118. DWORD m_lastbufinvalid;
  119. #ifdef ACTIVEX_CONTROL
  120. int m_firstframe;
  121. #endif
  122. };
  123. #endif