static gboolean gst_base_video_decoder_src_query (GstPad * pad, GstQuery * query) { GstBaseVideoDecoder *enc; gboolean res; enc = GST_BASE_VIDEO_DECODER (gst_pad_get_parent (pad)); switch GST_QUERY_TYPE (query) { case GST_QUERY_CONVERT: { GstFormat src_fmt, dest_fmt; gint64 src_val, dest_val; gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); res = gst_base_video_decoder_src_convert (pad, src_fmt, src_val, &dest_fmt, &dest_val); if (!res) goto error; gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); break; } default: res = gst_pad_query_default (pad, query); } gst_object_unref (enc); return res; error: GST_DEBUG_OBJECT (enc, "query failed"); gst_object_unref (enc); return res; }
static gboolean gst_base_video_decoder_src_event (GstPad * pad, GstEvent * event) { GstBaseVideoDecoder *base_video_decoder; gboolean res = FALSE; base_video_decoder = GST_BASE_VIDEO_DECODER (gst_pad_get_parent (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: { GstFormat format, tformat; gdouble rate; GstEvent *real_seek; GstSeekFlags flags; GstSeekType cur_type, stop_type; gint64 cur, stop; gint64 tcur, tstop; gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, &stop_type, &stop); gst_event_unref (event); tformat = GST_FORMAT_TIME; res = gst_base_video_decoder_src_convert (pad, format, cur, &tformat, &tcur); if (!res) goto convert_error; res = gst_base_video_decoder_src_convert (pad, format, stop, &tformat, &tstop); if (!res) goto convert_error; real_seek = gst_event_new_seek (rate, GST_FORMAT_TIME, flags, cur_type, tcur, stop_type, tstop); res = gst_pad_push_event (GST_BASE_VIDEO_CODEC_SINK_PAD (base_video_decoder), real_seek); break; } case GST_EVENT_QOS: { gdouble proportion; GstClockTimeDiff diff; GstClockTime timestamp; gst_event_parse_qos (event, &proportion, &diff, ×tamp); GST_OBJECT_LOCK (base_video_decoder); base_video_decoder->proportion = proportion; base_video_decoder->earliest_time = timestamp + diff; GST_OBJECT_UNLOCK (base_video_decoder); GST_DEBUG_OBJECT (base_video_decoder, "got QoS %" GST_TIME_FORMAT ", %" G_GINT64_FORMAT ", %g", GST_TIME_ARGS (timestamp), diff, proportion); res = gst_pad_push_event (GST_BASE_VIDEO_CODEC_SINK_PAD (base_video_decoder), event); break; } default: res = gst_pad_push_event (GST_BASE_VIDEO_CODEC_SINK_PAD (base_video_decoder), event); break; } done: gst_object_unref (base_video_decoder); return res; convert_error: GST_DEBUG_OBJECT (base_video_decoder, "could not convert format"); goto done; }
static gboolean gst_base_video_decoder_src_query (GstPad * pad, GstQuery * query) { GstBaseVideoDecoder *dec; gboolean res = TRUE; dec = GST_BASE_VIDEO_DECODER (gst_pad_get_parent (pad)); switch GST_QUERY_TYPE (query) { case GST_QUERY_POSITION: { GstFormat format; gint64 time; gst_query_parse_position (query, &format, NULL); GST_DEBUG ("query in format %d", format); if (format != GST_FORMAT_TIME) { goto error; } time = dec->last_timestamp; time = gst_segment_to_stream_time (&dec->segment, GST_FORMAT_TIME, time); gst_query_set_position (query, format, time); res = TRUE; break; } case GST_QUERY_DURATION: { res = gst_pad_peer_query (dec->sinkpad, query); break; } case GST_QUERY_CONVERT: { GstFormat src_fmt, dest_fmt; gint64 src_val, dest_val; GST_DEBUG ("convert query"); gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); res = gst_base_video_decoder_src_convert (pad, src_fmt, src_val, &dest_fmt, &dest_val); if (!res) goto error; gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); break; } default: res = gst_pad_query_default (pad, query); } gst_object_unref (dec); return res; error: GST_ERROR_OBJECT (dec, "query failed"); gst_object_unref (dec); return res; }