Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android能否基于Unity Texture2D创建SurfaceTexture?_Java_Android_Unity3d_Stream_Surface - Fatal编程技术网

Java Android能否基于Unity Texture2D创建SurfaceTexture?

Java Android能否基于Unity Texture2D创建SurfaceTexture?,java,android,unity3d,stream,surface,Java,Android,Unity3d,Stream,Surface,我的问题与:。这家伙似乎和我一样,也在问同样的问题。我已经创建了一个插件,允许在Android设备上启动stream,但我无法管理如何在Unity界面元素(MeshRenderer,RawImage)上显示视频帧 我的统一代码: private void InitAndroidStreamerObject() { androidStreamerObj = new AndroidJavaObject("makeitbetter.figazzz.com.vitamiousin

我的问题与:。这家伙似乎和我一样,也在问同样的问题。我已经创建了一个插件,允许在Android设备上启动stream,但我无法管理如何在Unity界面元素(MeshRenderer,RawImage)上显示视频帧

我的统一代码:

private void InitAndroidStreamerObject()
    {
        androidStreamerObj = new AndroidJavaObject("makeitbetter.figazzz.com.vitamiousing7.AndroidStreamer");
        int androidInt = androidStreamerObj.Call<int>("AndroidInt");

        Debug.Log("androidInt = " + androidInt);
    }

    public void StartStream()
    {
        //"http://dlqncdn.miaopai.com/stream/MVaux41A4lkuWloBbGUGaQ__.mp4"; //"rtmp://live.hkstv.hk.lxdns.com/live/hks";
        string streamLink = "rtmp://live.hkstv.hk.lxdns.com/live/hks";

        System.IntPtr ptr = _inputTexture.GetNativeTexturePtr();
        Debug.Log("ptr on Unity side = " + ptr.ToInt32());
        androidStreamerObj.Call("LaunchStream", streamLink, ptr.ToInt32());
    }
您可以说这部分代码:

SurfaceTexture unityTexture = new SurfaceTexture(texId);
                if(unityTexture == null)
                    Log.d("Unity", "unityTexture NULL");
                else
                    Log.d("Unity", "unityTexture is ok");

                _cachedSurface = new Surface(unityTexture);
                if(_cachedSurface == null)
                    Log.d("Unity", "cachedSurface NULL");
                else
                    Log.d("Unity", "cachedSurface is ok");

                _streamConnection.setSurfaceToPlayer(_cachedSurface);
不行。但它的工作绝对很好,我试图改变表面,它是好的。但如果我试图从统一系统中做同样的事情,那就不是了。
我知道我可以通过低级本机插件接口来做我需要做的事情。但到目前为止,我还不知道如何在我的Android插件中使用它。在搜索一些教程时,我什么也没找到。如果有人能告诉我该怎么办,我将不胜感激。谢谢你

你运气好吗?你好,@gil28,我已经用Unity Render Native插件完成了这项任务。你可以在Linkedin上找到我,我会尽力帮助你,你能帮我吗?
SurfaceTexture unityTexture = new SurfaceTexture(texId);
                if(unityTexture == null)
                    Log.d("Unity", "unityTexture NULL");
                else
                    Log.d("Unity", "unityTexture is ok");

                _cachedSurface = new Surface(unityTexture);
                if(_cachedSurface == null)
                    Log.d("Unity", "cachedSurface NULL");
                else
                    Log.d("Unity", "cachedSurface is ok");

                _streamConnection.setSurfaceToPlayer(_cachedSurface);