Beispiel #1
0
//FIXME this should be part of the library
void
shmdata_base_reader_clean_element (GstElement *element)
{
    if (element != NULL && GST_IS_ELEMENT(element)
            && GST_STATE_CHANGE_FAILURE != GST_STATE_RETURN(element)) {
        {   // unlinking pads
            GstIterator *pad_iter = gst_element_iterate_pads(element);
            gst_iterator_foreach(pad_iter, (GFunc) shmdata_base_reader_unlink_pad, NULL);
            gst_iterator_free(pad_iter);
        }
        {   // releasing request pads
            GstIterator *pad_iter = gst_element_iterate_pads(element);
            gst_iterator_foreach(pad_iter,
                                 (GFunc) shmdata_base_reader_release_request_pad,
                                 element);
            gst_iterator_free(pad_iter);
        }

        GstState state = GST_STATE_TARGET(element);
        if (state != GST_STATE_NULL) {
            if (GST_STATE_CHANGE_ASYNC ==
                    gst_element_set_state(element, GST_STATE_NULL)) {
                while (GST_STATE(element) != GST_STATE_NULL) {
                    // warning this may be blocking
                    gst_element_get_state(element, NULL, NULL,
                                          GST_CLOCK_TIME_NONE);
                }
            }
        }
        if (GST_IS_BIN(gst_element_get_parent(element)))
            gst_bin_remove(GST_BIN(gst_element_get_parent(element)), element);
        else
            gst_object_unref(element);
    }
}
static void
gst_streamid_demux_reset (GstStreamidDemux * demux)
{
  GstIterator *it = NULL;
  GstIteratorResult itret = GST_ITERATOR_OK;

  GST_OBJECT_LOCK (demux);
  if (demux->active_srcpad != NULL)
    demux->active_srcpad = NULL;

  demux->nb_srcpads = 0;
  GST_OBJECT_UNLOCK (demux);

  if (demux->stream_id_pairs != NULL) {
    g_hash_table_unref (demux->stream_id_pairs);
    demux->stream_id_pairs = NULL;
  }

  it = gst_element_iterate_src_pads (GST_ELEMENT_CAST (demux));
  while (itret == GST_ITERATOR_OK || itret == GST_ITERATOR_RESYNC) {
    itret =
        gst_iterator_foreach (it,
        (GstIteratorForeachFunction) gst_streamid_demux_release_srcpad, demux);
    if (itret == GST_ITERATOR_RESYNC)
      gst_iterator_resync (it);
  }
  gst_iterator_free (it);
}
Beispiel #3
0
static GstStateChangeReturn
fs_funnel_change_state (GstElement *element, GstStateChange transition)
{
  FsFunnel *funnel = FS_FUNNEL (element);
  GstStateChangeReturn ret;

  switch (transition) {
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      {
        GstIterator *iter = gst_element_iterate_sink_pads (element);
        GstIteratorResult res;

        do {
          res = gst_iterator_foreach (iter, reset_pad, NULL);
        } while (res == GST_ITERATOR_RESYNC);

        gst_iterator_free (iter);

        if (res == GST_ITERATOR_ERROR)
          return GST_STATE_CHANGE_FAILURE;

        GST_OBJECT_LOCK (funnel);
        funnel->has_segment = FALSE;
        GST_OBJECT_UNLOCK (funnel);
      }
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  return ret;
}
Beispiel #4
0
static GstStateChangeReturn
gst_funnel_change_state (GstElement * element, GstStateChange transition)
{
  GstStateChangeReturn ret;

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
  if (ret == GST_STATE_CHANGE_FAILURE)
    return ret;

  switch (transition) {
    case GST_STATE_CHANGE_PAUSED_TO_READY:
    {
      GstIterator *iter = gst_element_iterate_sink_pads (element);
      GstIteratorResult res;

      do {
        res = gst_iterator_foreach (iter, reset_pad, element);
        if (res == GST_ITERATOR_RESYNC)
          gst_iterator_resync (iter);
      } while (res == GST_ITERATOR_RESYNC);
      gst_iterator_free (iter);

      if (res == GST_ITERATOR_ERROR)
        return GST_STATE_CHANGE_FAILURE;

    }
      break;
    default:
      break;
  }

  return ret;
}
static void
gst_tee_pull_eos (GstTee * tee)
{
  GstIterator *iter;

  iter = gst_element_iterate_src_pads (GST_ELEMENT (tee));
  gst_iterator_foreach (iter, (GstIteratorForeachFunction) gst_tee_push_eos,
      tee);
  gst_iterator_free (iter);
}
Beispiel #6
0
void
nle_object_seek_all_children (NleObject * object, GstEvent * seek_event)
{
  GstIterator *it = gst_bin_iterate_recurse (GST_BIN (object));

  while (gst_iterator_foreach (it, _send_seek_event,
          seek_event) == GST_ITERATOR_RESYNC)
    gst_iterator_resync (it);

  gst_iterator_free (it);
  gst_event_unref (seek_event);
}
Beispiel #7
0
gboolean gstreamer_run_pipeline(GMainLoop *loop, const char *s, StartupState state) {
	main_set_real_time_scheduling_policy();

	GError *error = NULL;
	pipeline = gst_parse_launch(s, &error);
	if (!pipeline) {
		printf("Error: Could not create gstreamer pipeline.\n");
		printf("Parse error: %s\n", error->message);
		return FALSE;
	}

	bus_quit_on_playing = FALSE;
	GstBus *bus;
	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
	bus_watch_id = gst_bus_add_watch(bus, bus_callback, loop);
	if (main_have_gui())
#if GST_CHECK_VERSION(1, 0, 0)
		gst_bus_set_sync_handler(bus, (GstBusSyncHandler)bus_sync_handler, NULL, NULL);
#else
		gst_bus_set_sync_handler(bus, (GstBusSyncHandler)bus_sync_handler, NULL);
#endif
	gst_object_unref(bus);

	// Iterate over all elements of the pipeline to hook a handler
	// listing newly created pads.
	if (created_pads_list != NULL) {
		g_list_free(created_pads_list);
		created_pads_list = NULL;
	}
	GstIterator *iterator = gst_bin_iterate_elements(GST_BIN(pipeline));
	gst_iterator_foreach(iterator, for_each_pipeline_element, NULL);
	gst_iterator_free(iterator);

	stats_reset();

	gst_element_set_state(pipeline, GST_STATE_READY);

	state_change_to_playing_already_occurred = FALSE;

	if (state == STARTUP_PLAYING)
		gst_element_set_state(pipeline, GST_STATE_PLAYING);
	else
		gst_element_set_state(pipeline, GST_STATE_PAUSED);

	pipeline_description = s;
	end_of_stream = FALSE;

	inform_pipeline_destroyed_cb_list = NULL;
	return TRUE;
}
static gboolean gst_sctp_dec_packet_event(GstPad *pad, GstSctpDec *self, GstEvent *event)
{
    switch (GST_EVENT_TYPE(event)) {
    case GST_EVENT_STREAM_START:
    case GST_EVENT_CAPS:
        /* We create our own stream-start events and the caps event does not
         * make sense */
        gst_event_unref(event);
        return TRUE;
    case GST_EVENT_EOS:
        /* Drop this, we're never EOS until shut down */
        gst_event_unref(event);
        return TRUE;
    case GST_EVENT_FLUSH_START: {
        GstIterator *it;

        it = gst_element_iterate_src_pads(GST_ELEMENT(self));
        while (gst_iterator_foreach(it, flush_srcpad, GINT_TO_POINTER(TRUE)) == GST_ITERATOR_RESYNC)
            gst_iterator_resync(it);
        gst_iterator_free(it);

        return gst_pad_event_default(pad, GST_OBJECT(self), event);
    }
    case GST_EVENT_FLUSH_STOP: {
        GstIterator *it;

        it = gst_element_iterate_src_pads(GST_ELEMENT(self));
        while (gst_iterator_foreach(it, flush_srcpad, GINT_TO_POINTER(FALSE)) == GST_ITERATOR_RESYNC)
            gst_iterator_resync(it);
        gst_iterator_free(it);

        return gst_pad_event_default(pad, GST_OBJECT(self), event);
    }
    default:
        return gst_pad_event_default(pad, GST_OBJECT(self), event);
    }
}
Beispiel #9
0
static void
fps_display_sink_update_sink_sync (GstFPSDisplaySink * self)
{
  GstIterator *iterator;

  if (self->video_sink == NULL)
    return;

  if (GST_IS_BIN (self->video_sink)) {
    iterator = gst_bin_iterate_sinks (GST_BIN (self->video_sink));
    gst_iterator_foreach (iterator, (GFunc) update_sub_sync,
        (void *) &self->sync);
    gst_iterator_free (iterator);
  } else
    update_sub_sync (self->video_sink, (void *) &self->sync);

}