public SILVER_ERROR GetTexture(out IntPtr[] textureData, out Int64 lTimestamp, out Vector3 orientation, out bool rotateMesh) { double startTime = Time.realtimeSinceStartup; SilverTexture textureInfo = new SilverTexture(); SILVER_ERROR Result = silverGetTexture(m_Instance, out textureInfo); if (Result != SILVER_ERROR.SILVER_SUCCESS || textureInfo.format == (int)SilverPixelFormat.PIX_FMT_NONE) { lTimestamp = 0; orientation = Vector3.zero; textureData = null; rotateMesh = false; return(Result); } // Only trapezoid, or any P4 style mesh requires rotation rotateMesh = (textureInfo.videoType == (int)SilverVideoType.eSilverMeshForm) || (textureInfo.videoType == (int)SilverVideoType.eSilverMultiViewMapping); double afterPluginEvent = Time.realtimeSinceStartup; double afterSetup = Time.realtimeSinceStartup; m_TextureInfo = textureInfo; switch ((SilverPixelFormat)textureInfo.format) { case SilverPixelFormat.PIX_FMT_YUV420P: { textureData = new IntPtr[3]; textureData[0] = textureInfo.pData; textureData[1] = textureInfo.pDataU; textureData[2] = textureInfo.pDataV; break; } case SilverPixelFormat.PIX_FMT_NV12: { textureData = new IntPtr[2]; textureData[0] = textureInfo.pData; textureData[1] = textureInfo.pDataU; break; } case SilverPixelFormat.PIX_FMT_RGBA: { textureData = new IntPtr[1]; textureData[0] = textureInfo.pData; break; } default: textureData = null; break; } double afterLoad = Time.realtimeSinceStartup; orientation.x = textureInfo.orientation.pitch; orientation.y = textureInfo.orientation.yaw; orientation.z = textureInfo.orientation.roll; lTimestamp = textureInfo.timestamp; double afterApply = Time.realtimeSinceStartup; int deltaTime = (int)((afterApply - startTime) * 1e6); int deltaPlugin = (int)((afterPluginEvent - startTime) * 1e6); int deltaSetup = (int)((afterSetup - afterPluginEvent) * 1e6); int deltaLoad = (int)((afterLoad - afterSetup) * 1e6); int deltaApply = (int)((afterApply - afterLoad) * 1e6); if (deltaTime > 5000) { // BW: Commented this out because, on android, plugin event was taking a long time; I think this is due to script synchronization, waiting // for the event to have been performed. This is desired behavior, I think. //Debug.LogWarning("GetTexture overrun: Plugin:"+deltaPlugin+", Setup:" + deltaSetup + ", Load:" + deltaLoad + ", apply:" + deltaApply); } return(Result); }
private static extern SILVER_ERROR silverGetTexture(IntPtr s, out SilverTexture Texture);