/indra/test_apps/llplugintest/llmediaplugintest.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 207 lines · 153 code · 23 blank · 31 comment · 0 complexity · 0d3b4563851a6d563ada1caee2f6b88a MD5 · raw file

  1. /**
  2. * @file LLMediaPluginTest.cpp
  3. * @brief Primary test application for LLMedia (Separate Process) Plugin system
  4. *
  5. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_MEDIA_PLUGIN_TEST_H
  27. #define LL_MEDIA_PLUGIN_TEST_H
  28. #include <vector>
  29. #include <string>
  30. #include "llpluginclassmedia.h"
  31. #include "llgl.h"
  32. // Forward declarations
  33. class GLUI_Rotation;
  34. class GLUI_Translation;
  35. class GLUI_Listbox;
  36. class GLUI_EditText;
  37. class GLUI_StaticText;
  38. class GLUI;
  39. class GLUI_Button;
  40. ////////////////////////////////////////////////////////////////////////////////
  41. //
  42. struct mediaPanel
  43. {
  44. public:
  45. mediaPanel();
  46. ~mediaPanel();
  47. int mId;
  48. std::string mStartUrl;
  49. std::string mMimeType;
  50. std::string mTarget;
  51. LLPluginClassMedia *mMediaSource;
  52. int mMediaWidth;
  53. int mMediaHeight;
  54. int mTextureWidth;
  55. int mTextureHeight;
  56. double mTextureScaleX;
  57. double mTextureScaleY;
  58. GLuint mMediaTextureHandle;
  59. GLuint mPickTextureHandle;
  60. unsigned char* mPickTexturePixels;
  61. bool mAppTextureCoordsOpenGL;
  62. bool mReadyToRender;
  63. };
  64. ////////////////////////////////////////////////////////////////////////////////
  65. //
  66. class LLMediaPluginTest : public LLPluginClassMediaOwner
  67. {
  68. public:
  69. LLMediaPluginTest( int app_window, int window_width, int window_height );
  70. ~LLMediaPluginTest();
  71. void reshape( int width, int height );
  72. void display();
  73. void idle();
  74. void gluiCallback( int control_id );
  75. void keyboard( int key );
  76. void mousePassive( int x, int y );
  77. void mouseButton( int button, int state, int x, int y );
  78. void mouseMove( int x, int y );
  79. void bindTexture(GLuint texture, GLint row_length = 0, GLint alignment = 1);
  80. bool checkGLError(const char *name = "OpenGL");
  81. void drawGeometry( int panel, bool selected );
  82. void startPanelHighlight( float red, float green, float blue, float line_width );
  83. void endPanelHighlight();
  84. enum { DrawTypePickTexture, DrawTypeMediaTexture };
  85. void draw( int draw_type );
  86. void windowPosToTexturePos( int window_x, int window_y, int& media_x, int& media_y, int& id );
  87. mediaPanel* addMediaPanel( std::string url );
  88. void updateMediaPanel( mediaPanel* panel );
  89. void remMediaPanel( mediaPanel* panel );
  90. mediaPanel* replaceMediaPanel( mediaPanel* panel, std::string url );
  91. void getRandomMediaSize( int& width, int& height, std::string mime_type );
  92. void navigateToNewURI( std::string uri );
  93. void initUrlHistory( std::string uri );
  94. void selectPanelById( int id );
  95. void selectPanel( mediaPanel* panel );
  96. mediaPanel* findMediaPanel( LLPluginClassMedia* panel );
  97. mediaPanel* findMediaPanel( const std::string &target_name );
  98. void makePickTexture( int id, GLuint* texture_handle, unsigned char** texture_pixels );
  99. void makeChrome();
  100. void resetView();
  101. void dumpPanelInfo();
  102. void updateStatusBar();
  103. GLfloat distanceToCamera( GLfloat point_x, GLfloat point_y, GLfloat point_z );
  104. // Inherited from LLPluginClassMediaOwner
  105. /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, LLPluginClassMediaOwner::EMediaEvent);
  106. private:
  107. const int mVersionMajor;
  108. const int mVersionMinor;
  109. const int mVersionPatch;
  110. const int mMaxPanels;
  111. int mAppWindow;
  112. int mWindowWidth;
  113. int mWindowHeight;
  114. int mCurMouseX;
  115. int mCurMouseY;
  116. unsigned char mPixelReadColor[ 3 ];
  117. bool mFuzzyMedia;
  118. const std::string mHomeWebUrl;
  119. std::vector< mediaPanel* > mMediaPanels;
  120. mediaPanel* mSelectedPanel;
  121. std::string mimeTypeFromUrl( std::string& url );
  122. std::string pluginNameFromMimeType( std::string& mime_type );
  123. GLUI_Rotation* mViewRotationCtrl;
  124. GLUI_Translation* mViewScaleCtrl;
  125. GLUI_Translation* mViewTranslationCtrl;
  126. float mViewportAspect;
  127. float mViewPos[ 3 ];
  128. float mViewRotation[ 16 ];
  129. float mDistanceCameraToSelectedGeometry;
  130. int mIdControlAddPanel;
  131. int mIdControlRemPanel;
  132. std::vector< std::pair< std::string, std::string > > mBookmarks;
  133. GLUI_Listbox* mBookmarkList;
  134. int mIdBookmarks;
  135. int mIdUrlEdit;
  136. GLUI_EditText* mUrlEdit;
  137. int mIdUrlInitHistoryEdit;
  138. GLUI_EditText* mUrlInitHistoryEdit;
  139. int mSelBookmark;
  140. int mIdRandomPanelCount;
  141. int mRandomPanelCount;
  142. int mIdRandomBookmarks;
  143. int mRandomBookmarks;
  144. int mIdDisableTimeout;
  145. int mDisableTimeout;
  146. int mIdUsePluginReadThread;
  147. int mUsePluginReadThread;
  148. int mIdLargePanelSpacing;
  149. int mLargePanelSpacing;
  150. int mIdControlCrashPlugin;
  151. int mIdControlHangPlugin;
  152. int mIdControlExitApp;
  153. GLUI* mGluiMediaTimeControlWindow;
  154. int mIdMediaTimeControlPlay;
  155. int mIdMediaTimeControlLoop;
  156. int mIdMediaTimeControlPause;
  157. int mIdMediaTimeControlStop;
  158. int mIdMediaTimeControlSeek;
  159. int mIdMediaTimeControlVolume;
  160. int mMediaTimeControlVolume;
  161. int mIdMediaTimeControlSeekSeconds;
  162. int mMediaTimeControlSeekSeconds;
  163. int mIdMediaTimeControlRewind;
  164. int mIdMediaTimeControlFastForward;
  165. GLUI* mGluiMediaBrowserControlWindow;
  166. int mIdMediaBrowserControlBack;
  167. GLUI_Button* mMediaBrowserControlBackButton;
  168. int mIdMediaBrowserControlStop;
  169. int mIdMediaBrowserControlForward;
  170. GLUI_Button* mMediaBrowserControlForwardButton;
  171. bool mGluiMediaTimeControlWindowFlag;
  172. bool mGluiMediaBrowserControlWindowFlag;
  173. bool mMediaBrowserControlBackButtonFlag;
  174. bool mMediaBrowserControlForwardButtonFlag;
  175. int mIdMediaBrowserControlHome;
  176. int mIdMediaBrowserControlReload;
  177. int mIdMediaBrowserControlClearCache;
  178. int mIdMediaBrowserControlClearCookies;
  179. int mIdMediaBrowserControlEnableCookies;
  180. int mMediaBrowserControlEnableCookies;
  181. GLUI* mBottomGLUIWindow;
  182. GLUI_StaticText* mStatusText;
  183. };
  184. #endif // LL_MEDIA_PLUGIN_TEST_H