static GstCaps * gst_openal_sink_getcaps (GstBaseSink * bsink) { GstOpenALSink *sink = GST_OPENAL_SINK (bsink); GstCaps *caps; if (sink->device == NULL) { GstPad *pad = GST_BASE_SINK_PAD (bsink); caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); } else if (sink->probed_caps) caps = gst_caps_copy (sink->probed_caps); else { if (sink->context) caps = gst_openal_helper_probe_caps (sink->context); else if (sink->custom_ctx) caps = gst_openal_helper_probe_caps (sink->custom_ctx); else { ALCcontext *ctx = alcCreateContext (sink->device, NULL); if (ctx) { caps = gst_openal_helper_probe_caps (ctx); alcDestroyContext (ctx); } else { GST_ELEMENT_WARNING (sink, RESOURCE, FAILED, ("Could not create temporary context."), GST_ALC_ERROR (sink->device)); caps = NULL; } } if (caps && !gst_caps_is_empty (caps)) sink->probed_caps = gst_caps_copy (caps); } return caps; }
static GstCaps * gst_openal_sink_getcaps (GstBaseSink * basesink, GstCaps * filter) { GstOpenALSink *sink = GST_OPENAL_SINK (basesink); GstCaps *caps; if (sink->default_device == NULL) { GstPad *pad = GST_BASE_SINK_PAD (basesink); GstCaps *tcaps = gst_pad_get_pad_template_caps (pad); caps = gst_caps_copy (tcaps); gst_caps_unref (tcaps); } else if (sink->probed_caps) caps = gst_caps_copy (sink->probed_caps); else { if (sink->default_context) caps = gst_openal_helper_probe_caps (sink->default_context); else if (sink->user_context) caps = gst_openal_helper_probe_caps (sink->user_context); else { ALCcontext *context = alcCreateContext (sink->default_device, NULL); if (context) { caps = gst_openal_helper_probe_caps (context); alcDestroyContext (context); } else { GST_ELEMENT_WARNING (sink, RESOURCE, FAILED, ("Could not create temporary context."), GST_ALC_ERROR (sink->default_device)); caps = NULL; } } if (caps && !gst_caps_is_empty (caps)) sink->probed_caps = gst_caps_copy (caps); } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); return intersection; } else { return caps; } }
static GstCaps * gst_openal_src_getcaps (GstBaseSrc * basesrc, GstCaps * filter) { GstOpenalSrc *openalsrc = GST_OPENAL_SRC (basesrc); GstCaps *caps; ALCdevice *device; device = alcOpenDevice (NULL); if (device == NULL) { GstPad *pad = GST_BASE_SRC_PAD (basesrc); GstCaps *tcaps = gst_pad_get_pad_template_caps (pad); GST_ELEMENT_WARNING (openalsrc, RESOURCE, OPEN_WRITE, ("Could not open temporary device."), GST_ALC_ERROR (device)); caps = gst_caps_copy (tcaps); gst_caps_unref (tcaps); } else if (openalsrc->probed_caps) caps = gst_caps_copy (openalsrc->probed_caps); else { ALCcontext *context = alcCreateContext (device, NULL); if (context) { caps = gst_openal_helper_probe_caps (context); alcDestroyContext (context); } else { GST_ELEMENT_WARNING (openalsrc, RESOURCE, FAILED, ("Could not create temporary context."), GST_ALC_ERROR (device)); caps = NULL; } if (caps && !gst_caps_is_empty (caps)) openalsrc->probed_caps = gst_caps_copy (caps); } if (device != NULL) { if (alcCloseDevice (device) == ALC_FALSE) { GST_ELEMENT_WARNING (openalsrc, RESOURCE, CLOSE, ("Could not close temporary device."), GST_ALC_ERROR (device)); } } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); return intersection; } else { return caps; } }