Gstreamer,如何在 android 上使用 C 播放 udp 流?
Gstreamer, how to play udp stream using C on android?
我正尝试在 android 上使用 Gstreamer 播放 udp 流。 (我用过this tutorial from the official Gstreamer website). I can play rtsp and https streams, but when I pass udp uri (like this: udp://@238.0.0.1:1234
) nothing happens (there is a black screen). In the log I have: Error received from element uridecodebin1: Your GStreamer installation is missing a plug-in.
I've found some documentation here关于安装插件,但我不知道该怎么做。
这是我使用的代码片段:
data->context = g_main_context_new ();
g_main_context_push_thread_default (data->context);
/* Build pipeline */
data->pipeline = gst_parse_launch ("playbin", &error);
if (error) {
gchar *message =
g_strdup_printf ("Unable to build pipeline: %s", error->message);
g_clear_error (&error);
set_ui_message (message, data);
g_free (message);
return NULL;
}
第二个:
/* Set playbin2's URI */
void gst_native_set_uri (JNIEnv * env, jobject thiz, jstring uri)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data || !data->pipeline)
return;
const gchar *char_uri = (*env)->GetStringUTFChars (env, uri, NULL);
GST_DEBUG ("Setting URI to %s", char_uri);
if (data->target_state >= GST_STATE_READY)
gst_element_set_state (data->pipeline, GST_STATE_READY);
g_object_set (data->pipeline, "uri", char_uri, NULL);
(*env)->ReleaseStringUTFChars (env, uri, char_uri);
data->duration = GST_CLOCK_TIME_NONE;
data->is_live |=
(gst_element_set_state (data->pipeline,
data->target_state) == GST_STATE_CHANGE_NO_PREROLL);
}
完整代码为here
这是我在 C 和 JNI 中做的第一件事,所以我将不胜感激工作代码片段。
好的,我无意中找到了解决方案。我刚刚通过将 $(GSTREAMER_PLUGINS_CODECS_RESTRICTED)
添加到 GSTREAMER_PLUGINS
行来修改我的 Android.mk
文件。现在 udp 流工作正常!
我正尝试在 android 上使用 Gstreamer 播放 udp 流。 (我用过this tutorial from the official Gstreamer website). I can play rtsp and https streams, but when I pass udp uri (like this: udp://@238.0.0.1:1234
) nothing happens (there is a black screen). In the log I have: Error received from element uridecodebin1: Your GStreamer installation is missing a plug-in.
I've found some documentation here关于安装插件,但我不知道该怎么做。
这是我使用的代码片段:
data->context = g_main_context_new ();
g_main_context_push_thread_default (data->context);
/* Build pipeline */
data->pipeline = gst_parse_launch ("playbin", &error);
if (error) {
gchar *message =
g_strdup_printf ("Unable to build pipeline: %s", error->message);
g_clear_error (&error);
set_ui_message (message, data);
g_free (message);
return NULL;
}
第二个:
/* Set playbin2's URI */
void gst_native_set_uri (JNIEnv * env, jobject thiz, jstring uri)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data || !data->pipeline)
return;
const gchar *char_uri = (*env)->GetStringUTFChars (env, uri, NULL);
GST_DEBUG ("Setting URI to %s", char_uri);
if (data->target_state >= GST_STATE_READY)
gst_element_set_state (data->pipeline, GST_STATE_READY);
g_object_set (data->pipeline, "uri", char_uri, NULL);
(*env)->ReleaseStringUTFChars (env, uri, char_uri);
data->duration = GST_CLOCK_TIME_NONE;
data->is_live |=
(gst_element_set_state (data->pipeline,
data->target_state) == GST_STATE_CHANGE_NO_PREROLL);
}
完整代码为here
这是我在 C 和 JNI 中做的第一件事,所以我将不胜感激工作代码片段。
好的,我无意中找到了解决方案。我刚刚通过将 $(GSTREAMER_PLUGINS_CODECS_RESTRICTED)
添加到 GSTREAMER_PLUGINS
行来修改我的 Android.mk
文件。现在 udp 流工作正常!