VRSoft.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. #include "VRSoftDef.h"
  2. #ifndef __VRSOFT_H__
  3. #define __VRSOFT_H__
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. // VR类型定义360VR还是180VR
  8. typedef enum _XMVRType {
  9. XMVR_TYPE_360D = 0, // 鱼眼360VR
  10. XMVR_TYPE_180D = 1, // 鱼眼180VR
  11. XMVR_TYPE_ORIGINAL = 2, // 原始图像
  12. XMVR_TYPE_SPE_CAM01 = 3, // XMVR_TYPE_LENOVO, 针对联想客户镜头
  13. XMVR_TYPE_SPE_CAM02 = 4, // 预留
  14. XMVR_TYPE_SPE_CAM03 = 5, // 预留
  15. XMVR_TYPE_DULE_360D = 10, // 双目鱼眼2x360
  16. XMVR_TYPE_MULTI_IMAGE = 20, // 多画面拼接, MxN画面,M/N以参数的形式输入,默认为4x4
  17. XMVR_TYPE_INVALID = 0xffff
  18. } XMVRType;
  19. // 360VR特有的模式
  20. typedef enum _XMVRMount {
  21. Ceiling = 0, // 天花板模式
  22. Wall = 1, // 墙壁模式
  23. WallInverted = 2, // 墙壁反转
  24. Table = 3, // 墙壁反转
  25. Mount_End
  26. } XMVRMount;
  27. typedef enum _XMVRShape {
  28. Shape_Ball = 0, // 球/半球(360VR默认)
  29. Shape_Ball_Hat = 1, // 球/半球,帽子型,半球倒转
  30. Shape_Ball_Bowl = 2, // 球/半球,碗状和Ball_Hat相反
  31. Shape_Cylinder = 3, // 圆柱
  32. Shape_CylinderS = 4, // 圆柱(近距离型,只能看到部分)
  33. Shape_Rectangle = 5, // 矩形,拉伸展开,一行的模式
  34. Shape_Rectangle_2R = 6, // 矩形,两行的模式
  35. Shape_Grid_4R = 7, // 球/半球矫正,4宫格模式,初始在4个不同的角度
  36. Shape_Grid_1O_5R = 8, // 左上角圆图显示,右边和下面5个小窗口显示
  37. Shape_Grid_1L_2R = 9, // 上面两个圆放大的矫正效果,下面是一行的效果
  38. Shape_Grid_3R = 10, // 3画面
  39. Shape_End
  40. } XMVRShape;
  41. typedef enum _XMVR180DrawMode {
  42. Original = 0,
  43. Stretch = 1,
  44. Cylinder = 2,
  45. Dewarper = 3
  46. } XMVR180DrawMode;
  47. // YUV数据格式定义
  48. typedef enum _XMVRPixelFormat {
  49. XM_PIX_FMT_NONE = 0,
  50. XM_PIX_FMT_RGB24 = 1,
  51. XM_PIX_FMT_BGR24 = 2,
  52. XM_PIX_FMT_YUV420P = 3,
  53. XM_PIX_FMT_YUYV422 = 4,
  54. XM_PIX_FMT_YUV422P = 5,
  55. XM_PIX_FMT_YUV444P = 6,
  56. XM_PIX_FMT_YUV410P = 7,
  57. XM_PIX_FMT_YUV411P = 8,
  58. XM_PIX_FMT_YUV420SP_NV12 = 9,
  59. XM_PIX_FMT_YUV420SP_NV21 = 10,
  60. XM_PIX_FMT_EGLImageKHR = 11, // Hi3798M特有
  61. } XMVRPixelFormat;
  62. typedef void * VRHANDLE;
  63. // 获取当前版本号
  64. const char * VRSoft_Version(void);
  65. // iPhone兼容专用(屏幕实际像素与逻辑像素比例,PPI和屏幕尺寸不同,会有所不同)
  66. // iPhone6P/7P为3,其余为2
  67. void VRSoft_SetPPIZoom(int zoomScale);
  68. // 创建句柄
  69. void VRSoft_Create(VRHANDLE * pHandle);
  70. // 创建句柄,触摸屏事件不在库里面处理
  71. void VRSoft_CreateNoTouchEvent(VRHANDLE * pHandle);
  72. // 销毁句柄
  73. void VRSoft_Release(VRHANDLE hVR);
  74. // 矫正准备,参数初始化
  75. void VRSoft_Prepare(VRHANDLE hVR);
  76. // 初始化可是窗口大小(Viewport)
  77. void VRSoft_Init(VRHANDLE hVR, int width, int height);
  78. // attribute
  79. void VRSoft_SetAttribute(VRHANDLE hVR, const char * name, const char * value);
  80. // 启动自动巡航,speed: 旋转速度,绝对值越大旋转速度越快
  81. void VRSoft_StartAutoCruise(VRHANDLE hVR, double speed);
  82. // 停止所有窗口巡航
  83. void VRSoft_StopAutoCruise(VRHANDLE hVR);
  84. // 获取当前窗口大小
  85. void VRSoft_getViewSize(VRHANDLE hVR, int * pOutWidth, int * pOutHeight);
  86. // 设置VR模式(180VR/360VR)
  87. void VRSoft_SetType(VRHANDLE hVR, XMVRType type);
  88. // 获取当前VR模式
  89. XMVRType VRSoft_GetType(VRHANDLE hVR);
  90. // 如果是180VR,设置图像显示,参考XMVR180DrawMode的定义
  91. void VRSoft_SetDrawMode(VRHANDLE hVR, XMVR180DrawMode drawMode);
  92. // 如果是180VR,设置图像渐变过程
  93. void VRSoft_SetDrawModeCartoon(VRHANDLE hVR,
  94. XMVR180DrawMode fromMode, XMVR180DrawMode toMode, int step, int total);
  95. // 如果是360VR,设置当前镜头角度(模式),参考XMVRMount的定义
  96. void VRSoft_SetCameraMount(VRHANDLE hVR, XMVRMount mount);
  97. // 如果是360VR,获取当前镜头角度(模式),参考XMVRMount的定义
  98. XMVRMount VRSoft_GetCameraMount(VRHANDLE hVR);
  99. // 如果是360VR,设置当前图像形状
  100. void VRSoft_SetShape(VRHANDLE hVR, XMVRShape shape);
  101. // 如果是360VR,获取当前图像形状
  102. int VRSoft_GetShape(VRHANDLE hVR);
  103. // 设置镜头偏移参数(如果圆心非正中时可设置调节)
  104. void VRSoft_SetFecParams(VRHANDLE hVR, int xCenter, int yCenter,
  105. int radius, int imgWidth, int imgHeight);
  106. // 刷新图像输出
  107. void VRSoft_Drawself(VRHANDLE hVR);
  108. // 设置RGB格式的图像数据
  109. void VRSoft_SetRGBTexture(VRHANDLE hVR, unsigned char * pData, int len, int width, int height);
  110. // 设置YUV420格式的图像数据
  111. void VRSoft_SetYUV420PTexture(VRHANDLE hVR, unsigned char * pData, int len, int width, int height);
  112. // 通用型数据设置接口
  113. void VRSoft_SetTexture(VRHANDLE hVR, XMVRPixelFormat format,
  114. unsigned char * pData, int len, int width, int height);
  115. // 设置多画面行数和列数, rowNum * columnNum <= 36, 默认3x3
  116. void VRSoft_Multi_SetScreenNumber(VRHANDLE hVR, int rowNum, int columnNum);
  117. // 设置RGB格式的图像数据(仅多画面拼接可用)
  118. void VRSoft_Multi_SetRGBTexture(VRHANDLE hVR, int gridId,
  119. unsigned char * pData, int len, int width, int height);
  120. // 设置YUV420格式的图像数据(仅多画面拼接可用)
  121. void VRSoft_Multi_SetYUV420PTexture(VRHANDLE hVR, int gridId,
  122. unsigned char * pData, int len, int width, int height);
  123. // 通用型数据设置接口(仅多画面拼接可用)
  124. void VRSoft_Multi_SetTexture(VRHANDLE hVR, int gridId,
  125. XMVRPixelFormat format,
  126. unsigned char * pData, int len, int width, int height);
  127. #ifdef HI3798M_OPTIMIZED
  128. // only for 3798M
  129. void VRSoft_SetEGLImageKHR(VRHANDLE hVR, EGLImageKHR * pImgHKR, int width, int height);
  130. #ifdef OUTPUT_YUV_IMAGE
  131. //void VRSoft_SetEGLImageKHR_YUVMode(VRHANDLE hVR,
  132. // EGLImageKHR * pImgHKRIn, EGLImageKHR * pImgHKROut, int width, int height);
  133. // 输入新的YUV数据,指定窗口索引
  134. void VRSoft_SetEGLImageKHR_YUVIn(VRHANDLE hVR, int gridId,
  135. EGLImageKHR * pImgHKRIn, int width, int height);
  136. // 设置YUV输出内存,一般只调用一次即可
  137. void VRSoft_SetEGLImageKHR_YUVOut(VRHANDLE hVR,
  138. EGLImageKHR * pImgHKROut);
  139. #endif
  140. #endif
  141. VR_BOOL VRSoft_NeedContinue(VRHANDLE hVR);
  142. // 查看OpenGL错误
  143. VR_BOOL checkOpenGLError(const char * file, int line);
  144. // 重置初始坐标
  145. void VRSoft_ResetPosition(VRHANDLE hVR);
  146. // for 360VR
  147. void VRSoft_SetPTZ(VRHANDLE hVR,
  148. double pan,
  149. double tilt,
  150. double zoom,
  151. double roll,
  152. double wallAngle);
  153. void VRSoft_GetPTZ(VRHANDLE hVR,
  154. double * pOutPan,
  155. double * pOutTilt,
  156. double * pOutZoom,
  157. double * pOutRoll);
  158. // 分屏/多屏处理时使用以下接口
  159. void VRSoft_SetPTZ_SubScreen(VRHANDLE hVR,
  160. int screenIndex,
  161. double pan,
  162. double tilt,
  163. double zoom,
  164. double roll,
  165. double wallAngle);
  166. void VRSoft_GetPTZ_SubScreen(VRHANDLE hVR,
  167. int screenIndex,
  168. double * pOutPan,
  169. double * pOutTilt,
  170. double * pOutZoom,
  171. double * pOutRoll);
  172. // for 180VR
  173. // zoom : 0.25 - 1.0 - 20.0
  174. void VRSoft_SetRotateZoom(VRHANDLE hVR,
  175. double rotateX,
  176. double rotateY,
  177. double rotateZ,
  178. double zoom);
  179. void VRSoft_GetRotateZoom(VRHANDLE hVR,
  180. double * pOutRotateX,
  181. double * pOutRotateY,
  182. double * pOutRotateZ,
  183. double * pOutZoom);
  184. void VRSoft_SetRotateZoom_SubScreen(VRHANDLE hVR,
  185. int screenIndex,
  186. double rotateX,
  187. double rotateY,
  188. double rotateZ,
  189. double zoom);
  190. void VRSoft_GetRotateZoom_SubScreen(VRHANDLE hVR,
  191. int screenIndex,
  192. double * pOutRotateX,
  193. double * pOutRotateY,
  194. double * pOutRotateZ,
  195. double * pOutZoom);
  196. // 触摸屏事件处理
  197. void VRSoft_OnTouchDown(VRHANDLE hVR, float x, float y);
  198. void VRSoft_OnTouchUp(VRHANDLE hVR, float x, float y);
  199. void VRSoft_OnTouchMove(VRHANDLE hVR, float x, float y);
  200. void VRSoft_OnTouchPinch(VRHANDLE hVR, float x0, float y0, float x1, float y1);
  201. // 手势捏合,相对缩放比例
  202. void VRSoft_OnTouchPinchScale(VRHANDLE hVR, float dScale);
  203. void VRSoft_OnTouchFling(VRHANDLE hVR, float velocityX, float velocityY);
  204. void VRSoft_AutoAdjust(VRHANDLE hVR);
  205. // 重力加速度感应器
  206. void VRSoft_OnAccelerometer(VRHANDLE hVR, float ax, float ay, float az);
  207. // 指南针/方向传感器事件
  208. void VRSoft_OnOrientation(VRHANDLE hVR, float xDegree, float yDegree, float zDegree);
  209. // 清除最后一帧(视频缓冲)信息
  210. void VRSoft_CleanUp(VRHANDLE hVR);
  211. // 将指定区域显示在屏幕可见区域(屏幕中心正上方)
  212. // 为了同时兼容不同分辨率,传入顶点坐标的同时传入相对应的窗口(视频)分辨率
  213. // (x0, y0) (x1, y1)是相对于xSize/ySize的坐标
  214. void VRSoft_DisplayRect(VRHANDLE hVR,
  215. int x0, int y0,
  216. int x1, int y1,
  217. int width, int height);
  218. // 将指定目标点显示在屏幕可见区域(屏幕中心正上方)
  219. // 为了同时兼容不同分辨率,传入顶点坐标的同时传入相对应的窗口(视频)分辨率
  220. // (x0, y0) (x1, y1)是相对于xSize/ySize的坐标
  221. void VRSoft_DisplayTarget(VRHANDLE hVR,
  222. int targetX, int targetY,
  223. int width, int height);
  224. #ifdef __cplusplus
  225. }
  226. #endif
  227. #endif