-static GstFlowReturn
-gst_identity_prepare_output_buffer (GstBaseTransform * trans,
- GstBuffer * in_buf, GstBuffer ** out_buf)
-{
- GstIdentity *identity = GST_IDENTITY (trans);
-
- /* only bother if we may have to alter metadata */
- if (identity->datarate > 0 || identity->single_segment) {
- if (gst_buffer_is_writable (in_buf))
- /* reuse */
- *out_buf = in_buf;
- else {
- /* copy */
- *out_buf = gst_buffer_copy (in_buf);
- }
- } else
- *out_buf = in_buf;
-
- return GST_FLOW_OK;
-}
-
-static void
-gst_identity_check_perfect (GstIdentity * identity, GstBuffer * buf)
-{
- GstClockTime timestamp;
-
- timestamp = GST_BUFFER_TIMESTAMP (buf);
-
- /* see if we need to do perfect stream checking */
- /* invalid timestamp drops us out of check. FIXME: maybe warn ? */
- if (timestamp != GST_CLOCK_TIME_NONE) {
- /* check if we had a previous buffer to compare to */
- if (identity->prev_timestamp != GST_CLOCK_TIME_NONE &&
- identity->prev_duration != GST_CLOCK_TIME_NONE) {
- guint64 offset, t_expected;
- gint64 dt;
-
- t_expected = identity->prev_timestamp + identity->prev_duration;
- dt = timestamp - t_expected;
- if (dt != 0) {
- GST_WARNING_OBJECT (identity,
- "Buffer not time-contiguous with previous one: " "prev ts %"
- GST_TIME_FORMAT ", prev dur %" GST_TIME_FORMAT ", new ts %"
- GST_TIME_FORMAT " (expected ts %" GST_TIME_FORMAT ", delta=%c%"
- GST_TIME_FORMAT ")", GST_TIME_ARGS (identity->prev_timestamp),
- GST_TIME_ARGS (identity->prev_duration), GST_TIME_ARGS (timestamp),
- GST_TIME_ARGS (t_expected), (dt < 0) ? '-' : '+',
- GST_TIME_ARGS ((dt < 0) ? (GstClockTime) (-dt) : dt));
- }
-
- offset = GST_BUFFER_OFFSET (buf);
- if (identity->prev_offset_end != offset &&
- identity->prev_offset_end != GST_BUFFER_OFFSET_NONE &&
- offset != GST_BUFFER_OFFSET_NONE) {
- GST_WARNING_OBJECT (identity,
- "Buffer not data-contiguous with previous one: "
- "prev offset_end %" G_GINT64_FORMAT ", new offset %"
- G_GINT64_FORMAT, identity->prev_offset_end, offset);
- }
- } else {
- GST_DEBUG_OBJECT (identity, "can't check time-contiguity, no timestamp "
- "and/or duration were set on previous buffer");
- }
- }
-}
-