コード例 #1
0
    //Create the textures on the Unity side
    public bool InitSDK(ref OZOInitInfo initInfo)
    {
        bool res = false;

        try
        {
            res = OZO_InitSDK(ref initInfo);
        }
        catch (DllNotFoundException e)
        {
            Debug.LogError("OZOPlayerSDK - library, or one of its dependencies is missing.\n" + e.ToString());
        }
        return(res);
    }
コード例 #2
0
    public IntPtr LoadDrmLibrary(ref OZOInitInfo initInfoRef)
    {
        try
        {
#if (UNITY_ANDROID && !UNITY_EDITOR)
            return(DRM_createDRMHandler(initInfoRef.activity));
#else
            return(DRM_createDRMHandler());
#endif
        }
        catch (DllNotFoundException e)
        {
            Debug.LogError("UnityDRMSample - library, or one of its dependencies is missing.\n" + e.ToString());
        }
        return(System.IntPtr.Zero);
    }
コード例 #3
0
 private static extern bool OZO_InitSDK(ref OZOInitInfo info);
コード例 #4
0
    private void InitializeSDK(string licenseId, bool useAnalytics, bool useWatermark, bool allowExclusiveModeAudio)
    {
#if ENABLE_DEBUG_LOG
#if !UNITY_IPHONE
        SetupDebugging();
#endif
#endif

#if ENABLE_DEBUG
        Debug.Log("OZOPlayerSDK: [AnalyticsEnabled:" + useAnalytics.ToString() + "]\n");
#endif
        {
            for (int i = 0; i < 2; ++i)
            {
                OZOViewRenderer[i].material      = new Material(OZOCameraMaterial);
                OZOViewRenderer[i].renderTexture = new RenderTexture(width, height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.sRGB);
                OZOViewRenderer[i].renderTexture.Create();

                OZOViewRenderer[i].renderTextureDepth = new RenderTexture(width, height, 16, RenderTextureFormat.Depth, RenderTextureReadWrite.sRGB);
                OZOViewRenderer[i].renderTextureDepth.Create();

                OZOViewRenderer[i].material.SetTexture("_MainTex", OZOViewRenderer[i].renderTexture);
                OZOViewRenderer[i].material.SetTexture("_DepthTex", OZOViewRenderer[i].renderTextureDepth);

                OZOViewRenderer[i].eyeDiff = OZOViewCameras[i].stereoSeparation * ((0 == i) ? 0.5f : -0.5f);
            }

            initInfo                  = new OZOInitInfo();
            initInfo.texturePtr0      = OZOViewRenderer[0].renderTexture.GetNativeTexturePtr();
            initInfo.texturePtr1      = OZOViewRenderer[1].renderTexture.GetNativeTexturePtr();
            initInfo.depthTexturePtr0 = OZOViewRenderer[0].renderTextureDepth.GetNativeDepthBufferPtr();
            initInfo.depthTexturePtr1 = OZOViewRenderer[1].renderTextureDepth.GetNativeDepthBufferPtr();

            initInfo.width       = width;
            initInfo.height      = height;
            initInfo.storagePath = Application.persistentDataPath;
#if (UNITY_ANDROID && !UNITY_EDITOR)
            Debug.Log("InitInfo: Android\n");
            AndroidJavaClass  jc           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject jo           = jc.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject assetManager = jo.Call <AndroidJavaObject>("getAssets");

            initInfo.activity     = jo.GetRawObject();
            initInfo.assetManager = assetManager.GetRawObject();
            initInfo.cachePath    = Application.temporaryCachePath;

#if ENABLE_DEBUG
            Debug.Log("InitInfo: activity: " + initInfo.activity + "\n");
            Debug.Log("InitInfo: assetManager: " + initInfo.assetManager + "\n");
            Debug.Log("InitInfo: cachePath: " + initInfo.cachePath + "\n");
#endif
#else
            initInfo.assetPath = Application.streamingAssetsPath;
#endif

            // create a custom DRM handler
            initInfo.drmHandler = LoadDrmLibrary(ref initInfo);

            initInfo.useAnalytics            = useAnalytics ? 1 : 0;
            initInfo.useWatermark            = useWatermark ? 1 : 0;
            initInfo.licenseId               = licenseId;
            initInfo.allowExclusiveModeAudio = allowExclusiveModeAudio ? 1 : 0;

            //managed handle lock (to keep the memory in the struct available)
            float[] colors = new float[4] {
                OZORendererClearColor.r, OZORendererClearColor.g, OZORendererClearColor.b, OZORendererClearColor.a
            };
            GCHandle colorHandle = GCHandle.Alloc(colors, GCHandleType.Pinned);
            initInfo.clearColor = Marshal.UnsafeAddrOfPinnedArrayElement(colors, 0);

            // Call unmanaged code
            bool result = InitSDK(ref initInfo);

            //free handles
            colorHandle.Free();

#if ENABLE_DEBUG
            Debug.Log("OZOPlayerSDK - initialized: " + result + "\n");
#endif
            if (result)
            {
#if ENABLE_DEBUG
                for (int i = 0; i < (int)OZO.Feature.COUNT; ++i)
                {
                    Debug.Log("OZOPlayerSDK - this device supports: " + ((OZO.Feature)i).ToString() + ": " + IsFeatureSupported((OZO.Feature)i).ToString());
                }
#endif
                //start the rendering
                renderFunc = GetRenderFunc();

                if (0 < clipAreas.Count)
                {
                    SetClipAreas(clipAreas.ToArray());
                }
            }
            else
            {
                Debug.LogError("OZOPlayerSDK - Error Initializing OZO Player SDK");
            }
        }
    }