static GstCaps * gst_alsasink_getcaps (GstBaseSink * bsink) { GstElementClass *element_class; GstPadTemplate *pad_template; GstAlsaSink *sink = GST_ALSA_SINK (bsink); GstCaps *caps; if (sink->handle == NULL) { GST_DEBUG_OBJECT (sink, "device not open, using template caps"); return NULL; /* base class will get template caps for us */ } if (sink->cached_caps) { GST_LOG_OBJECT (sink, "Returning cached caps"); return gst_caps_ref (sink->cached_caps); } element_class = GST_ELEMENT_GET_CLASS (sink); pad_template = gst_element_class_get_pad_template (element_class, "sink"); g_return_val_if_fail (pad_template != NULL, NULL); caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->device, sink->handle, gst_pad_template_get_caps (pad_template)); if (caps) { sink->cached_caps = gst_caps_ref (caps); } GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, caps); return caps; }
static GstCaps * gst_alsasink_getcaps (GstBaseSink * bsink, GstCaps * filter) { GstElementClass *element_class; GstPadTemplate *pad_template; GstAlsaSink *sink = GST_ALSA_SINK (bsink); GstCaps *caps, *templ_caps; if (sink->handle == NULL) { GST_DEBUG_OBJECT (sink, "device not open, using template caps"); return NULL; /* base class will get template caps for us */ } if (sink->cached_caps) { if (filter) { caps = gst_caps_intersect_full (filter, sink->cached_caps, GST_CAPS_INTERSECT_FIRST); GST_LOG_OBJECT (sink, "Returning cached caps %" GST_PTR_FORMAT " with " "filter %" GST_PTR_FORMAT " applied: %" GST_PTR_FORMAT, sink->cached_caps, filter, caps); return caps; } else { GST_LOG_OBJECT (sink, "Returning cached caps %" GST_PTR_FORMAT, sink->cached_caps); return gst_caps_ref (sink->cached_caps); } } element_class = GST_ELEMENT_GET_CLASS (sink); pad_template = gst_element_class_get_pad_template (element_class, "sink"); g_return_val_if_fail (pad_template != NULL, NULL); templ_caps = gst_pad_template_get_caps (pad_template); caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->device, sink->handle, templ_caps); gst_caps_unref (templ_caps); if (caps) { sink->cached_caps = gst_caps_ref (caps); } GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, caps); if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); return intersection; } else { return caps; } }
static GstCaps * gst_alsasrc_getcaps (GstBaseSrc * bsrc, GstCaps * filter) { GstElementClass *element_class; GstPadTemplate *pad_template; GstAlsaSrc *src; GstCaps *caps, *templ_caps; src = GST_ALSA_SRC (bsrc); if (src->handle == NULL) { GST_DEBUG_OBJECT (src, "device not open, using template caps"); return GST_BASE_SRC_CLASS (parent_class)->get_caps (bsrc, filter); } if (src->cached_caps) { GST_LOG_OBJECT (src, "Returning cached caps"); if (filter) return gst_caps_intersect_full (filter, src->cached_caps, GST_CAPS_INTERSECT_FIRST); else return gst_caps_ref (src->cached_caps); } element_class = GST_ELEMENT_GET_CLASS (src); pad_template = gst_element_class_get_pad_template (element_class, "src"); g_return_val_if_fail (pad_template != NULL, NULL); templ_caps = gst_pad_template_get_caps (pad_template); GST_INFO_OBJECT (src, "template caps %" GST_PTR_FORMAT, templ_caps); caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->device, src->handle, templ_caps); gst_caps_unref (templ_caps); if (caps) { src->cached_caps = gst_caps_ref (caps); } GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps); if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); return intersection; } else { return caps; } }