Example #1
0
static GstElement *
gst_switch_request_new_case (GstSwitch * swit, GstPadTemplate * templ,
    const GstCaps * caps)
{
  GstElement *swcase = NULL;
  gchar *name;

  name = g_strdup_printf ("case_%d", GST_BIN_NUMCHILDREN (GST_BIN (swit)));
  swcase = gst_element_factory_make (CASE_ELEMENT_NAME, name);
  g_free (name);

  if (!gst_bin_add (GST_BIN (swit), swcase))
    goto error_bin_add_case;

  INFO ("new %s for %s.%s (%d cases)", GST_ELEMENT_NAME (swcase),
      GST_ELEMENT_NAME (swit), GST_PAD_TEMPLATE_NAME_TEMPLATE (templ),
      GST_BIN_NUMCHILDREN (GST_BIN (swit)));

  return swcase;

error_bin_add_case:
  {
    GST_ERROR_OBJECT (swit, "Bin add failed for %s.%s",
        GST_ELEMENT_NAME (swit), GST_PAD_TEMPLATE_NAME_TEMPLATE (templ));
    if (swcase)
      gst_object_unref (GST_OBJECT (swcase));
    return NULL;
  }
}
Example #2
0
gint
main (gint argc, gchar * argv[])
{
  GstBin *bin;
  GstClockTime start, end;
  GstElement *sink, *new_sink;

  /* default parameters */
  gint depth = 4;
  gint children = 3;
  gint flavour = FLAVOUR_AUDIO;
  const gchar *flavour_str = "audio";

  gst_init (&argc, &argv);

  /* check command line options */
  if (argc) {
    gint arg;
    for (arg = 0; arg < argc; arg++) {
      if (!strcmp (argv[arg], "-d")) {
        arg++;
        if (arg < argc)
          depth = atoi (argv[arg]);
      } else if (!strcmp (argv[arg], "-c")) {
        arg++;
        if (arg < argc)
          children = atoi (argv[arg]);
      } else if (!strcmp (argv[arg], "-f")) {
        arg++;
        if (arg < argc) {
          flavour_str = argv[arg];
          switch (*flavour_str) {
            case 'a':
              flavour = FLAVOUR_AUDIO;
              break;
            case 'v':
              flavour = FLAVOUR_VIDEO;
              break;
            default:
              break;
          }
        }
      }
    }
  }

  /* build pipeline */
  g_print ("building %s pipeline with depth = %d and children = %d\n",
      flavour_str, depth, children);
  start = gst_util_get_timestamp ();
  bin = GST_BIN (gst_pipeline_new ("pipeline"));
  sink = gst_element_factory_make ("fakesink", NULL);
  gst_bin_add (bin, sink);
  if (!create_node (bin, sink, "sink", &new_sink, children, flavour)) {
    goto Error;
  }
  if (!create_nodes (bin, new_sink, depth, children, flavour)) {
    goto Error;
  }
  end = gst_util_get_timestamp ();
  /* num-threads = num-sources = pow (children, depth) */
  g_print ("%" GST_TIME_FORMAT " built pipeline with %d elements\n",
      GST_TIME_ARGS (end - start), GST_BIN_NUMCHILDREN (bin));

  /* meassure */
  g_print ("starting pipeline\n");
  gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
  GST_DEBUG_BIN_TO_DOT_FILE (bin, GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE, "capsnego");
  start = gst_util_get_timestamp ();
  gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
  event_loop (GST_ELEMENT (bin), start);
  end = gst_util_get_timestamp ();
  g_print ("%" GST_TIME_FORMAT " reached paused\n",
      GST_TIME_ARGS (end - start));

  /* clean up */
Error:
  gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
  gst_object_unref (bin);
  return 0;
}
Example #3
0
/**
 * bt_edit_application_load_song:
 * @self: the application instance to load a new song in
 * @file_name: the song filename to load
 * @err: where to store the error message in case of an error, or %NULL
 *
 * Loads a new song. If there is a previous song instance it will be freed.
 *
 * Returns: true for success
 */
gboolean
bt_edit_application_load_song (const BtEditApplication * self,
    const char *file_name, GError ** err)
{
  gboolean res = FALSE;
  BtSongIO *loader;
  BtSong *song;

  g_return_val_if_fail (BT_IS_EDIT_APPLICATION (self), FALSE);

  GST_INFO ("song name = %s", file_name);

  if ((loader = bt_song_io_from_file (file_name, err))) {
    BtSetup *setup;
    GList *missing_machines, *missing_waves;

    bt_edit_application_ui_lock (self);
    g_signal_connect (loader, "notify::status",
        G_CALLBACK (on_songio_status_changed), (gpointer) self);

    // create new song and release the previous one
    song = bt_song_new (BT_APPLICATION (self));
    g_object_set ((gpointer) self, "song", NULL, NULL);

#ifdef USE_DEBUG
    // do sanity check that bin is empty
    {
      GstBin *bin;
      g_object_get ((gpointer) self, "bin", &bin, NULL);

      if (GST_BIN_NUMCHILDREN (bin)) {
        GList *node = GST_BIN_CHILDREN (bin);
        GST_WARNING ("bin.num_children=%d has left-overs",
            GST_BIN_NUMCHILDREN (bin));

        while (node) {
          GST_WARNING_OBJECT (node->data, "removing object %"
              G_OBJECT_REF_COUNT_FMT, G_OBJECT_LOG_REF_COUNT (node->data));
          gst_bin_remove (bin, GST_ELEMENT (node->data));
          node = GST_BIN_CHILDREN (bin);
        }
      }
      gst_object_unref (bin);
    }
#endif

    // this is synchronous execution
    // https://github.com/Buzztrax/buzztrax/issues/52
    // if we bump glib from 2.32 -> 2.36 we can use GTask and
    // g_task_run_in_thread()
    if (bt_song_io_load (loader, song, err)) {
      BtMachine *machine;

      // get sink-machine
      g_object_get (song, "setup", &setup, NULL);
      if ((machine =
              bt_setup_get_machine_by_type (setup, BT_TYPE_SINK_MACHINE))) {
        if (bt_machine_enable_input_post_level (machine)) {
          // DEBUG
          //bt_song_write_to_highlevel_dot_file(song);
          // DEBUG
          // set new song
          g_object_set ((gpointer) self, "song", song, NULL);
          res = TRUE;
          GST_INFO ("new song activated");
        } else {
          GST_WARNING ("Can't add input level/gain element in sink machine");
        }
        GST_DEBUG ("unreffing stuff after loading");
        g_object_unref (machine);
      } else {
        GST_WARNING ("Can't look up sink machine");
      }
      g_object_unref (setup);
    } else {
      GST_WARNING ("could not load song \"%s\"", file_name);
    }
    self->priv->unsaved = FALSE;
    g_object_notify (G_OBJECT (self), "unsaved");

    bt_edit_application_ui_unlock (self);

    // get missing element info
    bt_child_proxy_get (song, "setup::missing-machines", &missing_machines,
        "wavetable::missing-waves", &missing_waves, NULL);
    // tell about missing machines and/or missing waves
    if (missing_machines || missing_waves) {
      GtkWidget *dialog;

      if ((dialog =
              GTK_WIDGET (bt_missing_song_elements_dialog_new (missing_machines,
                      missing_waves)))) {
        bt_edit_application_attach_child_window (self, GTK_WINDOW (dialog));
        gtk_widget_show_all (dialog);

        gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);
      }
    }
    g_object_unref (song);
    g_object_unref (loader);
  } else {
    GST_WARNING ("Unknown extension \"%s\"", file_name);
  }
  return res;
}
Example #4
0
void test_launch_lines2()
{
  GstElement *cur;
  gint i;
  gboolean b;
  gchar *s = NULL;
  
  xmlfile = "test_launch_lines2";
  std_log(LOG_FILENAME_LINE, "Test Started  test_launch_lines2");
  /**
   * checks:
   * - specifying an element works :)
   * - if only 1 element is requested, no bin is returned, but the element
   */
  cur = setup_pipeline (PIPELINE1);
  fail_unless (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"),
      "parse_launch did not produce a fakesrc");
  gst_object_unref (cur);

  /**
   * checks:
   * - properties works
   * - string, int, boolean and enums can be properly set
   * - first test of escaping strings
   */
  cur = setup_pipeline (PIPELINE2);
  g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i,
      "silent", &b, NULL);
  fail_if (s == NULL, "name was NULL");
  fail_unless (strcmp (s, "donald") == 0, "fakesrc name was not 'donald'");
  fail_unless (i == 27, "num-buffers was not 27");
  fail_unless (b == TRUE, "silent was not TRUE");
  g_free (s);

  g_object_get (G_OBJECT (cur), "sizetype", &i, NULL);
  fail_unless (i == 3, "sizetype != 3");

  g_object_get (G_OBJECT (cur), "data", &i, NULL);
  fail_unless (i == 2, "data != 2");
  gst_object_unref (cur);

  /**
   * checks:
   * - specifying multiple elements without links works
   * - if multiple toplevel elements exist, a pipeline is returned
   */
  cur = setup_pipeline (PIPELINE3);
  fail_unless (GST_BIN_NUMCHILDREN (cur) == 3,
      "Pipeline does not contain 3 children");
  gst_object_unref (cur);

  /**
   * checks:
   * - test default link "!"
   * - test if specifying pads on links works
   */
  cur = setup_pipeline (PIPELINE4);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - test if appending the links works, too
   * - check if the pipeline constructed works the same as the one before (how?)
   */
  cur = setup_pipeline (PIPELINE5);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - test various types of bins
   * - test if linking across bins works
   * - test if escaping strings works
   */
  cur = setup_pipeline (PIPELINE6);
  fail_unless (GST_IS_PIPELINE (cur), "Parse did not produce a pipeline");
  g_object_get (G_OBJECT (cur), "name", &s, NULL);
  fail_if (s == NULL, "name was NULL");
  fail_unless (strcmp (s, "john") == 0, "Name was not 'john'");
  g_free (s);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - test request pads
   */
  cur = setup_pipeline (PIPELINE7);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - multiple pads on 1 link
   */
  cur = setup_pipeline (PIPELINE8);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - failed in grammar.y cvs version 1.17
   */
  cur = setup_pipeline (PIPELINE9);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - failed in grammar.y cvs version 1.17
   */
  cur = setup_pipeline (PIPELINE10);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - failed in grammar.y cvs version 1.18
   */
  cur = setup_pipeline (PIPELINE11);
  check_pipeline_runs (cur);
  gst_object_unref (cur);

  /**
   * checks:
   * - URI detection works
   */
  cur = setup_pipeline (PIPELINE12);
  gst_object_unref (cur);

  /** * checks:
   * - URI sink detection works
   */
  cur = setup_pipeline (PIPELINE13);
  gst_object_unref (cur);

  /* Checks handling of a assignment followed by error inside a bin. 
   * This should warn, but ignore the error and carry on */
  cur = setup_pipeline ("( filesrc blocksize=4 location=/dev/null @ )");
  gst_object_unref (cur);
  std_log(LOG_FILENAME_LINE, "Test Successful");
   create_xml(0);
}
Example #5
0
/*
 * Method: size
 *
 * Returns: the number of elements in the container.
 */
static VALUE
rb_gst_bin_size(VALUE self)
{
    return INT2NUM(GST_BIN_NUMCHILDREN(SELF(self)));
}