static gboolean gst_deinterleave_src_query (GstPad * pad, GstQuery * query) { GstDeinterleave *self = GST_DEINTERLEAVE (gst_pad_get_parent (pad)); gboolean res; res = gst_pad_query_default (pad, query); if (res && GST_QUERY_TYPE (query) == GST_QUERY_DURATION) { GstFormat format; gint64 dur; gst_query_parse_duration (query, &format, &dur); /* Need to divide by the number of channels in byte format * to get the correct value. All other formats should be fine */ if (format == GST_FORMAT_BYTES && dur != -1) gst_query_set_duration (query, format, dur / self->channels); } else if (res && GST_QUERY_TYPE (query) == GST_QUERY_POSITION) { GstFormat format; gint64 pos; gst_query_parse_position (query, &format, &pos); /* Need to divide by the number of channels in byte format * to get the correct value. All other formats should be fine */ if (format == GST_FORMAT_BYTES && pos != -1) gst_query_set_position (query, format, pos / self->channels); } gst_object_unref (self); return res; }
static gboolean gst_cdxa_parse_src_query (GstPad * srcpad, GstQuery * query) { GstCDXAParse *cdxa = GST_CDXA_PARSE (gst_pad_get_parent (srcpad)); gboolean res = FALSE; GST_DEBUG_OBJECT (cdxa, "Handling %s query", gst_query_type_get_name (GST_QUERY_TYPE (query))); res = gst_pad_query_default (srcpad, query); if (res) { GstFormat format; gint64 val; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION: gst_query_parse_duration (query, &format, &val); if (format == GST_FORMAT_BYTES) { val = gst_cdxa_parse_convert_sink_to_src_offset (cdxa, val); gst_query_set_duration (query, format, val); } break; case GST_QUERY_POSITION: gst_query_parse_position (query, &format, &val); if (format == GST_FORMAT_BYTES) { val = gst_cdxa_parse_convert_sink_to_src_offset (cdxa, val); gst_query_set_position (query, format, val); } break; default: break; } } gst_object_unref (cdxa); return res; }
static gboolean gst_interleave_src_query (GstPad * pad, GstQuery * query) { GstInterleave *self = GST_INTERLEAVE (gst_pad_get_parent (pad)); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { GstFormat format; gst_query_parse_position (query, &format, NULL); switch (format) { case GST_FORMAT_TIME: /* FIXME, bring to stream time, might be tricky */ gst_query_set_position (query, format, self->timestamp); res = TRUE; break; case GST_FORMAT_BYTES: gst_query_set_position (query, format, self->offset * self->channels * self->width); res = TRUE; break; case GST_FORMAT_DEFAULT: gst_query_set_position (query, format, self->offset); res = TRUE; break; default: break; } break; } case GST_QUERY_DURATION: res = gst_interleave_src_query_duration (self, query); break; case GST_QUERY_LATENCY: res = gst_interleave_src_query_latency (self, query); break; default: /* FIXME, needs a custom query handler because we have multiple * sinkpads */ res = gst_pad_query_default (pad, query); break; } gst_object_unref (self); return res; }
static gboolean gst_segment_clip_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstSegmentClip *self = GST_SEGMENT_CLIP (parent); gboolean ret; GST_LOG_OBJECT (pad, "Handling query of type '%s'", gst_query_type_get_name (GST_QUERY_TYPE (query))); if (GST_QUERY_TYPE (query) == GST_QUERY_CAPS) { GstCaps *caps; gst_query_parse_caps (query, &caps); caps = gst_segment_clip_getcaps (self, pad, caps); gst_query_set_caps_result (query, caps); gst_caps_unref (caps); ret = TRUE; } else { ret = gst_pad_query_default (pad, parent, query); } return ret; }
/** * gst_query_set_latency: * @query: a #GstQuery * @live: if there is a live element upstream * @min_latency: the minimal latency of the live element * @max_latency: the maximal latency of the live element * * Answer a latency query by setting the requested values in the given format. * * Since: 0.10.12 */ void gst_query_set_latency (GstQuery * query, gboolean live, GstClockTime min_latency, GstClockTime max_latency) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY); structure = gst_query_get_structure (query); gst_structure_id_set (structure, GST_QUARK (LIVE), G_TYPE_BOOLEAN, live, GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, min_latency, GST_QUARK (MAX_LATENCY), G_TYPE_UINT64, max_latency, NULL); }
static gboolean gst_app_src_query (GstBaseSrc * src, GstQuery * query) { GstAppSrc *appsrc = GST_APP_SRC_CAST (src); GstAppSrcPrivate *priv = appsrc->priv; gboolean res; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { GstClockTime min, max; gboolean live; /* Query the parent class for the defaults */ res = gst_base_src_query_latency (src, &live, &min, &max); /* overwrite with our values when we need to */ g_mutex_lock (&priv->mutex); if (priv->min_latency != -1) min = priv->min_latency; if (priv->max_latency != -1) max = priv->max_latency; g_mutex_unlock (&priv->mutex); gst_query_set_latency (query, live, min, max); break; } case GST_QUERY_SCHEDULING: { gst_query_set_scheduling (query, GST_SCHEDULING_FLAG_SEEKABLE, 1, -1, 0); gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH); switch (priv->stream_type) { case GST_APP_STREAM_TYPE_STREAM: case GST_APP_STREAM_TYPE_SEEKABLE: break; case GST_APP_STREAM_TYPE_RANDOM_ACCESS: gst_query_add_scheduling_mode (query, GST_PAD_MODE_PULL); break; } res = TRUE; break; } default: res = GST_BASE_SRC_CLASS (parent_class)->query (src, query); break; } return res; }
static gboolean tee_query_function (GstPad * pad, GstObject * parent, GstQuery * query) { if (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS) { GstCaps *caps; KmsTreeBin *self = KMS_TREE_BIN (GST_OBJECT_PARENT (parent)); gst_query_parse_accept_caps (query, &caps); kms_tree_bin_set_input_caps (self, caps); } return gst_pad_query_default (pad, parent, query); }
static gboolean gst_tta_parse_query (GstPad * pad, GstQuery * query) { GstTtaParse *ttaparse = GST_TTA_PARSE (gst_pad_get_parent (pad)); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { GstFormat format; gint64 cur; gst_query_parse_position (query, &format, NULL); switch (format) { case GST_FORMAT_TIME: cur = ttaparse->index[ttaparse->current_frame].time; break; default: format = GST_FORMAT_BYTES; cur = ttaparse->index[ttaparse->current_frame].pos; break; } gst_query_set_position (query, format, cur); break; } case GST_QUERY_DURATION: { GstFormat format; gint64 end; gst_query_parse_duration (query, &format, NULL); switch (format) { case GST_FORMAT_TIME: end = ((gdouble) ttaparse->data_length / (gdouble) ttaparse->samplerate) * GST_SECOND; break; default: format = GST_FORMAT_BYTES; end = ttaparse->index[ttaparse->num_frames].pos + ttaparse->index[ttaparse->num_frames].size; break; } gst_query_set_duration (query, format, end); break; } default: return FALSE; break; } return TRUE; }
static gboolean gst_gtk_gl_sink_query (GstBaseSink * bsink, GstQuery * query) { GstGtkGLSink *gtk_sink = GST_GTK_GL_SINK (bsink); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT: { const gchar *context_type; GstContext *context, *old_context; res = gst_gl_handle_context_query ((GstElement *) gtk_sink, query, >k_sink->display, >k_sink->gtk_context); if (gtk_sink->display) gst_gl_display_filter_gl_api (gtk_sink->display, GST_GL_API_OPENGL3); gst_query_parse_context_type (query, &context_type); if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) { GstStructure *s; gst_query_parse_context (query, &old_context); if (old_context) context = gst_context_copy (old_context); else context = gst_context_new ("gst.gl.local_context", FALSE); s = gst_context_writable_structure (context); gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, gtk_sink->context, NULL); gst_query_set_context (query, context); gst_context_unref (context); res = gtk_sink->context != NULL; } GST_LOG_OBJECT (gtk_sink, "context query of type %s %i", context_type, res); break; } default: res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query); break; } return res; }
/** * @brief This function handles sink pad query. */ static gboolean gst_tensor_aggregator_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstTensorAggregator *self; self = GST_TENSOR_AGGREGATOR (parent); GST_DEBUG_OBJECT (self, "Received %s query: %" GST_PTR_FORMAT, GST_QUERY_TYPE_NAME (query), query); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CAPS: { GstCaps *caps; GstCaps *filter; gst_query_parse_caps (query, &filter); caps = gst_tensor_aggregator_query_caps (self, pad, filter); gst_query_set_caps_result (query, caps); gst_caps_unref (caps); return TRUE; } case GST_QUERY_ACCEPT_CAPS: { GstCaps *caps; GstCaps *template_caps; gboolean res = FALSE; gst_query_parse_accept_caps (query, &caps); silent_debug_caps (caps, "accept-caps"); if (gst_caps_is_fixed (caps)) { template_caps = gst_pad_get_pad_template_caps (pad); res = gst_caps_can_intersect (template_caps, caps); gst_caps_unref (template_caps); } gst_query_set_accept_caps_result (query, res); return TRUE; } default: break; } return gst_pad_query_default (pad, parent, query); }
static gboolean gst_base_audio_src_query (GstBaseSrc * bsrc, GstQuery * query) { GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { GstClockTime min_latency, max_latency; GstRingBufferSpec *spec; GST_OBJECT_LOCK (src); if (G_UNLIKELY (src->ringbuffer == NULL || src->ringbuffer->spec.rate == 0)) { GST_OBJECT_UNLOCK (src); goto done; } spec = &src->ringbuffer->spec; /* we have at least 1 segment of latency */ min_latency = gst_util_uint64_scale_int (spec->segsize, GST_SECOND, spec->rate * spec->bytes_per_sample); /* we cannot delay more than the buffersize else we lose data */ max_latency = gst_util_uint64_scale_int (spec->segtotal * spec->segsize, GST_SECOND, spec->rate * spec->bytes_per_sample); GST_OBJECT_UNLOCK (src); GST_DEBUG_OBJECT (src, "report latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT, GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency)); /* we are always live, the min latency is 1 segment and the max latency is * the complete buffer of segments. */ gst_query_set_latency (query, TRUE, min_latency, max_latency); res = TRUE; break; } default: res = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query); break; } done: return res; }
static gboolean gst_gio_src_query (GstBaseSrc * base_src, GstQuery * query) { gboolean res; GstGioSrc *src = GST_GIO_SRC (base_src); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_SCHEDULING: { gchar *scheme; GstSchedulingFlags flags; flags = 0; if (src->file == NULL) goto forward_parent; scheme = g_file_get_uri_scheme (src->file); if (scheme == NULL) goto forward_parent; if (strcmp (scheme, "file") == 0) { GST_LOG_OBJECT (src, "local URI, assuming random access is possible"); flags |= GST_SCHEDULING_FLAG_SEEKABLE; } else if (strcmp (scheme, "http") == 0 || strcmp (scheme, "https") == 0) { GST_LOG_OBJECT (src, "blacklisted protocol '%s', " "no random access possible", scheme); } else { GST_LOG_OBJECT (src, "unhandled protocol '%s', asking parent", scheme); goto forward_parent; } g_free (scheme); gst_query_set_scheduling (query, flags, 1, -1, 0); gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH); if (flags & GST_SCHEDULING_FLAG_SEEKABLE) gst_query_add_scheduling_mode (query, GST_PAD_MODE_PULL); res = TRUE; break; } default: forward_parent: res = GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_SRC_CLASS, query, (base_src, query), FALSE); break; } return res; }
/** * gst_query_set_buffering_range: * @query: a #GstQuery * @format: the format to set for the @start and @stop values * @start: the start to set * @stop: the stop to set * @estimated_total: estimated total amount of download time * * Set the available query result fields in @query. * * Since: 0.10.20 */ void gst_query_set_buffering_range (GstQuery * query, GstFormat format, gint64 start, gint64 stop, gint64 estimated_total) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING); structure = gst_query_get_structure (query); gst_structure_id_set (structure, GST_QUARK (FORMAT), GST_TYPE_FORMAT, format, GST_QUARK (START_VALUE), G_TYPE_INT64, start, GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop, GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, estimated_total, NULL); }
/** * gst_query_set_seeking: * @query: a #GstQuery * @format: the format to set for the @segment_start and @segment_end values * @seekable: the seekable flag to set * @segment_start: the segment_start to set * @segment_end: the segment_end to set * * Set the seeking query result fields in @query. */ void gst_query_set_seeking (GstQuery * query, GstFormat format, gboolean seekable, gint64 segment_start, gint64 segment_end) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING); structure = gst_query_get_structure (query); gst_structure_id_set (structure, GST_QUARK (FORMAT), GST_TYPE_FORMAT, format, GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, seekable, GST_QUARK (SEGMENT_START), G_TYPE_INT64, segment_start, GST_QUARK (SEGMENT_END), G_TYPE_INT64, segment_end, NULL); }
/** * gst_query_parse_position: * @query: a #GstQuery * @format: the storage for the #GstFormat of the position values (may be NULL) * @cur: the storage for the current position (may be NULL) * * Parse a position query, writing the format into @format, and the position * into @cur, if the respective parameters are non-NULL. */ void gst_query_parse_position (GstQuery * query, GstFormat * format, gint64 * cur) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION); structure = gst_query_get_structure (query); if (format) *format = g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (cur) *cur = g_value_get_int64 (gst_structure_id_get_value (structure, GST_QUARK (CURRENT))); }
static gboolean gst_inter_sub_src_query (GstBaseSrc * src, GstQuery * query) { GstInterSubSrc *intersubsrc = GST_INTER_SUB_SRC (src); gboolean ret; GST_DEBUG_OBJECT (intersubsrc, "query"); switch (GST_QUERY_TYPE (query)) { default: ret = GST_BASE_SRC_CLASS (parent_class)->query (src, query); } return ret; }
static GstPadProbeReturn cb_latency (GstPad * pad, GstPadProbeInfo * info, gpointer data) { if (GST_QUERY_TYPE (GST_PAD_PROBE_INFO_QUERY (info)) != GST_QUERY_LATENCY) { return GST_PAD_PROBE_OK; } GST_LOG_OBJECT (pad, "Modifing latency query. New latency %" G_GUINT64_FORMAT, (guint64) (LATENCY * GST_MSECOND)); gst_query_set_latency (GST_PAD_PROBE_INFO_QUERY (info), TRUE, 0, LATENCY * GST_MSECOND); return GST_PAD_PROBE_HANDLED; }
static gboolean gst_directsound_sink_query (GstBaseSink * sink, GstQuery * query) { gboolean res = TRUE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_ACCEPT_CAPS: res = gst_directsound_sink_acceptcaps (sink, query); break; default: res = GST_BASE_SINK_CLASS (parent_class)->query (sink, query); } return res; }
/** * gst_query_set_segment: * @query: a #GstQuery * @rate: the rate of the segment * @format: the #GstFormat of the segment values (@start_value and @stop_value) * @start_value: the start value * @stop_value: the stop value * * Answer a segment query by setting the requested values. The normal * playback segment of a pipeline is 0 to duration at the default rate of * 1.0. If a seek was performed on the pipeline to play a different * segment, this query will return the range specified in the last seek. * * @start_value and @stop_value will respectively contain the configured * playback range start and stop values expressed in @format. * The values are always between 0 and the duration of the media and * @start_value <= @stop_value. @rate will contain the playback rate. For * negative rates, playback will actually happen from @stop_value to * @start_value. */ void gst_query_set_segment (GstQuery * query, gdouble rate, GstFormat format, gint64 start_value, gint64 stop_value) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT); structure = gst_query_get_structure (query); gst_structure_id_set (structure, GST_QUARK (RATE), G_TYPE_DOUBLE, rate, GST_QUARK (FORMAT), GST_TYPE_FORMAT, format, GST_QUARK (START_VALUE), G_TYPE_INT64, start_value, GST_QUARK (STOP_VALUE), G_TYPE_INT64, stop_value, NULL); }
/** * gst_query_set_convert: * @query: a #GstQuery * @src_format: the source #GstFormat * @src_value: the source value * @dest_format: the destination #GstFormat * @dest_value: the destination value * * Answer a convert query by setting the requested values. */ void gst_query_set_convert (GstQuery * query, GstFormat src_format, gint64 src_value, GstFormat dest_format, gint64 dest_value) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT); structure = gst_query_get_structure (query); gst_structure_id_set (structure, GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format, GST_QUARK (SRC_VALUE), G_TYPE_INT64, src_value, GST_QUARK (DEST_FORMAT), GST_TYPE_FORMAT, dest_format, GST_QUARK (DEST_VALUE), G_TYPE_INT64, dest_value, NULL); }
static gboolean kms_agnostic_bin2_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) { gboolean ret; if (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS) { gst_query_set_accept_caps_result (query, TRUE); return TRUE; } ret = gst_pad_query_default (pad, parent, query); if (ret && GST_QUERY_TYPE (query) == GST_QUERY_LATENCY) { GstClockTime min_latency; GstClockTime max_latency; gst_query_parse_latency (query, NULL, &min_latency, &max_latency); gst_query_set_latency (query, TRUE, min_latency, max_latency); } return ret; }
static GstPadProbeReturn query_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { APP_STATE_T *state = (APP_STATE_T *) user_data; GstQuery *query = GST_PAD_PROBE_INFO_QUERY (info); GstStructure *external_gl_context_desc = NULL; gchar *platform = NULL; gchar *gl_apis = NULL; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_ALLOCATION: { platform = gst_gl_platform_to_string (GST_GL_PLATFORM_EGL); gl_apis = gst_gl_api_to_string (GST_GL_API_GLES2); external_gl_context_desc = gst_structure_new ("GstVideoGLTextureUploadMeta", "gst.gl.context.handle", G_TYPE_POINTER, state->context, "gst.gl.context.type", G_TYPE_STRING, platform, "gst.gl.context.apis", G_TYPE_STRING, gl_apis, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, external_gl_context_desc); gst_structure_free (external_gl_context_desc); g_free (gl_apis); g_free (platform); GST_DEBUG ("done alocation"); return GST_PAD_PROBE_OK; break; } case GST_QUERY_CONTEXT: { return gst_gl_handle_context_query (state->pipeline, query, (GstGLDisplay **) & state->gst_display); break; } case GST_QUERY_DRAIN: { flush_internal (state); break; } default: break; } return GST_PAD_PROBE_OK; }
static gboolean stereosplit_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstGLStereoSplit *split = GST_GL_STEREOSPLIT (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT: { const gchar *context_type; GstContext *context, *old_context; gboolean ret; ret = gst_gl_handle_context_query ((GstElement *) split, query, &split->display, &split->other_context); if (split->display) gst_gl_display_filter_gl_api (split->display, SUPPORTED_GL_APIS); gst_query_parse_context_type (query, &context_type); if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) { GstStructure *s; gst_query_parse_context (query, &old_context); if (old_context) context = gst_context_copy (old_context); else context = gst_context_new ("gst.gl.local_context", FALSE); s = gst_context_writable_structure (context); gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, split->context, NULL); gst_query_set_context (query, context); gst_context_unref (context); ret = split->context != NULL; } GST_LOG_OBJECT (split, "context query of type %s %i", context_type, ret); if (ret) return ret; return gst_pad_query_default (pad, parent, query); } /* FIXME: Handle caps query */ default: return gst_pad_query_default (pad, parent, query); } }
static gboolean gst_type_find_handle_src_query (GstPad * pad, GstQuery * query) { GstTypeFindElement *typefind; gboolean res = FALSE; GstPad *peer; typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); peer = gst_pad_get_peer (typefind->sink); if (peer == NULL) return FALSE; res = gst_pad_query (peer, query); if (!res) goto out; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { gint64 peer_pos; GstFormat format; if (typefind->store == NULL) goto out; gst_query_parse_position (query, &format, &peer_pos); /* FIXME: this code assumes that there's no discont in the queue */ switch (format) { case GST_FORMAT_BYTES: peer_pos -= GST_BUFFER_SIZE (typefind->store); break; default: /* FIXME */ break; } gst_query_set_position (query, format, peer_pos); break; } default: break; } out: gst_object_unref (peer); return res; }
static gboolean gst_decklink_src_query (GstElement * element, GstQuery * query) { GstDecklinkSrc *decklinksrc = GST_DECKLINK_SRC (element); gboolean ret; GST_DEBUG_OBJECT (decklinksrc, "query"); switch (GST_QUERY_TYPE (query)) { default: ret = GST_ELEMENT_CLASS (parent_class)->query (element, query); break; } return ret; }
static gboolean gst_rsvg_dec_src_query (GstPad * pad, GstQuery * query) { GstRsvgDec *rsvg = GST_RSVG_DEC (gst_pad_get_parent (pad)); gboolean res = TRUE; switch (GST_QUERY_TYPE (query)) { default: res = gst_pad_query_default (pad, query); break; } gst_object_unref (rsvg); return res; }
static gboolean gst_decklink_sink_audiosink_query (GstPad * pad, GstObject * parent, GstQuery * query) { gboolean res; GST_DEBUG_OBJECT (pad, "query: %" GST_PTR_FORMAT, query); switch (GST_QUERY_TYPE (query)) { default: res = gst_pad_query_default (pad, parent, query); break; } return res; }
/** * gst_query_parse_duration: * @query: a #GstQuery * @format: the storage for the #GstFormat of the duration value, or NULL. * @duration: the storage for the total duration, or NULL. * * Parse a duration query answer. Write the format of the duration into @format, * and the value into @duration, if the respective variables are non-NULL. */ void gst_query_parse_duration (GstQuery * query, GstFormat * format, gint64 * duration) { GstStructure *structure; g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_DURATION); structure = gst_query_get_structure (query); if (format) *format = g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (duration) *duration = g_value_get_int64 (gst_structure_id_get_value (structure, GST_QUARK (DURATION))); }
static gboolean gst_vaapidecode_src_query (GstVideoDecoder * vdec, GstQuery * query) { gboolean ret = TRUE; GstVaapiDecode *const decode = GST_VAAPIDECODE (vdec); GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (decode); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CAPS:{ GstCaps *caps, *filter = NULL; GstPad *pad = GST_VIDEO_DECODER_SRC_PAD (vdec); gst_query_parse_caps (query, &filter); caps = gst_pad_get_pad_template_caps (pad); if (filter) { GstCaps *tmp = caps; caps = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (tmp); } gst_query_set_caps_result (query, caps); gst_caps_unref (caps); break; } case GST_QUERY_CONTEXT:{ ret = gst_vaapi_handle_context_query (query, plugin->display); break; } default:{ #if GST_CHECK_VERSION(1,4,0) ret = GST_VIDEO_DECODER_CLASS (gst_vaapidecode_parent_class)->src_query (vdec, query); #else GstPad *pad = GST_VIDEO_DECODER_SRC_PAD (vdec); GstObject *parent = gst_pad_get_parent (pad); ret = plugin->srcpad_query (pad, parent, query); if (parent) gst_object_unref (parent); #endif break; } } return ret; }
static gboolean _src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstFormat fmt; if (GST_QUERY_TYPE (query) != GST_QUERY_DURATION) return FALSE; gst_query_parse_duration (query, &fmt, NULL); if (fmt != GST_FORMAT_BYTES) return FALSE; gst_query_set_duration (query, fmt, sizeof (mxf_file)); return TRUE; }