static GstCaps * rsn_stream_selector_getcaps (GstPad * pad) { GstPad *otherpad; GstObject *parent; GstCaps *caps; otherpad = rsn_stream_selector_get_linked_pad (pad, FALSE); parent = gst_object_get_parent (GST_OBJECT (pad)); if (!otherpad) { GST_DEBUG_OBJECT (parent, "Pad %s:%s not linked, returning ANY", GST_DEBUG_PAD_NAME (pad)); caps = gst_caps_new_any (); } else { GST_DEBUG_OBJECT (parent, "Pad %s:%s is linked (to %s:%s), returning peer caps", GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (otherpad)); /* if the peer has caps, use those. If the pad is not linked, this function * returns NULL and we return ANY */ if (!(caps = gst_pad_peer_get_caps (otherpad))) caps = gst_caps_new_any (); gst_object_unref (otherpad); } gst_object_unref (parent); return caps; }
static gboolean gst_wrapper_camera_bin_src_set_mode (GstBaseCameraSrc * bcamsrc, GstCameraBinMode mode) { GstPhotography *photography = (GstPhotography *) gst_bin_get_by_interface (GST_BIN_CAST (bcamsrc), GST_TYPE_PHOTOGRAPHY); GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (bcamsrc); if (self->output_selector) { if (mode == MODE_IMAGE) { self->image_renegotiate = TRUE; g_object_set (self->output_selector, "active-pad", self->outsel_imgpad, NULL); } else { self->video_renegotiate = TRUE; g_object_set (self->output_selector, "active-pad", self->outsel_vidpad, NULL); } } self->mode = mode; if (photography) { if (g_object_class_find_property (G_OBJECT_GET_CLASS (photography), "capture-mode")) { g_object_set (G_OBJECT (photography), "capture-mode", mode, NULL); } } else { GstCaps *anycaps = gst_caps_new_any (); gst_wrapper_camera_bin_reset_video_src_caps (self, anycaps); gst_caps_unref (anycaps); } return TRUE; }
static GstCaps * gst_caps_debug_getcaps (GstPad * pad) { GstCaps *caps; GstCapsDebug *capsdebug; gchar *s; GstPad *otherpad; capsdebug = GST_CAPS_DEBUG (gst_pad_get_parent (pad)); otherpad = (pad == capsdebug->srcpad) ? capsdebug->sinkpad : capsdebug->srcpad; GST_INFO ("%s called getcaps", THISPAD); caps = gst_pad_peer_get_caps (otherpad); s = gst_caps_to_string (caps); GST_INFO ("%s returned %s", OTHERPAD, s); g_free (s); if (caps == NULL) caps = gst_caps_new_any (); gst_object_unref (capsdebug); return caps; }
static void gst_capsfilter_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstCapsFilter *capsfilter = GST_CAPSFILTER (object); switch (prop_id) { case PROP_FILTER_CAPS:{ GstCaps *new_caps; GstCaps *old_caps; const GstCaps *new_caps_val = gst_value_get_caps (value); if (new_caps_val == NULL) { new_caps = gst_caps_new_any (); } else { new_caps = (GstCaps *) new_caps_val; gst_caps_ref (new_caps); } old_caps = capsfilter->filter_caps; capsfilter->filter_caps = new_caps; gst_caps_unref (old_caps); GST_DEBUG_OBJECT (capsfilter, "set new caps %" GST_PTR_FORMAT, new_caps); /* FIXME: Need to activate these caps on the pads * http://bugzilla.gnome.org/show_bug.cgi?id=361718 */ break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gst_multi_file_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstMultiFileSrc *src = GST_MULTI_FILE_SRC (object); switch (prop_id) { case PROP_LOCATION: gst_multi_file_src_set_location (src, g_value_get_string (value)); break; case PROP_INDEX: GST_OBJECT_LOCK (src); /* index was really meant to be read-only, but for backwards-compatibility * we set start_index to make it work as it used to */ if (!GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_FLAG_STARTED)) src->start_index = g_value_get_int (value); else src->index = g_value_get_int (value); GST_OBJECT_UNLOCK (src); break; case PROP_START_INDEX: src->start_index = g_value_get_int (value); break; case PROP_STOP_INDEX: src->stop_index = g_value_get_int (value); break; case PROP_CAPS: { GstStructure *st = NULL; const GstCaps *caps = gst_value_get_caps (value); GstCaps *new_caps; if (caps == NULL) { new_caps = gst_caps_new_any (); } else { new_caps = gst_caps_copy (caps); } gst_caps_replace (&src->caps, new_caps); gst_pad_set_caps (GST_BASE_SRC_PAD (src), new_caps); if (new_caps && gst_caps_get_size (new_caps) == 1 && (st = gst_caps_get_structure (new_caps, 0)) && gst_structure_get_fraction (st, "framerate", &src->fps_n, &src->fps_d)) { GST_INFO_OBJECT (src, "Seting framerate to %d/%d", src->fps_n, src->fps_d); } else { src->fps_n = -1; src->fps_d = -1; } } break; case PROP_LOOP: src->loop = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static GstCaps * gst_play_sink_audio_convert_getcaps (GstPad * pad) { GstPlaySinkAudioConvert *self = GST_PLAY_SINK_AUDIO_CONVERT (gst_pad_get_parent (pad)); GstCaps *ret; GstPad *otherpad, *peer = NULL; GST_PLAY_SINK_AUDIO_CONVERT_LOCK (self); otherpad = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (pad)); GST_PLAY_SINK_AUDIO_CONVERT_UNLOCK (self); if (otherpad) { peer = gst_pad_get_peer (otherpad); gst_object_unref (otherpad); otherpad = NULL; } if (peer) { ret = gst_pad_get_caps_reffed (peer); gst_object_unref (peer); } else { ret = gst_caps_new_any (); } gst_object_unref (self); return ret; }
static GstCaps * gst_play_sink_video_convert_getcaps (GstPad * pad) { GstPlaySinkVideoConvert *self = GST_PLAY_SINK_VIDEO_CONVERT (gst_pad_get_parent (pad)); GstCaps *ret; GstPad *otherpad, *peer; GST_PLAY_SINK_VIDEO_CONVERT_LOCK (self); if (pad == self->srcpad) otherpad = gst_object_ref (self->sinkpad); else otherpad = gst_object_ref (self->srcpad); GST_PLAY_SINK_VIDEO_CONVERT_UNLOCK (self); peer = gst_pad_get_peer (otherpad); if (peer) { ret = gst_pad_get_caps_reffed (peer); gst_object_unref (peer); } else { ret = gst_caps_new_any (); } gst_object_unref (otherpad); gst_object_unref (self); return ret; }
static void gst_multi_file_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstMultiFileSrc *src = GST_MULTI_FILE_SRC (object); switch (prop_id) { case ARG_LOCATION: gst_multi_file_src_set_location (src, g_value_get_string (value)); break; case ARG_INDEX: src->index = g_value_get_int (value); break; case ARG_CAPS: { const GstCaps *caps = gst_value_get_caps (value); GstCaps *new_caps; if (caps == NULL) { new_caps = gst_caps_new_any (); } else { new_caps = gst_caps_copy (caps); } gst_caps_replace (&src->caps, new_caps); gst_pad_set_caps (GST_BASE_SRC_PAD (src), new_caps); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gst_capsfilter_init (GstCapsFilter * filter, GstCapsFilterClass * g_class) { GstBaseTransform *trans = GST_BASE_TRANSFORM (filter); gst_base_transform_set_gap_aware (trans, TRUE); filter->filter_caps = gst_caps_new_any (); }
void test_mutability() { GstStructure *s1; GstCaps *c1; gint ret; //xmlfile = "test_mutability"; std_log(LOG_FILENAME_LINE, "Test Started test_mutability"); c1 = gst_caps_new_any (); s1 = gst_structure_from_string ("audio/x-raw-int,rate=44100", NULL); gst_structure_set (s1, "rate", G_TYPE_INT, 48000, NULL); gst_caps_append_structure (c1, s1); gst_structure_set (s1, "rate", G_TYPE_INT, 22500, NULL); gst_caps_ref (c1); ASSERT_CRITICAL (gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL)); fail_unless (gst_structure_get_int (s1, "rate", &ret)); fail_unless (ret == 22500); ASSERT_CRITICAL (gst_caps_set_simple (c1, "rate", G_TYPE_INT, 11250, NULL)); fail_unless (gst_structure_get_int (s1, "rate", &ret)); fail_unless (ret == 22500); gst_caps_unref (c1); gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL); fail_unless (gst_structure_get_int (s1, "rate", &ret)); fail_unless (ret == 11250); gst_caps_set_simple (c1, "rate", G_TYPE_INT, 1, NULL); fail_unless (gst_structure_get_int (s1, "rate", &ret)); fail_unless (ret == 1); gst_caps_unref (c1); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
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_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; }
static void gst_caps_setter_init (GstCapsSetter * filter) { filter->caps = gst_caps_new_any (); filter->join = DEFAULT_JOIN; filter->replace = DEFAULT_REPLACE; }
static void gst_caps_setter_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstCapsSetter *filter; g_return_if_fail (GST_IS_CAPS_SETTER (object)); filter = GST_CAPS_SETTER (object); switch (prop_id) { case PROP_CAPS:{ GstCaps *new_caps; const GstCaps *new_caps_val = gst_value_get_caps (value); gint i; if (new_caps_val == NULL) { new_caps = gst_caps_new_any (); } else { new_caps = gst_caps_copy (new_caps_val); } for (i = 0; new_caps && (i < gst_caps_get_size (new_caps)); ++i) { GstStructure *s; s = gst_caps_get_structure (new_caps, i); if (!gst_structure_foreach (s, gst_caps_is_fixed_foreach, NULL)) { GST_ERROR_OBJECT (filter, "rejected unfixed caps: %" GST_PTR_FORMAT, new_caps); gst_caps_unref (new_caps); new_caps = NULL; break; } } if (new_caps) { GST_OBJECT_LOCK (filter); gst_caps_replace (&filter->caps, new_caps); /* drop extra ref */ gst_caps_unref (new_caps); GST_OBJECT_UNLOCK (filter); GST_DEBUG_OBJECT (filter, "set new caps %" GST_PTR_FORMAT, new_caps); } /* try to activate these new caps next time around */ gst_base_transform_reconfigure (GST_BASE_TRANSFORM (filter)); break; } case PROP_JOIN: filter->join = g_value_get_boolean (value); break; case PROP_REPLACE: filter->replace = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gst_capsfilter_init (GstCapsFilter * filter) { GstBaseTransform *trans = GST_BASE_TRANSFORM (filter); gst_base_transform_set_gap_aware (trans, TRUE); gst_base_transform_set_prefer_passthrough (trans, FALSE); filter->filter_caps = gst_caps_new_any (); }
static GstCaps * generate_sink_template(void) { GstCaps *caps; caps = gst_caps_new_any(); return caps; }
static GstCaps * gst_v4ljpegsrc_getcaps (GstPad * pad) { GstCaps *list; GstV4lJpegSrc *v4ljpegsrc = GST_V4LJPEGSRC (gst_pad_get_parent (pad)); GstV4lSrc *v4lsrc = GST_V4LSRC (v4ljpegsrc); struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap; gfloat fps = 0.0; if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) { return gst_caps_new_any (); } if (!v4lsrc->autoprobe) { /* FIXME: query current caps and return those, with _any appended */ return gst_caps_new_any (); } list = gst_caps_new_simple ("image/jpeg", NULL); GST_DEBUG_OBJECT (v4ljpegsrc, "Device reports w: %d-%d, h: %d-%d, fps: %f", vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight, fps); if (vcap->minwidth < vcap->maxwidth) { gst_caps_set_simple (list, "width", GST_TYPE_INT_RANGE, vcap->minwidth, vcap->maxwidth, NULL); } else { gst_caps_set_simple (list, "width", G_TYPE_INT, vcap->minwidth, NULL); } if (vcap->minheight < vcap->maxheight) { gst_caps_set_simple (list, "height", GST_TYPE_INT_RANGE, vcap->minheight, vcap->maxheight, NULL); } else { gst_caps_set_simple (list, "height", G_TYPE_INT, vcap->minheight, NULL); } if (v4lsrc->fps_list) { GstStructure *structure = gst_caps_get_structure (list, 0); gst_structure_set_value (structure, "framerate", v4lsrc->fps_list); } GST_DEBUG_OBJECT (v4ljpegsrc, "caps: %" GST_PTR_FORMAT, list); return list; }
void test_merge_fundamental() { GstCaps *c1, *c2; //xmlfile = "test_merge_fundamental"; std_log(LOG_FILENAME_LINE, "Test Started test_merge_fundamental"); /* ANY + specific = ANY */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c2 = gst_caps_new_any (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 0, NULL); fail_unless (gst_caps_is_any (c2), NULL); gst_caps_unref (c2); /* specific + ANY = ANY */ c2 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c1 = gst_caps_new_any (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 0, NULL); fail_unless (gst_caps_is_any (c2), NULL); gst_caps_unref (c2); /* EMPTY + specific = specific */ c1 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c2 = gst_caps_new_empty (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); fail_if (gst_caps_is_empty (c2), NULL); gst_caps_unref (c2); /* specific + EMPTY = specific */ c2 = gst_caps_from_string ("audio/x-raw-int,rate=44100"); c1 = gst_caps_new_empty (); gst_caps_merge (c2, c1); GST_DEBUG ("merged: (%d) %" GST_PTR_FORMAT, gst_caps_get_size (c2), c2); fail_unless (gst_caps_get_size (c2) == 1, NULL); fail_if (gst_caps_is_empty (c2), NULL); gst_caps_unref (c2); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static GstCaps * gst_compare_getcaps (GstPad * pad) { GstCompare *comp; GstPad *otherpad; GstCaps *result; comp = GST_COMPARE (gst_pad_get_parent (pad)); if (G_UNLIKELY (comp == NULL)) return gst_caps_new_any (); otherpad = (pad == comp->srcpad ? comp->sinkpad : comp->srcpad); result = gst_pad_peer_get_caps (otherpad); if (result == NULL) result = gst_caps_new_any (); gst_object_unref (comp); return result; }
/** * Retrieve the capabilities of our pads * * GST can put a pipeline together automatically by finding src and sink * pads that have compatible capabilities. In order to find out what * those capabilities are, it knows to call this method to have returned * a structure of those salient attributes. * * \param src -> to an instance of this class * \return pointer to the capabilities structure */ static GstCaps * gst_ccnxsrc_getcaps (GstBaseSrc * src) { Gstccnxsrc *me; me = GST_CCNXSRC (src); if (me->caps) return gst_caps_ref (me->caps); else return gst_caps_new_any (); }
static GstCaps * gst_udpsrc_getcaps (GstBaseSrc * src) { GstUDPSrc *udpsrc; udpsrc = GST_UDPSRC (src); if (udpsrc->caps) { return gst_caps_ref (udpsrc->caps); } else { return gst_caps_new_any (); } }
static GstCaps * gst_multi_file_src_getcaps (GstBaseSrc * src) { GstMultiFileSrc *multi_file_src = GST_MULTI_FILE_SRC (src); GST_DEBUG_OBJECT (src, "returning %" GST_PTR_FORMAT, multi_file_src->caps); if (multi_file_src->caps) { return gst_caps_ref (multi_file_src->caps); } else { return gst_caps_new_any (); } }
static GstCaps * gst_stream_splitter_sink_getcaps (GstPad * pad, GstCaps * filter) { GstStreamSplitter *stream_splitter = (GstStreamSplitter *) GST_PAD_PARENT (pad); guint32 cookie; GList *tmp; GstCaps *res = NULL; /* Return the combination of all downstream caps */ STREAMS_LOCK (stream_splitter); resync: if (G_UNLIKELY (stream_splitter->srcpads == NULL)) { res = (filter ? gst_caps_ref (filter) : gst_caps_new_any ()); goto beach; } res = NULL; cookie = stream_splitter->cookie; tmp = stream_splitter->srcpads; while (tmp) { GstPad *srcpad = (GstPad *) tmp->data; /* Ensure srcpad doesn't get destroyed while we query peer */ gst_object_ref (srcpad); STREAMS_UNLOCK (stream_splitter); if (res) { GstCaps *peercaps = gst_pad_peer_query_caps (srcpad, filter); if (peercaps) res = gst_caps_merge (res, peercaps); } else { res = gst_pad_peer_query_caps (srcpad, filter); } STREAMS_LOCK (stream_splitter); gst_object_unref (srcpad); if (G_UNLIKELY (cookie != stream_splitter->cookie)) { if (res) gst_caps_unref (res); goto resync; } tmp = tmp->next; } beach: STREAMS_UNLOCK (stream_splitter); return res; }
/* * Set the value of a property for the client src. */ static void gst_dccp_client_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstDCCPClientSrc *src = GST_DCCP_CLIENT_SRC (object); switch (prop_id) { case PROP_PORT: src->port = g_value_get_int (value); break; case PROP_HOST: if (!g_value_get_string (value)) { g_warning ("host property cannot be NULL"); break; } g_free (src->host); src->host = g_strdup (g_value_get_string (value)); break; case PROP_SOCK_FD: src->sock_fd = g_value_get_int (value); break; case PROP_CLOSED: src->closed = g_value_get_boolean (value); break; case PROP_CCID: src->ccid = g_value_get_int (value); break; case PROP_CAPS: { const GstCaps *new_caps_val = gst_value_get_caps (value); GstCaps *new_caps; GstCaps *old_caps; if (new_caps_val == NULL) { new_caps = gst_caps_new_any (); } else { new_caps = gst_caps_copy (new_caps_val); } old_caps = src->caps; src->caps = new_caps; if (old_caps) gst_caps_unref (old_caps); gst_pad_set_caps (GST_BASE_SRC (src)->srcpad, new_caps); break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static GstCaps * gst_data_uri_src_get_caps (GstBaseSrc * basesrc, GstCaps * filter) { GstDataURISrc *src = GST_DATA_URI_SRC (basesrc); GstCaps *caps; GST_OBJECT_LOCK (src); caps = gst_pad_get_current_caps (GST_BASE_SRC_PAD (basesrc)); if (!caps) caps = gst_caps_new_any (); GST_OBJECT_UNLOCK (src); return caps; }
/** * Retrieve the capabilities of our pads * * GST can put a pipeline together automatically by finding src and sink * pads that have compatible capabilities. In order to find out what * those capabilities are, it knows to call this method to have returned * a structure of those salient attributes. * * \param sink -> to an instance of this class * \return pointer to the capabilities structure */ static GstCaps * gst_ccnxsink_getcaps (GstBaseSink * sink) { Gstccnxsink *me; GST_DEBUG ("CCNxSink: get caps"); me = GST_CCNXSINK (sink); // Very common to see a cast to the proper structure type if (me->caps) return gst_caps_ref (me->caps); else return gst_caps_new_any (); }
void test_double_append() { GstStructure *s1; GstCaps *c1; //xmlfile = "test_double_append"; std_log(LOG_FILENAME_LINE, "Test Started test_double_append"); c1 = gst_caps_new_any (); s1 = gst_structure_from_string ("audio/x-raw-int,rate=44100", NULL); gst_caps_append_structure (c1, s1); ASSERT_CRITICAL (gst_caps_append_structure (c1, s1)); gst_caps_unref (c1); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static GstCaps * gst_aravis_get_caps (GstBaseSrc * src) { GstAravis* gst_aravis = GST_ARAVIS(src); GstCaps *caps; if (gst_aravis->all_caps != NULL) caps = gst_caps_copy (gst_aravis->all_caps); else caps = gst_caps_new_any (); GST_LOG_OBJECT (gst_aravis, "Available caps = %" GST_PTR_FORMAT, caps); return caps; }
static GstCaps * gst_audio_ringbuffer_getcaps (GstPad * pad) { GstAudioRingbuffer *ringbuffer; GstPad *otherpad; GstCaps *result; ringbuffer = GST_AUDIO_RINGBUFFER (GST_PAD_PARENT (pad)); otherpad = (pad == ringbuffer->srcpad ? ringbuffer->sinkpad : ringbuffer->srcpad); result = gst_pad_peer_get_caps (otherpad); if (result == NULL) result = gst_caps_new_any (); return result; }
static GstCaps * gst_selector_pad_getcaps (GstPad * pad) { RsnStreamSelector *sel; GstCaps *caps; sel = RSN_STREAM_SELECTOR (gst_pad_get_parent (pad)); GST_DEBUG_OBJECT (sel, "Getting caps of srcpad peer"); caps = gst_pad_peer_get_caps (sel->srcpad); if (caps == NULL) caps = gst_caps_new_any (); gst_object_unref (sel); return caps; }