gint len_mask = 0x80, read = 1, n = 1, num_ffs = 0;
guint64 total;
guint8 b;
+ GstFlowReturn ret;
g_return_val_if_fail (_id != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (_length != NULL, GST_FLOW_ERROR);
/* read element id */
needed = 2;
- buf = peek (ctx, needed);
- if (!buf)
- goto not_enough_data;
-
+ ret = peek (ctx, needed, &buf);
+ if (ret != GST_FLOW_OK)
+ goto peek_error;
b = GST_READ_UINT8 (buf);
total = (guint64) b;
while (read <= 4 && !(total & len_mask)) {
/* need id and at least something for subsequent length */
needed = read + 1;
- buf = peek (ctx, needed);
- if (!buf)
- goto not_enough_data;
-
+ ret = peek (ctx, needed, &buf);
+ if (ret != GST_FLOW_OK)
+ goto peek_error;
while (n < read) {
b = GST_READ_UINT8 (buf + n);
total = (total << 8) | b;
num_ffs++;
needed += read - 1;
- buf = peek (ctx, needed);
- if (!buf)
- goto not_enough_data;
-
+ ret = peek (ctx, needed, &buf);
+ if (ret != GST_FLOW_OK)
+ goto peek_error;
buf += (needed - read);
n = 1;
while (n < read) {
return GST_FLOW_OK;
/* ERRORS */
-not_enough_data:
+peek_error:
{
+ GST_WARNING_OBJECT (el, "peek failed, ret = %d", ret);
*_needed = needed;
- return GST_FLOW_UNEXPECTED;
+ return ret;
}
invalid_id:
{
ebml->el = NULL;
}
-static const guint8 *
-gst_ebml_read_peek (GstByteReader * br, guint peek)
+static GstFlowReturn
+gst_ebml_read_peek (GstByteReader * br, guint peek, const guint8 ** data)
{
- const guint8 *data = NULL;
-
- if (G_LIKELY (gst_byte_reader_peek_data (br, peek, &data)))
- return data;
+ if (G_LIKELY (gst_byte_reader_peek_data (br, peek, data)))
+ return GST_FLOW_OK;
else
- return NULL;
+ return GST_FLOW_UNEXPECTED;
}
static GstFlowReturn
GArray *readers;
} GstEbmlRead;
-typedef const guint8 * (*GstPeekData) (gpointer * context, guint peek);
+typedef GstFlowReturn (*GstPeekData) (gpointer * context, guint peek, const guint8 ** data);
/* returns UNEXPECTED if not enough data */
GstFlowReturn gst_ebml_peek_id_length (guint32 * _id, guint64 * _length,
return GST_FLOW_OK;
}
-static const guint8 *
-gst_matroska_read_common_peek_pull (GstMatroskaReadCommon * common, guint peek)
+static GstFlowReturn
+gst_matroska_read_common_peek_pull (GstMatroskaReadCommon * common, guint peek,
+ guint8 ** data)
{
- guint8 *data = NULL;
-
- gst_matroska_read_common_peek_bytes (common, common->offset, peek, NULL,
- &data);
- return data;
+ return gst_matroska_read_common_peek_bytes (common, common->offset, peek,
+ NULL, data);
}
GstFlowReturn