static gboolean gst_asf_parse_sink_activate (GstPad * sinkpad, GstObject * parent) { GstQuery *query; gboolean pull_mode; query = gst_query_new_scheduling (); if (!gst_pad_peer_query (sinkpad, query)) { gst_query_unref (query); goto activate_push; } pull_mode = gst_query_has_scheduling_mode_with_flags (query, GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE); gst_query_unref (query); if (!pull_mode) goto activate_push; GST_DEBUG_OBJECT (sinkpad, "activating pull"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE); activate_push: { GST_DEBUG_OBJECT (sinkpad, "activating push"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE); } }
static gboolean gst_stream_combiner_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstStreamCombiner *stream_combiner = (GstStreamCombiner *) parent; GstPad *sinkpad = NULL; gboolean ret = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CAPS: ret = gst_pad_query_default (pad, parent, query); break; default: STREAMS_LOCK (stream_combiner); if (stream_combiner->current) sinkpad = stream_combiner->current; else if (stream_combiner->sinkpads) sinkpad = (GstPad *) stream_combiner->sinkpads->data; STREAMS_UNLOCK (stream_combiner); if (sinkpad) /* Forward upstream as is */ ret = gst_pad_peer_query (sinkpad, query); break; } return ret; }
static gboolean gst_hls_demux_sink_event (GstPad * pad, GstEvent * event) { GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_parent (pad)); GstQuery *query; gboolean ret; gchar *uri; switch (event->type) { case GST_EVENT_EOS:{ gchar *playlist; if (demux->playlist == NULL) { GST_WARNING_OBJECT (demux, "Received EOS without a playlist."); break; } GST_DEBUG_OBJECT (demux, "Got EOS on the sink pad: main playlist fetched"); query = gst_query_new_uri (); ret = gst_pad_peer_query (demux->sinkpad, query); if (ret) { gst_query_parse_uri (query, &uri); gst_hls_demux_set_location (demux, uri); g_free (uri); } gst_query_unref (query); playlist = gst_hls_src_buf_to_utf8_playlist ((gchar *) GST_BUFFER_DATA (demux->playlist), GST_BUFFER_SIZE (demux->playlist)); gst_buffer_unref (demux->playlist); if (playlist == NULL) { GST_WARNING_OBJECT (demux, "Error validating first playlist."); } else if (!gst_m3u8_client_update (demux->client, playlist)) { /* In most cases, this will happen if we set a wrong url in the * source element and we have received the 404 HTML response instead of * the playlist */ GST_ELEMENT_ERROR (demux, STREAM, DECODE, ("Invalid playlist."), NULL); return FALSE; } if (!ret && gst_m3u8_client_is_live (demux->client)) { GST_ELEMENT_ERROR (demux, RESOURCE, NOT_FOUND, ("Failed querying the playlist uri, " "required for live sources."), NULL); return FALSE; } gst_task_start (demux->task); gst_event_unref (event); return TRUE; } default: break; } return gst_pad_event_default (pad, event); }
static gboolean gst_stream_combiner_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstStreamCombiner *stream_combiner = (GstStreamCombiner *) parent; return gst_pad_peer_query (stream_combiner->srcpad, query); }
/*********************************************************************************** * Query ***********************************************************************************/ static gboolean mpegts_demuxer_sink_query (GstPad *pad, GstObject *parent, GstQuery *query) { gboolean result = TRUE; MpegTSDemuxer *demuxer = MPEGTS_DEMUXER(parent); switch (GST_QUERY_TYPE(query)) { case GST_QUERY_DURATION: { GstFormat format; gst_query_parse_duration(query, &format, NULL); if (format == GST_FORMAT_TIME) result = gst_pad_peer_query(pad, query); else if (format == GST_FORMAT_BYTES) { g_mutex_lock(&demuxer->lock); int bit_rate = (demuxer->context != NULL) ? demuxer->context->bit_rate : 0; g_mutex_unlock(&demuxer->lock); if (bit_rate > 0) { gint64 duration = GST_CLOCK_TIME_NONE; if (gst_pad_peer_query_duration(pad, GST_FORMAT_TIME, &duration)) { // Approximate duration in bytes for a certain time duration and bit rate. if (duration != GST_CLOCK_TIME_NONE) duration = (double)(duration * bit_rate) / GST_SECOND / 8; gst_query_set_duration(query, format, duration); } else result = FALSE; } else result = gst_pad_peer_query(pad, query); } break; } default: result = gst_pad_peer_query(pad, query); break; } return result; }
static gboolean gst_wayland_sink_find_display (GstWaylandSink * sink) { GstQuery *query; GstMessage *msg; GstContext *context = NULL; GError *error = NULL; gboolean ret = TRUE; g_mutex_lock (&sink->display_lock); if (!sink->display) { /* first query upstream for the needed display handle */ query = gst_query_new_context (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE); if (gst_pad_peer_query (GST_VIDEO_SINK_PAD (sink), query)) { gst_query_parse_context (query, &context); gst_wayland_sink_set_display_from_context (sink, context); } gst_query_unref (query); if (G_LIKELY (!sink->display)) { /* now ask the application to set the display handle */ msg = gst_message_new_need_context (GST_OBJECT_CAST (sink), GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE); g_mutex_unlock (&sink->display_lock); gst_element_post_message (GST_ELEMENT_CAST (sink), msg); /* at this point we expect gst_wayland_sink_set_context * to get called and fill sink->display */ g_mutex_lock (&sink->display_lock); if (!sink->display) { /* if the application didn't set a display, let's create it ourselves */ GST_OBJECT_LOCK (sink); sink->display = gst_wl_display_new (sink->display_name, &error); GST_OBJECT_UNLOCK (sink); if (error) { GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE, ("Could not initialise Wayland output"), ("Failed to create GstWlDisplay: '%s'", error->message)); g_error_free (error); ret = FALSE; } else { /* inform the world about the new display */ context = gst_wayland_display_handle_context_new (sink->display->display); msg = gst_message_new_have_context (GST_OBJECT_CAST (sink), context); gst_element_post_message (GST_ELEMENT_CAST (sink), msg); } } } } g_mutex_unlock (&sink->display_lock); return ret; }
static gboolean gst_goom_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { gboolean res = FALSE; GstGoom *goom; goom = GST_GOOM (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { /* We need to send the query upstream and add the returned latency to our * own */ GstClockTime min_latency, max_latency; gboolean us_live; GstClockTime our_latency; guint max_samples; if (goom->rate == 0) break; if ((res = gst_pad_peer_query (goom->sinkpad, query))) { gst_query_parse_latency (query, &us_live, &min_latency, &max_latency); GST_DEBUG_OBJECT (goom, "Peer latency: min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency)); /* the max samples we must buffer buffer */ max_samples = MAX (GOOM_SAMPLES, goom->spf); our_latency = gst_util_uint64_scale_int (max_samples, GST_SECOND, goom->rate); GST_DEBUG_OBJECT (goom, "Our latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (our_latency)); /* we add some latency but only if we need to buffer more than what * upstream gives us */ min_latency += our_latency; if (max_latency != -1) max_latency += our_latency; GST_DEBUG_OBJECT (goom, "Calculated total latency : min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency)); gst_query_set_latency (query, TRUE, min_latency, max_latency); } break; } default: res = gst_pad_query_default (pad, parent, query); break; } return res; }
static gboolean gst_audio_fx_base_fir_filter_query (GstBaseTransform * trans, GstPadDirection direction, GstQuery * query) { GstAudioFXBaseFIRFilter *self = GST_AUDIO_FX_BASE_FIR_FILTER (trans); gboolean res = TRUE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { GstClockTime min, max; gboolean live; guint64 latency; gint rate = GST_AUDIO_FILTER_RATE (self); if (rate == 0) { res = FALSE; } else if ((res = gst_pad_peer_query (GST_BASE_TRANSFORM (self)->sinkpad, query))) { gst_query_parse_latency (query, &live, &min, &max); GST_DEBUG_OBJECT (self, "Peer latency: min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min), GST_TIME_ARGS (max)); if (self->fft && !self->low_latency) latency = self->block_length - self->kernel_length + 1; else latency = self->latency; /* add our own latency */ latency = gst_util_uint64_scale_round (latency, GST_SECOND, rate); GST_DEBUG_OBJECT (self, "Our latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (latency)); min += latency; if (max != GST_CLOCK_TIME_NONE) max += latency; GST_DEBUG_OBJECT (self, "Calculated total latency : min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min), GST_TIME_ARGS (max)); gst_query_set_latency (query, live, min, max); } break; } default: res = GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction, query); break; } return res; }
static gboolean gst_rtp_jitter_buffer_query (GstPad * pad, GstQuery * query) { GstRtpJitterBuffer *jitterbuffer; GstRtpJitterBufferPrivate *priv; gboolean res = FALSE; jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad)); priv = jitterbuffer->priv; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { /* We need to send the query upstream and add the returned latency to our * own */ GstClockTime min_latency, max_latency; gboolean us_live; GstClockTime our_latency; if ((res = gst_pad_peer_query (priv->sinkpad, query))) { gst_query_parse_latency (query, &us_live, &min_latency, &max_latency); GST_DEBUG_OBJECT (jitterbuffer, "Peer latency: min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency)); /* store this so that we can safely sync on the peer buffers. */ JBUF_LOCK (priv); priv->peer_latency = min_latency; our_latency = ((guint64) priv->latency_ms) * GST_MSECOND; JBUF_UNLOCK (priv); GST_DEBUG_OBJECT (jitterbuffer, "Our latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (our_latency)); /* we add some latency but can buffer an infinite amount of time */ min_latency += our_latency; max_latency = -1; GST_DEBUG_OBJECT (jitterbuffer, "Calculated total latency : min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency)); gst_query_set_latency (query, TRUE, min_latency, max_latency); } break; } default: res = gst_pad_query_default (pad, query); break; } gst_object_unref (jitterbuffer); return res; }
static void push_query (gpointer data, gpointer user_data) { GstHarness *h = user_data; GstCaps *caps = gst_caps_new_empty_simple ("mycaps"); GstQuery *query = gst_query_new_allocation (caps, FALSE); gst_caps_unref (caps); gst_pad_peer_query (h->srcpad, query); gst_query_unref (query); }
static gboolean gst_gdk_pixbuf_dec_setup_pool (GstGdkPixbufDec * filter, GstVideoInfo * info) { GstCaps *target; GstQuery *query; GstBufferPool *pool; GstStructure *config; guint size, min, max; target = gst_pad_get_current_caps (filter->srcpad); /* try to get a bufferpool now */ /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); if (!gst_pad_peer_query (filter->srcpad, query)) { /* not a problem, we use the query defaults */ GST_DEBUG_OBJECT (filter, "ALLOCATION query failed"); } if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { pool = NULL; size = info->size; min = max = 0; } gst_query_unref (query); if (pool == NULL) { /* we did not get a pool, make one ourselves then */ pool = gst_buffer_pool_new (); } /* and configure */ config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, target, size, min, max); gst_buffer_pool_set_config (pool, config); if (filter->pool) { gst_buffer_pool_set_active (filter->pool, FALSE); gst_object_unref (filter->pool); } filter->pool = pool; /* and activate */ gst_buffer_pool_set_active (filter->pool, TRUE); gst_caps_unref (target); return TRUE; }
static gboolean gst_gl_base_mixer_do_bufferpool (GstGLBaseMixer * mix, GstCaps * outcaps) { GstQuery *query; gboolean result = TRUE; GstBufferPool *pool = NULL; GstAllocator *allocator; GstAllocationParams params; GstAggregator *agg = GST_AGGREGATOR (mix); /* find a pool for the negotiated caps now */ GST_DEBUG_OBJECT (mix, "doing allocation query"); query = gst_query_new_allocation (outcaps, TRUE); if (!gst_pad_peer_query (agg->srcpad, query)) { /* not a problem, just debug a little */ GST_DEBUG_OBJECT (mix, "peer ALLOCATION query failed"); } GST_DEBUG_OBJECT (mix, "calling decide_allocation"); result = gst_gl_base_mixer_decide_allocation (mix, query); GST_DEBUG_OBJECT (mix, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result, query); if (!result) goto no_decide_allocation; /* we got configuration from our peer or the decide_allocation method, * parse them */ if (gst_query_get_n_allocation_params (query) > 0) { gst_query_parse_nth_allocation_param (query, 0, &allocator, ¶ms); } else { allocator = NULL; gst_allocation_params_init (¶ms); } if (gst_query_get_n_allocation_pools (query) > 0) gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL); /* now store */ result = gst_gl_base_mixer_set_allocation (mix, pool, allocator, ¶ms, query); return result; /* Errors */ no_decide_allocation: { GST_WARNING_OBJECT (mix, "Failed to decide allocation"); gst_query_unref (query); return result; } }
gboolean gst_splitmux_part_reader_src_query (GstSplitMuxPartReader * part, GstPad * src_pad, GstQuery * query) { GstPad *target = NULL; gboolean ret; GList *cur; SPLITMUX_PART_LOCK (part); /* Find the pad corresponding to the visible output target pad */ for (cur = g_list_first (part->pads); cur != NULL; cur = g_list_next (cur)) { GstSplitMuxPartPad *part_pad = SPLITMUX_PART_PAD_CAST (cur->data); if (part_pad->target == src_pad) { target = gst_object_ref (GST_OBJECT_CAST (part_pad)); break; } } SPLITMUX_PART_UNLOCK (part); if (target == NULL) return FALSE; ret = gst_pad_peer_query (target, query); gst_object_unref (GST_OBJECT_CAST (target)); if (ret == FALSE) goto out; /* Post-massaging of queries */ switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION:{ GstFormat fmt; gint64 position; gst_query_parse_position (query, &fmt, &position); if (fmt != GST_FORMAT_TIME) return FALSE; SPLITMUX_PART_LOCK (part); position += part->start_offset; GST_LOG_OBJECT (part, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS (position)); SPLITMUX_PART_UNLOCK (part); gst_query_set_position (query, fmt, position); break; } default: break; } out: gst_object_unref (target); return ret; }
static gboolean gst_compare_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstCompare *comp; GstPad *otherpad; comp = GST_COMPARE (parent); otherpad = (pad == comp->srcpad ? comp->sinkpad : comp->srcpad); return gst_pad_peer_query (otherpad, query); }
static gboolean gst_stream_splitter_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstStreamSplitter *stream_splitter = (GstStreamSplitter *) parent; GST_DEBUG_OBJECT (pad, "%s", GST_QUERY_TYPE_NAME (query)); /* Forward upstream as is */ return gst_pad_peer_query (stream_splitter->sinkpad, query); }
static gboolean stereosplit_do_bufferpool (GstGLStereoSplit * self, GstCaps * caps) { GstQuery *query; query = gst_query_new_allocation (caps, TRUE); if (!gst_pad_peer_query (self->left_pad, query)) { if (!gst_pad_peer_query (self->right_pad, query)) { GST_DEBUG_OBJECT (self, "peer ALLOCATION query failed on both src pads"); } } if (!stereosplit_decide_allocation (self, query)) { gst_query_unref (query); return FALSE; } gst_query_unref (query); return TRUE; }
static void gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; GstBufferPool *pool; guint size, min, max; GstStructure *config; /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (caps, TRUE); if (!gst_pad_peer_query (dec->srcpad, query)) { GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); } if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); size = MAX (size, info->size); } else { pool = NULL; size = info->size; min = max = 0; } if (pool == NULL) { /* we did not get a pool, make one ourselves then */ pool = gst_video_buffer_pool_new (); } if (dec->pool) { gst_buffer_pool_set_active (dec->pool, FALSE); gst_object_unref (dec->pool); } dec->pool = pool; config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, caps, size, min, max); if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) { /* just set the option, if the pool can support it we will transparently use * it through the video info API. We could also see if the pool support this * option and only activate it then. */ gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); } gst_buffer_pool_set_config (pool, config); /* and activate */ gst_buffer_pool_set_active (pool, TRUE); gst_query_unref (query); }
static GstFlowReturn gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; GstBufferPool *pool = NULL; guint size, min, max; GstStructure *config; /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (caps, TRUE); if (!gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) { /* not a problem, we use the defaults of query */ GST_DEBUG_OBJECT (depay, "could not get downstream ALLOCATION hints"); } if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { GST_DEBUG_OBJECT (depay, "didn't get downstream pool hints"); size = info->size; min = max = 0; } if (pool == NULL) { /* we did not get a pool, make one ourselves then */ pool = gst_video_buffer_pool_new (); } if (depay->pool) gst_object_unref (depay->pool); depay->pool = pool; config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, caps, size, min, max); if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) { /* just set the metadata, if the pool can support it we will transparently use * it through the video info API. We could also see if the pool support this * metadata and only activate it then. */ gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); } gst_buffer_pool_set_config (pool, config); /* and activate */ gst_buffer_pool_set_active (pool, TRUE); gst_query_unref (query); return GST_FLOW_OK; }
static gboolean gst_y4m_dec_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstY4mDec *y4mdec = GST_Y4M_DEC (parent); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION: { GstFormat format; GstQuery *peer_query; GST_DEBUG ("duration query"); gst_query_parse_duration (query, &format, NULL); if (format != GST_FORMAT_TIME) { res = FALSE; GST_DEBUG_OBJECT (y4mdec, "not handling duration query in format %d", format); break; } peer_query = gst_query_new_duration (GST_FORMAT_BYTES); res = gst_pad_peer_query (y4mdec->sinkpad, peer_query); if (res) { gint64 duration; int n_frames; gst_query_parse_duration (peer_query, &format, &duration); n_frames = gst_y4m_dec_bytes_to_frames (y4mdec, duration); GST_DEBUG ("duration in frames %d", n_frames); duration = gst_y4m_dec_frames_to_timestamp (y4mdec, n_frames); GST_DEBUG ("duration in time %" GST_TIME_FORMAT, GST_TIME_ARGS (duration)); gst_query_set_duration (query, GST_FORMAT_TIME, duration); res = TRUE; } gst_query_unref (peer_query); break; } default: res = gst_pad_query_default (pad, parent, query); break; } return res; }
static gboolean context_pad_query (const GValue * item, GValue * value, gpointer user_data) { GstPad *const pad = g_value_get_object (item); GstQuery *const query = user_data; if (gst_pad_peer_query (pad, query)) { g_value_set_boolean (value, TRUE); return FALSE; } _init_context_debug (); GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, pad, "context pad peer query failed"); return TRUE; }
static void query_upstream_latency (MpegTSBase * base) { GstQuery *query; query = gst_query_new_latency (); if (gst_pad_peer_query (base->sinkpad, query)) { gst_query_parse_latency (query, &base->upstream_live, NULL, NULL); GST_DEBUG_OBJECT (base, "Upstream is %s", base->upstream_live ? "LIVE" : "NOT LIVE"); } else GST_WARNING_OBJECT (base, "Failed to query upstream latency"); gst_query_unref (query); base->queried_latency = TRUE; }
static gboolean progress_buffer_checkgetrange(GstPad *pad) { ProgressBuffer *element = PROGRESS_BUFFER(GST_PAD_PARENT(pad)); #if ENABLE_PULL_MODE gboolean result = FALSE; GstStructure *s = gst_structure_new(GETRANGE_QUERY_NAME, NULL, NULL); GstQuery *query = gst_query_new_custom(GST_QUERY_CUSTOM, s); if (gst_pad_peer_query(pad, query)) result = gst_structure_get_boolean(s, GETRANGE_QUERY_SUPPORTS_FIELDNANE, &result) && result; // INLINE - gst_query_unref() gst_query_unref(query); return result; #else return gst_pad_check_pull_range(element->sinkpad); #endif }
static gboolean gst_segment_clip_query (GstPad * pad, GstQuery * query) { GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad)); gboolean ret; GstPad *otherpad; otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad; GST_LOG_OBJECT (pad, "Handling query of type '%s'", gst_query_type_get_name (GST_QUERY_TYPE (query))); ret = gst_pad_peer_query (otherpad, query); gst_object_unref (self); return ret; }
static gboolean gst_jp2k_decimator_query (GstPad * pad, GstQuery * query) { GstJP2kDecimator *self = GST_JP2K_DECIMATOR (gst_pad_get_parent (pad)); gboolean ret; GstPad *otherpad; otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad; GST_LOG_OBJECT (pad, "Handling query of type '%s'", gst_query_type_get_name (GST_QUERY_TYPE (query))); ret = gst_pad_peer_query (otherpad, query); gst_object_unref (self); return ret; }
static gboolean gst_tee_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstTee *tee; gboolean res; GstPad *sinkpad; tee = GST_TEE (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_SCHEDULING: { gboolean pull_mode; GST_OBJECT_LOCK (tee); pull_mode = TRUE; if (tee->pull_mode == GST_TEE_PULL_MODE_NEVER) { GST_INFO_OBJECT (tee, "Cannot activate in pull mode, pull-mode " "set to NEVER"); pull_mode = FALSE; } else if (tee->pull_mode == GST_TEE_PULL_MODE_SINGLE && tee->pull_pad) { GST_INFO_OBJECT (tee, "Cannot activate multiple src pads in pull mode, " "pull-mode set to SINGLE"); pull_mode = FALSE; } sinkpad = gst_object_ref (tee->sinkpad); GST_OBJECT_UNLOCK (tee); if (pull_mode) { /* ask peer if we can operate in pull mode */ res = gst_pad_peer_query (sinkpad, query); } else { res = TRUE; } gst_object_unref (sinkpad); break; } default: res = gst_pad_query_default (pad, parent, query); break; } return res; }
static gboolean gst_output_selector_query (GstPad * pad, GstObject * parent, GstQuery * query) { gboolean res = TRUE; GstOutputSelector *sel; GstPad *active = NULL; sel = GST_OUTPUT_SELECTOR (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CAPS: { switch (sel->pad_negotiation_mode) { case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL: /* Send caps to all src pads */ res = gst_pad_proxy_query_caps (pad, query); break; case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE: res = FALSE; break; default: active = gst_output_selector_get_active (sel); if (active) { res = gst_pad_peer_query (active, query); gst_object_unref (active); } else { res = FALSE; } break; } break; } case GST_QUERY_DRAIN: if (sel->latest_buffer) { gst_buffer_unref (sel->latest_buffer); sel->latest_buffer = NULL; } /* fall through */ default: res = gst_pad_query_default (pad, parent, query); break; } return res; }
static gboolean gst_stream_synchronizer_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstPad *opad; gboolean ret = FALSE; GST_LOG_OBJECT (pad, "Handling query %s", GST_QUERY_TYPE_NAME (query)); opad = gst_stream_get_other_pad_from_pad (GST_STREAM_SYNCHRONIZER (parent), pad); if (opad) { ret = gst_pad_peer_query (opad, query); gst_object_unref (opad); } return ret; }
static gpointer thread_func (gpointer data) { int i = 0; for (i = 0; i < 100; i++) { GstCaps *caps; GstQuery *query; gboolean ok; caps = gst_caps_new_any (); query = gst_query_new_allocation (caps, FALSE); ok = gst_pad_peer_query (mysrcpad, query); gst_query_unref (query); gst_caps_unref (caps); query = NULL; caps = NULL; if (!ok) break; } return NULL; }
static gboolean gst_raw_parse_sink_activate (GstPad * sinkpad, GstObject * parent) { GstQuery *query; gboolean pull_mode = FALSE; query = gst_query_new_scheduling (); if (gst_pad_peer_query (sinkpad, query)) pull_mode = gst_query_has_scheduling_mode_with_flags (query, GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE); gst_query_unref (query); if (pull_mode) { GST_DEBUG ("going to pull mode"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE); } else { GST_DEBUG ("going to push (streaming) mode"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE); } }
static gboolean gst_rtp_ssrc_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstRtpSsrcDemux *demux; gboolean res = FALSE; demux = GST_RTP_SSRC_DEMUX (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { if ((res = gst_pad_peer_query (demux->rtp_sink, query))) { gboolean live; GstClockTime min_latency, max_latency; GstRtpSsrcDemuxPad *demuxpad; demuxpad = gst_pad_get_element_private (pad); gst_query_parse_latency (query, &live, &min_latency, &max_latency); GST_DEBUG_OBJECT (demux, "peer min latency %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency)); GST_DEBUG_OBJECT (demux, "latency for SSRC %08x", demuxpad->ssrc); gst_query_set_latency (query, live, min_latency, max_latency); } break; } default: res = gst_pad_query_default (pad, parent, query); break; } return res; }