Exemplo n.º 1
0
/**
 * gst_ghost_pad_set_target:
 * @gpad: the #GstGhostPad
 * @newtarget: (transfer none) (allow-none): the new pad target
 *
 * Set the new target of the ghostpad @gpad. Any existing target
 * is unlinked and links to the new target are established. if @newtarget is
 * %NULL the target will be cleared.
 *
 * Returns: (transfer full): %TRUE if the new target could be set. This function
 *     can return %FALSE when the internal pads could not be linked.
 */
gboolean
gst_ghost_pad_set_target (GstGhostPad * gpad, GstPad * newtarget)
{
    GstPad *internal;
    GstPad *oldtarget;
    GstPadLinkReturn lret;

    g_return_val_if_fail (GST_IS_GHOST_PAD (gpad), FALSE);
    g_return_val_if_fail (GST_PAD_CAST (gpad) != newtarget, FALSE);
    g_return_val_if_fail (newtarget != GST_PROXY_PAD_INTERNAL (gpad), FALSE);

    GST_OBJECT_LOCK (gpad);
    internal = GST_PROXY_PAD_INTERNAL (gpad);

    if (newtarget)
        GST_DEBUG_OBJECT (gpad, "set target %s:%s", GST_DEBUG_PAD_NAME (newtarget));
    else
        GST_DEBUG_OBJECT (gpad, "clearing target");

    /* clear old target */
    if ((oldtarget = gst_pad_get_peer (internal))) {
        GST_OBJECT_UNLOCK (gpad);

        /* unlink internal pad */
        if (GST_PAD_IS_SRC (internal))
            gst_pad_unlink (internal, oldtarget);
        else
            gst_pad_unlink (oldtarget, internal);

        gst_object_unref (oldtarget);
    } else {
        GST_OBJECT_UNLOCK (gpad);
    }

    if (newtarget) {
        /* and link to internal pad without any checks */
        GST_DEBUG_OBJECT (gpad, "connecting internal pad to target %"
                          GST_PTR_FORMAT, newtarget);

        if (GST_PAD_IS_SRC (internal))
            lret =
                gst_pad_link_full (internal, newtarget, GST_PAD_LINK_CHECK_NOTHING);
        else
            lret =
                gst_pad_link_full (newtarget, internal, GST_PAD_LINK_CHECK_NOTHING);

        if (lret != GST_PAD_LINK_OK)
            goto link_failed;
    }

    return TRUE;

    /* ERRORS */
link_failed:
    {
        GST_WARNING_OBJECT (gpad, "could not link internal and target, reason:%s",
                            gst_pad_link_get_name (lret));
        return FALSE;
    }
}
Exemplo n.º 2
0
static void
kms_base_rtp_session_link_pads (GstPad * src, GstPad * sink)
{
  GstPadLinkReturn ret;

  ret = gst_pad_link_full (src, sink, GST_PAD_LINK_CHECK_CAPS);
  if (ret != GST_PAD_LINK_OK) {
    GST_ERROR ("Error linking pads (src: %" GST_PTR_FORMAT ", sink: %"
        GST_PTR_FORMAT "), ret: '%s'", src, sink, gst_pad_link_get_name (ret));
  }
}
Exemplo n.º 3
0
static void
_check_media_info (GstSegment * segment, BufferDesc * bufs)
{
  GList *reports;
  GstEvent *segev;
  GstBuffer *buffer;
  GstElement *decoder;
  GstPad *srcpad, *sinkpad;
  GstValidateReport *report;
  GstValidateMonitor *monitor;
  GstValidateRunner *runner;
  GstMediaDescriptor *mdesc;

  GError *err = NULL;
  gint i, num_issues = 0;

  fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE));
  runner = gst_validate_runner_new ();

  mdesc = (GstMediaDescriptor *)
      gst_media_descriptor_parser_new_from_xml (runner, media_info, &err);

  decoder = fake_decoder_new ();
  monitor = gst_validate_monitor_factory_create (GST_OBJECT (decoder),
      runner, NULL);
  gst_validate_monitor_set_media_descriptor (monitor, mdesc);

  srcpad = gst_pad_new ("src", GST_PAD_SRC);
  sinkpad = decoder->sinkpads->data;
  ASSERT_OBJECT_REFCOUNT (sinkpad, "decoder ref", 1);
  fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE));
  fail_unless_equals_int (gst_element_set_state (decoder, GST_STATE_PLAYING),
      GST_STATE_CHANGE_SUCCESS);

  assert_equals_string (gst_pad_link_get_name (gst_pad_link (srcpad, sinkpad)),
      gst_pad_link_get_name (GST_PAD_LINK_OK));

  gst_check_setup_events_with_stream_id (srcpad, decoder,
      gst_caps_from_string ("video/x-fake"), GST_FORMAT_TIME, "the-stream");


  if (segment) {
    segev = gst_event_new_segment (segment);
    fail_unless (gst_pad_push_event (srcpad, segev));
  }

  for (i = 0; bufs[i].content != NULL; i++) {
    BufferDesc *buf = &bufs[i];
    buffer = _create_buffer (buf);

    assert_equals_string (gst_flow_get_name (gst_pad_push (srcpad, buffer)),
        gst_flow_get_name (GST_FLOW_OK));
    reports = gst_validate_runner_get_reports (runner);

    num_issues += buf->num_issues;
    assert_equals_int (g_list_length (reports), num_issues);

    if (buf->num_issues) {
      GList *tmp = g_list_nth (reports, num_issues - buf->num_issues);

      while (tmp) {
        report = tmp->data;

        fail_unless_equals_int (report->level,
            GST_VALIDATE_REPORT_LEVEL_WARNING);
        fail_unless_equals_int (report->issue->issue_id, WRONG_BUFFER);
        tmp = tmp->next;
      }
    }
  }

  /* clean up */
  fail_unless (gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, FALSE));
  fail_unless_equals_int (gst_element_set_state (decoder, GST_STATE_NULL),
      GST_STATE_CHANGE_SUCCESS);

  gst_object_unref (srcpad);
  check_destroyed (decoder, sinkpad, NULL);
  check_destroyed (runner, NULL, NULL);
}