コード例 #1
0
ファイル: snra-client.c プロジェクト: elisescu/aurena
static void
snra_client_finalize (GObject * object)
{
  SnraClient *client = (SnraClient *) (object);

  if (client->avahi_sb)
    avahi_service_browser_free (client->avahi_sb);
  if (client->avahi_client)
    avahi_client_free (client->avahi_client);
  if (client->glib_poll)
    avahi_glib_poll_free (client->glib_poll);

  if (client->net_clock)
    gst_object_unref (client->net_clock);
  if (client->soup)
    g_object_unref (client->soup);
  if (client->json)
    g_object_unref (client->json);
  if (client->player) {
    GstBus *bus = gst_element_get_bus (client->player);
    gst_bus_remove_signal_watch (bus);
    gst_object_unref (bus);
    gst_object_unref (client->player);
  }

  g_free (client->server_host);
  g_free (client->connected_server);

  G_OBJECT_CLASS (snra_client_parent_class)->finalize (object);
}
コード例 #2
0
AudioFileReader::~AudioFileReader()
{
    if (m_pipeline) {
        GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
        ASSERT(bus);
        g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
        gst_bus_remove_signal_watch(bus.get());

        gst_element_set_state(m_pipeline, GST_STATE_NULL);
        gst_object_unref(GST_OBJECT(m_pipeline));
    }

    if (m_decodebin) {
        g_signal_handlers_disconnect_by_func(m_decodebin.get(), reinterpret_cast<gpointer>(onGStreamerDecodebinPadAddedCallback), this);
        m_decodebin.clear();
    }

    if (m_deInterleave) {
        g_signal_handlers_disconnect_by_func(m_deInterleave.get(), reinterpret_cast<gpointer>(onGStreamerDeinterleavePadAddedCallback), this);
        g_signal_handlers_disconnect_by_func(m_deInterleave.get(), reinterpret_cast<gpointer>(onGStreamerDeinterleaveReadyCallback), this);
        m_deInterleave.clear();
    }

#ifndef GST_API_VERSION_1
    gst_buffer_list_iterator_free(m_frontLeftBuffersIterator);
    gst_buffer_list_iterator_free(m_frontRightBuffersIterator);
#endif
    gst_buffer_list_unref(m_frontLeftBuffers);
    gst_buffer_list_unref(m_frontRightBuffers);
}
コード例 #3
0
AlertTonePreview::~AlertTonePreview ()
{
    SYS_DEBUG ("Stopping the playback.");

    if (m_gstVolume)
    {
        gst_object_unref (m_gstVolume);
        m_gstVolume = NULL;
    }

    GstBus *bus = gst_element_get_bus (m_gstPipeline);
    gst_bus_remove_signal_watch (bus);
    gst_object_unref (bus);

    gst_element_set_state (m_gstPipeline, GST_STATE_NULL);
    gst_object_unref (m_gstPipeline);
    m_gstPipeline = NULL;

#ifdef HAVE_LIBRESOURCEQT
   disconnect (resources,
               SIGNAL (resourcesGranted (QList<ResourcePolicy::ResourceType>)),
               this,
               SLOT (audioResourceAcquired ()));
   disconnect (resources,
               SIGNAL (lostResources ()),
               this,
               SLOT (audioResourceLost()));

    resources->release ();
#endif
}
コード例 #4
0
MediaPipeline::~MediaPipeline() throw()
{
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline) );
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  g_object_unref (pipeline);
}
コード例 #5
0
ファイル: main.c プロジェクト: jcaden/tee_test
static void
execute_test (int count)
{
  guint timeout_id;
  gchar *name = g_strdup_printf ("negotiation_test_%d", count);
  GstElement *pipeline = gst_pipeline_new (name);
  GstElement *audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *tee = gst_element_factory_make ("tee", "tee");
  GstElement *queue = gst_element_factory_make ("queue", NULL);
  GstElement *sink = gst_element_factory_make ("appsink", NULL);
  gint *branches, i;

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  g_free (name);

  if (bus == NULL) {
    GST_ERROR ("Bus is NULL");
    g_atomic_int_set (&error, 1);
    return;
  }

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_message), pipeline);

  g_object_set (G_OBJECT (sink), "emit-signals", TRUE, "sync", FALSE, NULL);
  g_signal_connect_data (G_OBJECT (sink), "new-sample", G_CALLBACK (new_sample),
      NULL, NULL, 0);

  branches = g_malloc0 (sizeof (gint));
  *branches = N_BRANCHES;
  g_object_set_data_full (G_OBJECT (pipeline), BRANCHES_COUNT_KEY, branches, g_free);
  GST_INFO ("Connecting %d branches", N_BRANCHES);

  for (i = 1; i < N_BRANCHES; i++) {
    g_timeout_add (500, connect_branch, pipeline);
  }

  gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, tee, queue, sink, NULL);
  gst_element_link_many (audiotestsrc, tee, queue, sink, NULL);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  timeout_id = g_timeout_add_seconds (35, timeout_check, pipeline);

  g_main_loop_run (loop);

  if (!g_source_remove (timeout_id)) {
    GST_ERROR ("Error removing source");
    g_atomic_int_set (&error, 1);
    return;
  }

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
}
コード例 #6
0
GST_END_TEST
GST_START_TEST (connection_of_elements_data)
{
  gchar *padname = NULL;
  KmsConnectData *data;
  GstBus *bus;

  data = kms_connect_data_create (MAX_CHECKS);
  data->data_probe = (KmsProbeType) data_probe_cb;
  data->audio_probe = (KmsProbeType) audio_probe_cb;
  data->video_probe = (KmsProbeType) video_probe_cb;

  /* Only tests data */
  data->video_checks = data->audio_checks = 0;

  loop = g_main_loop_new (NULL, TRUE);
  pipeline = gst_pipeline_new (__FUNCTION__);
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  data->src = gst_element_factory_make ("dummysrc", NULL);
  data->sink = gst_element_factory_make ("dummysink", NULL);
  g_signal_connect (data->src, "pad-added", G_CALLBACK (src_pads_added), data);
  g_signal_connect (data->sink, "pad-added",
      G_CALLBACK (sink_pads_added), data);

  g_signal_connect (data->sink, "pad-removed",
      G_CALLBACK (sink_pads_removed), data);

  gst_bin_add_many (GST_BIN (pipeline), data->src, data->sink, NULL);

  /* request src pad using action */
  g_signal_emit_by_name (data->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data->data_src);
  fail_if (data->data_src == NULL);

  GST_DEBUG ("Data pad name %s", data->data_src);

  g_object_set (G_OBJECT (data->src), "data", TRUE, NULL);
  g_object_set (G_OBJECT (data->sink), "data", TRUE, NULL);

  g_timeout_add_seconds (4, print_timedout_pipeline, NULL);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_free (padname);
  g_main_loop_unref (loop);
  kms_connect_data_destroy (data);
}
コード例 #7
0
AudioDestinationGStreamer::~AudioDestinationGStreamer()
{
    GRefPtr<GstBus> bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)));
    ASSERT(bus);
    g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
    gst_bus_remove_signal_watch(bus.get());

    gst_element_set_state(m_pipeline, GST_STATE_NULL);
    gst_object_unref(m_pipeline);
}
コード例 #8
0
GST_END_TEST
GST_START_TEST (reconnect_test)
{
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  GstElement *decoder = gst_element_factory_make ("vp8dec", NULL);
  GstElement *fakesink2 = gst_element_factory_make ("fakesink", NULL);
  gboolean ret;

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
  g_object_set (G_OBJECT (videotestsrc), "is-live", TRUE, NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (fakesink2), "sync", FALSE, "signal-handoffs", TRUE,
      NULL);
  g_signal_connect (G_OBJECT (fakesink2), "handoff",
      G_CALLBACK (fakesink_hand_off2), loop);
  g_object_set_data (G_OBJECT (fakesink2), DECODER_KEY, decoder);
  g_object_set_data (G_OBJECT (decoder), AGNOSTIC_KEY, agnosticbin);
  g_object_set_data (G_OBJECT (decoder), FAKESINK_KEY, fakesink2);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), videotestsrc, agnosticbin, fakesink,
      decoder, fakesink2, NULL);
  mark_point ();
  ret = gst_element_link_many (videotestsrc, agnosticbin, fakesink, NULL);
  fail_unless (ret);
  mark_point ();
  ret = gst_element_link_many (agnosticbin, decoder, fakesink2, NULL);
  fail_unless (ret);
  mark_point ();
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_timeout_add_seconds (10, timeout_check, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #9
0
GST_END_TEST
GST_START_TEST (encoded_input_link)
{
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *encoder = gst_element_factory_make ("vp8enc", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
  GstElement *filter = gst_element_factory_make ("capsfilter", NULL);
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  GstCaps *caps;
  gboolean ret;

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (fakesink), "sync", FALSE, "signal-handoffs", TRUE,
      NULL);
  g_signal_connect (G_OBJECT (fakesink), "handoff",
      G_CALLBACK (fakesink_hand_off), loop);

  caps = gst_caps_from_string ("video/x-raw");
  g_object_set (G_OBJECT (filter), "caps", caps, NULL);
  gst_caps_unref (caps);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), videotestsrc, encoder, agnosticbin,
      filter, fakesink, NULL);
  mark_point ();
  ret = gst_element_link_many (videotestsrc, encoder, agnosticbin, filter,
      fakesink, NULL);
  fail_unless (ret);
  mark_point ();
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_timeout_add_seconds (10, timeout_check, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #10
0
static void
play_agnosticbin_vp8_to_raw (void)
{
  gboolean ret;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *vp8enc = gst_element_factory_make ("vp8enc", NULL);
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  GstElement *capsfilter = gst_element_factory_make ("capsfilter", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);

  loop = g_main_loop_new (NULL, TRUE);
  GstCaps *caps;

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  mark_point ();
  g_object_set (G_OBJECT (videotestsrc), "num-buffers", 100, NULL);
  g_object_set (G_OBJECT (vp8enc), "keyframe-max-dist", 1, NULL);

  caps = gst_caps_new_empty_simple ("video/x-raw");
  g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
  gst_caps_unref (caps);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), videotestsrc, vp8enc, agnosticbin,
      capsfilter, fakesink, NULL);
  mark_point ();
  ret =
      gst_element_link_many (videotestsrc, vp8enc, agnosticbin, capsfilter,
      fakesink, NULL);
  fail_unless (ret);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "play_agnosticbin_vp8_to_raw_end");

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
}
コード例 #11
0
MediaPipelineImpl::~MediaPipelineImpl ()
{
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline) );

  if (busMessageHandler > 0) {
    unregister_signal_handler (bus, busMessageHandler);
  }

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  g_object_unref (pipeline);
}
コード例 #12
0
GST_END_TEST
GST_START_TEST (encoded_input_n_encoded_ouput)
{
  loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *encoder = gst_element_factory_make ("alawenc", NULL);
  GstElement *agnosticbin =
      gst_element_factory_make ("agnosticbin", "agnosticbin");
  gboolean ret;
  int *count, i;

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, encoder, agnosticbin,
      NULL);
  mark_point ();
  ret = gst_element_link_many (audiotestsrc, encoder, agnosticbin, NULL);
  fail_unless (ret);
  mark_point ();
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();

  count = g_malloc0 (sizeof (int));
  *count = N_ITERS;
  g_object_set_data_full (G_OBJECT (pipeline), COUNT_KEY, count, g_free);
  GST_INFO ("Connecting %d outputs", N_ITERS);

  g_timeout_add_seconds (6, timeout_check, pipeline);
  for (i = 0; i < N_ITERS; i++) {
    g_timeout_add (700, connect_output, pipeline);
  }

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #13
0
static void
kms_http_post_endpoint_finalize (GObject * object)
{
  KmsHttpPostEndpoint *self = KMS_HTTP_POST_ENDPOINT (object);

  if (self->priv->bus != NULL) {
    if (self->priv->handler_id > 0) {
      g_signal_handler_disconnect (self->priv->bus, self->priv->handler_id);
    }
    gst_bus_remove_signal_watch (self->priv->bus);
    g_object_unref (self->priv->bus);
  }

  G_OBJECT_CLASS (kms_http_post_endpoint_parent_class)->finalize (object);
}
コード例 #14
0
ファイル: agnosticbin.c プロジェクト: KennyDark/kms-core
static void
play_agnosticbin_raw_to_vorbis (void)
{
  gboolean ret;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);

  GstElement *audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *vorbisdec = gst_element_factory_make ("vorbisdec", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);

  loop = g_main_loop_new (NULL, TRUE);

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (audiotestsrc), "num-buffers", 100, "is-live", TRUE,
      NULL);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, agnosticbin, vorbisdec,
      fakesink, NULL);
  mark_point ();
  ret =
      gst_element_link_many (audiotestsrc, agnosticbin, vorbisdec, fakesink,
      NULL);
  fail_unless (ret);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  g_timeout_add_seconds (10, timeout_check, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, __FUNCTION__);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
}
コード例 #15
0
ファイル: gstbus.c プロジェクト: like0403/gstreamer
/**
 * gst_bus_poll:
 * @bus: a #GstBus
 * @events: a mask of #GstMessageType, representing the set of message types to
 * poll for (note special handling of extended message types below)
 * @timeout: the poll timeout, as a #GstClockTime, or #GST_CLOCK_TIME_NONE to poll
 * indefinitely.
 *
 * Poll the bus for messages. Will block while waiting for messages to come.
 * You can specify a maximum time to poll with the @timeout parameter. If
 * @timeout is negative, this function will block indefinitely.
 *
 * All messages not in @events will be popped off the bus and will be ignored.
 * It is not possible to use message enums beyond #GST_MESSAGE_EXTENDED in the
 * @events mask
 *
 * Because poll is implemented using the "message" signal enabled by
 * gst_bus_add_signal_watch(), calling gst_bus_poll() will cause the "message"
 * signal to be emitted for every message that poll sees. Thus a "message"
 * signal handler will see the same messages that this function sees -- neither
 * will steal messages from the other.
 *
 * This function will run a main loop from the default main context when
 * polling.
 *
 * You should never use this function, since it is pure evil. This is
 * especially true for GUI applications based on Gtk+ or Qt, but also for any
 * other non-trivial application that uses the GLib main loop. As this function
 * runs a GLib main loop, any callback attached to the default GLib main
 * context may be invoked. This could be timeouts, GUI events, I/O events etc.;
 * even if gst_bus_poll() is called with a 0 timeout. Any of these callbacks
 * may do things you do not expect, e.g. destroy the main application window or
 * some other resource; change other application state; display a dialog and
 * run another main loop until the user clicks it away. In short, using this
 * function may add a lot of complexity to your code through unexpected
 * re-entrancy and unexpected changes to your application's state.
 *
 * For 0 timeouts use gst_bus_pop_filtered() instead of this function; for
 * other short timeouts use gst_bus_timed_pop_filtered(); everything else is
 * better handled by setting up an asynchronous bus watch and doing things
 * from there.
 *
 * Returns: (transfer full) (nullable): the message that was received,
 *     or %NULL if the poll timed out. The message is taken from the
 *     bus and needs to be unreffed with gst_message_unref() after
 *     usage.
 */
GstMessage *
gst_bus_poll (GstBus * bus, GstMessageType events, GstClockTime timeout)
{
  GstBusPollData *poll_data;
  GstMessage *ret;
  gulong id;

  g_return_val_if_fail (GST_IS_BUS (bus), NULL);

  poll_data = g_slice_new (GstBusPollData);
  poll_data->source_running = TRUE;
  poll_data->loop = g_main_loop_new (NULL, FALSE);
  poll_data->events = events;
  poll_data->message = NULL;

  if (timeout != GST_CLOCK_TIME_NONE)
    poll_data->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
        timeout / GST_MSECOND, (GSourceFunc) poll_timeout, poll_data,
        (GDestroyNotify) poll_destroy_timeout);
  else
    poll_data->timeout_id = 0;

  id = g_signal_connect_data (bus, "message", G_CALLBACK (poll_func), poll_data,
      (GClosureNotify) poll_destroy, 0);

  /* these can be nested, so it's ok */
  gst_bus_add_signal_watch (bus);

  GST_DEBUG ("running mainloop %p", poll_data->loop);
  g_main_loop_run (poll_data->loop);
  GST_DEBUG ("mainloop stopped %p", poll_data->loop);

  gst_bus_remove_signal_watch (bus);

  /* holds a ref */
  ret = poll_data->message;

  if (poll_data->timeout_id)
    g_source_remove (poll_data->timeout_id);

  /* poll_data will be freed now */
  g_signal_handler_disconnect (bus, id);

  GST_DEBUG_OBJECT (bus, "finished poll with message %p", ret);

  return ret;
}
コード例 #16
0
GST_END_TEST
GST_START_TEST (encoded_input_to_valve)
{
  loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *encoder = gst_element_factory_make ("alawenc", NULL);
  GstElement *valve = gst_element_factory_make ("valve", "valve");
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  gboolean ret;

  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (valve), "drop", TRUE, NULL);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, encoder, agnosticbin,
      valve, NULL);
  mark_point ();
  ret = gst_element_link_many (audiotestsrc, encoder, agnosticbin, valve, NULL);
  fail_unless (ret);
  mark_point ();
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_timeout_add_seconds (6, timeout_check, pipeline);
  g_timeout_add (700, connect_appsink, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #17
0
gboolean
check_run_main_loop_until_msg_or_error (BtSong * song, const gchar * msg)
{
  GstStateChangeReturn sret;
  GstState state, pending;

  GMainLoop *main_loop = g_main_loop_new (NULL, FALSE);
  GstElement *bin =
      (GstElement *) check_gobject_get_object_property (song, "bin");
  GstBus *bus = gst_element_get_bus (bin);
  gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
  g_signal_connect (bus, "message::error", G_CALLBACK (_check_message_received),
      (gpointer) main_loop);
  g_signal_connect (bus, msg,
      G_CALLBACK (_check_message_received), (gpointer) main_loop);

  _check_run_main_loop_error = FALSE;
  sret = gst_element_get_state (bin, &state, &pending, G_GUINT64_CONSTANT (0));

  // be careful to not run this when the song already finished
  if (sret != GST_STATE_CHANGE_FAILURE) {
    GST_INFO_OBJECT (song, "running main_loop: sret=%s, state=%s/%s",
        gst_element_state_change_return_get_name (sret),
        gst_element_state_get_name (state),
        gst_element_state_get_name (pending));
    g_main_loop_run (main_loop);
  } else {
    GST_INFO_OBJECT (song, "skipping main_loop: sret=%s, state=%s/%s",
        gst_element_state_change_return_get_name (sret),
        gst_element_state_get_name (state),
        gst_element_state_get_name (pending));
  }
  gst_bus_remove_signal_watch (bus);
  g_signal_handlers_disconnect_matched (bus, G_SIGNAL_MATCH_DATA, 0, 0, NULL,
      NULL, (gpointer) main_loop);
  gst_object_unref (bus);
  gst_object_unref (bin);
  g_main_loop_unref (main_loop);
  GST_INFO_OBJECT (song, "finished main_loop");
  return sret == GST_STATE_CHANGE_FAILURE ? FALSE : !_check_run_main_loop_error;
}
コード例 #18
0
GST_END_TEST
GST_START_TEST (request_audio_src_pad_pending)
{
  GstElement *dummysrc;
  gchar *padname = NULL;
  GstBus *bus;

  loop = g_main_loop_new (NULL, TRUE);
  pipeline = gst_pipeline_new (__FUNCTION__);
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  dummysrc = gst_element_factory_make ("dummysrc", NULL);
  g_signal_connect (dummysrc, "pad-added", G_CALLBACK (pad_added_delayed),
      &padname);

  gst_bin_add (GST_BIN (pipeline), dummysrc);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* request src pad using action */
  g_signal_emit_by_name (dummysrc, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_AUDIO, NULL, GST_PAD_SRC, &padname);
  fail_if (padname == NULL);

  GST_DEBUG ("Pad name %s", padname);
  g_object_set (G_OBJECT (dummysrc), "audio", TRUE, NULL);

  g_free (padname);

  g_timeout_add_seconds (4, print_timedout_pipeline, NULL);
  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #19
0
GST_END_TEST
GST_START_TEST (add_later)
{
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *videosrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *typefind = gst_element_factory_make ("typefind", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", "fakesink");
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (fakesink), "sync", FALSE, "signal-handoffs", TRUE,
      NULL);
  g_signal_connect (G_OBJECT (fakesink), "handoff",
      G_CALLBACK (fakesink_hand_off), loop);

  g_signal_connect (G_OBJECT (typefind), "have-type", G_CALLBACK (type_found),
      pipeline);

  gst_bin_add_many (GST_BIN (pipeline), videosrc, typefind, fakesink, NULL);
  gst_element_link (videosrc, typefind);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  g_timeout_add_seconds (10, timeout_check, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (pipeline);
  g_object_unref (bus);
  g_main_loop_unref (loop);
}
コード例 #20
0
static void
play_agnosticbin_video_passthrough (void)
{
  gboolean ret;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);

  loop = g_main_loop_new (NULL, TRUE);

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (videotestsrc), "num-buffers", 100, NULL);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), videotestsrc, agnosticbin, fakesink,
      NULL);
  mark_point ();
  ret = gst_element_link_many (videotestsrc, agnosticbin, fakesink, NULL);
  fail_unless (ret);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
}
コード例 #21
0
static void
start_playerendpoint (void)
{
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *playerendpoint =
      gst_element_factory_make ("playerendpoint", NULL);
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);

  g_object_set (G_OBJECT (pipeline), "async-handling", TRUE, NULL);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_signal_connect (G_OBJECT (playerendpoint), "eos",
      G_CALLBACK (playerendpoint_eos), loop);
  g_object_set (G_OBJECT (playerendpoint), "uri",
      "http://ci.kurento.com/downloads/small.webm", NULL);

  gst_bin_add (GST_BIN (pipeline), playerendpoint);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  mark_point ();
  g_object_set (G_OBJECT (playerendpoint), "state",
      KMS_URI_END_POINT_STATE_START, NULL);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
}
コード例 #22
0
GST_END_TEST
GST_START_TEST (delay_stream)
{
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstElement *agnosticbin =
      gst_element_factory_make ("agnosticbin", "agnosticbin");
  GstElement *fakesink = gst_element_factory_make ("fakesink", NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (fakesink), "async", FALSE, "sync", FALSE,
      "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink), "handoff",
      G_CALLBACK (fakesink_hand_off), loop);

  gst_bin_add_many (GST_BIN (pipeline), agnosticbin, fakesink, NULL);
  gst_element_link (agnosticbin, fakesink);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  g_timeout_add_seconds (1, link_source, pipeline);
  g_timeout_add_seconds (11, timeout_check, pipeline);

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (pipeline);
  g_object_unref (bus);
  g_main_loop_unref (loop);
}
コード例 #23
0
ファイル: videoscale.c プロジェクト: tezet/gst-plugins-base
static void
_test_negotiation (const gchar * src_templ, const gchar * sink_templ,
    gint width, gint height, gint par_n, gint par_d)
{
  GstElement *pipeline;
  GstElement *src, *capsfilter1, *scale, *capsfilter2, *sink;
  GstBus *bus;
  GMainLoop *loop;
  GstCaps *caps;
  TestNegotiationData data = { 0, 0, 0, 0, FALSE, NULL };
  GstPad *pad;

  GST_DEBUG ("Running test for src templ caps '%s' and sink templ caps '%s'",
      src_templ, sink_templ);

  pipeline = gst_element_factory_make ("pipeline", "pipeline");
  fail_unless (pipeline != NULL);

  src = gst_element_factory_make ("videotestsrc", "src");
  fail_unless (src != NULL);
  g_object_set (G_OBJECT (src), "num-buffers", 1, NULL);

  capsfilter1 = gst_element_factory_make ("capsfilter", "filter1");
  fail_unless (capsfilter1 != NULL);
  caps = gst_caps_from_string (src_templ);
  fail_unless (caps != NULL);
  g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
  gst_caps_unref (caps);

  scale = gst_element_factory_make ("videoscale", "scale");
  fail_unless (scale != NULL);

  capsfilter2 = gst_element_factory_make ("capsfilter", "filter2");
  fail_unless (capsfilter2 != NULL);
  caps = gst_caps_from_string (sink_templ);
  fail_unless (caps != NULL);
  g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
  gst_caps_unref (caps);

  pad = gst_element_get_static_pad (capsfilter2, "sink");
  fail_unless (pad != NULL);
  g_signal_connect (pad, "notify::caps",
      G_CALLBACK (_test_negotiation_notify_caps), &data);
  gst_object_unref (pad);

  sink = gst_element_factory_make ("fakesink", "sink");
  fail_unless (sink != NULL);
  g_object_set (sink, "async", FALSE, NULL);

  gst_bin_add_many (GST_BIN (pipeline), src, capsfilter1, scale, capsfilter2,
      sink, NULL);

  fail_unless (gst_element_link_pads_full (src, "src", capsfilter1, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter1, "src", scale, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (scale, "src", capsfilter2, "sink",
          LINK_CHECK_FLAGS));
  fail_unless (gst_element_link_pads_full (capsfilter2, "src", sink, "sink",
          LINK_CHECK_FLAGS));

  loop = g_main_loop_new (NULL, FALSE);

  bus = gst_element_get_bus (pipeline);
  fail_unless (bus != NULL);
  gst_bus_add_signal_watch (bus);

  data.loop = loop;
  data.width = width;
  data.height = height;
  data.par_n = par_n;
  data.par_d = par_d;
  data.ok = FALSE;

  g_signal_connect (bus, "message", G_CALLBACK (_test_negotiation_message),
      &data);

  gst_bus_remove_signal_watch (bus);
  gst_object_unref (bus);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS);

  g_main_loop_run (loop);

  fail_unless (data.ok == TRUE);

  fail_unless (gst_element_set_state (pipeline,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);

  gst_object_unref (pipeline);
  g_main_loop_unref (loop);
}
コード例 #24
0
ファイル: test-utils.c プロジェクト: cfoch/ges
gboolean
ges_generate_test_file_audio_video (const gchar * filedest,
    const gchar * audio_enc,
    const gchar * video_enc,
    const gchar * mux, const gchar * video_pattern, const gchar * audio_wave)
{
  GError *error = NULL;
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *message;
  gchar *pipeline_str;
  gboolean done = FALSE;
  gboolean ret = FALSE;

  if (g_file_test (filedest, G_FILE_TEST_EXISTS)) {
    GST_INFO ("The file %s already existed.", filedest);
    return TRUE;
  }

  pipeline_str = g_strdup_printf ("audiotestsrc num-buffers=430 wave=%s "
      "%c %s ! %s name=m ! filesink location= %s/%s "
      "videotestsrc pattern=%s num-buffers=300 ! %s ! m.",
      audio_wave,
      audio_enc ? '!' : ' ',
      audio_enc ? audio_enc : "",
      mux, g_get_current_dir (), filedest, video_pattern, video_enc);

  pipeline = gst_parse_launch (pipeline_str, &error);

  if (pipeline == NULL)
    return FALSE;

  g_free (pipeline_str);

  bus = gst_element_get_bus (GST_ELEMENT (pipeline));
  gst_bus_add_signal_watch (bus);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  while (!done) {
    message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_CLOCK_TIME_NONE);
    if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EOS) {
      done = TRUE;
      ret = TRUE;
    } else if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
      gchar *debug = NULL;
      GError *err = NULL;

      gst_message_parse_error (message, &err, &debug);
      done = TRUE;
      ret = FALSE;
      GST_ERROR ("Got error %s from %s fron the bus while generation: %s"
          "debug infos: %s", GST_OBJECT_NAME (message->src), err->message,
          debug ? debug : "none", filedest);
      g_clear_error (&err);
      g_free (debug);
    }
  }

  gst_bus_remove_signal_watch (bus);
  gst_object_unref (bus);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);

  return ret;
}
コード例 #25
0
ファイル: dtls.c プロジェクト: TribeMedia/kms-elements
GST_END_TEST
/* Temporaly disabled */
#if 0
GST_START_TEST (test_dtls_send_recv_data)
{
  gchar *cert_key_pem_file;
  GTlsConnection *conn;

  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstElement *pipeline = gst_pipeline_new (__FUNCTION__);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  GstElement *fakesrc_client = gst_element_factory_make ("fakesrc", NULL);
  GstElement *dtlsenc_client = gst_element_factory_make ("kmsdtlsenc", NULL);
  GstElement *dtlsdec_client = gst_element_factory_make ("kmsdtlsdec", NULL);
  GstElement *fakesink_client = gst_element_factory_make ("fakesink", NULL);

  GstElement *fakesrc_server = gst_element_factory_make ("fakesrc", NULL);
  GstElement *dtlsenc_server = gst_element_factory_make ("kmsdtlsenc", NULL);
  GstElement *dtlsdec_server = gst_element_factory_make ("kmsdtlsdec", NULL);
  GstElement *fakesink_server = gst_element_factory_make ("fakesink", NULL);

  cert_key_pem_file = generate_certkey_pem_file_path ();
  generate_certkey_pem_file (cert_key_pem_file);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  g_object_set (G_OBJECT (fakesink_client), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_client), "handoff",
      G_CALLBACK (fakesink_dtls_client_hand_off), loop);
  g_object_set (G_OBJECT (fakesink_server), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_server), "handoff",
      G_CALLBACK (fakesink_dtls_server_hand_off), loop);

  g_object_set (G_OBJECT (fakesrc_client), "sizetype", 2, NULL);
  g_object_set (G_OBJECT (fakesrc_server), "sizetype", 2, NULL);

  g_object_set (G_OBJECT (dtlsenc_client), "channel-id", "client-id", NULL);
  g_object_set (G_OBJECT (dtlsenc_client), "is-client", TRUE, NULL);
  g_object_set (G_OBJECT (dtlsdec_client), "channel-id", "client-id", NULL);
  g_object_set (G_OBJECT (dtlsdec_client), "is-client", TRUE, NULL);
  g_object_set (G_OBJECT (dtlsdec_client), "certificate-pem-file",
      cert_key_pem_file, NULL);

  g_object_set (G_OBJECT (dtlsenc_server), "channel-id", "server-id", NULL);
  g_object_set (G_OBJECT (dtlsenc_server), "is-client", FALSE, NULL);
  g_object_set (G_OBJECT (dtlsdec_server), "channel-id", "server-id", NULL);
  g_object_set (G_OBJECT (dtlsdec_server), "is-client", FALSE, NULL);
  g_object_set (G_OBJECT (dtlsdec_server), "certificate-pem-file",
      cert_key_pem_file, NULL);

  mark_point ();
  gst_bin_add_many (GST_BIN (pipeline), fakesrc_client, dtlsdec_client,
      dtlsenc_client, fakesink_client, NULL);
  gst_bin_add_many (GST_BIN (pipeline), fakesrc_server, dtlsdec_server,
      dtlsenc_server, fakesink_server, NULL);
  mark_point ();

  gst_element_link_many (fakesrc_client, dtlsenc_client, dtlsdec_server,
      fakesink_server, NULL);
  gst_element_link_many (fakesrc_server, dtlsenc_server, dtlsdec_client,
      fakesink_client, NULL);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "dtls_before_playing");

  gst_element_set_state (fakesink_server, GST_STATE_PLAYING);
  gst_element_set_state (dtlsdec_server, GST_STATE_PLAYING);
  gst_element_set_state (dtlsenc_client, GST_STATE_PLAYING);
  gst_element_set_state (fakesrc_client, GST_STATE_PLAYING);

  gst_element_set_state (fakesink_client, GST_STATE_PLAYING);
  gst_element_set_state (dtlsdec_client, GST_STATE_PLAYING);
  gst_element_set_state (dtlsenc_server, GST_STATE_PLAYING);
  gst_element_set_state (fakesrc_server, GST_STATE_PLAYING);

  /* Init DTLS handshake over dtlsenc connection */
  g_object_get (dtlsenc_client, "tls-connection", &conn, NULL);
  g_tls_connection_handshake_async (conn, G_PRIORITY_DEFAULT, NULL, NULL, NULL);

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "dtls_before_entering_loop");

  g_main_loop_run (loop);

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "dtls_end");

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_main_loop_unref (loop);

  g_remove (cert_key_pem_file);
  g_free (cert_key_pem_file);
}
コード例 #26
0
/*
 * Create a demux element, run a test using the input data and check
 * the output data
 */
void
gst_adaptive_demux_test_run (const gchar * element_name,
    const gchar * manifest_uri,
    const GstAdaptiveDemuxTestCallbacks * callbacks, gpointer user_data)
{
  GstBus *bus;
  GstElement *demux;
  GstElement *manifest_source;
  gboolean ret;
  GstStateChangeReturn stateChange;
  GstAdaptiveDemuxTestEnginePrivate *priv;

  priv = g_slice_new0 (GstAdaptiveDemuxTestEnginePrivate);
  priv->engine.output_streams =
      g_ptr_array_new_with_free_func
      (adaptive_demux_engine_stream_state_finalize);
  g_mutex_init (&priv->engine.lock);
  priv->callbacks = callbacks;
  priv->user_data = user_data;
  priv->engine.loop = g_main_loop_new (NULL, TRUE);
  fail_unless (priv->engine.loop != NULL);
  GST_TEST_LOCK (priv);
  priv->engine.pipeline = gst_pipeline_new ("pipeline");
  fail_unless (priv->engine.pipeline != NULL);
  GST_DEBUG ("created pipeline %" GST_PTR_FORMAT, priv->engine.pipeline);

  /* register a callback to listen for error messages */
  bus = gst_pipeline_get_bus (GST_PIPELINE (priv->engine.pipeline));
  gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
  g_signal_connect (bus, "message::error",
      G_CALLBACK (on_ErrorMessageOnBus), priv);

  manifest_source =
      gst_element_make_from_uri (GST_URI_SRC, manifest_uri, NULL, NULL);
  fail_unless (manifest_source != NULL);
  priv->engine.manifest_source = manifest_source;

  demux = gst_check_setup_element (element_name);
  fail_unless (demux != NULL);
  priv->engine.demux = demux;
  GST_DEBUG ("created demux %" GST_PTR_FORMAT, demux);

  g_signal_connect (demux, "element-added", G_CALLBACK (on_demuxElementAdded),
      priv);
  g_signal_connect (demux, "pad-added", G_CALLBACK (on_demuxNewPad), priv);
  g_signal_connect (demux, "pad-removed",
      G_CALLBACK (on_demuxPadRemoved), priv);

  gst_bin_add_many (GST_BIN (priv->engine.pipeline), manifest_source, demux,
      NULL);
  ASSERT_OBJECT_REFCOUNT (manifest_source, element_name, 1);
  ASSERT_OBJECT_REFCOUNT (demux, element_name, 1);

  ret = gst_element_link (manifest_source, demux);
  fail_unless_equals_int (ret, TRUE);

  priv->engine.clock = gst_system_clock_obtain ();
  if (GST_IS_TEST_CLOCK (priv->engine.clock)) {
    /*
     * live tests will want to manipulate the clock, so they will register a
     * gst_test_clock as the system clock.
     * The on demand tests do not care about the clock, so they will let the
     * system clock to the default one.
     * If a gst_test_clock was installed as system clock, we register a
     * periodic callback to update its value.
     */
    priv->clock_update_id =
        g_timeout_add (100, gst_adaptive_demux_update_test_clock, priv);
  }

  /* call a test callback before we start the pipeline */
  if (callbacks->pre_test)
    (*callbacks->pre_test) (&priv->engine, priv->user_data);

  GST_TEST_UNLOCK (priv);

  GST_DEBUG ("Starting pipeline");
  stateChange = gst_element_set_state (priv->engine.pipeline, GST_STATE_PAUSED);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);
  /* wait for completion of the move to PAUSED */
  stateChange = gst_element_get_state (priv->engine.pipeline, NULL, NULL,
      GST_CLOCK_TIME_NONE);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);

  g_idle_add ((GSourceFunc) start_pipeline_playing, priv);

  /* block until a callback calls g_main_loop_quit (engine.loop) */
  GST_DEBUG ("main thread waiting for streams to finish");
  g_main_loop_run (priv->engine.loop);
  GST_DEBUG ("main thread finished. Stopping pipeline");

  /* no need to use gst_element_get_state as the move the GST_STATE_NULL
     is always synchronous */
  stateChange = gst_element_set_state (priv->engine.pipeline, GST_STATE_NULL);
  fail_unless (stateChange != GST_STATE_CHANGE_FAILURE);

  GST_TEST_LOCK (priv);

  /* call a test callback after the stop of the pipeline */
  if (callbacks->post_test)
    (*callbacks->post_test) (&priv->engine, priv->user_data);

  g_signal_handlers_disconnect_by_func (bus,
      G_CALLBACK (on_ErrorMessageOnBus), priv);
  gst_bus_remove_signal_watch (bus);
  g_signal_handlers_disconnect_by_func (demux, G_CALLBACK (on_demuxNewPad),
      priv);
  g_signal_handlers_disconnect_by_func (demux, G_CALLBACK (on_demuxPadRemoved),
      priv);

  GST_DEBUG ("main thread pipeline stopped");
  if (priv->clock_update_id != 0)
    g_source_remove (priv->clock_update_id);
  gst_object_unref (priv->engine.clock);
  gst_object_unref (priv->engine.pipeline);
  priv->engine.pipeline = NULL;
  g_main_loop_unref (priv->engine.loop);
  g_ptr_array_unref (priv->engine.output_streams);
  gst_object_unref (bus);

  GST_TEST_UNLOCK (priv);
  g_mutex_clear (&priv->engine.lock);
  g_slice_free (GstAdaptiveDemuxTestEnginePrivate, priv);
}
コード例 #27
0
GST_END_TEST
GST_START_TEST (connect_chain_of_elements)
{
  gchar *padname = NULL;
  KmsConnectData *data1, *data2;
  gchar *filter_factory;
  GstBus *bus;

  loop = g_main_loop_new (NULL, TRUE);
  pipeline = gst_pipeline_new (__FUNCTION__);
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  data1 = kms_connect_data_create (0);
  data2 = kms_connect_data_create (MAX_CHECKS);
  data2->data_probe = (KmsProbeType) data_probe_cb;
  data2->audio_probe = (KmsProbeType) audio_probe_cb;
  data2->video_probe = (KmsProbeType) video_probe_cb;

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  data1->src = gst_element_factory_make ("dummysrc", NULL);
  data1->sink = gst_element_factory_make ("filterelement", NULL);

  data2->src = data1->sink;
  data2->sink = gst_element_factory_make ("dummysink", NULL);

  g_signal_connect (data1->src, "pad-added", G_CALLBACK (src_pads_added),
      data1);
  g_signal_connect (data1->sink, "pad-added", G_CALLBACK (sink_pads_added),
      data1);

  g_signal_connect (data2->src, "pad-added", G_CALLBACK (src_pads_added),
      data2);
  g_signal_connect (data2->sink, "pad-added", G_CALLBACK (sink_pads_added),
      data2);
  g_signal_connect (data2->sink, "pad-removed", G_CALLBACK (sink_pads_removed),
      data2);

  gst_bin_add_many (GST_BIN (pipeline), data1->src, data1->sink, data2->sink,
      NULL);

  /*******************************/
  /* Connect dummysrc to filter  */
  /*******************************/

  /* request src pad using action */
  g_signal_emit_by_name (data1->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_VIDEO, NULL, GST_PAD_SRC, &data1->video_src);
  fail_if (data1->video_src == NULL);
  g_signal_emit_by_name (data1->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_AUDIO, NULL, GST_PAD_SRC, &data1->audio_src);
  fail_if (data1->audio_src == NULL);
  g_signal_emit_by_name (data1->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data1->data_src);
  fail_if (data1->data_src == NULL);

  GST_DEBUG ("Video pad name %s", data1->video_src);
  GST_DEBUG ("Audio pad name %s", data1->audio_src);
  GST_DEBUG ("Data pad name %s", data1->data_src);

  filter_factory = "videoflip";
  GST_DEBUG ("Setting property uri to : %s", filter_factory);
  g_object_set (G_OBJECT (data1->sink), "filter_factory", filter_factory, NULL);

  g_object_set (G_OBJECT (data1->src), "video", TRUE, "audio", TRUE, "data",
      TRUE, NULL);

  /*******************************/
  /* Connect filter to dummysink */
  /*******************************/

  /* request src pad using action */
  g_signal_emit_by_name (data2->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_VIDEO, NULL, GST_PAD_SRC, &data2->video_src);
  fail_if (data2->video_src == NULL);
  g_signal_emit_by_name (data2->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_AUDIO, NULL, GST_PAD_SRC, &data2->audio_src);
  fail_if (data2->audio_src == NULL);
  g_signal_emit_by_name (data2->src, "request-new-pad",
      KMS_ELEMENT_PAD_TYPE_DATA, NULL, GST_PAD_SRC, &data2->data_src);
  fail_if (data2->data_src == NULL);

  GST_DEBUG ("Video pad name %s", data2->video_src);
  GST_DEBUG ("Audio pad name %s", data2->audio_src);
  GST_DEBUG ("Data pad name %s", data2->data_src);

  g_object_set (G_OBJECT (data2->sink), "video", TRUE, "audio", TRUE, "data",
      TRUE, NULL);

  g_timeout_add_seconds (4, print_timedout_pipeline, NULL);

  gst_element_sync_state_with_parent (data1->src);
  gst_element_sync_state_with_parent (data1->sink);
  gst_element_sync_state_with_parent (data2->sink);

  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_object_unref (pipeline);
  g_free (padname);
  g_main_loop_unref (loop);
  kms_connect_data_destroy (data1);
  kms_connect_data_destroy (data2);
}
コード例 #28
0
static void
test_audio_sendrecv (const gchar * audio_enc_name,
    GstStaticCaps expected_caps, gchar * codec)
{
  GArray *codecs_array;
  gchar *codecs[] = { codec, NULL };
  HandOffData *hod;
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstSDPMessage *offer, *answer;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *audiotestsrc_offerer =
      gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *audiotestsrc_answerer =
      gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *audio_enc_offerer =
      gst_element_factory_make (audio_enc_name, NULL);
  GstElement *audio_enc_answerer =
      gst_element_factory_make (audio_enc_name, NULL);
  GstElement *rtpendpoint_offerer =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *rtpendpoint_answerer =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *fakesink_offerer = gst_element_factory_make ("fakesink", NULL);
  GstElement *fakesink_answerer = gst_element_factory_make ("fakesink", NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  codecs_array = create_codecs_array (codecs);
  g_object_set (rtpendpoint_offerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (codecs_array), NULL);
  g_object_set (rtpendpoint_answerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (codecs_array), NULL);
  g_array_unref (codecs_array);

  hod = g_slice_new (HandOffData);
  hod->expected_caps = expected_caps;
  hod->loop = loop;

  g_object_set (G_OBJECT (fakesink_offerer), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_offerer), "handoff",
      G_CALLBACK (sendrecv_offerer_fakesink_hand_off), hod);
  g_object_set (G_OBJECT (fakesink_answerer), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_answerer), "handoff",
      G_CALLBACK (sendrecv_answerer_fakesink_hand_off), hod);

  /* Add elements */
  gst_bin_add (GST_BIN (pipeline), rtpendpoint_offerer);
  connect_sink_async (rtpendpoint_offerer, audiotestsrc_offerer,
      audio_enc_offerer, NULL, pipeline, "sink_audio");

  gst_bin_add (GST_BIN (pipeline), rtpendpoint_answerer);
  connect_sink_async (rtpendpoint_answerer, audiotestsrc_answerer,
      audio_enc_answerer, NULL, pipeline, "sink_audio");

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* SDP negotiation */
  mark_point ();
  g_signal_emit_by_name (rtpendpoint_offerer, "generate-offer", &offer);
  fail_unless (offer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpoint_answerer, "process-offer", offer, &answer);
  fail_unless (answer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpoint_offerer, "process-answer", answer);
  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  gst_bin_add (GST_BIN (pipeline), fakesink_offerer);
  g_object_set_data (G_OBJECT (rtpendpoint_offerer), AUDIO_SINK,
      fakesink_offerer);
  g_signal_connect (rtpendpoint_offerer, "pad-added",
      G_CALLBACK (connect_sink_on_srcpad_added), NULL);
  fail_unless (kms_element_request_srcpad (rtpendpoint_offerer,
          KMS_ELEMENT_PAD_TYPE_AUDIO));

  gst_bin_add (GST_BIN (pipeline), fakesink_answerer);
  g_object_set_data (G_OBJECT (rtpendpoint_answerer), AUDIO_SINK,
      fakesink_answerer);
  g_signal_connect (rtpendpoint_answerer, "pad-added",
      G_CALLBACK (connect_sink_on_srcpad_added), NULL);
  fail_unless (kms_element_request_srcpad (rtpendpoint_answerer,
          KMS_ELEMENT_PAD_TYPE_AUDIO));

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_audio_sendrecv_before_entering_loop");

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_audio_sendrecv_end");

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
  g_slice_free (HandOffData, hod);
}