Ejemplo n.º 1
0
/* we can only accept caps that we and downstream can handle. */
static GstCaps *
gst_live_adder_sink_getcaps (GstPad * pad)
{
    GstLiveAdder *adder;
    GstCaps *result, *peercaps, *sinkcaps;

    adder = GST_LIVE_ADDER (GST_PAD_PARENT (pad));

    /* get the downstream possible caps */
    peercaps = gst_pad_peer_get_caps (adder->srcpad);
    /* get the allowed caps on this sinkpad, we use the fixed caps function so
     * that it does not call recursively in this function. */
    sinkcaps = gst_pad_get_fixed_caps_func (pad);
    if (peercaps) {
        /* if the peer has caps, intersect */
        GST_DEBUG_OBJECT (adder, "intersecting peer and template caps");
        result = gst_caps_intersect (peercaps, sinkcaps);
        gst_caps_unref (peercaps);
        gst_caps_unref (sinkcaps);
    } else {
        /* the peer has no caps (or there is no peer), just use the allowed caps
         * of this sinkpad. */
        GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
        result = sinkcaps;
    }

    return result;
}
Ejemplo n.º 2
0
/* we can only accept caps that we and downstream can handle.
 * if we have filtercaps set, use those to constrain the target caps.
 */
static GstCaps *
gst_adder_sink_getcaps (GstPad * pad)
{
  GstAdder *adder;
  GstCaps *result, *peercaps, *sinkcaps, *filter_caps;

  adder = GST_ADDER (GST_PAD_PARENT (pad));

  GST_OBJECT_LOCK (adder);
  /* take filter */
  if ((filter_caps = adder->filter_caps))
    gst_caps_ref (filter_caps);
  GST_OBJECT_UNLOCK (adder);

  /* get the downstream possible caps */
  peercaps = gst_pad_peer_get_caps (adder->srcpad);

  /* get the allowed caps on this sinkpad, we use the fixed caps function so
   * that it does not call recursively in this function. */
  sinkcaps = gst_pad_get_fixed_caps_func (pad);
  if (peercaps) {
    /* restrict with filter-caps if any */
    if (filter_caps) {
      GST_DEBUG_OBJECT (adder, "filtering peer caps");
      result = gst_caps_intersect (peercaps, filter_caps);
      gst_caps_unref (peercaps);
      peercaps = result;
    }
    /* if the peer has caps, intersect */
    GST_DEBUG_OBJECT (adder, "intersecting peer and template caps");
    result = gst_caps_intersect (peercaps, sinkcaps);
    gst_caps_unref (peercaps);
    gst_caps_unref (sinkcaps);
  } else {
    /* the peer has no caps (or there is no peer), just use the allowed caps
     * of this sinkpad. */
    /* restrict with filter-caps if any */
    if (filter_caps) {
      GST_DEBUG_OBJECT (adder, "no peer caps, using filtered sinkcaps");
      result = gst_caps_intersect (sinkcaps, filter_caps);
      gst_caps_unref (sinkcaps);
    } else {
      GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
      result = sinkcaps;
    }
  }

  if (filter_caps)
    gst_caps_unref (filter_caps);

  GST_LOG_OBJECT (adder, "getting caps on pad %p,%s to %" GST_PTR_FORMAT, pad,
      GST_PAD_NAME (pad), result);

  return result;
}