{"action":"created","issue":{"url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/7","labels_url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/7/comments","events_url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/7/events","html_url":"https://github.com/saki4510t/UVCCamera/issues/7","id":96295957,"number":7,"title":"Question about iFrameCallback","user":{"login":"zkdzegede","id":2668400,"avatar_url":"https://avatars.githubusercontent.com/u/2668400?v=3","gravatar_id":"","url":"https://api.github.com/users/zkdzegede","html_url":"https://github.com/zkdzegede","followers_url":"https://api.github.com/users/zkdzegede/followers","following_url":"https://api.github.com/users/zkdzegede/following{/other_user}","gists_url":"https://api.github.com/users/zkdzegede/gists{/gist_id}","starred_url":"https://api.github.com/users/zkdzegede/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zkdzegede/subscriptions","organizations_url":"https://api.github.com/users/zkdzegede/orgs","repos_url":"https://api.github.com/users/zkdzegede/repos","events_url":"https://api.github.com/users/zkdzegede/events{/privacy}","received_events_url":"https://api.github.com/users/zkdzegede/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-07-21T11:40:43Z","updated_at":"2016-01-06T12:51:24Z","closed_at":null,"body":"I want to pass the frame to another library that is compatible with the android camera API.  This uses a byte[] of yuv frames.\r\n\r\nHow can I convert the ByteBuffer to a properly formatted yuv_image byte array? \r\n\r\n日本語でも英語でも大丈夫です。\r\n\r\n```java\r\ncamera.setPreviewCallbackWithBuffer(new Camera.PreviewCallback() {\r\n       @Override\r\n       public void onPreviewFrame(byte[] yuv_image, Camera camera) {\r\n       }\r\n});\r\n\r\n```\r\n\r\n\r\nversus \r\n\r\n\r\n```java\r\nmUVCCamera.setFrameCallback(new IFrameCallback() {\r\n        @Override\r\n        public void onFrame(final ByteBuffer frame) {\r\n        }              \r\n}, \r\nUVCCamera.PIXEL_FORMAT_NV21);\r\n```"},"comment":{"url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/comments/169317013","html_url":"https://github.com/saki4510t/UVCCamera/issues/7#issuecomment-169317013","issue_url":"https://api.github.com/repos/saki4510t/UVCCamera/issues/7","id":169317013,"user":{"login":"saki4510t","id":6743409,"avatar_url":"https://avatars.githubusercontent.com/u/6743409?v=3","gravatar_id":"","url":"https://api.github.com/users/saki4510t","html_url":"https://github.com/saki4510t","followers_url":"https://api.github.com/users/saki4510t/followers","following_url":"https://api.github.com/users/saki4510t/following{/other_user}","gists_url":"https://api.github.com/users/saki4510t/gists{/gist_id}","starred_url":"https://api.github.com/users/saki4510t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saki4510t/subscriptions","organizations_url":"https://api.github.com/users/saki4510t/orgs","repos_url":"https://api.github.com/users/saki4510t/repos","events_url":"https://api.github.com/users/saki4510t/events{/privacy}","received_events_url":"https://api.github.com/users/saki4510t/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T12:51:24Z","updated_at":"2016-01-06T12:51:24Z","body":"@muCodes, @SAKSBP \r\nHi, it is strange behavior that I never met. As I tested on my several devices, I can see all log from `onFrame` callback...it may depends on the device/Android version.\r\n\r\nThe callback method is called from native pthread attached to JavaVM. Currently I don't provide any argument when calling `AttachCurrentThread`.\r\nThe code is as followings.\r\n```\r\nvoid *UVCPreview::capture_thread_func(void *vptr_args) {\r\n\tint result;\r\n\r\n\tENTER();\r\n\tUVCPreview *preview = reinterpret_cast<UVCPreview *>(vptr_args);\r\n\tif (LIKELY(preview)) {\r\n\t\tJavaVM *vm = getVM();\r\n\t\tJNIEnv *env;\r\n\t\t// attach to JavaVM\r\n\t\tvm->AttachCurrentThread(&env, NULL);\r\n\t\tpreview->do_capture(env);\r\n\t\t// detach from JavaVM\r\n\t\tvm->DetachCurrentThread();\r\n\t\tMARK(\"DetachCurrentThread\");\r\n\t}\r\n\tPRE_EXIT();\r\n\tpthread_exit(NULL);\r\n}\r\n```\r\n\r\nI'm not sure now why it occur but I assume your issue may solve by passing argument to `AttachCurrentThread`. If you have time, could you try following code?\r\n```\r\nvoid *UVCPreview::capture_thread_func(void *vptr_args) {\r\n\tint result;\r\n\r\n\tENTER();\r\n\tUVCPreview *preview = reinterpret_cast<UVCPreview *>(vptr_args);\r\n\tif (LIKELY(preview)) {\r\n\t\tJavaVM *vm = getVM();\r\n\t\tJNIEnv *env;\r\n\t\tJavaVMAttachArgs args;\r\n\t\targs.name = \"capture_thread\";\r\n\t\targs.group = NULL;\r\n\t\targs.version = JNI_VERSION_1_6;\r\n\t\t// attach to JavaVM\r\n\t\tvm->AttachCurrentThread(&env, &args);\r\n\t\tpreview->do_capture(env);\r\n\t\t// detach from JavaVM\r\n\t\tvm->DetachCurrentThread();\r\n\t\tMARK(\"DetachCurrentThread\");\r\n\t}\r\n\tPRE_EXIT();\r\n\tpthread_exit(NULL);\r\n}\r\n```\r\nsaki"}}