static GstCaps* fs_funnel_getcaps (GstPad * pad) { FsFunnel *funnel = FS_FUNNEL (gst_pad_get_parent (pad)); GstCaps *caps; caps = gst_pad_peer_get_caps_reffed (funnel->srcpad); if (caps == NULL) caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); gst_object_unref (funnel); return caps; }
static GstCaps * gst_selector_pad_getcaps (GstPad * pad) { GstInputSelector *sel; GstCaps *caps; sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad)); GST_DEBUG_OBJECT (sel, "Getting caps of srcpad peer"); caps = gst_pad_peer_get_caps_reffed (sel->srcpad); if (caps == NULL) caps = gst_caps_new_any (); gst_object_unref (sel); return caps; }
static GstCaps * gst_jp2k_decimator_getcaps (GstPad * pad) { GstJP2kDecimator *self = GST_JP2K_DECIMATOR (gst_pad_get_parent (pad)); GstPad *otherpad; GstCaps *tmp, *ret; otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad; tmp = gst_pad_peer_get_caps_reffed (otherpad); if (tmp) { ret = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad)); gst_caps_unref (tmp); } else { ret = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); } gst_object_unref (self); GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret); return ret; }
/* This is essentially gst_base_src_negotiate_default() but the caps * are guaranteed to have a channel layout for > 2 channels */ static gboolean gst_pulsesrc_negotiate (GstBaseSrc * basesrc) { GstCaps *thiscaps; GstCaps *caps = NULL; GstCaps *peercaps = NULL; gboolean result = FALSE; /* first see what is possible on our source pad */ thiscaps = gst_pad_get_caps_reffed (GST_BASE_SRC_PAD (basesrc)); GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps); /* nothing or anything is allowed, we're done */ if (thiscaps == NULL || gst_caps_is_any (thiscaps)) goto no_nego_needed; /* get the peer caps */ peercaps = gst_pad_peer_get_caps_reffed (GST_BASE_SRC_PAD (basesrc)); GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps); if (peercaps) { /* get intersection */ caps = gst_caps_intersect (thiscaps, peercaps); GST_DEBUG_OBJECT (basesrc, "intersect: %" GST_PTR_FORMAT, caps); gst_caps_unref (thiscaps); gst_caps_unref (peercaps); } else { /* no peer, work with our own caps then */ caps = thiscaps; } if (caps) { /* take first (and best, since they are sorted) possibility */ caps = gst_caps_make_writable (caps); gst_caps_truncate (caps); /* now fixate */ if (!gst_caps_is_empty (caps)) { gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps); GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps); if (gst_caps_is_any (caps)) { /* hmm, still anything, so element can do anything and * nego is not needed */ result = TRUE; } else if (gst_caps_is_fixed (caps)) { /* yay, fixed caps, use those then */ result = gst_pulsesrc_create_stream (GST_PULSESRC_CAST (basesrc), caps); if (result) result = gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps); } } gst_caps_unref (caps); } return result; no_nego_needed: { GST_DEBUG_OBJECT (basesrc, "no negotiation needed"); if (thiscaps) gst_caps_unref (thiscaps); return TRUE; } }
static gboolean gst_droid_cam_src_vfsrc_negotiate (GstDroidCamSrc * src) { GstCaps *caps; GstCaps *peer; GstCaps *common; gboolean ret; GstDroidCamSrcClass *klass; GST_DEBUG_OBJECT (src, "vfsrc negotiate"); klass = GST_DROID_CAM_SRC_GET_CLASS (src); caps = gst_droid_cam_src_vfsrc_getcaps (src->vfsrc); if (!caps || gst_caps_is_empty (caps)) { GST_ELEMENT_ERROR (src, STREAM, FORMAT, ("Failed to get any supported caps"), (NULL)); if (caps) { gst_caps_unref (caps); } ret = FALSE; goto out; } GST_LOG_OBJECT (src, "caps %" GST_PTR_FORMAT, caps); peer = gst_pad_peer_get_caps_reffed (src->vfsrc); if (!peer || gst_caps_is_empty (peer) || gst_caps_is_any (peer)) { if (peer) { gst_caps_unref (peer); } gst_caps_unref (caps); /* Use default. */ GST_CAMERA_BUFFER_POOL_LOCK (src->pool); caps = gst_caps_new_simple (GST_NATIVE_BUFFER_NAME, "width", G_TYPE_INT, DEFAULT_VF_WIDTH, "height", G_TYPE_INT, DEFAULT_VF_HEIGHT, "framerate", GST_TYPE_FRACTION, DEFAULT_FPS, 1, "orientation-angle", G_TYPE_INT, src->pool->orientation, NULL); GST_CAMERA_BUFFER_POOL_UNLOCK (src->pool); GST_DEBUG_OBJECT (src, "using default caps %" GST_PTR_FORMAT, caps); ret = gst_pad_set_caps (src->vfsrc, caps); gst_caps_unref (caps); goto out; } GST_DEBUG_OBJECT (src, "peer caps %" GST_PTR_FORMAT, peer); common = gst_caps_intersect (caps, peer); GST_LOG_OBJECT (src, "caps intersection %" GST_PTR_FORMAT, common); gst_caps_unref (caps); gst_caps_unref (peer); if (gst_caps_is_empty (common)) { GST_ELEMENT_ERROR (src, STREAM, FORMAT, ("No common caps"), (NULL)); gst_caps_unref (common); ret = FALSE; goto out; } if (!gst_caps_is_fixed (common)) { gst_pad_fixate_caps (src->vfsrc, common); } ret = gst_pad_set_caps (src->vfsrc, common); gst_caps_unref (common); out: if (ret) { /* set camera parameters */ ret = klass->set_camera_params (src); } return ret; }
static GstCaps * gst_rtp_h264_pay_getcaps (GstBaseRTPPayload * payload, GstPad * pad) { GstCaps *template_caps; GstCaps *allowed_caps; GstCaps *caps, *icaps; gboolean append_unrestricted; guint i; allowed_caps = gst_pad_peer_get_caps_reffed (GST_BASE_RTP_PAYLOAD_SRCPAD (payload)); if (allowed_caps == NULL) return NULL; template_caps = gst_static_pad_template_get_caps (&gst_rtp_h264_pay_sink_template); if (gst_caps_is_any (allowed_caps)) { caps = gst_caps_ref (template_caps); goto done; } if (gst_caps_is_empty (allowed_caps)) { caps = gst_caps_ref (allowed_caps); goto done; } caps = gst_caps_new_empty (); append_unrestricted = FALSE; for (i = 0; i < gst_caps_get_size (allowed_caps); i++) { GstStructure *s = gst_caps_get_structure (allowed_caps, i); GstStructure *new_s = gst_structure_new ("video/x-h264", NULL); const gchar *profile_level_id; profile_level_id = gst_structure_get_string (s, "profile-level-id"); if (profile_level_id && strlen (profile_level_id) == 6) { const gchar *profile; const gchar *level; long int spsint; guint8 sps[3]; spsint = strtol (profile_level_id, NULL, 16); sps[0] = spsint >> 16; sps[1] = spsint >> 8; sps[2] = spsint; profile = gst_codec_utils_h264_get_profile (sps, 3); level = gst_codec_utils_h264_get_level (sps, 3); if (profile && level) { GST_LOG_OBJECT (payload, "In caps, have profile %s and level %s", profile, level); if (!strcmp (profile, "constrained-baseline")) gst_structure_set (new_s, "profile", G_TYPE_STRING, profile, NULL); else { GValue val = { 0, }; GValue profiles = { 0, }; g_value_init (&profiles, GST_TYPE_LIST); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, profile); gst_value_list_append_value (&profiles, &val); g_value_set_static_string (&val, "constrained-baseline"); gst_value_list_append_value (&profiles, &val); gst_structure_take_value (new_s, "profile", &profiles); } if (!strcmp (level, "1")) gst_structure_set (new_s, "level", G_TYPE_STRING, level, NULL); else { GValue levels = { 0, }; GValue val = { 0, }; int j; g_value_init (&levels, GST_TYPE_LIST); g_value_init (&val, G_TYPE_STRING); for (j = 0; all_levels[j]; j++) { g_value_set_static_string (&val, all_levels[j]); gst_value_list_prepend_value (&levels, &val); if (!strcmp (level, all_levels[j])) break; } gst_structure_take_value (new_s, "level", &levels); } } else { /* Invalid profile-level-id means baseline */ gst_structure_set (new_s, "profile", G_TYPE_STRING, "constrained-baseline", NULL); } } else { /* No profile-level-id means baseline or unrestricted */ gst_structure_set (new_s, "profile", G_TYPE_STRING, "constrained-baseline", NULL); append_unrestricted = TRUE; } gst_caps_merge_structure (caps, new_s); }