安卓Java的Unity本机纹理。 E / NativeCrypto错误

时间:2018-09-13 08:05:19

标签: java android unity3d opengl-es

我正在尝试将相机的预览从本机Java插件转移到一个整体中。 我在Unity中创建Texture2D,将openGl的名称划分为Java插件。在Java代码中,我创建SearTexture并使用此纹理启动相机。我希望在Unity侧面可以看到相机预览。

我只能看到黑色的污迹。

在logcat中也有几个错误:

09-13 10:58:36.979 9773-9773/com.aaa.nativecamera E/MPlugin: Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport

09-13 10:58:41.557 9773-9799/com.aaa.nativecamera E/NativeCrypto: ssl=0xdf2c07c0 cert_verify_callback x509_store_ctx=0xcaf7f4ac arg=0x0
ssl=0xdf2c07c0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

09-13 10:58:43.113 9773-9800/com.aaa.nativecamera E/NativeCrypto: ssl=0xc742bcc0 cert_verify_callback x509_store_ctx=0xcae804ac arg=0x0
ssl=0xc742bcc0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA

在logcat中也有一条奇怪的消息

09-13 11:02:17.797 9773-9785/com.aaa.nativecamera I/BufferQueueProducer: [SurfaceTexture-22-9773-0](this:0xc73fa000,id:0,api:4,p:412,c:9773) queueBuffer: slot 1 is dropped, handle=0xe7fb4400

Java本机插件:

...
public int startCamera(int pointer){
    PermissionFragment.RequestPermissions();
    int texturePointer = createExternalTexture(pointer);
    mSurfaceTexture = new SurfaceTexture(texturePointer);
    mSurfaceTexture.setOnFrameAvailableListener(this);
    mSurfaceTexture.detachFromGLContext();

    startPreview();

    return texturePointer;
}
...
private void startPreview() {
    mCamera = Camera.open();
    if (mCamera == null) {
        throw new RuntimeException("Default camera not available");
    }

    try {
        mCamera.setPreviewTexture(mSurfaceTexture);
        mCamera.setDisplayOrientation(90);
        mCamera.startPreview();
    } catch (IOException ioe) {
        // Something bad happened
    }
}
...
private int createExternalTexture(int pointer) {
    int[] textureIdContainer = new int[1];

    int error;
    if (pointer == 0) {
        GLES20.glGenTextures(1, textureIdContainer, 0);
        error = GLES20.glGetError();
    } else {
        textureIdContainer[0] = pointer;
    }

    GLES20.glActiveTexture(GLES10.GL_TEXTURE0 + textureIdContainer[0]);//GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
    error = GLES20.glGetError();
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES10.GL_TEXTURE0 + textureIdContainer[0]);
    error = GLES20.glGetError();

    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    error = GLES20.glGetError();
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    error = GLES20.glGetError();
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
            GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    error = GLES20.glGetError();
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
            GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    error = GLES20.glGetError();

    return textureIdContainer[0];
}

Unity脚本:

void Start ()
{
    nativeCamera = new NativeCamera();

    texture = new Texture2D(1024, 720, TextureFormat.ARGB32 ,false, false);

    p = nativeCamera.StartCamera((int) texture.GetNativeTexturePtr());
    rawImage.texture = texture;
}

如果您能指出我的错误,我将不胜感激。

对不起,我的英语。

0 个答案:

没有答案