gboolean tag_node_compare (TagNode * tnode, const GstTagList * tlist) { if (gst_structure_is_equal (GST_STRUCTURE (tlist), GST_STRUCTURE (tnode->taglist)) == FALSE) { return FALSE; } tnode->found = TRUE; return TRUE; }
static GstPadProbeReturn pay_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { rtp_pipeline *p = (rtp_pipeline *) user_data; GstEvent *event = GST_PAD_PROBE_INFO_DATA (info); if (GST_EVENT_TYPE (event) == GST_EVENT_CUSTOM_DOWNSTREAM) { const GstStructure *s0 = gst_event_get_structure (p->custom_event); const GstStructure *s1 = gst_event_get_structure (event); if (gst_structure_is_equal (s0, s1)) { return GST_PAD_PROBE_DROP; } } return GST_PAD_PROBE_OK; }
/* Append new_structure to dest, but only if it does not already exist in res. This function takes ownership of new_structure. */ static bool webkitMediaPlayReadyDecryptCapsAppendIfNotDuplicate(GstCaps* destination, GstStructure* structure) { bool duplicate = false; unsigned size = gst_caps_get_size(destination); for (unsigned index = 0; !duplicate && index < size; ++index) { GstStructure* s = gst_caps_get_structure(destination, index); if (gst_structure_is_equal(s, structure)) duplicate = true; } if (!duplicate) gst_caps_append_structure(destination, structure); else gst_structure_free(structure); return duplicate; }
/* Append new_structure to dest, but only if it does not already exist in res. This function takes ownership of new_structure. */ static gboolean gst_cenc_decrypt_append_if_not_duplicate(GstCaps *dest, GstStructure *new_struct) { gboolean duplicate=FALSE; gint j; for (j = 0; !duplicate && j < gst_caps_get_size (dest); ++j) { GstStructure *s = gst_caps_get_structure (dest, j); if(gst_structure_is_equal (s,new_struct)){ duplicate=TRUE; } } if(!duplicate){ gst_caps_append_structure (dest, new_struct); } else{ gst_structure_free (new_struct); } return duplicate; }
static void check_message_structure (GstStructure * expected_s) { GstMessage *message; gboolean have_message = FALSE; while (!have_message && (message = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ELEMENT)) != NULL) { if (gst_message_has_name (message, gst_structure_get_name (expected_s))) { const GstStructure *s = gst_message_get_structure (message); fail_unless (gst_structure_is_equal (s, expected_s)); have_message = TRUE; } gst_message_unref (message); } fail_unless (have_message); gst_structure_free (expected_s); }
static void check_caps_identical (GstCaps * a, GstCaps * b, const char *name) { int i; if (gst_caps_get_size (a) != gst_caps_get_size (b)) goto fail; for (i = 0; i < gst_caps_get_size (a); i++) { GstStructure *sa, *sb; sa = gst_caps_get_structure (a, i); sb = gst_caps_get_structure (b, i); if (!gst_structure_is_equal (sa, sb)) goto fail; } return; fail: fail ("%s caps (%s) is not equal to caps (%s)", name, gst_caps_to_string (a), gst_caps_to_string (b)); }
/** * gst_buffer_pool_set_config: * @pool: a #GstBufferPool * @config: (transfer full): a #GstStructure * * Set the configuration of the pool. If the pool is already configured, and * the configuration haven't change, this function will return %TRUE. If the * pool is active, this method will return %FALSE and active configuration * will remain. Buffers allocated form this pool must be returned or else this * function will do nothing and return %FALSE. * * @config is a #GstStructure that contains the configuration parameters for * the pool. A default and mandatory set of parameters can be configured with * gst_buffer_pool_config_set_params(), gst_buffer_pool_config_set_allocator() * and gst_buffer_pool_config_add_option(). * * If the parameters in @config can not be set exactly, this function returns * %FALSE and will try to update as much state as possible. The new state can * then be retrieved and refined with gst_buffer_pool_get_config(). * * This function takes ownership of @config. * * Returns: %TRUE when the configuration could be set. */ gboolean gst_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config) { gboolean result; GstBufferPoolClass *pclass; GstBufferPoolPrivate *priv; g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE); g_return_val_if_fail (config != NULL, FALSE); priv = pool->priv; GST_BUFFER_POOL_LOCK (pool); /* nothing to do if config is unchanged */ if (priv->configured && gst_structure_is_equal (config, priv->config)) goto config_unchanged; /* can't change the settings when active */ if (priv->active) goto was_active; /* we can't change when outstanding buffers */ if (g_atomic_int_get (&priv->outstanding) != 0) goto have_outstanding; pclass = GST_BUFFER_POOL_GET_CLASS (pool); /* set the new config */ if (G_LIKELY (pclass->set_config)) result = pclass->set_config (pool, config); else result = FALSE; /* save the config regardless of the result so user can read back the * modified config and evaluate if the changes are acceptable */ if (priv->config) gst_structure_free (priv->config); priv->config = config; if (result) { /* now we are configured */ priv->configured = TRUE; } GST_BUFFER_POOL_UNLOCK (pool); return result; config_unchanged: { gst_structure_free (config); GST_BUFFER_POOL_UNLOCK (pool); return TRUE; } /* ERRORS */ was_active: { gst_structure_free (config); GST_INFO_OBJECT (pool, "can't change config, we are active"); GST_BUFFER_POOL_UNLOCK (pool); return FALSE; } have_outstanding: { gst_structure_free (config); GST_WARNING_OBJECT (pool, "can't change config, have outstanding buffers"); GST_BUFFER_POOL_UNLOCK (pool); return FALSE; } }
static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform* base, GstPadDirection direction, GstCaps* caps, GstCaps* filter) { if (direction == GST_PAD_UNKNOWN) return nullptr; GstCaps* transformedCaps = gst_caps_new_empty(); WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(base); WebKitMediaCommonEncryptionDecryptClass* klass = WEBKIT_MEDIA_CENC_DECRYPT_GET_CLASS(self); GST_DEBUG_OBJECT(base, "direction: %s, caps: %" GST_PTR_FORMAT " filter: %" GST_PTR_FORMAT, (direction == GST_PAD_SRC) ? "src" : "sink", caps, filter); unsigned size = gst_caps_get_size(caps); for (unsigned i = 0; i < size; ++i) { GstStructure* in = gst_caps_get_structure(caps, i); GstStructure* out = nullptr; if (direction == GST_PAD_SINK) { if (!gst_structure_has_field(in, "original-media-type")) continue; out = gst_structure_copy(in); gst_structure_set_name(out, gst_structure_get_string(out, "original-media-type")); // Filter out the DRM related fields from the down-stream caps. for (int j = 0; j < gst_structure_n_fields(in); ++j) { const gchar* fieldName = gst_structure_nth_field_name(in, j); if (g_str_has_prefix(fieldName, "protection-system") || g_str_has_prefix(fieldName, "original-media-type")) gst_structure_remove_field(out, fieldName); } } else { GstStructure* tmp = gst_structure_copy(in); // Filter out the video related fields from the up-stream caps, // because they are not relevant to the input caps of this element and // can cause caps negotiation failures with adaptive bitrate streams. for (int index = gst_structure_n_fields(tmp) - 1; index >= 0; --index) { const gchar* fieldName = gst_structure_nth_field_name(tmp, index); GST_TRACE("Check field \"%s\" for removal", fieldName); if (!g_strcmp0(fieldName, "base-profile") || !g_strcmp0(fieldName, "codec_data") || !g_strcmp0(fieldName, "height") || !g_strcmp0(fieldName, "framerate") || !g_strcmp0(fieldName, "level") || !g_strcmp0(fieldName, "pixel-aspect-ratio") || !g_strcmp0(fieldName, "profile") || !g_strcmp0(fieldName, "rate") || !g_strcmp0(fieldName, "width")) { gst_structure_remove_field(tmp, fieldName); GST_TRACE("Removing field %s", fieldName); } } out = gst_structure_copy(tmp); gst_structure_set(out, "protection-system", G_TYPE_STRING, klass->protectionSystemId, "original-media-type", G_TYPE_STRING, gst_structure_get_name(in), nullptr); gst_structure_set_name(out, "application/x-cenc"); gst_structure_free(tmp); } bool duplicate = false; unsigned size = gst_caps_get_size(transformedCaps); for (unsigned index = 0; !duplicate && index < size; ++index) { GstStructure* s = gst_caps_get_structure(transformedCaps, index); if (gst_structure_is_equal(s, out)) duplicate = true; } if (!duplicate) gst_caps_append_structure(transformedCaps, out); else gst_structure_free(out); } if (filter) { GstCaps* intersection; GST_DEBUG_OBJECT(base, "Using filter caps %" GST_PTR_FORMAT, filter); intersection = gst_caps_intersect_full(transformedCaps, filter, GST_CAPS_INTERSECT_FIRST); gst_caps_unref(transformedCaps); transformedCaps = intersection; } GST_DEBUG_OBJECT(base, "returning %" GST_PTR_FORMAT, transformedCaps); return transformedCaps; }