Exemplo n.º 1
0
G_MODULE_EXPORT gboolean
preview_draw_cb(
    GtkWidget *widget,
    cairo_t *cr,
    signal_user_data_t *ud)
{
#if defined(_ENABLE_GST)
#if GST_CHECK_VERSION(1, 0, 0)
    if (ud->preview->live_enabled && ud->preview->state == PREVIEW_STATE_LIVE)
    {
        if (GST_STATE(ud->preview->play) >= GST_STATE_PAUSED)
        {
            GstElement *vsink;
            GstVideoOverlay *vover;

            g_object_get(ud->preview->play, "video-sink", &vsink, NULL);
            if (GST_IS_BIN(vsink))
                vover = GST_VIDEO_OVERLAY(gst_bin_get_by_interface(
                                    GST_BIN(vsink), GST_TYPE_VIDEO_OVERLAY));
            else
                vover = GST_VIDEO_OVERLAY(vsink);
            gst_video_overlay_expose(vover);
            // For some reason, the exposed region doesn't always get
            // cleaned up here. But a delayed gst_x_overlay_expose()
            // takes care of it.
            g_idle_add((GSourceFunc)delayed_expose_cb, ud);
        }
        return FALSE;
    }
#else
    if (ud->preview->live_enabled && ud->preview->state == PREVIEW_STATE_LIVE)
    {
        if (GST_STATE(ud->preview->play) >= GST_STATE_PAUSED)
        {
            GstElement *vsink;
            GstXOverlay *xover;

            g_object_get(ud->preview->play, "video-sink", &vsink, NULL);
            if (GST_IS_BIN(vsink))
                xover = GST_X_OVERLAY(gst_bin_get_by_interface(
                                        GST_BIN(vsink), GST_TYPE_X_OVERLAY));
            else
                xover = GST_X_OVERLAY(vsink);
            gst_x_overlay_expose(xover);
            // For some reason, the exposed region doesn't always get
            // cleaned up here. But a delayed gst_x_overlay_expose()
            // takes care of it.
            g_idle_add((GSourceFunc)delayed_expose_cb, ud);
        }
        return FALSE;
    }
#endif
#endif

    if (ud->preview->pix != NULL)
    {
        _draw_pixbuf(cr, ud->preview->pix);
    }
    return FALSE;
}
Exemplo n.º 2
0
EXPORT_C
#endif

void
_gst_debug_bin_to_dot_file_with_ts (GstBin * bin, GstDebugGraphDetails details,
    const gchar * file_name)
{
  gchar *ts_file_name = NULL;
  GstClockTime elapsed;

  g_return_if_fail (GST_IS_BIN (bin));

  if (!file_name) {
    file_name = g_get_application_name ();
    if (!file_name)
      file_name = "unnamed";
  }

  /* add timestamp */
  elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
      gst_util_get_timestamp ());
  ts_file_name =
      g_strdup_printf ("%" GST_TIME_FORMAT "-%s", GST_TIME_ARGS (elapsed),
      file_name);

  _gst_debug_bin_to_dot_file (bin, details, ts_file_name);
  g_free (ts_file_name);
}
void _bp_dvd_find_navigation (BansheePlayer *player)
{
    GstElement *video_sink = NULL;
    GstElement *navigation = NULL;
    GstNavigation *previous_navigation;

    previous_navigation = player->navigation;
    g_object_get (player->playbin, "video-sink", &video_sink, NULL);

    if (video_sink == NULL) {
        player->navigation = NULL;
        if (previous_navigation != NULL) {
            gst_object_unref (previous_navigation);
        }
    }

    navigation = GST_IS_BIN (video_sink)
        ? gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_NAVIGATION)
        : video_sink;

    player->navigation = GST_IS_NAVIGATION (navigation) ? GST_NAVIGATION (navigation) : NULL;

    if (previous_navigation != NULL) {
        gst_object_unref (previous_navigation);
    }

    gst_object_unref (video_sink);
}
void
BasePlatformInterface::PrepareVideoWindow(GstMessage *aMessage)
{
  GstElement *element = NULL;
  GstXOverlay *xoverlay = NULL;

  if (GST_IS_BIN (mVideoSink)) {
    /* Get the actual implementing object from the bin */
    element = gst_bin_get_by_interface(GST_BIN (mVideoSink),
            GST_TYPE_X_OVERLAY);
  }
  else {
    element = mVideoSink;
  }

  if (GST_IS_X_OVERLAY (element)) {
    xoverlay = GST_X_OVERLAY (element);
    LOG(("xoverlay interface found, setting video window"));
  }
  else {
    LOG(("No xoverlay interface found, cannot set video window"));
    return;
  }

  SetXOverlayWindowID(xoverlay);

  ResizeToWindow();
}
static guint
watch_container (InsanityGstPipelineTest * ptest, GstBin * bin)
{
  GstIterator *it;
  gboolean done = FALSE;
  GValue data = { 0, };
  GstElement *e;

  it = gst_bin_iterate_elements (bin);
  while (!done) {
    switch (gst_iterator_next (it, &data)) {
      case GST_ITERATOR_OK:
        e = GST_ELEMENT_CAST (g_value_get_object (&data));
        add_element_used (ptest, e);
        if (GST_IS_BIN (e)) {
          watch_container (ptest, GST_BIN (e));
        }
        g_value_reset (&data);
        break;
      case GST_ITERATOR_RESYNC:
        gst_iterator_resync (it);
        break;
      case GST_ITERATOR_DONE:
      default:
        done = TRUE;
        break;
    }
  }
  g_value_unset (&data);
  gst_iterator_free (it);

  return g_signal_connect (bin, "element-added", (GCallback) on_element_added,
      ptest);
}
/*
 * gst_debug_bin_to_dot_file_with_ts:
 * @bin: the top-level pipeline that should be analyzed
 * @file_name: output base filename (e.g. "myplayer")
 *
 * This works like gst_debug_bin_to_dot_file(), but adds the current timestamp
 * to the filename, so that it can be used to take multiple snapshots.
 */
void
gst_debug_bin_to_dot_file_with_ts (GstBin * bin,
    GstDebugGraphDetails details, const gchar * file_name)
{
  gchar *ts_file_name = NULL;
  GstClockTime elapsed;

  g_return_if_fail (GST_IS_BIN (bin));

  if (!file_name) {
    file_name = g_get_application_name ();
    if (!file_name)
      file_name = "unnamed";
  }

  /* add timestamp */
  elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
      gst_util_get_timestamp ());

  /* we don't use GST_TIME_FORMAT as such filenames would fail on some
   * filesystems like fat */
  ts_file_name =
      g_strdup_printf ("%u.%02u.%02u.%09u-%s", GST_TIME_ARGS (elapsed),
      file_name);

  gst_debug_bin_to_dot_file (bin, details, ts_file_name);
  g_free (ts_file_name);
}
Exemplo n.º 7
0
static CoglGstVideoSink *
find_cogl_gst_video_sink (GstElement *element)
{
  GstElement *sink_element = NULL;
  GstIterator *iterator;
  GstElement *iterator_value;
  GValue value;

  if (!GST_IS_BIN (element))
    return NULL;

  iterator = gst_bin_iterate_recurse (GST_BIN (element));

  g_value_init (&value, GST_TYPE_ELEMENT);

  while (gst_iterator_next (iterator, &value) == GST_ITERATOR_OK)
    {
      iterator_value = g_value_get_object (&value);

      g_value_reset (&value);

      if (COGL_GST_IS_VIDEO_SINK (iterator_value))
        {
          sink_element = iterator_value;
          break;
        }
    }

  g_value_unset (&value);

  gst_iterator_free (iterator);

  return COGL_GST_VIDEO_SINK (sink_element);
}
Exemplo n.º 8
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);
    }
}
Exemplo n.º 9
0
static gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ERROR:{
      GError *err;
      gchar *debug;

      gst_message_parse_error (message, &err, &debug);
      g_print ("Error: %s\n", err->message);
      g_error_free (err);
      g_free (debug);

      /* Write debug graph to file */
      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (camerabin),
          GST_DEBUG_GRAPH_SHOW_ALL, "camerabin.error");

      g_main_loop_quit (loop);
      break;
    }
    case GST_MESSAGE_STATE_CHANGED:
      if (GST_IS_BIN (GST_MESSAGE_SRC (message))) {
        GstState oldstate, newstate;

        gst_message_parse_state_changed (message, &oldstate, &newstate, NULL);
        GST_DEBUG_OBJECT (GST_MESSAGE_SRC (message), "state-changed: %s -> %s",
            gst_element_state_get_name (oldstate),
            gst_element_state_get_name (newstate));
      }
      break;
    case GST_MESSAGE_EOS:
      /* end-of-stream */
      GST_INFO ("got eos() - should not happen");
      g_main_loop_quit (loop);
      break;
    case GST_MESSAGE_ELEMENT:
      if (GST_MESSAGE_SRC (message) == (GstObject *) camerabin) {
        const GstStructure *structure = gst_message_get_structure (message);

        if (gst_structure_has_name (structure, "image-done")) {
#ifndef GST_DISABLE_GST_DEBUG
          const gchar *fname = gst_structure_get_string (structure, "filename");

          GST_DEBUG ("image done: %s", fname);
#endif
          if (capture_count < capture_total) {
            g_idle_add ((GSourceFunc) run_pipeline, NULL);
          } else {
            g_main_loop_quit (loop);
          }
        }
      }
      break;
    default:
      /* unhandled message */
      break;
  }
  return TRUE;
}
static void
on_element_added (GstElement * bin, GstElement * element,
    InsanityGstPipelineTest * ptest)
{
  add_element_used (ptest, element);
  if (GST_IS_BIN (element))
    watch_container (ptest, GST_BIN (element));
}
Exemplo n.º 11
0
static void
log_new_element_stats (GstElementStats * stats, GstElement * element,
    GstClockTime elapsed)
{
  gst_tracer_record_log (tr_new_element, (guint64) (guintptr) g_thread_self (),
      elapsed, stats->index, stats->parent_ix, GST_OBJECT_NAME (element),
      G_OBJECT_TYPE_NAME (element), GST_IS_BIN (element));
}
void
fs_element_added_notifier_add (FsElementAddedNotifier *notifier,
    GstBin *bin)
{
  g_return_if_fail (notifier && FS_IS_ELEMENT_ADDED_NOTIFIER (notifier));
  g_return_if_fail (bin && GST_IS_BIN (bin));

  _element_added_callback (NULL, GST_ELEMENT_CAST (bin), notifier);
}
static gboolean
gst_validate_bin_monitor_setup (GstValidateMonitor * monitor)
{
  GstIterator *iterator;
  gboolean done;
  GstElement *element;
  GstValidateBinMonitor *bin_monitor = GST_VALIDATE_BIN_MONITOR_CAST (monitor);
  GstBin *bin = GST_VALIDATE_BIN_MONITOR_GET_BIN (bin_monitor);

  if (!GST_IS_BIN (bin)) {
    GST_WARNING_OBJECT (monitor, "Trying to create bin monitor with other "
        "type of object");
    return FALSE;
  }

  GST_DEBUG_OBJECT (bin_monitor, "Setting up monitor for bin %" GST_PTR_FORMAT,
      bin);

  if (g_object_get_data ((GObject *) bin, "validate-monitor")) {
    GST_DEBUG_OBJECT (bin_monitor,
        "Bin already has a validate-monitor associated");
    return FALSE;
  }

  bin_monitor->element_added_id =
      g_signal_connect (bin, "element-added",
      G_CALLBACK (_validate_bin_element_added), monitor);

  iterator = gst_bin_iterate_elements (bin);
  done = FALSE;
  while (!done) {
    GValue value = { 0, };

    switch (gst_iterator_next (iterator, &value)) {
      case GST_ITERATOR_OK:
        element = g_value_get_object (&value);
        gst_validate_bin_monitor_wrap_element (bin_monitor, element);
        g_value_reset (&value);
        break;
      case GST_ITERATOR_RESYNC:
        /* TODO how to handle this? */
        gst_iterator_resync (iterator);
        break;
      case GST_ITERATOR_ERROR:
        done = TRUE;
        break;
      case GST_ITERATOR_DONE:
        done = TRUE;
        break;
    }
  }
  gst_iterator_free (iterator);

  return TRUE;
}
static void
calculate_latency (GstElement * parent, GstPad * pad, guint64 ts)
{
  if (parent && (!GST_IS_BIN (parent)) &&
      GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SINK)) {
    GstEvent *ev = g_object_get_qdata ((GObject *) pad, latency_probe_id);

    log_latency (gst_event_get_structure (ev), pad, ts);
    gst_event_unref (ev);
  }
}
Exemplo n.º 15
0
gboolean
shmdata_base_reader_set_bin (shmdata_base_reader_t * reader, GstElement *bin)
{
    if (!GST_IS_BIN (bin))
    {
        g_warning ("base reader: not a bin");
        return FALSE;
    }
    reader->bin_ = bin;
    return TRUE;
}
static void
gst_wrapper_camera_bin_reset_video_src_caps (GstWrapperCameraBinSrc * self,
    GstCaps * caps)
{
  GstClock *clock;
  gint64 base_time;

  GST_DEBUG_OBJECT (self, "Resetting src caps to %" GST_PTR_FORMAT, caps);
  if (self->src_vid_src) {
    clock = gst_element_get_clock (self->src_vid_src);
    base_time = gst_element_get_base_time (self->src_vid_src);

    gst_element_set_state (self->src_vid_src, GST_STATE_READY);
    set_capsfilter_caps (self, caps);

    self->drop_newseg = TRUE;

    GST_DEBUG_OBJECT (self, "Bringing source up");
    gst_element_sync_state_with_parent (self->src_vid_src);

    if (clock) {
      gst_element_set_clock (self->src_vid_src, clock);
      gst_element_set_base_time (self->src_vid_src, base_time);

      if (GST_IS_BIN (self->src_vid_src)) {
        GstIterator *it =
            gst_bin_iterate_elements (GST_BIN (self->src_vid_src));
        gpointer item = NULL;
        gboolean done = FALSE;
        while (!done) {
          switch (gst_iterator_next (it, &item)) {
            case GST_ITERATOR_OK:
              gst_element_set_base_time (GST_ELEMENT (item), base_time);
              gst_object_unref (item);
              break;
            case GST_ITERATOR_RESYNC:
              gst_iterator_resync (it);
              break;
            case GST_ITERATOR_ERROR:
              done = TRUE;
              break;
            case GST_ITERATOR_DONE:
              done = TRUE;
              break;
          }
        }
        gst_iterator_free (it);
      }

      gst_object_unref (clock);
    }
  }
}
static void
_element_added_callback (GstBin *parent, GstElement *element,
    gpointer user_data)
{
  FsElementAddedNotifier *notifier = FS_ELEMENT_ADDED_NOTIFIER (user_data);

  if (GST_IS_BIN (element)) {
    GstIterator *iter = NULL;
    gboolean done;

    g_signal_connect_object (element, "element-added",
        G_CALLBACK (_element_added_callback), notifier, 0);

    if (parent)
      g_signal_connect_object (element, "parent-unset",
          G_CALLBACK (_bin_unparented_cb), notifier, 0);

    iter = gst_bin_iterate_elements (GST_BIN (element));

    done = FALSE;
    while (!done)
    {
      gpointer item = NULL;

      switch (gst_iterator_next (iter, &item)) {
       case GST_ITERATOR_OK:
         /* We make sure the callback has not already been added */
         if (g_signal_handler_find (item,
                 G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
                 0, 0, NULL, /* id, detail, closure */
                 _element_added_callback, notifier) == 0)
           _element_added_callback (GST_BIN_CAST (element), item, notifier);
         gst_object_unref (item);
         break;
       case GST_ITERATOR_RESYNC:
         // We don't rollback anything, we just ignore already processed ones
         gst_iterator_resync (iter);
         break;
       case GST_ITERATOR_ERROR:
         g_error ("Wrong parameters were given?");
         done = TRUE;
         break;
       case GST_ITERATOR_DONE:
         done = TRUE;
         break;
     }
    }

    gst_iterator_free (iter);
  }

  g_signal_emit (notifier, signals[ELEMENT_ADDED], 0, parent, element);
}
Exemplo n.º 18
0
static void
log_new_element_stats (GstElementStats * stats, GstElement * element,
    GstClockTime elapsed)
{
  gst_tracer_log_trace (gst_structure_new ("new-element",
          "thread-id", G_TYPE_UINT, GPOINTER_TO_UINT (g_thread_self ()),
          "ts", G_TYPE_UINT64, elapsed,
          "ix", G_TYPE_UINT, stats->index,
          "parent-ix", G_TYPE_UINT, stats->parent_ix,
          "name", G_TYPE_STRING, GST_OBJECT_NAME (element),
          "type", G_TYPE_STRING, G_OBJECT_TYPE_NAME (element),
          "is-bin", G_TYPE_BOOLEAN, GST_IS_BIN (element), NULL));
}
Exemplo n.º 19
0
static void
send_latency_probe (GstElement * parent, GstPad * pad, guint64 ts)
{
  if (parent && (!GST_IS_BIN (parent)) &&
      GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SOURCE)) {
    GstEvent *latency_probe = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
        gst_structure_new_id (latency_probe_id,
            latency_probe_pad, GST_TYPE_PAD, pad,
            latency_probe_ts, G_TYPE_UINT64, ts,
            NULL));
    gst_pad_push_event (pad, latency_probe);
  }
}
static gboolean
bp_video_find_xoverlay (BansheePlayer *player)
{
    GstElement *video_sink = NULL;
    GstElement *xoverlay;
    GstXOverlay *previous_xoverlay;
    gboolean    found_xoverlay;

    g_object_get (player->playbin, "video-sink", &video_sink, NULL);

    g_mutex_lock (player->video_mutex);
    previous_xoverlay = player->xoverlay;

    if (video_sink == NULL) {
        player->xoverlay = NULL;
        if (previous_xoverlay != NULL) {
            gst_object_unref (previous_xoverlay);
        }
        g_mutex_unlock (player->video_mutex);
        return FALSE;
    }
   
    xoverlay = GST_IS_BIN (video_sink)
        ? gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_X_OVERLAY)
        : video_sink;
    
    player->xoverlay = GST_IS_X_OVERLAY (xoverlay) ? GST_X_OVERLAY (xoverlay) : NULL;
    
    if (previous_xoverlay != NULL) {
        gst_object_unref (previous_xoverlay);
    }
        
#if !defined(GDK_WINDOWING_WIN32) // We can't rely on aspect ratio from dshowvideosink
    if (player->xoverlay != NULL && g_object_class_find_property (
        G_OBJECT_GET_CLASS (player->xoverlay), "force-aspect-ratio")) {
        g_object_set (G_OBJECT (player->xoverlay), "force-aspect-ratio", TRUE, NULL);
    }
#endif
    
    if (player->xoverlay != NULL && g_object_class_find_property (
        G_OBJECT_GET_CLASS (player->xoverlay), "handle-events")) {
        g_object_set (G_OBJECT (player->xoverlay), "handle-events", FALSE, NULL);
    }

    gst_object_unref (video_sink);
    found_xoverlay = (player->xoverlay != NULL) ? TRUE : FALSE;

    g_mutex_unlock (player->video_mutex);
    return found_xoverlay;
}
Exemplo n.º 21
0
static gboolean
timeout_check (gpointer pipeline)
{
  if (GST_IS_BIN (pipeline)) {
    gchar *timeout_file =
        g_strdup_printf ("timeout-%s", GST_OBJECT_NAME (pipeline));

    GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
        GST_DEBUG_GRAPH_SHOW_ALL, timeout_file);
    g_free (timeout_file);
  }

  return FALSE;
}
Exemplo n.º 22
0
void
GstUtils::set_element_property_in_bin(GstElement *bin,
                                      const gchar *factory_name,
                                      const gchar *property_name,
                                      gboolean property_value) {
  if (!GST_IS_BIN(bin))
    return;

  if (g_list_length(GST_BIN_CHILDREN(GST_BIN(bin))) > 0) {
    GList *child = nullptr, *children = GST_BIN_CHILDREN(GST_BIN(bin));
    for (child = children; child != nullptr; child = g_list_next(child)) {
      GstElement *current_element = GST_ELEMENT(child->data);
      GstElementFactory *factory = gst_element_get_factory(current_element);
      // g_print ("The '%s' element is a member of the category %s.\n"
      //  "Description: %s\n",
      //  gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (sub_factory)),
      //  gst_element_factory_get_klass (sub_factory),
      //  gst_element_factory_get_description (sub_factory));
      if (g_strcmp0(factory_name,
                    gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)))
          == 0) {
        g_debug("GstUtils: setting property for %s", factory_name);
        g_object_set(G_OBJECT(current_element), property_name,
                     property_value, nullptr);
      }

      if (GST_IS_BIN(current_element)) {  // recursive
        GstUtils::set_element_property_in_bin(current_element,
                                              factory_name,
                                              property_name,
                                              property_value);
      }
      
    }
  }
}
/*
 * gst_debug_bin_to_dot_data:
 * @bin: the top-level pipeline that should be analyzed
 *
 * To aid debugging applications one can use this method to obtain the whole
 * network of gstreamer elements that form the pipeline into an dot file.
 * This data can be processed with graphviz to get an image.
 *
 * Returns: (transfer full): a string containing the pipeline in graphviz
 * dot format.
 */
gchar *
gst_debug_bin_to_dot_data (GstBin * bin, GstDebugGraphDetails details)
{
  GString *str;

  g_return_val_if_fail (GST_IS_BIN (bin), NULL);

  str = g_string_new (NULL);

  debug_dump_header (bin, details, str);
  debug_dump_element (bin, details, str, 1);
  debug_dump_footer (str);

  return g_string_free (str, FALSE);
}
Exemplo n.º 24
0
void GstUtils::clean_element(GstElement *element) {
  if (nullptr == element)
    return;
  if (!GST_IS_ELEMENT(element)) {
    g_warning("%s failed (not a gst element)", __FUNCTION__);
    return;
  }
  if (GST_STATE_CHANGE_FAILURE == GST_STATE_RETURN(element)) {
    g_warning("%s failed (state error)", __FUNCTION__);
    return;
  }
  // if (GST_IS_BIN(element))
  //   g_debug("%d, %d, %d, state return %d", GST_STATE(element),
  //           GST_STATE_TARGET(element), GST_STATE_PENDING(element),
  //           GST_STATE_RETURN(element));
  
  // FIXME {  // unlinking pads
  //   GstIterator *pad_iter;
  //   pad_iter = gst_element_iterate_pads(element);
  //   gst_iterator_foreach(pad_iter, (GFunc) GstUtils::unlink_pad, nullptr);
  //   gst_iterator_free(pad_iter);
  // }
  
  // FIXME {  // releasing request pads
  //   GstIterator *pad_iter;
  //   pad_iter = gst_element_iterate_pads(element);
  //   gst_iterator_foreach(pad_iter, (GFunc) GstUtils::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, nullptr, nullptr,
  //                             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
    if (!GST_IS_BIN(gst_element_get_parent(element))
        && ((GObject *) element)->ref_count > 0)
    gst_object_unref(element);
}
Exemplo n.º 25
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);

}
Exemplo n.º 26
0
static void
print_element_flag_info (GstElement * element)
{
  gboolean have_flags = FALSE;

  n_print ("\n");
  n_print ("Element Flags:\n");

  if (!have_flags)
    n_print ("  no flags set\n");

  if (GST_IS_BIN (element)) {
    n_print ("\n");
    n_print ("Bin Flags:\n");
    if (!have_flags)
      n_print ("  no flags set\n");
  }
}
Exemplo n.º 27
0
static GstElement *
get_sink_element (GstBin * bin)
{
  GstElement *e;
  GList *node;

  GST_INFO_OBJECT (bin, "looking for audio_sink");
  for (node = GST_BIN_CHILDREN (bin); node; node = g_list_next (node)) {
    e = (GstElement *) node->data;
    if (GST_IS_BIN (e) && GST_OBJECT_FLAG_IS_SET (e, GST_ELEMENT_FLAG_SINK)) {
      return get_sink_element ((GstBin *) e);
    }
    if (GST_OBJECT_FLAG_IS_SET (e, GST_ELEMENT_FLAG_SINK)) {
      return e;
    }
  }
  return NULL;
}
Exemplo n.º 28
0
static void hook_element (GstElement *elem, PipelineChangeListenerContext *ctx)
{
	GstIterator *itr;
	gpointer     item;

	/* check if we've already examined this element, to prevent loops: */
	if (!already_visited (ctx->visited_nodes, elem))
	{
		GST_INFO_OBJECT (elem, "");

		g_signal_connect (elem, "pad-added", (GCallback)pad_added, ctx);

		/* Since it is likely that some pads are already hooked, let's iterate them
		 * (since there will be no pad-added signal for them) and simulate the
		 * the missed signal
		 *
		 * XXX here we probably should do something sane if the underlying data
		 * structure changes as we iterate.. hmm
		 */
		for( itr = gst_element_iterate_pads (elem);
		     gst_iterator_next (itr, &item) == GST_ITERATOR_OK;
		     gst_object_unref (item) )
		{
			pad_added (elem, GST_PAD(item), ctx);
		}
		gst_iterator_free (itr);

		/* in case this elem is a bin, we need to hook all the elements within
		 * the bin too:
		 */
		if( GST_IS_BIN (elem) )
		{
			for( itr = gst_bin_iterate_elements (GST_BIN (elem));
			     gst_iterator_next (itr, &item) == GST_ITERATOR_OK;
			     gst_object_unref (item) )
			{
				hook_element (GST_ELEMENT (item), ctx);
			}
			gst_iterator_free (itr);
		}

		ctx->needs_cb = TRUE;
	}
}
Exemplo n.º 29
0
/* slightly convoluted way to find a working video sink that's not a bin,
 * one could use autovideosink from gst-plugins-good instead
 */
static GstElement *
find_video_sink (void)
{
  GstStateChangeReturn sret;
  GstElement *sink;

  if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {
    sret = gst_element_set_state (sink, GST_STATE_READY);
    if (sret == GST_STATE_CHANGE_SUCCESS)
      return sink;
  
    gst_element_set_state (sink, GST_STATE_NULL);
  }
  gst_object_unref (sink);

  if ((sink = gst_element_factory_make ("ximagesink", NULL))) {
    sret = gst_element_set_state (sink, GST_STATE_READY);
    if (sret == GST_STATE_CHANGE_SUCCESS)
      return sink;
  
    gst_element_set_state (sink, GST_STATE_NULL);
  }
  gst_object_unref (sink);

  if (strcmp (DEFAULT_VIDEOSINK, "xvimagesink") == 0 ||
      strcmp (DEFAULT_VIDEOSINK, "ximagesink") == 0)
    return NULL;

  if ((sink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL))) {
    if (GST_IS_BIN (sink)) {
      gst_object_unref (sink);
      return NULL;
    }
  
    sret = gst_element_set_state (sink, GST_STATE_READY);
    if (sret == GST_STATE_CHANGE_SUCCESS)
      return sink;
  
    gst_element_set_state (sink, GST_STATE_NULL);
  }
  gst_object_unref (sink);
  return NULL;
}
Exemplo n.º 30
0
static void
print_children_info (GstElement * element)
{
  GList *children;

  if (!GST_IS_BIN (element))
    return;

  children = (GList *) GST_BIN (element)->children;
  if (children) {
    n_print ("\n");
    n_print ("Children:\n");
  }

  while (children) {
    n_print ("  %s\n", GST_ELEMENT_NAME (GST_ELEMENT (children->data)));
    children = g_list_next (children);
  }
}