int main (int argc, char *argv[]) { gboolean testret; gint ret = 0; gst_init (&argc, &argv); testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps), gst_static_caps_get (&rawcaps)); g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps), gst_static_caps_get (&sinkcaps)); g_print ("4 <-> 1 == %d (valid, subset)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps), gst_static_caps_get (&mp1parsecaps)); g_print ("1 <-> 4 == %d (invalid, superset)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps), gst_static_caps_get (&rawcaps2)); g_print ("2 <-> 3 == %d (invalid, ranges)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps), gst_static_caps_get (&rawcaps3)); g_print ("2 <-> 5 == %d (valid)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps3), gst_static_caps_get (&rawcaps)); g_print ("5 <-> 2 == %d (invalid)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2), gst_static_caps_get (&rawcaps3)); g_print ("3 <-> 5 == %d (valid)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps2), gst_static_caps_get (&rawcaps)); g_print ("3 <-> 2 == %d (invalid, property missing in source)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps), gst_static_caps_get (&rawcaps)); g_print ("2 <-> 2 == %d (valid, same caps)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; testret = gst_caps_is_always_compatible (gst_static_caps_get (&rawcaps6), gst_static_caps_get (&rawcaps7)); g_print ("6 <-> 7 == %d (invalid, second caps doesn't fit)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; return ret; }
static gboolean match_element(GstPluginFeature *feature, gpointer gdata) { struct typeinfo *data = (struct typeinfo*)gdata; GstElementFactory *factory; const GList *list; if (!GST_IS_ELEMENT_FACTORY(feature)) return FALSE; factory = GST_ELEMENT_FACTORY(feature); if (!strstr(gst_element_factory_get_klass(factory), data->type)) return FALSE; for (list = gst_element_factory_get_static_pad_templates(factory); list; list = list->next) { GstStaticPadTemplate *pad = (GstStaticPadTemplate*)list->data; GstCaps *caps; gboolean ret; if (pad->direction != GST_PAD_SINK) continue; caps = gst_static_caps_get(&pad->static_caps); ret = gst_caps_is_always_compatible(caps, data->caps); gst_caps_unref(caps); if (ret) return TRUE; } return FALSE; }
/** * gst_vaapi_profile_from_caps: * @caps: a #GstCaps * * Converts @caps into the corresponding #GstVaapiProfile. If the * profile cannot be represented by #GstVaapiProfile, then zero is * returned. * * Return value: the #GstVaapiProfile describing the @caps */ GstVaapiProfile gst_vaapi_profile_from_caps(const GstCaps *caps) { const GstVaapiProfileMap *m; GstCaps *caps_test; GstStructure *structure; const gchar *profile_str; GstVaapiProfile profile, best_profile; GstBuffer *codec_data = NULL; const gchar *name; gsize namelen; if (!caps) return 0; structure = gst_caps_get_structure(caps, 0); if (!structure) return 0; name = gst_structure_get_name(structure); namelen = strlen(name); profile_str = gst_structure_get_string(structure, "profile"); if (!profile_str) { const GValue *v_codec_data; v_codec_data = gst_structure_get_value(structure, "codec_data"); if (v_codec_data) codec_data = gst_value_get_buffer(v_codec_data); } profile = 0; best_profile = 0; for (m = gst_vaapi_profiles; !profile && m->profile; m++) { if (strncmp(name, m->media_str, namelen) != 0) continue; caps_test = gst_caps_from_string(m->media_str); if (gst_caps_is_always_compatible(caps, caps_test)) { best_profile = m->profile; if (profile_str && m->profile_str && strcmp(profile_str, m->profile_str) == 0) profile = best_profile; } if (!profile) { profile = gst_vaapi_profile_from_codec_data( gst_vaapi_profile_get_codec(m->profile), codec_data ); if (!profile && WORKAROUND_QTDEMUX_NO_H263_PROFILES && strncmp(name, "video/x-h263", namelen) == 0) { /* HACK: qtdemux does not report profiles for h263 */ profile = m->profile; } } gst_caps_unref(caps_test); } return profile ? profile : best_profile; }
static gboolean is_raw_caps (GstCaps * caps) { gboolean ret; GstCaps *raw_caps = gst_caps_from_string (KMS_AGNOSTIC_RAW_CAPS); ret = gst_caps_is_always_compatible (caps, raw_caps); gst_caps_unref (raw_caps); return ret; }
gboolean kms_utils_caps_are_raw (const GstCaps * caps) { gboolean ret; GstCaps *raw_caps = gst_caps_from_string (KMS_AGNOSTIC_RAW_CAPS); ret = gst_caps_is_always_compatible (caps, raw_caps); gst_caps_unref (raw_caps); return ret; }
gboolean kms_utils_caps_are_raw (const GstCaps * caps) { gboolean ret; GstCaps *raw_caps = gst_static_caps_get (&static_raw_caps); ret = gst_caps_is_always_compatible (caps, raw_caps); gst_caps_unref (raw_caps); return ret; }
static void _sink_check_caps (GstPad * pad, GstCaps * caps) { GstCaps *tcaps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 11025, "channels", G_TYPE_INT, 1, "format", G_TYPE_STRING, "U8", "layout", G_TYPE_STRING, "interleaved", NULL); fail_unless (gst_caps_is_always_compatible (caps, tcaps)); gst_caps_unref (tcaps); }
static gboolean gst_vaapidecode_reset(GstVaapiDecode *decode, GstCaps *caps) { GstVaapiCodec codec; /* Only reset decoder if codec type changed */ if (decode->decoder && decode->decoder_caps) { if (gst_caps_is_always_compatible(caps, decode->decoder_caps)) return TRUE; codec = gst_vaapi_codec_from_caps(caps); if (codec == gst_vaapi_decoder_get_codec(decode->decoder)) return TRUE; } gst_vaapidecode_destroy(decode); return gst_vaapidecode_create(decode, caps); }
static void shmdata_any_reader_on_new_buffer_from_source (GstElement * elt, gpointer user_data) { shmdata_any_reader_t *me = (shmdata_any_reader_t *) user_data; GstBuffer *buf; /* pull the next item, this can return NULL when there is no more data and * EOS has been received */ buf = gst_app_sink_pull_buffer (GST_APP_SINK (me->sink_)); if (me->on_data_ != NULL) { if (me->type_ == NULL || gst_caps_is_always_compatible (me->data_caps_, GST_BUFFER_CAPS (buf))) { gchar *caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf)); me->on_data_ (me, (void *) buf, (void *) GST_BUFFER_DATA (buf), (int) GST_BUFFER_SIZE (buf), (unsigned long long) GST_TIME_AS_NSECONDS (GST_BUFFER_TIMESTAMP (buf)), (const char *) caps_string, (void *) me->on_data_user_data_); g_free (caps_string); } else { g_debug ("incompatible data frame retrieved, data %p, data size %d, timestamp %llu, caps %"GST_PTR_FORMAT, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), GST_TIME_AS_MSECONDS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_CAPS (buf)); } } /* if (buf) */ /* gst_buffer_unref (buf); */ }
static gboolean gst_vaapidecode_reset_full (GstVaapiDecode * decode, GstCaps * caps, gboolean hard) { GstVaapiCodec codec; /* Reset tracked frame size */ decode->current_frame_size = 0; if (!hard && decode->decoder && decode->decoder_caps) { if (gst_caps_is_always_compatible (caps, decode->decoder_caps)) return TRUE; codec = gst_vaapi_codec_from_caps (caps); if (codec == gst_vaapi_decoder_get_codec (decode->decoder)) return TRUE; } gst_vaapidecode_destroy (decode); return gst_vaapidecode_create (decode, caps); }
bool Caps::isAlwaysCompatibleWith(const CapsPtr & caps2) const { return gst_caps_is_always_compatible(object<GstCaps>(), caps2); }
/* * Method: always_compatible?(caps) * caps: another Gst::Caps. * * A given caps structure is always compatible with another if every media format that is * in the first is also contained in the second. * * Returns: whether self is compatible with the given caps. */ static VALUE rg_always_compatible_p (VALUE self, VALUE caps) { return CBOOL2RVAL (gst_caps_is_always_compatible (RGST_CAPS (self), RGST_CAPS (caps))); }