static GstCaps * gst_capsfilter_transform_caps (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCapsFilter *capsfilter = GST_CAPSFILTER (base); GstCaps *ret, *filter_caps, *tmp; GST_OBJECT_LOCK (capsfilter); filter_caps = gst_caps_ref (capsfilter->filter_caps); GST_OBJECT_UNLOCK (capsfilter); if (filter) { tmp = gst_caps_intersect_full (filter, filter_caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (filter_caps); filter_caps = tmp; } ret = gst_caps_intersect_full (filter_caps, caps, GST_CAPS_INTERSECT_FIRST); GST_DEBUG_OBJECT (capsfilter, "input: %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (capsfilter, "filter: %" GST_PTR_FORMAT, filter); GST_DEBUG_OBJECT (capsfilter, "caps filter: %" GST_PTR_FORMAT, filter_caps); GST_DEBUG_OBJECT (capsfilter, "intersect: %" GST_PTR_FORMAT, ret); gst_caps_unref (filter_caps); return ret; }
static GstCaps * gst_rtp_mux_getcaps (GstPad * pad, GstRTPMux * mux, GstCaps * filter) { GstCaps *caps = NULL; GstIterator *iter = NULL; GValue v = { 0 }; GstIteratorResult res; GstCaps *peercaps; GstCaps *othercaps; GstCaps *tcaps; GstCaps *other_filtered; peercaps = gst_pad_peer_query_caps (mux->srcpad, filter); if (peercaps) { tcaps = gst_pad_get_pad_template_caps (pad); othercaps = gst_caps_intersect_full (peercaps, tcaps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); } else { tcaps = gst_pad_get_pad_template_caps (mux->srcpad); if (filter) othercaps = gst_caps_intersect_full (filter, tcaps, GST_CAPS_INTERSECT_FIRST); else othercaps = gst_caps_copy (tcaps); } gst_caps_unref (tcaps); clear_caps (othercaps, FALSE); other_filtered = gst_caps_copy (othercaps); clear_caps (other_filtered, TRUE); g_value_init (&v, GST_TYPE_CAPS); iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux)); do { gst_value_set_caps (&v, other_filtered); res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad); gst_iterator_resync (iter); } while (res == GST_ITERATOR_RESYNC); gst_iterator_free (iter); gst_caps_unref (other_filtered); caps = gst_caps_intersect ((GstCaps *) gst_value_get_caps (&v), othercaps); g_value_unset (&v); gst_caps_unref (othercaps); if (res == GST_ITERATOR_ERROR) { gst_caps_unref (caps); caps = gst_caps_new_empty (); } 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; } }
static GstCaps * gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) { GstCaps *peercaps, *templ; GstCaps *res; templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { guint i, n; /* Rename structure names */ peercaps = gst_caps_make_writable (peercaps); n = gst_caps_get_size (peercaps); for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (peercaps, i); if (gst_structure_has_name (s, "audio/AMR")) gst_structure_set_name (s, "audio/x-amr-nb-sh"); else gst_structure_set_name (s, "audio/x-amr-wb-sh"); } res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); res = gst_caps_make_writable (res); /* Append the template caps because we still want to accept * caps without any fields in the case upstream does not * know anything. */ gst_caps_append (res, templ); } else { res = templ; } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (res); res = intersection; } return res; }
static GstCaps * gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) { GstCaps *peercaps, *templ; GstCaps *res; /* FIXME: handle filter */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)), peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); if (peercaps) { guint i, n; /* Remove the framed and alignment field. We can convert * between different alignments. */ peercaps = gst_caps_make_writable (peercaps); n = gst_caps_get_size (peercaps); for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (peercaps, i); gst_structure_remove_field (s, "framed"); gst_structure_remove_field (s, "alignment"); } res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); gst_caps_unref (templ); } else { res = templ; } return res; }
static GstCaps * gst_pixbufscale_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *ret; int i; ret = gst_caps_copy (caps); for (i = 0; i < gst_caps_get_size (ret); i++) { GstStructure *structure = gst_caps_get_structure (ret, i); gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 16, 4096, "height", GST_TYPE_INT_RANGE, 16, 4096, NULL); gst_structure_remove_field (structure, "pixel-aspect-ratio"); } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (ret); ret = intersection; } GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret); return ret; }
static GstCaps * gst_decklink_audio_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) { GstDecklinkAudioSrc *self = GST_DECKLINK_AUDIO_SRC_CAST (bsrc); GstCaps *caps; // We don't support renegotiation caps = gst_pad_get_current_caps (GST_BASE_SRC_PAD (bsrc)); if (!caps) { GstCaps *channel_filter, *templ; templ = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc)); channel_filter = gst_caps_new_simple ("audio/x-raw", "channels", G_TYPE_INT, self->channels, NULL); caps = gst_caps_intersect (channel_filter, templ); gst_caps_unref (channel_filter); gst_caps_unref (templ); } if (filter) { GstCaps *tmp = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = tmp; } return caps; }
static GstCaps * gst_gl_filter_transform_caps (GstBaseTransform * bt, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *newcaps, *result; if (direction == GST_PAD_SINK) newcaps = gst_static_pad_template_get_caps (&gst_gl_filter_src_pad_template); else if (direction == GST_PAD_SRC) newcaps = gst_static_pad_template_get_caps (&gst_gl_filter_sink_pad_template); else newcaps = gst_caps_new_any (); if (filter) { result = gst_caps_intersect_full (filter, newcaps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (newcaps); newcaps = result; } GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, newcaps); return newcaps; }
static GstCaps * gst_pvrvideosink_getcaps (GstBaseSink * bsink, GstCaps * filter) { GstPVRVideoSink *pvrvideosink; GstCaps *caps; GST_DEBUG_OBJECT (bsink, "filter:%" GST_PTR_FORMAT, filter); pvrvideosink = GST_PVRVIDEOSINK (bsink); /* FIXME : If we have curently configured caps, we should return those * intersected with the filter*/ caps = gst_pad_get_pad_template_caps (GST_BASE_SINK (pvrvideosink)->sinkpad); if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = intersection; } GST_DEBUG_OBJECT (bsink, "Returning %" GST_PTR_FORMAT, caps); return caps; }
/* Based on gstbasetextoverlay.c */ static GstCaps * gst_overlay_composition_src_query_caps (GstOverlayComposition * self, GstCaps * filter) { GstCaps *peer_caps = NULL, *caps = NULL, *overlay_filter = NULL; if (filter) { /* duplicate filter caps which contains the composition into one version * with the meta and one without. Filter the other caps by the software * caps */ GstCaps *sw_caps = gst_static_caps_get (&overlay_composition_caps); overlay_filter = intersect_by_feature (filter, GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, sw_caps); gst_caps_unref (sw_caps); } peer_caps = gst_pad_peer_query_caps (self->sinkpad, overlay_filter); if (overlay_filter) gst_caps_unref (overlay_filter); if (peer_caps) { GST_DEBUG_OBJECT (self->srcpad, "peer caps %" GST_PTR_FORMAT, peer_caps); if (gst_caps_is_any (peer_caps)) { /* if peer returns ANY caps, return filtered sink pad template caps */ caps = gst_caps_copy (gst_pad_get_pad_template_caps (self->sinkpad)); } else { /* return upstream caps + composition feature + upstream caps * filtered by the software caps. */ GstCaps *sw_caps = gst_static_caps_get (&overlay_composition_caps); caps = add_feature_and_intersect (peer_caps, GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, sw_caps); gst_caps_unref (sw_caps); } gst_caps_unref (peer_caps); } else { /* no peer, our padtemplate is enough then */ caps = gst_pad_get_pad_template_caps (self->srcpad); } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = intersection; } GST_DEBUG_OBJECT (self->srcpad, "returning %" GST_PTR_FORMAT, caps); return caps; }
static GstCaps * transform_caps_ct2 (GstBaseTransform * trans, GstPadDirection dir, GstCaps * caps, GstCaps * filter) { GstCaps *res; if (dir == GST_PAD_SINK) { /* everything on the sinkpad can be transformed to the output formats */ if (set_caps_ct2_case == 1) res = gst_caps_new_empty_simple ("foo/x-bar"); else res = gst_caps_new_empty_simple ("baz/x-foo"); } else { /* all on the srcpad can be transformed to the format of the sinkpad */ res = gst_caps_new_empty_simple ("foo/x-bar"); } if (filter) { GstCaps *temp = gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (res); res = temp; } return res; }
static GstCaps * gst_oss_sink_getcaps (GstBaseSink * bsink, GstCaps * filter) { GstOssSink *osssink; GstCaps *caps; osssink = GST_OSSSINK (bsink); if (osssink->fd == -1) { caps = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink)); } else if (osssink->probed_caps) { caps = gst_caps_ref (osssink->probed_caps); } else { caps = gst_oss_helper_probe_caps (osssink->fd); if (caps && !gst_caps_is_empty (caps)) { osssink->probed_caps = gst_caps_ref (caps); } } if (filter && caps) { 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_inter_audio_src_get_caps (GstBaseSrc * src, GstCaps * filter) { GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src); GstCaps *caps; GST_DEBUG_OBJECT (interaudiosrc, "get_caps"); if (!interaudiosrc->surface) return GST_BASE_SRC_CLASS (parent_class)->get_caps (src, filter); g_mutex_lock (&interaudiosrc->surface->mutex); if (interaudiosrc->surface->audio_info.finfo) { caps = gst_audio_info_to_caps (&interaudiosrc->surface->audio_info); if (filter) { GstCaps *tmp; tmp = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = tmp; } } else { caps = NULL; } g_mutex_unlock (&interaudiosrc->surface->mutex); if (caps) return caps; else return GST_BASE_SRC_CLASS (parent_class)->get_caps (src, filter); }
static GstCaps * gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc, GstCaps * filter) { GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (basesrc); GstCaps *caps; if (src->caps) { caps = gst_caps_ref (src->caps); } else { caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (src)); } if (caps) { GstCaps *filtcaps; if (filter) { filtcaps = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); } else { filtcaps = gst_caps_ref (caps); } gst_caps_unref (caps); return filtcaps; } return NULL; }
/* Generic code for now, requires changes in future when we * add hardware query for supported formats, Framerate control etc */ static GstCaps * gst_msdkvpp_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *out_caps; GST_DEBUG_OBJECT (trans, "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps, (direction == GST_PAD_SINK) ? "sink" : "src"); if (direction == GST_PAD_SRC) out_caps = gst_static_pad_template_get_caps (&gst_msdkvpp_sink_factory); else out_caps = gst_static_pad_template_get_caps (&gst_msdkvpp_src_factory); if (out_caps && filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (out_caps, filter, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (out_caps); out_caps = intersection; } GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, out_caps); return out_caps; }
/* Get the intersection of parser caps and available (sorted) decoders */ static GstCaps * get_parser_caps_filter (GstDecodebin3 * dbin, GstCaps * caps) { GList *tmp; GstCaps *filter_caps = gst_caps_new_empty (); g_mutex_lock (&dbin->factories_lock); gst_decode_bin_update_factories_list (dbin); for (tmp = dbin->decoder_factories; tmp; tmp = tmp->next) { GstElementFactory *factory = (GstElementFactory *) tmp->data; GstCaps *tcaps, *intersection; const GList *tmps; GST_LOG ("Trying factory %s", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); for (tmps = gst_element_factory_get_static_pad_templates (factory); tmps; tmps = tmps->next) { GstStaticPadTemplate *st = (GstStaticPadTemplate *) tmps->data; if (st->direction != GST_PAD_SINK || st->presence != GST_PAD_ALWAYS) continue; tcaps = gst_static_pad_template_get_caps (st); intersection = gst_caps_intersect_full (tcaps, caps, GST_CAPS_INTERSECT_FIRST); filter_caps = gst_caps_merge (filter_caps, intersection); gst_caps_unref (tcaps); } } g_mutex_unlock (&dbin->factories_lock); GST_DEBUG_OBJECT (dbin, "Got filter caps %" GST_PTR_FORMAT, filter_caps); return filter_caps; }
/** * @brief Get pad caps for caps negotiation. */ static GstCaps * gst_tensor_aggregator_query_caps (GstTensorAggregator * self, GstPad * pad, GstCaps * filter) { GstCaps *caps; GstTensorConfig config; /* tensor config info for given pad */ if (pad == self->sinkpad) { config = self->in_config; } else { config = self->out_config; } /* caps from tensor config info */ caps = gst_tensor_caps_from_config (&config); silent_debug_caps (caps, "caps"); silent_debug_caps (filter, "filter"); if (caps && filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = intersection; } return caps; }
static GstCaps * gst_app_src_internal_get_caps (GstBaseSrc * bsrc, GstCaps * filter) { GstAppSrc *appsrc = GST_APP_SRC (bsrc); GstCaps *caps; GST_OBJECT_LOCK (appsrc); if ((caps = appsrc->priv->caps)) gst_caps_ref (caps); GST_OBJECT_UNLOCK (appsrc); if (filter) { if (caps) { GstCaps *intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = intersection; } else { caps = gst_caps_ref (filter); } } GST_DEBUG_OBJECT (appsrc, "caps: %" GST_PTR_FORMAT, caps); return caps; }
static GstCaps * gst_decklink_video_sink_get_caps (GstBaseSink * bsink, GstCaps * filter) { GstDecklinkVideoSink *self = GST_DECKLINK_VIDEO_SINK_CAST (bsink); GstCaps *mode_caps, *caps; if (self->mode == GST_DECKLINK_MODE_AUTO && self->video_format == GST_DECKLINK_VIDEO_FORMAT_AUTO) mode_caps = gst_decklink_mode_get_template_caps (FALSE); else if (self->video_format == GST_DECKLINK_VIDEO_FORMAT_AUTO) mode_caps = gst_decklink_mode_get_caps_all_formats (self->mode, FALSE); else if (self->mode == GST_DECKLINK_MODE_AUTO) mode_caps = gst_decklink_pixel_format_get_caps (gst_decklink_pixel_format_from_type (self->video_format), FALSE); else mode_caps = gst_decklink_mode_get_caps (self->mode, gst_decklink_pixel_format_from_type (self->video_format), FALSE); mode_caps = gst_caps_make_writable (mode_caps); /* For output we support any framerate and only really care about timestamps */ gst_caps_map_in_place (mode_caps, reset_framerate, NULL); if (filter) { caps = gst_caps_intersect_full (filter, mode_caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (mode_caps); } else { caps = mode_caps; } return caps; }
static GstCaps * gst_h263_parse_get_sink_caps (GstBaseParse * parse) { GstCaps *peercaps; GstCaps *res; peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); if (peercaps) { guint i, n; /* Remove parsed field */ peercaps = gst_caps_make_writable (peercaps); n = gst_caps_get_size (peercaps); for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (peercaps, i); gst_structure_remove_field (s, "parsed"); } res = gst_caps_intersect_full (peercaps, gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)), GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); } else { res = gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse))); } return res; }
static GstCaps * gst_decklink_video_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) { GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (bsrc); GstCaps *mode_caps, *caps; BMDPixelFormat format; GstDecklinkModeEnum mode; g_mutex_lock (&self->lock); mode = self->caps_mode; format = self->caps_format; g_mutex_unlock (&self->lock); mode_caps = gst_decklink_mode_get_caps (mode, format); if (filter) { caps = gst_caps_intersect_full (filter, mode_caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (mode_caps); } else { caps = mode_caps; } return caps; }
static GstCaps * gst_frei0r_mixer_get_caps (GstFrei0rMixer * self, GstPad * pad, GstCaps * filter) { GstCaps *caps = NULL; if (self->caps) { caps = gst_caps_ref (self->caps); } else { GstCaps *tmp; caps = gst_pad_get_pad_template_caps (self->src); if (filter) { tmp = caps; caps = gst_caps_intersect_full (tmp, filter, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (tmp); } caps = gst_frei0r_mixer_query_pad_caps (self->src, pad, caps); caps = gst_frei0r_mixer_query_pad_caps (self->sink0, pad, caps); caps = gst_frei0r_mixer_query_pad_caps (self->sink1, pad, caps); if (self->sink2) caps = gst_frei0r_mixer_query_pad_caps (self->sink2, pad, caps); } return caps; }
static GstCaps * gst_rtp_g722_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, GstCaps * filter) { GstCaps *otherpadcaps; GstCaps *caps; otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); caps = gst_pad_get_pad_template_caps (pad); if (otherpadcaps) { if (!gst_caps_is_empty (otherpadcaps)) { caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL); gst_caps_set_simple (caps, "rate", G_TYPE_INT, 16000, NULL); } gst_caps_unref (otherpadcaps); } if (filter) { GstCaps *tmp; GST_DEBUG_OBJECT (rtppayload, "Intersect %" GST_PTR_FORMAT " and filter %" GST_PTR_FORMAT, caps, filter); tmp = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = tmp; } return caps; }
static GstCaps * gst_shmdata_src_getcaps (GstBaseSrc * src, GstCaps * filter) { GstShmdataSrc *shmdatasrc; GstCaps *caps, *result; shmdatasrc = GST_SHMDATA_SRC (src); GST_OBJECT_LOCK (src); if ((caps = shmdatasrc->caps)) gst_caps_ref (caps); GST_OBJECT_UNLOCK (src); if (caps) { if (filter) { result = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); } else { result = caps; } } else { result = (filter) ? gst_caps_ref (filter) : gst_caps_new_any (); } return result; }
/** * gst_dvbsub_overlay_intersect_by_feature: * * Creates a new #GstCaps based on the following filtering rule. * * For each individual caps contained in given caps, if the * caps uses the given caps feature, keep a version of the caps * with the feature and an another one without. Otherwise, intersect * the caps with the given filter. * * Returns: the new #GstCaps */ static GstCaps * gst_dvbsub_overlay_intersect_by_feature (GstCaps * caps, const gchar * feature, GstCaps * filter) { int i, caps_size; GstCaps *new_caps; new_caps = gst_caps_new_empty (); caps_size = gst_caps_get_size (caps); for (i = 0; i < caps_size; i++) { GstStructure *caps_structure = gst_caps_get_structure (caps, i); GstCapsFeatures *caps_features = gst_caps_features_copy (gst_caps_get_features (caps, i)); GstCaps *filtered_caps; GstCaps *simple_caps = gst_caps_new_full (gst_structure_copy (caps_structure), NULL); gst_caps_set_features (simple_caps, 0, caps_features); if (gst_caps_features_contains (caps_features, feature)) { gst_caps_append (new_caps, gst_caps_copy (simple_caps)); gst_caps_features_remove (caps_features, feature); filtered_caps = gst_caps_ref (simple_caps); } else { filtered_caps = gst_caps_intersect_full (simple_caps, filter, GST_CAPS_INTERSECT_FIRST); } gst_caps_unref (simple_caps); gst_caps_append (new_caps, filtered_caps); } return new_caps; }
static GstCaps * gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) { GstCaps *peercaps, *templ; GstCaps *res; templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { guint i, n; /* Remove the framed and alignment field. We can convert * between different alignments. */ peercaps = gst_caps_make_writable (peercaps); n = gst_caps_get_size (peercaps); for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (peercaps, i); gst_structure_remove_field (s, "framed"); gst_structure_remove_field (s, "alignment"); } res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); res = gst_caps_make_writable (res); /* Append the template caps because we still want to accept * caps without any fields in the case upstream does not * know anything. */ gst_caps_append (res, templ); } else { res = templ; } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (res); res = intersection; } return res; }
static GstCaps * gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, GstCaps * filter) { GstCaps *caps, *peercaps, *tcaps; GstStructure *s; const gchar *stereo; if (pad == GST_RTP_BASE_PAYLOAD_SRCPAD (payload)) return GST_RTP_BASE_PAYLOAD_CLASS (gst_rtp_opus_pay_parent_class)->get_caps (payload, pad, filter); tcaps = gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload)); peercaps = gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), tcaps); gst_caps_unref (tcaps); if (!peercaps) return GST_RTP_BASE_PAYLOAD_CLASS (gst_rtp_opus_pay_parent_class)->get_caps (payload, pad, filter); if (gst_caps_is_empty (peercaps)) return peercaps; caps = gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SINKPAD (payload)); s = gst_caps_get_structure (peercaps, 0); stereo = gst_structure_get_string (s, "stereo"); if (stereo != NULL) { caps = gst_caps_make_writable (caps); if (!strcmp (stereo, "1")) { GstCaps *caps2 = gst_caps_copy (caps); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 2, NULL); gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 1, NULL); caps = gst_caps_merge (caps, caps2); } else if (!strcmp (stereo, "0")) { GstCaps *caps2 = gst_caps_copy (caps); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL); gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 2, NULL); caps = gst_caps_merge (caps, caps2); } } gst_caps_unref (peercaps); if (filter) { GstCaps *tmp = gst_caps_intersect_full (caps, filter, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = tmp; } GST_DEBUG_OBJECT (payload, "Returning caps: %" GST_PTR_FORMAT, caps); return caps; }
static GstCaps * gst_decklink_audio_sink_get_caps (GstBaseSink * bsink, GstCaps * filter) { GstDecklinkAudioSink *self = GST_DECKLINK_AUDIO_SINK_CAST (bsink); GstCaps *caps; if ((caps = gst_pad_get_current_caps (GST_BASE_SINK_PAD (bsink)))) return caps; caps = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink)); GST_OBJECT_LOCK (self); if (self->output && self->output->attributes) { int64_t max_channels = 0; HRESULT ret; GstStructure *s; GValue arr = G_VALUE_INIT; GValue v = G_VALUE_INIT; ret = self->output->attributes->GetInt (BMDDeckLinkMaximumAudioChannels, &max_channels); /* 2 should always be supported */ if (ret != S_OK) { max_channels = 2; } caps = gst_caps_make_writable (caps); s = gst_caps_get_structure (caps, 0); g_value_init (&arr, GST_TYPE_LIST); g_value_init (&v, G_TYPE_INT); if (max_channels >= 16) { g_value_set_int (&v, 16); gst_value_list_append_value (&arr, &v); } if (max_channels >= 8) { g_value_set_int (&v, 8); gst_value_list_append_value (&arr, &v); } g_value_set_int (&v, 2); gst_value_list_append_value (&arr, &v); gst_structure_set_value (s, "channels", &arr); g_value_unset (&v); g_value_unset (&arr); } GST_OBJECT_UNLOCK (self); if (filter) { GstCaps *intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (caps); caps = intersection; } return caps; }
static GstCaps * gst_video_scale_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *ret; GstStructure *structure; GstCapsFeatures *features; gint i, n; GST_DEBUG_OBJECT (trans, "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps, (direction == GST_PAD_SINK) ? "sink" : "src"); ret = gst_caps_new_empty (); n = gst_caps_get_size (caps); for (i = 0; i < n; i++) { structure = gst_caps_get_structure (caps, i); features = gst_caps_get_features (caps, i); /* If this is already expressed by the existing caps * skip this structure */ if (i > 0 && gst_caps_is_subset_structure_full (ret, structure, features)) continue; /* make copy */ structure = gst_structure_copy (structure); /* If the features are non-sysmem we can only do passthrough */ if (!gst_caps_features_is_any (features) && gst_caps_features_is_equal (features, GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY)) { gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL); /* if pixel aspect ratio, make a range of it */ if (gst_structure_has_field (structure, "pixel-aspect-ratio")) { gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL); } } gst_caps_append_structure_full (ret, structure, gst_caps_features_copy (features)); } if (filter) { GstCaps *intersection; intersection = gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (ret); ret = intersection; } GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret); return ret; }