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 gboolean gst_ffmpegauddec_set_format (GstAudioDecoder * decoder, GstCaps * caps) { GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) decoder; GstFFMpegAudDecClass *oclass; gboolean ret = TRUE; oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); GST_DEBUG_OBJECT (ffmpegdec, "setcaps called"); GST_OBJECT_LOCK (ffmpegdec); if (ffmpegdec->last_caps && gst_caps_is_equal (ffmpegdec->last_caps, caps)) { GST_DEBUG_OBJECT (ffmpegdec, "same caps"); GST_OBJECT_UNLOCK (ffmpegdec); return TRUE; } gst_caps_replace (&ffmpegdec->last_caps, caps); /* close old session */ if (ffmpegdec->opened) { GST_OBJECT_UNLOCK (ffmpegdec); gst_ffmpegauddec_drain (ffmpegdec); GST_OBJECT_LOCK (ffmpegdec); if (!gst_ffmpegauddec_close (ffmpegdec, TRUE)) { GST_OBJECT_UNLOCK (ffmpegdec); return FALSE; } } /* get size and so */ gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id, oclass->in_plugin->type, caps, ffmpegdec->context); /* workaround encoder bugs */ ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT; ffmpegdec->context->err_recognition = 1; /* open codec - we don't select an output pix_fmt yet, * simply because we don't know! We only get it * during playback... */ if (!gst_ffmpegauddec_open (ffmpegdec)) goto open_failed; done: GST_OBJECT_UNLOCK (ffmpegdec); return ret; /* ERRORS */ open_failed: { GST_DEBUG_OBJECT (ffmpegdec, "Failed to open"); ret = FALSE; goto done; } }
static gboolean gst_app_sink_stop (GstBaseSink * psink) { GstAppSink *appsink = GST_APP_SINK_CAST (psink); GstAppSinkPrivate *priv = appsink->priv; g_mutex_lock (priv->mutex); GST_DEBUG_OBJECT (appsink, "stopping"); priv->flushing = TRUE; priv->started = FALSE; gst_app_sink_flush_unlocked (appsink); gst_caps_replace (&priv->preroll_caps, NULL); gst_caps_replace (&priv->last_caps, NULL); g_mutex_unlock (priv->mutex); return TRUE; }
static void gst_jack_audio_src_dispose (GObject * object) { GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object); gst_caps_replace (&src->caps, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); }
/* * Method: replace(caps) * caps: another Gst::Caps. * * Replaces the current caps inplace with the given caps. * * Returns: self. */ static VALUE rg_replace_bang (VALUE self, VALUE caps) { GstCaps *current = RGST_CAPS (self); gst_caps_replace (¤t, RGST_CAPS (caps)); return self; }
static void _teardown_test (void) { GstBus *bus; gst_element_set_state (demux, GST_STATE_NULL); bus = GST_ELEMENT_BUS (demux); gst_bus_set_flushing (bus, TRUE); gst_object_unref (bus); gst_pad_set_active (mjpg_pad, FALSE); gst_object_unref (mjpg_pad); if (h264_pad) { gst_pad_set_active (h264_pad, FALSE); gst_object_unref (h264_pad); } if (yuy2_pad) { gst_pad_set_active (yuy2_pad, FALSE); gst_object_unref (yuy2_pad); } if (nv12_pad) { gst_pad_set_active (nv12_pad, FALSE); gst_object_unref (nv12_pad); } if (jpg_pad) { gst_pad_set_active (jpg_pad, FALSE); gst_object_unref (jpg_pad); } if (gerror) { g_error_free (gerror); gerror = NULL; } if (error_debug) { g_free (error_debug); error_debug = NULL; } gst_object_unref (demux); mjpg_pad = h264_pad = yuy2_pad = nv12_pad = jpg_pad = NULL; demux = NULL; gst_caps_replace (&negotiated_caps_h264, NULL); gst_caps_replace (&negotiated_caps_yuy2, NULL); gst_caps_replace (&negotiated_caps_nv12, NULL); gst_caps_replace (&negotiated_caps_jpg, NULL); }
/** * gst_aggregator_set_src_caps: * @self: The #GstAggregator * @caps: The #GstCaps to set on the src pad. * * Sets the caps to be used on the src pad. */ void gst_aggregator_set_src_caps (GstAggregator * self, GstCaps * caps) { GST_AGGREGATOR_SETCAPS_LOCK (self); gst_caps_replace (&self->priv->srccaps, caps); _push_mandatory_events (self); GST_AGGREGATOR_SETCAPS_UNLOCK (self); }
void gst_fragment_set_caps (GstFragment * fragment, GstCaps * caps) { g_return_if_fail (fragment != NULL); g_mutex_lock (&fragment->priv->lock); gst_caps_replace (&fragment->priv->caps, caps); g_mutex_unlock (&fragment->priv->lock); }
static void gst_caps_setter_finalize (GObject * object) { GstCapsSetter *filter = GST_CAPS_SETTER (object); gst_caps_replace (&filter->caps, NULL); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void gst_audiomixer_dispose (GObject * object) { GstAudioMixer *audiomixer = GST_AUDIO_MIXER (object); gst_caps_replace (&audiomixer->filter_caps, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); }
void gst_fragment_set_caps (GstFragment * fragment, GstCaps * caps) { g_return_if_fail (fragment != NULL); G_MUTEX_LOCK (fragment->priv->lock); gst_caps_replace (&fragment->priv->caps, caps); G_MUTEX_UNLOCK (fragment->priv->lock); }
static void gst_capsfilter_dispose (GObject * object) { GstCapsFilter *filter = GST_CAPSFILTER (object); gst_caps_replace (&filter->filter_caps, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); }
static void gst_base_camera_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object); switch (prop_id) { case PROP_MODE: gst_base_camera_src_set_mode (GST_BASE_CAMERA_SRC (self), g_value_get_enum (value)); break; case PROP_ZOOM:{ self->zoom = g_value_get_float (value); /* limit to max-zoom */ if (self->zoom > self->max_zoom) { GST_DEBUG_OBJECT (self, "Clipping zoom %f to max-zoom %f", self->zoom, self->max_zoom); self->zoom = self->max_zoom; } /* does not set it if in NULL, the src is not created yet */ if (GST_STATE (self) != GST_STATE_NULL) gst_base_camera_src_setup_zoom (self); break; } case PROP_POST_PREVIEW: self->post_preview = g_value_get_boolean (value); break; case PROP_PREVIEW_CAPS:{ GstCaps *new_caps = NULL; new_caps = (GstCaps *) gst_value_get_caps (value); if (!gst_caps_is_equal (self->preview_caps, new_caps)) { gst_caps_replace (&self->preview_caps, new_caps); gst_base_camera_src_setup_preview (self, new_caps); } else { GST_DEBUG_OBJECT (self, "New preview caps equal current preview caps"); } } break; case PROP_PREVIEW_FILTER: if (self->preview_filter) gst_object_unref (self->preview_filter); self->preview_filter = g_value_dup_object (value); if (!gst_camerabin_preview_set_filter (self->preview_pipeline, self->preview_filter)) { GST_WARNING_OBJECT (self, "Cannot change preview filter, is element in NULL state?"); } break; case PROP_AUTO_START: self->auto_start = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec); break; } }
static void gst_esdsink_finalize (GObject * object) { GstEsdSink *esdsink = GST_ESDSINK (object); gst_caps_replace (&esdsink->cur_caps, NULL); g_free (esdsink->host); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void start_typefinding (GstTypeFindElement * typefind) { GST_DEBUG_OBJECT (typefind, "starting typefinding"); gst_pad_set_caps (typefind->src, NULL); if (typefind->caps) { gst_caps_replace (&typefind->caps, NULL); } typefind->mode = MODE_TYPEFIND; }
gboolean gst_sndio_close (struct gstsndio *sio) { GST_DEBUG_OBJECT (sio->obj, "close"); gst_caps_replace (&sio->cur_caps, NULL); sio_close (sio->hdl); sio->hdl = NULL; return TRUE; }
static void gst_interleave_release_pad (GstElement * element, GstPad * pad) { GstInterleave *self = GST_INTERLEAVE (element); GList *l; GstAudioChannelPosition position; g_return_if_fail (GST_IS_INTERLEAVE_PAD (pad)); /* Take lock to make sure we're not changing this when processing buffers */ GST_OBJECT_LOCK (self->collect); g_atomic_int_add (&self->channels, -1); if (gst_pad_has_current_caps (pad)) g_atomic_int_add (&self->configured_sinkpads_counter, -1); position = GST_INTERLEAVE_PAD_CAST (pad)->channel; g_value_array_remove (self->input_channel_positions, position); /* Update channel numbers */ GST_OBJECT_LOCK (self); for (l = GST_ELEMENT_CAST (self)->sinkpads; l != NULL; l = l->next) { GstInterleavePad *ipad = GST_INTERLEAVE_PAD (l->data); if (GST_INTERLEAVE_PAD_CAST (pad)->channel < ipad->channel) ipad->channel--; } GST_OBJECT_UNLOCK (self); /* Update the src caps if we already have them */ if (self->sinkcaps) { if (self->channels > 0) { GstCaps *srccaps; GstStructure *s; srccaps = gst_caps_copy (self->sinkcaps); s = gst_caps_get_structure (srccaps, 0); gst_structure_set (s, "channels", G_TYPE_INT, self->channels, NULL); gst_interleave_set_channel_positions (self, s); gst_pad_set_active (self->src, TRUE); gst_pad_set_caps (self->src, srccaps); gst_caps_unref (srccaps); } else { gst_caps_replace (&self->sinkcaps, NULL); } } GST_OBJECT_UNLOCK (self->collect); gst_collect_pads_remove_pad (self->collect, pad); gst_element_remove_pad (element, pad); }
static void gst_audio_aggregator_dispose (GObject * object) { GstAudioAggregator *aagg = GST_AUDIO_AGGREGATOR (object); gst_caps_replace (&aagg->current_caps, NULL); g_mutex_clear (&aagg->priv->mutex); G_OBJECT_CLASS (gst_audio_aggregator_parent_class)->dispose (object); }
/* this is not made atomic because if the buffer were reffed from multiple * threads, it would have a refcount > 2 and thus be immutable. */ void gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps) { g_return_if_fail (buffer != NULL); #if GST_VERSION_NANO == 1 /* we enable this extra debugging in git versions only for now */ g_return_if_fail (gst_buffer_is_metadata_writable (buffer)); #endif gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps); }
static void videocrop_test_cropping_deinit_context (GstVideoCropTestContext * ctx) { GST_LOG ("deiniting context"); gst_element_set_state (ctx->pipeline, GST_STATE_NULL); gst_object_unref (ctx->pipeline); gst_buffer_replace (&ctx->last_buf, NULL); gst_caps_replace (&ctx->last_caps, NULL); memset (ctx, 0x00, sizeof (GstVideoCropTestContext)); }
static void handoff_cb (GstElement * sink, GstBuffer * buf, GstPad * pad, GstVideoCropTestContext * ctx) { GstCaps *caps; gst_buffer_replace (&ctx->last_buf, buf); caps = gst_pad_get_current_caps (pad); gst_caps_replace (&ctx->last_caps, caps); gst_caps_unref (caps); }
static void gst_capsfilter_dispose (GObject * object) { GstCapsFilter *filter = GST_CAPSFILTER (object); gst_caps_replace (&filter->filter_caps, NULL); g_list_free_full (filter->pending_events, (GDestroyNotify) gst_event_unref); filter->pending_events = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); }
static gboolean gst_type_find_element_activate (GstPad * pad) { // set state machine, and caps to NULL start_typefinding (typefind); { gst_pad_set_caps (typefind->src, NULL); gst_caps_replace (&typefind->caps, NULL); typefind->mode = MODE_TYPEFIND; } }
/** * gst_vaapi_plugin_base_close: * @plugin: a #GstVaapiPluginBase * * Deallocates all internal resources that were allocated so * far. i.e. put the base plugin object into a clean state. */ void gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin) { gst_vaapi_display_replace (&plugin->display, NULL); gst_object_replace (&plugin->gl_context, NULL); gst_caps_replace (&plugin->sinkpad_caps, NULL); plugin->sinkpad_caps_changed = FALSE; gst_video_info_init (&plugin->sinkpad_info); if (plugin->sinkpad_buffer_pool) { gst_object_unref (plugin->sinkpad_buffer_pool); plugin->sinkpad_buffer_pool = NULL; } g_clear_object (&plugin->srcpad_buffer_pool); gst_caps_replace (&plugin->srcpad_caps, NULL); plugin->srcpad_caps_changed = FALSE; gst_video_info_init (&plugin->srcpad_info); gst_caps_replace (&plugin->allowed_raw_caps, NULL); }
static gboolean gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry) { GstBuffer *buf; guint avail; const gchar *next_fragment_uri; GstClockTime duration; GstClockTime timestamp; gboolean discont; if (!gst_m3u8_client_get_next_fragment (demux->client, &discont, &next_fragment_uri, &duration, ×tamp)) { GST_INFO_OBJECT (demux, "This playlist doesn't contain more fragments"); demux->end_of_playlist = TRUE; gst_task_start (demux->task); return FALSE; } GST_INFO_OBJECT (demux, "Fetching next fragment %s", next_fragment_uri); if (!gst_hls_demux_fetch_location (demux, next_fragment_uri)) return FALSE; avail = gst_adapter_available (demux->download); buf = gst_adapter_take_buffer (demux->download, avail); GST_BUFFER_DURATION (buf) = duration; GST_BUFFER_TIMESTAMP (buf) = timestamp; /* We actually need to do this every time we switch bitrate */ if (G_UNLIKELY (demux->do_typefind)) { GstCaps *caps = gst_type_find_helper_for_buffer (NULL, buf, NULL); if (!demux->input_caps || !gst_caps_is_equal (caps, demux->input_caps)) { gst_caps_replace (&demux->input_caps, caps); /* gst_pad_set_caps (demux->srcpad, demux->input_caps); */ GST_INFO_OBJECT (demux, "Input source caps: %" GST_PTR_FORMAT, demux->input_caps); demux->do_typefind = FALSE; } else gst_caps_unref (caps); } gst_buffer_set_caps (buf, demux->input_caps); if (discont) { GST_DEBUG_OBJECT (demux, "Marking fragment as discontinuous"); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); } g_queue_push_tail (demux->queue, buf); gst_task_start (demux->task); gst_adapter_clear (demux->download); return TRUE; }
static void start_typefinding (GstTypeFindElement * typefind) { GST_DEBUG_OBJECT (typefind, "starting typefinding"); GST_OBJECT_LOCK (typefind); if (typefind->caps) gst_caps_replace (&typefind->caps, NULL); GST_OBJECT_UNLOCK (typefind); typefind->mode = MODE_TYPEFIND; }
static void gst_slvideo_update_caps (GstSLVideo * slvideo) { GstCaps *caps; // GStreamer will automatically convert colourspace if necessary. // GStreamer will automatically resize media to one of these enumerated // powers-of-two that we ask for (yay GStreamer!) caps = gst_caps_from_string (SLV_ALLCAPS); gst_caps_replace (&slvideo->caps, caps); }
static gboolean gst_alsasink_acceptcaps (GstPad * pad, GstCaps * caps) { GstAlsaSink *alsa = GST_ALSA_SINK (gst_pad_get_parent_element (pad)); GstCaps *pad_caps; GstStructure *st; gboolean ret = FALSE; GstRingBufferSpec spec = { 0 }; pad_caps = gst_pad_get_caps_reffed (pad); if (pad_caps) { ret = gst_caps_can_intersect (pad_caps, caps); gst_caps_unref (pad_caps); if (!ret) goto done; } /* If we've not got fixed caps, creating a stream might fail, so let's just * return from here with default acceptcaps behaviour */ if (!gst_caps_is_fixed (caps)) goto done; /* parse helper expects this set, so avoid nasty warning * will be set properly later on anyway */ spec.latency_time = GST_SECOND; if (!gst_ring_buffer_parse_caps (&spec, caps)) goto done; /* Make sure input is framed (one frame per buffer) and can be payloaded */ switch (spec.type) { case GST_BUFTYPE_AC3: case GST_BUFTYPE_EAC3: case GST_BUFTYPE_DTS: case GST_BUFTYPE_MPEG: { gboolean framed = FALSE, parsed = FALSE; st = gst_caps_get_structure (caps, 0); gst_structure_get_boolean (st, "framed", &framed); gst_structure_get_boolean (st, "parsed", &parsed); if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0) goto done; } default: { } } ret = TRUE; done: gst_caps_replace (&spec.caps, NULL); gst_object_unref (alsa); return ret; }
static void gst_vaapidecode_destroy (GstVaapiDecode * decode) { gst_vaapidecode_purge (decode); gst_vaapi_decoder_replace (&decode->decoder, NULL); gst_caps_replace (&decode->decoder_caps, NULL); decode->active = FALSE; gst_vaapidecode_release (gst_object_ref (decode)); }
static void bt_test_audio_synth_finalize (GObject * object) { BtTestAudioSynth *self = (BtTestAudioSynth *) object; if (self->caps) { gst_caps_replace (&self->caps, NULL); } reset_buffer_info (self); G_OBJECT_CLASS (bt_test_audio_synth_parent_class)->finalize (object); }