0

关于Gstreamer rtsp客户端的问题,我搜索了很久。但没有运气。

现在我可以通过 Gstreamer(gstreamer-1.0-android-armv7-1.6.0) 从 Android 设备上的服务器显示实时流或录制的流,然后我想在播放录制的流时发送 PLAY/PAUSE/ 以更改服务器状态。

我的问题:在使用 gst-rtsp-stream 时,是否有一种简单的方法来获取和访问管道?有人可以提供一个例子吗?

11 月 10 日更新:

GstBus *bus;
CustomData *data = (CustomData *)userdata;
GSource *timeout_source;
GSource *bus_source;
GError *error = NULL;
guint flags;

/* Create our own GLib Main Context and make it the default one */
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 latency to 0 ns */
gst_pipeline_set_latency(data->pipeline, 0);

/* Disable subtitles */
g_object_get (data->pipeline, "flags", &flags, NULL);
flags &= ~GST_PLAY_FLAG_TEXT;
g_object_set (data->pipeline, "flags", flags, NULL);

/* Set the pipeline to READY, so it can already accept a window handle, if we have one */
data->target_state = GST_STATE_READY;
gst_element_set_state(data->pipeline, GST_STATE_READY);

/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
bus = gst_element_get_bus (data->pipeline);

bus_source = gst_bus_create_watch (bus);

g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL);

g_source_attach (bus_source, data->context);

g_source_unref (bus_source);

g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, data);

g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, data);

gst_object_unref (bus);
4

0 回答 0