32, 32, SND_PCM_FORMAT_S32, SND_PCM_FORMAT_U32}
};
-static void
+static GstCaps *
add_format (const gchar * str, GstStructure * s, snd_pcm_format_mask_t * mask,
GstCaps * caps)
{
format = gst_audio_format_from_string (str);
if (format == GST_AUDIO_FORMAT_UNKNOWN)
- return;
+ return caps;
finfo = gst_audio_format_get_info (format);
if (pcmformats[w].width == width && pcmformats[w].depth == depth)
break;
if (w == G_N_ELEMENTS (pcmformats))
- return; /* Unknown format */
+ return caps; /* Unknown format */
if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat) &&
snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) {
scopy = NULL;
}
if (scopy) {
- gst_caps_merge_structure (caps, scopy);
+ caps = gst_caps_merge_structure (caps, scopy);
}
+ return caps;
}
val = gst_value_list_get_value (format, i);
if (G_VALUE_HOLDS_STRING (val))
- add_format (g_value_get_string (val), s, mask, caps);
+ caps = add_format (g_value_get_string (val), s, mask, caps);
}
} else if (G_VALUE_HOLDS_STRING (format)) {
- add_format (g_value_get_string (format), s, mask, caps);
+ caps = add_format (g_value_get_string (format), s, mask, caps);
} else
continue;
}
#define CHANNEL_MASK_5_1 (CHANNEL_MASK_4_0 | (ONE_64<<GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) | (ONE_64<<GST_AUDIO_CHANNEL_POSITION_LFE1))
#define CHANNEL_MASK_7_1 (CHANNEL_MASK_5_1 | (ONE_64<<GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT) | (ONE_64<<GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT))
-static void
+static GstCaps *
caps_add_channel_configuration (GstCaps * caps,
const GstStructure * in_structure, gint min_chans, gint max_chans)
{
if (min_chans == max_chans && max_chans == 1) {
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_merge_structure (caps, s);
- return;
+ caps = gst_caps_merge_structure (caps, s);
+ return caps;
}
g_assert (min_chans >= 1);
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, 2, "channel-mask",
GST_TYPE_BITMASK, CHANNEL_MASK_STEREO, NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
} else if (min_chans == 1 && max_chans >= 2) {
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, 2, "channel-mask",
GST_TYPE_BITMASK, CHANNEL_MASK_STEREO, NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
}
/* don't know whether to use 2.1 or 3.0 here - but I suspect
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, 3, "channel-mask",
GST_TYPE_BITMASK, CHANNEL_MASK_2_1, NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
}
/* everything else (4, 6, 8 channels) needs a channel layout */
}
gst_structure_set (s, "channels", G_TYPE_INT, c, "channel-mask",
GST_TYPE_BITMASK, channel_mask, NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
}
}
s = get_channel_free_structure (in_structure);
gst_structure_set (s, "channels", G_TYPE_INT, c, "channel-mask",
GST_TYPE_BITMASK, G_GUINT64_CONSTANT (0), NULL);
- gst_caps_merge_structure (caps, s);
+ caps = gst_caps_merge_structure (caps, s);
}
+ return caps;
}
static GstCaps *
c_max = max_chans;
}
- caps_add_channel_configuration (caps, s, c_min, c_max);
+ caps = caps_add_channel_configuration (caps, s, c_min, c_max);
}
gst_caps_unref (in_caps);
if (gst_caps_is_empty (target))
goto no_format;
- target = gst_caps_make_writable (target);
- gst_caps_truncate (target);
+ target = gst_caps_truncate (target);
} else {
/* need a copy, we'll be modifying it when fixating */
- target = gst_caps_copy (caps);
- gst_caps_unref (caps);
+ target = gst_caps_ref (caps);
}
GST_DEBUG_OBJECT (visual, "before fixate caps %" GST_PTR_FORMAT, target);
+ target = gst_caps_make_writable (target);
/* fixate in case something is not fixed. This does nothing if the value is
* already fixed. For video we always try to fixate to something like
* 320x240x25 by convention. */
gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT);
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
DEFAULT_FPS_N, DEFAULT_FPS_D);
- gst_caps_fixate (target);
+ target = gst_caps_fixate (target);
GST_DEBUG_OBJECT (visual, "after fixate caps %" GST_PTR_FORMAT, target);
return ret;
}
-static void
+static GstCaps *
gst_text_render_fixate_caps (GstTextRender * render, GstCaps * caps)
{
GstStructure *s;
- gst_caps_truncate (caps);
+ caps = gst_caps_truncate (caps);
+
+ caps = gst_caps_make_writable (caps);
s = gst_caps_get_structure (caps, 0);
GST_DEBUG ("Fixating caps %" GST_PTR_FORMAT, caps);
gst_structure_fixate_field_nearest_int (s, "height",
MAX (render->image_height + render->ypad, DEFAULT_RENDER_HEIGHT));
GST_DEBUG ("Fixated to %" GST_PTR_FORMAT, caps);
+
+ return caps;
}
#define CAIRO_UNPREMULTIPLY(a,r,g,b) G_STMT_START { \
goto done;
}
- gst_text_render_fixate_caps (render, caps);
+ caps = gst_text_render_fixate_caps (render, caps);
if (!gst_text_render_src_setcaps (render, caps)) {
GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
peer = gst_pad_get_peer (encoder->srcpad);
if (peer) {
- const GstCaps *templ_caps;
+ GstCaps *templ_caps;
GstCaps *peer_caps, *tmp_caps;
GstStructure *s;
guint i, n;
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_audio_base_sink_setcaps (GstBaseSink * bsink,
GstCaps * caps);
-static void gst_audio_base_sink_fixate (GstBaseSink * bsink, GstCaps * caps);
+static GstCaps *gst_audio_base_sink_fixate (GstBaseSink * bsink,
+ GstCaps * caps);
static gboolean gst_audio_base_sink_query_pad (GstBaseSink * bsink,
GstQuery * query);
}
}
-static void
+static GstCaps *
gst_audio_base_sink_fixate (GstBaseSink * bsink, GstCaps * caps)
{
GstStructure *s;
gint width, depth;
+ caps = gst_caps_make_writable (caps);
+
s = gst_caps_get_structure (caps, 0);
/* fields for all formats */
if (gst_structure_has_field (s, "endianness"))
gst_structure_fixate_field_nearest_int (s, "endianness", G_BYTE_ORDER);
- GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps);
+ caps = GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps);
+
+ return caps;
}
static void
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_audio_base_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
static gboolean gst_audio_base_src_query (GstBaseSrc * bsrc, GstQuery * query);
-static void gst_audio_base_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
+static GstCaps *gst_audio_base_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
/* static guint gst_audio_base_src_signals[LAST_SIGNAL] = { 0 }; */
}
}
-static void
+static GstCaps *
gst_audio_base_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstStructure *s;
+ caps = gst_caps_make_writable (caps);
+
s = gst_caps_get_structure (caps, 0);
/* fields for all formats */
GST_AUDIO_DEF_CHANNELS);
gst_structure_fixate_field_string (s, "format", GST_AUDIO_DEF_FORMAT);
- GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+ caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+
+ return caps;
}
static gboolean
if ((val = gst_structure_get_value (allowed_s, "channel-mask")))
gst_structure_set_value (s, "channel-mask", val);
- gst_caps_merge_structure (filter_caps, s);
+ filter_caps = gst_caps_merge_structure (filter_caps, s);
}
}
for (ltmp = GST_ENCODING_CONTAINER_PROFILE (profile)->encodingprofiles;
ltmp; ltmp = ltmp->next) {
GstEncodingProfile *sprof = (GstEncodingProfile *) ltmp->data;
- gst_caps_merge (res, gst_encoding_profile_get_input_caps (sprof));
+ res = gst_caps_merge (res, gst_encoding_profile_get_input_caps (sprof));
}
return res;
}
}
/* now fixate, start by taking the first caps */
- gst_caps_truncate (temp);
+ temp = gst_caps_truncate (temp);
/* get first structure */
s = gst_caps_get_structure (temp, 0);
outs = gst_caps_get_structure (result, 0);
gst_audio_convert_fixate_channels (base, ins, outs);
- gst_caps_fixate (result);
+ result = gst_caps_fixate (result);
GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, result);
if (G_UNLIKELY (!gst_structure_get_int (s, "rate", &rate)))
return othercaps;
+ othercaps = gst_caps_truncate (othercaps);
othercaps = gst_caps_make_writable (othercaps);
- gst_caps_truncate (othercaps);
s = gst_caps_get_structure (othercaps, 0);
gst_structure_fixate_field_nearest_int (s, "rate", rate);
+
return othercaps;
}
static gboolean gst_audio_test_src_setcaps (GstBaseSrc * basesrc,
GstCaps * caps);
-static void gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
+static GstCaps *gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
static gboolean gst_audio_test_src_is_seekable (GstBaseSrc * basesrc);
static gboolean gst_audio_test_src_do_seek (GstBaseSrc * basesrc,
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static void
+static GstCaps *
gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (bsrc);
GstStructure *structure;
+ caps = gst_caps_make_writable (caps);
+
structure = gst_caps_get_structure (caps, 0);
GST_DEBUG_OBJECT (src, "fixating samplerate to %d", GST_AUDIO_DEF_RATE);
/* fixate to mono unless downstream requires stereo, for backwards compat */
gst_structure_fixate_field_nearest_int (structure, "channels", 1);
- GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+ caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+
+ return caps;
}
static gboolean
if (res) {
GstCaps *peercaps = gst_pad_peer_query_caps (srcpad, filter);
if (peercaps)
- gst_caps_merge (res, gst_caps_make_writable (peercaps));
+ res = gst_caps_merge (res, peercaps);
} else {
res = gst_pad_peer_query_caps (srcpad, filter);
}
tcaps = gst_static_pad_template_get_caps (st);
intersection =
gst_caps_intersect_full (tcaps, caps, GST_CAPS_INTERSECT_FIRST);
- gst_caps_merge (filter_caps, intersection);
+ filter_caps = gst_caps_merge (filter_caps, intersection);
gst_caps_unref (tcaps);
}
}
/* Append the parser caps to prevent any not-negotiated errors */
- gst_caps_merge (filter_caps, gst_caps_copy (caps));
+ filter_caps = gst_caps_merge (filter_caps, gst_caps_ref (caps));
delem->capsfilter = gst_element_factory_make ("capsfilter", NULL);
g_object_set (G_OBJECT (delem->capsfilter), "caps", filter_caps, NULL);
GstCaps *peer_caps = gst_pad_query_caps (peer, filter);
gst_object_unref (peer);
if (self->converter_caps && is_raw_caps (peer_caps, self->audio)) {
- peer_caps = gst_caps_make_writable (peer_caps);
- gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps));
- ret = peer_caps;
+ ret = gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps));
} else {
ret = peer_caps;
}
GST_DEBUG ("Found renderer element %s (%s) with caps %" GST_PTR_FORMAT,
gst_element_factory_get_longname (factory),
gst_plugin_feature_get_name (feature), templ_caps);
- gst_caps_merge (*subcaps, templ_caps);
+ *subcaps = gst_caps_merge (*subcaps, templ_caps);
return TRUE;
} else if (!is_renderer && !have_video_sink && templ_caps) {
GST_DEBUG ("Found parser element %s (%s) with caps %" GST_PTR_FORMAT,
gst_element_factory_get_longname (factory),
gst_plugin_feature_get_name (feature), templ_caps);
- gst_caps_merge (*subcaps, templ_caps);
+ *subcaps = gst_caps_merge (*subcaps, templ_caps);
return TRUE;
} else {
if (templ_caps)
}
/* fixate remaining fields */
- result = gst_caps_make_writable (result);
- gst_caps_fixate (result);
+ result = gst_caps_fixate (result);
return result;
}
G_MAXINT, 1, NULL);
}
if (s1 != NULL)
- gst_caps_merge_structure (ret, s1);
- gst_caps_merge_structure (ret, s2);
+ ret = gst_caps_merge_structure (ret, s1);
+ ret = gst_caps_merge_structure (ret, s2);
if (s3 != NULL)
- gst_caps_merge_structure (ret, s3);
+ ret = gst_caps_merge_structure (ret, s3);
}
if (filter) {
GstCaps *intersection;
if (G_UNLIKELY (!gst_structure_get_fraction (s, "framerate", &num, &denom)))
return othercaps;
+ othercaps = gst_caps_truncate (othercaps);
othercaps = gst_caps_make_writable (othercaps);
- gst_caps_truncate (othercaps);
s = gst_caps_get_structure (othercaps, 0);
gst_structure_fixate_field_nearest_fraction (s, "framerate", num, denom);
"v308, Y800, Y16, RGB16, RGB15, ARGB64, AYUV64, NV12 } "
-static GstStaticCaps gst_video_scale_format_caps[] = {
- GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS))
-};
+static GstStaticCaps gst_video_scale_format_caps =
+GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS));
#define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())
static GType
static volatile gsize inited = 0;
if (g_once_init_enter (&inited)) {
- gint i;
-
- g_assert (caps == NULL);
-
- caps = gst_caps_new_empty ();
- for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++)
- gst_caps_append (caps,
- gst_caps_make_writable
- (gst_static_caps_get (&gst_video_scale_format_caps[i])));
+ caps = gst_static_caps_get (&gst_video_scale_format_caps);
g_once_init_leave (&inited, 1);
}
-
return caps;
}
GValue fpar = { 0, }, tpar = {
0,};
+ othercaps = gst_caps_truncate (othercaps);
othercaps = gst_caps_make_writable (othercaps);
- gst_caps_truncate (othercaps);
GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
static GstCaps *gst_video_test_src_getcaps (GstBaseSrc * bsrc,
GstCaps * filter);
static gboolean gst_video_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
-static void gst_video_test_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
+static GstCaps *gst_video_test_src_src_fixate (GstBaseSrc * bsrc,
+ GstCaps * caps);
static gboolean gst_video_test_src_is_seekable (GstBaseSrc * psrc);
static gboolean gst_video_test_src_do_seek (GstBaseSrc * bsrc,
gst_base_src_set_live (GST_BASE_SRC (src), DEFAULT_IS_LIVE);
}
-static void
+static GstCaps *
gst_video_test_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstStructure *structure;
+ caps = gst_caps_make_writable (caps);
+
structure = gst_caps_get_structure (caps, 0);
gst_structure_fixate_field_nearest_int (structure, "width", 320);
if (gst_structure_has_field (structure, "interlaced"))
gst_structure_fixate_field_boolean (structure, "interlaced", FALSE);
- GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+ caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+
+ return caps;
}
static void