使用ANativeWindow_lock返回错误 -22 与安卓 Gstreamer SDK
USE ANativeWindow_lock return error -22 with android Gstreamer SDK
everyone,
现在我正在使用Android Gstreamer SDK来实现流媒体,通过修改 http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video 这个项目,我想在流式传输时捕获图像,所以我添加了一个 JNI 函数来渲染帧,这是我在下面的函数:
void gst_native_render_image(JNIEnv *env, jobject thiz, jobject surface){
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Releasing Native Window %p", data->native_window);
ANativeWindow_Buffer buffer;
//ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
render_window = ANativeWindow_fromSurface(env, surface);
ANativeWindow_acquire(render_window);
//ANativeWindow *window = data->native_window;
GST_DEBUG("Got window %p", render_window);
if(render_window > 0){
int width = ANativeWindow_getWidth(render_window);
int height = ANativeWindow_getHeight(render_window);
GST_DEBUG("Got window %d %d", width,height);
ANativeWindow_setBuffersGeometry(render_window, width, height, WINDOW_FORMAT_RGBA_8888);
memset((void*)&buffer,0,sizeof(buffer));
int lockResult = 0;
lockResult = ANativeWindow_lock(render_window, &buffer, NULL);
if (lockResult == 0) {
GST_DEBUG("GStreamer: ANativeWindow_locked");
memcpy(buffer.bits, g_buffer, 640*320);
ANativeWindow_unlockAndPost(render_window);
}
else{
GST_DEBUG("GStreamer: ANativeWindow_lock failed error %d",lockResult);
}
GST_DEBUG("Releasing window");
ANativeWindow_release(render_window);
(*env)->CallVoidMethod(env, thiz, surface_pixel_render_id); // call JAVA method to save the pixel data....oranhuang
}else {
GST_DEBUG("surface is null");
}
}
但我总是得到返回错误 -22 和 ANativeWindow_lock()
.
我还需要做什么或以错误的方式使用ANativeWindow_lock()
吗????
'因为与ANativeWindow_lock()
的讨论很少,我不知道如何修复我的错误消息。
我遇到了类似的问题,也花了我数千个小时。然而,解决方案非常简单,以下是ANativeWindow_fromSurface
评论中的一句话:
/*...
This acquires a reference on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
...*/
因此,窗口对象将在ANativeWindow_fromSurface
时锁定。不只是ANativeWindow_acquire
!因此,答案是:如果您在锁定窗口之前已经调用过ANativeWindow_acquire
一次,则必须调用ANativeWindow_release
两次才能释放它。
相关文章:
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- Gstreamer 管道从命令 lne 到 c 代码
- Vulkan SDK 版本 1.1.85.0 在 Kubuntu 18.10 上链接
- Gstreamer:每 5 秒使用多文件墨水保存图像/jpeg
- GStreamer在开始任何播放之前进行搜索
- 升级到 Windows 10 版本 1809 SDK 后,我无法编译使用 C++/WinRT 的项目
- 在设计 SDK 时,我是否应该在 C++ 头文件中完全隐藏内部类?
- Eventloop 卡住:NAO C++ SDK OnFaceDetection 示例
- 构建失败错误:无法使用 qibuild 构建C++ SDK Helloworld
- 在 Android 上安装 GStreamer 插件
- QT GStreamer Windows linker problems
- Microsoft C++ 用于图形 API 的 Rest SDK
- 如何检索 Steamwork SDK 的当前版本
- Opencv GStreamer管道在Raspberry Pi 4上不起作用
- 佳能SDK无法从相机下载图片
- gStreamer 将元素添加到通过 gst_parse_launch 创建的管道中
- gstreamer with openCV in rpi4
- 如何使用 CPP REST SDK 实现 CAS(中央认证服务)?
- 使用ANativeWindow_lock返回错误 -22 与安卓 Gstreamer SDK
- 部署GStreamer SDK应用