Exemplo n.º 1
0
        //
        // @fn SILVER_ERROR silverGetErrorString(SilverPlayer* p)
        // @brief Return last error code
        // @param \pPlayer Pointer to player object
        // @param \pString Pointer to target buffer for error text
        // @param \maxSize Length of target buffer for error text
        // @return Extended information about the last error that occurred within library
        // If no error, retrurns zero length string.
        public string GetErrorString(SILVER_ERROR error)
        {
            IntPtr result;

            result = silverGetErrorString(error);
            return(Marshal.PtrToStringAnsi(result));
        }
Exemplo n.º 2
0
        public SILVER_ERROR GetExternalTexture(out IntPtr externalTexture)
        {
            Int64        texId  = 0;
            SILVER_ERROR Result = silverGetExternalTexture(m_Instance, out texId);

            externalTexture = new IntPtr(texId);
            return(Result);
        }
Exemplo n.º 3
0
        //
        // @fn SILVER_ERROR silverGetVideoInfo(SilverPlayer* p, SilverVideoInfo * pVideoInfo)
        // @brief Return extended information on the video sequence currently loaded
        // @param \pPlayer Pointer to player object
        // @param \pVideoInfo - Where state information is stored
        // @return SILVER_SUCCESS on function success, other error code on failure.
        public SILVER_ERROR GetVideoInfo(out SilverVideoInfo VideoInfo)
        {
            VideoInfo = new SilverVideoInfo();
            if (m_Instance == IntPtr.Zero)
            {
                return(SILVER_ERROR.SILVER_NOT_EXIST);
            }
            SILVER_ERROR Result = silverGetVideoInfo(m_Instance, out VideoInfo);

            return(Result);
        }
Exemplo n.º 4
0
        //
        // @fn SILVER_ERROR silverGetCurrentSeekPosition(SilverPlayer* p, int64_t* pSeekPositionUs)
        // @brief Return current seek position of sequence
        // @param \pPlayer Pointer to player object
        // @param \pSeekPositionUs - Current position in microseconds
        // @return SILVER_SUCCESS on function success, other error code on failure.
        // Note:
        // If it cannot be determined, such as Live stream, it is up to calling application to decide
        // what do display. Function with return 0 duration for Live stream.
        public SILVER_ERROR GetCurrentSeekPosition(out Int64 SeekPositionUs)
        {
            SeekPositionUs = 0;
            if (m_Instance == IntPtr.Zero)
            {
                return(SILVER_ERROR.SILVER_NOT_EXIST);
            }
            SILVER_ERROR result = silverGetCurrentSeekPosition(m_Instance, out SeekPositionUs);

            return(result);
        }
Exemplo n.º 5
0
        // @fn SILVER_ERROR silverInitialize(SilverPlayer** ppPlayer, SilverConfiguration* pConfiguration)
        // @brief Creates a new Silver Player instance
        // @param ppPlayer Pointer to player pointer object, receives resulting player instance pointer.
        // @param pConfiguration Configuration structure
        // @return SILVER_SUCCESS on function success, other error code on failure.
        public SILVER_ERROR Initialize()
        {
            if (m_Instance != IntPtr.Zero)
            {
                return(SILVER_ERROR.SILVER_ALREADY_EXIST);
            }

            IntPtr javaVM = new IntPtr(0);

#if UNITY_ANDROID && !UNITY_EDITOR
            javaVM = getJavaVM();
#endif
            SilverConfiguration Configuration = new SilverConfiguration();
            Configuration.javaVM = javaVM;
            Configuration.path   = Application.persistentDataPath;
            SILVER_ERROR Result = silverInitialize(out m_Instance, ref Configuration);
            m_TextureInfo.format = (int)SilverPixelFormat.PIX_FMT_NONE;
            m_PluginCallback     = silverGetUnityRenderCallback(m_Instance);

            // Call plugin to allocate opengl texture.
            GL.IssuePluginEvent(m_PluginCallback, (int)SILVER_PLUGIN.INITIALIZE);

            return(Result);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 private static extern IntPtr silverGetErrorString(SILVER_ERROR error);