}
static gboolean
-gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
+gst_ffmpegdec_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- gboolean res;
-
- /* just forward to peer */
- res = gst_pad_query_default (pad, parent, query);
- #if 0
- {
- GstFormat bfmt;
-
- bfmt = GST_FORMAT_BYTES;
+ GstFFMpegDec *ffmpegdec;
+ gboolean res = FALSE;
- /* ok, do bitrate calc... */
- if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
- *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
- !gst_pad_query (peer, type, &bfmt, value))
- return FALSE;
- ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++ ffmpegdec = (GstFFMpegDec *) parent;
- if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
- *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
- *value *= GST_SECOND / ffmpegdec->context->bit_rate;
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_LATENCY:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec, "latency query %d",
+ ffmpegdec->context->has_b_frames);
+ if ((res = gst_pad_peer_query (ffmpegdec->sinkpad, query))) {
+ if (ffmpegdec->context->has_b_frames) {
+ gboolean live;
+ GstClockTime min_lat, max_lat, our_lat;
+
+ gst_query_parse_latency (query, &live, &min_lat, &max_lat);
+ if (ffmpegdec->format.video.fps_n > 0)
+ our_lat =
+ gst_util_uint64_scale_int (ffmpegdec->context->has_b_frames *
+ GST_SECOND, ffmpegdec->format.video.fps_d,
+ ffmpegdec->format.video.fps_n);
+ else
+ our_lat =
+ gst_util_uint64_scale_int (ffmpegdec->context->has_b_frames *
+ GST_SECOND, 1, 25);
+ if (min_lat != -1)
+ min_lat += our_lat;
+ if (max_lat != -1)
+ max_lat += our_lat;
+ gst_query_set_latency (query, live, min_lat, max_lat);
+ }
+ }
+ }
+ break;
+ default:
+ res = gst_pad_query_default (pad, query);
+ break;
}
- #endif
- gst_object_unref (ffmpegdec);
-
return res;
}
static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
- GstPadTemplate * templ, const gchar * name);
+ GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
- static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
+ static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads2 * pads,
gpointer user_data);
-static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
GstStateChange transition);
/* pad templates */
srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
gst_element_class_add_pad_template (element_class, srctempl);
+ gst_object_unref (srctempl);
if (audiosinkcaps) {
- audiosinktempl = gst_pad_template_new ("audio_%d",
+ audiosinktempl = gst_pad_template_new ("audio_%u",
GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
gst_element_class_add_pad_template (element_class, audiosinktempl);
+ gst_object_unref (audiosinktempl);
}
if (videosinkcaps) {
- videosinktempl = gst_pad_template_new ("video_%d",
+ videosinktempl = gst_pad_template_new ("video_%u",
GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
gst_element_class_add_pad_template (element_class, videosinktempl);
+ gst_object_unref (videosinktempl);
}
beach:
GstBuffer *buf;
AVPacket pkt;
gboolean need_free = FALSE;
+ gsize size;
/* push out current buffer */
- buf = gst_collect_pads_pop (ffmpegmux->collect,
- (GstCollectData *) best_pad);
+ buf = gst_collect_pads2_pop (ffmpegmux->collect,
+ (GstCollectData2 *) best_pad);
ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;