android - GStreamer 管道正在播放,但没有填充回调(仅在 Android 上发生,在 Windows 和 Linux 上有效)
问题描述
我在 Android 上使用 GStreamer(版本 1.14.1)并且已经有一个在 Windows 和 Linux 上运行的实现(在 C++ 代码中)。
我按照 GStreamer 网站上的 Android 教程构建了自己的gstreamer-android.so
库以在 Android Studio 中使用。在我的 C++ 代码中,我添加了
GST_PLUGIN_STATIC_DECLARE
宏GST_PLUGIN_STATIC_REGISTER
来注册静态插件。在运行时,所有 GstElements 都可以成功创建。(我正在使用gst_element_factory_make()
调用来做到这一点。)
我像这样构建管道:
GstCaps* video_caps = gst_caps_new_full(
gst_structure_new("video/x-raw", "format", G_TYPE_STRING, "RGBA", NULL),
gst_structure_new("video/x-h264", "format", G_TYPE_STRING, "RGBA", NULL),
NULL);
g_object_set(m_app_sink, "emit-signals", TRUE, "caps", video_caps, NULL);
g_signal_connect(m_app_sink, "new-sample", G_CALLBACK(cb_new_sample), this);
gst_bin_add_many(GST_BIN(m_pipeline), source, m_decoder, m_video_flip, m_queue, m_video_convert, m_app_sink, NULL);
if (!gst_element_link_many(source, m_decoder, NULL)) {
gst_object_unref(m_pipeline);
return false;
}
if (!gst_element_link_many(m_video_flip, m_queue, m_video_convert, m_app_sink, NULL)) {
gst_object_unref(m_pipeline);
return false;
}
g_signal_connect(m_decoder, "pad-added", G_CALLBACK(cb_pad_added), this);
稍后在代码中以gst_element_set_state(m_pipeline, GST_STATE_PLAYING);
我正在使用不同的元素来执行此操作,例如source
: filesrc
、udpsrc
和videotestsrc
.
当我将管道切换到播放状态时,我希望pad-added
从decodebin
被触发的回调中获得回调,然后我会在此处进行 pad 的链接。所有这一切都已经在 Windows 和 Linux 上适用于所有 3 个来源。
在 Android 上,回调只会被触发videotestsrc
,但如果我使用其他来源之一则不会。
但我错过了什么?为什么它适用于 videotestsrc 但不适用于文件和 udp 流?(Android 应用中的权限设置已正确设置并注册了静态插件。)
有人知道在 Android 上手动构建管道并使用回调的示例实现吗?(到目前为止,我只能找到带有 的示例playbin
,但我无法使用,因为我需要从视频流中抓取帧。)
我真的没有想法,为什么我没有收到这个回调。非常感谢任何帮助和建议。谢谢!
更新:
创建我自己的调试功能后(按照这篇文章),我可以看到 H.264 的编码器插件存在问题。
2019-07-30 09:56:29.034 27551-27611/at.myapp.player E/GStreamer.cpp:: gstdecodebin2.c,gst_decode_bin_expose: error: no suitable plugins found:
Missing decoder: H.264 (Constrained Baseline Profile) (video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4, profile=(string)constrained-baseline, codec_data=(buffer)0142c028ffe1001c6742c028db01e0089f97016a020202800000030080015f90078c197001000568ca8132c8, width=(int)1920, height=(int)1080, framerate=(fraction)25/1, pixel-aspect-ratio=(fraction)1/1)
但我还不知道如何解决它。我虽然通过添加GST_PLUGIN_STATIC_REGISTER(openh264);
这个应该在那里,不是吗?
解决方案
好,我知道了!
我添加了GST_PLUGIN_STATIC_REGISTER(videoparsersbad)
,现在一切都对我有用!:)
推荐阅读
- android - 如何从android firebase实时数据库中的onDataChange返回arrayList
- c# - 有没有办法向剃须刀 PageModel 添加扩展方法?
- istio - Istio 断路器黑名单/白名单错误代码
- java - Hybris 站点地图不包含所有产品
- google-tag-manager - 为什么数据层显示在源代码中但不在 GTM 调试器中
- reactjs - 找不到@typescript-eslint/no-unused-expressions'
- tree - 蒙特卡洛树搜索扩展
- javascript - 如何延迟父组件的渲染,直到子组件中的 setState 完成?
- flutter - 如何制作像 Google 一样的 TextFormField?
- html - 覆盖 flex 属性以在 HTML 中手动设置跨度宽度的方法