static gchar * debug_dump_get_element_state (GstElement * element) { gchar *state_name = NULL; const gchar *state_icons = "~0-=>"; GstState state = GST_STATE_VOID_PENDING, pending = GST_STATE_VOID_PENDING; gst_element_get_state (element, &state, &pending, 0); if (pending == GST_STATE_VOID_PENDING) { gboolean is_locked = gst_element_is_locked_state (element); state_name = g_strdup_printf ("\\n[%c]%s", state_icons[state], (is_locked ? "(locked)" : "")); } else { state_name = g_strdup_printf ("\\n[%c] -> [%c]", state_icons[state], state_icons[pending]); } return state_name; }
static gboolean stop_data(GstElement *source) { if (gst_element_is_locked_state(source) == FALSE) { if (gst_element_set_locked_state(source, TRUE) == TRUE) { std::clog << "##### LOCK OK" << std::endl; std::clog << "##### LOCK NOW" << std::endl; GstState rtspstate; gst_element_get_state(source, &rtspstate, NULL, GST_CLOCK_TIME_NONE); switch (rtspstate) { case GST_STATE_PLAYING: gst_element_set_state(source, GST_STATE_PAUSED); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_PAUSED: gst_element_set_state(source, GST_STATE_READY); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_READY: gst_element_set_state(source, GST_STATE_NULL); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_NULL: gst_object_unref(GST_OBJECT(source)); g_idle_remove_by_data(source); break; } std::clog << "########## State: " << gst_element_state_get_name( rtspstate) << std::endl; // gst_object_unref(GST_OBJECT(source)); } } }