if (runtime >= offset)
gst_pts = runtime - offset;
}
- GST_LOG ("Buf (uS) PTS %" G_GINT64_FORMAT " DTS %" G_GINT64_FORMAT
- " STC %" G_GINT64_FORMAT " (latency %" G_GINT64_FORMAT
- "uS) TS %" GST_TIME_FORMAT,
- buffer->pts, buffer->dts, param.value, param.value - buffer->pts,
- GST_TIME_ARGS (gst_pts));
+ GST_LOG ("Buf %05u bytes FLAGS 0x%05x (uS) PTS %" G_GINT64_FORMAT
+ " DTS %" G_GINT64_FORMAT " STC %" G_GINT64_FORMAT
+ " (latency %" G_GINT64_FORMAT "uS) TS %" GST_TIME_FORMAT,
+ buffer->length, buffer->flags, buffer->pts, buffer->dts, param.value,
+ param.value - buffer->pts, GST_TIME_ARGS (gst_pts));
}
else {
GST_LOG ("use-stc=false. Not applying STC to buffer");
GST_BUFFER_DTS(buf) = GST_BUFFER_PTS(buf) = gst_pts;
/* FIXME: Can we avoid copies and give MMAL our own buffers to fill? */
gst_buffer_fill(buf, 0, buffer->data, buffer->length);
- ret = GST_FLOW_OK;
+
+ /* NAL_END is bogus and can't be trusted */
+ if ((buffer->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END))
+ ret = GST_FLOW_OK;
+ else
+ ret = GST_FLOW_KEEP_ACCUMULATING;
}
mmal_buffer_header_mem_unlock(buffer);
}
g_mutex_unlock (&src->config_lock);
- /* FIXME: Use custom allocator */
- ret = raspi_capture_fill_buffer (src->capture_state, buf, clock, base_time);
- if (*buf) {
- GST_LOG_OBJECT (src, "Made buffer of size %" G_GSIZE_FORMAT,
- gst_buffer_get_size (*buf));
- /* Only set the duration when we have a PTS update from the rpi encoder.
- * not every buffer is a frame */
- if (GST_BUFFER_PTS_IS_VALID (*buf))
- GST_BUFFER_DURATION (*buf) = src->duration;
- }
+ *buf = NULL;
+
+ do {
+ GstBuffer *cbuf = NULL;
+
+ /* FIXME: Use custom allocator */
+ ret =
+ raspi_capture_fill_buffer (src->capture_state, &cbuf, clock, base_time);
+
+ if (cbuf != NULL) {
+ GST_LOG_OBJECT (src, "Made buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (cbuf));
+
+ if (*buf == NULL) {
+ /* Only set the duration when we have a PTS update from the rpi encoder.
+ * not every buffer is a frame */
+ if (GST_BUFFER_PTS_IS_VALID (cbuf))
+ GST_BUFFER_DURATION (cbuf) = src->duration;
+
+ *buf = cbuf;
+ } else {
+ *buf = gst_buffer_append (*buf, cbuf);
+ }
+ cbuf = NULL;
+ }
+ } while (ret == GST_FLOW_KEEP_ACCUMULATING);
if (ret == GST_FLOW_ERROR_TIMEOUT) {
GST_ELEMENT_ERROR (src, STREAM, FAILED,
ret = GST_FLOW_ERROR;
}
+ if (ret != GST_FLOW_OK)
+ gst_clear_buffer (buf);
+
if (clock)
gst_object_unref (clock);
return ret;