0

I have searched the question about Gstreamer rtsp client for a long time. But no luck.

Now I can display the live stream or the recorded stream by Gstreamer(gstreamer-1.0-android-armv7-1.6.0) from server on Android device, then I want to send PLAY/PAUSE/ to change server state when playing recorded stream.

My question: is there a simple way to obtain and access pipeline when working with gst-rtsp-stream? Could someone please provide an example?

Nov 10 Update:

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);
hhbgk
  • 21
  • 3
  • how do you implement the rtsp client (just gst-launch or c++ or what)? maybe using `gst-play --interactive` (and hitting space) can do this, but maybe its not possible. by using c++ you simply set the pipeline to PLAYING/PAUSED.. – nayana Nov 09 '15 at 15:33
  • @otopolsky,thanks for your reply.I am using C code. I update above now. – hhbgk Nov 10 '15 at 06:19
  • So have you tried to execute `gst_element_set_state (data->pipeline, GST_STATE_PAUSED);` or .._PLAYING ? you may want to implement some callback function called pause(GstElement *pipeline) and inside call something like that.. you can also test it with [g_timeout_add](https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-timeout-add) which will call it in some seconds in future.. – nayana Nov 25 '15 at 08:30

0 Answers0