use new bytestream api
Original commit message from CVS: use new bytestream api
This commit is contained in:
parent
a26984bd9d
commit
ee40ec1e0a
@ -58,11 +58,12 @@ parse_packhead (GstMPEGPacketize * packetize)
|
|||||||
gint length = 8 + 4;
|
gint length = 8 + 4;
|
||||||
guint8 *buf;
|
guint8 *buf;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
guint32 got_bytes;
|
||||||
|
|
||||||
GST_DEBUG (0, "packetize: in parse_packhead");
|
GST_DEBUG (0, "packetize: in parse_packhead");
|
||||||
|
|
||||||
buf = gst_bytestream_peek_bytes (packetize->bs, length);
|
got_bytes = gst_bytestream_peek_bytes (packetize->bs, &buf, length);
|
||||||
if (!buf) return NULL;
|
if (got_bytes < length) return NULL;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
|
|
||||||
GST_DEBUG (0, "code %02x", *buf);
|
GST_DEBUG (0, "code %02x", *buf);
|
||||||
@ -72,16 +73,16 @@ parse_packhead (GstMPEGPacketize * packetize)
|
|||||||
GST_DEBUG (0, "packetize::parse_packhead setting mpeg2");
|
GST_DEBUG (0, "packetize::parse_packhead setting mpeg2");
|
||||||
packetize->MPEG2 = TRUE;
|
packetize->MPEG2 = TRUE;
|
||||||
length += 2;
|
length += 2;
|
||||||
buf = gst_bytestream_peek_bytes (packetize->bs, length);
|
got_bytes = gst_bytestream_peek_bytes (packetize->bs, &buf, length);
|
||||||
if (!buf) return NULL;
|
if (got_bytes < length) return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GST_DEBUG (0, "packetize::parse_packhead setting mpeg1");
|
GST_DEBUG (0, "packetize::parse_packhead setting mpeg1");
|
||||||
packetize->MPEG2 = FALSE;
|
packetize->MPEG2 = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
outbuf = gst_bytestream_read (packetize->bs, length);
|
got_bytes = gst_bytestream_read (packetize->bs, &outbuf, length);
|
||||||
if (!outbuf) return NULL;
|
if (got_bytes < length) return NULL;
|
||||||
|
|
||||||
return GST_DATA (outbuf);
|
return GST_DATA (outbuf);
|
||||||
}
|
}
|
||||||
@ -93,18 +94,19 @@ parse_generic (GstMPEGPacketize *packetize)
|
|||||||
GstByteStream *bs = packetize->bs;
|
GstByteStream *bs = packetize->bs;
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
guint32 got_bytes;
|
||||||
|
|
||||||
GST_DEBUG (0, "packetize: in parse_syshead");
|
GST_DEBUG (0, "packetize: in parse_syshead");
|
||||||
|
|
||||||
buf = gst_bytestream_peek_bytes (bs, 2 + 4);
|
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, 2 + 4);
|
||||||
if (!buf) return NULL;
|
if (got_bytes < 6) return NULL;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
|
|
||||||
length = GUINT16_FROM_BE (*(guint16 *) buf);
|
length = GUINT16_FROM_BE (*(guint16 *) buf);
|
||||||
GST_DEBUG (0, "packetize: header_length %d", length);
|
GST_DEBUG (0, "packetize: header_length %d", length);
|
||||||
|
|
||||||
outbuf = gst_bytestream_read (packetize->bs, 2 + length + 4);
|
got_bytes = gst_bytestream_read (packetize->bs, &outbuf, 2 + length + 4);
|
||||||
if (!outbuf) return NULL;
|
if (got_bytes < 2 + length + 4) return NULL;
|
||||||
|
|
||||||
return GST_DATA (outbuf);
|
return GST_DATA (outbuf);
|
||||||
}
|
}
|
||||||
@ -118,9 +120,10 @@ parse_chunk (GstMPEGPacketize *packetize)
|
|||||||
guint32 code;
|
guint32 code;
|
||||||
const gint chunksize = 4096;
|
const gint chunksize = 4096;
|
||||||
GstBuffer *outbuf = NULL;
|
GstBuffer *outbuf = NULL;
|
||||||
|
guint32 got_bytes;
|
||||||
|
|
||||||
buf = gst_bytestream_peek_bytes (bs, chunksize);
|
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, chunksize);
|
||||||
if (!buf)
|
if (got_bytes < chunksize)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
offset = 4;
|
offset = 4;
|
||||||
|
|
||||||
@ -134,13 +137,13 @@ parse_chunk (GstMPEGPacketize *packetize)
|
|||||||
GST_DEBUG (0, " code = %08x", code);
|
GST_DEBUG (0, " code = %08x", code);
|
||||||
|
|
||||||
if ((offset % chunksize) == 0) {
|
if ((offset % chunksize) == 0) {
|
||||||
buf = gst_bytestream_peek_bytes (bs, offset + chunksize);
|
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, offset + chunksize);
|
||||||
if (!buf)
|
if (got_bytes < offset + chunksize)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offset > 4) {
|
if (offset > 4) {
|
||||||
outbuf = gst_bytestream_read (bs, offset-4);
|
got_bytes = gst_bytestream_read (bs, &outbuf, offset-4);
|
||||||
}
|
}
|
||||||
return GST_DATA (outbuf);
|
return GST_DATA (outbuf);
|
||||||
}
|
}
|
||||||
@ -155,9 +158,10 @@ find_start_code (GstMPEGPacketize *packetize)
|
|||||||
gint offset;
|
gint offset;
|
||||||
guint32 code;
|
guint32 code;
|
||||||
const gint chunksize = 4096;
|
const gint chunksize = 4096;
|
||||||
|
guint32 got_bytes;
|
||||||
|
|
||||||
buf = gst_bytestream_peek_bytes (bs, chunksize);
|
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, chunksize);
|
||||||
if (!buf)
|
if (got_bytes < chunksize)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
offset = 4;
|
offset = 4;
|
||||||
|
|
||||||
@ -174,8 +178,8 @@ find_start_code (GstMPEGPacketize *packetize)
|
|||||||
if (offset == chunksize) {
|
if (offset == chunksize) {
|
||||||
if (!gst_bytestream_flush (bs, offset))
|
if (!gst_bytestream_flush (bs, offset))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
buf = gst_bytestream_peek_bytes (bs, chunksize);
|
got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&buf, chunksize);
|
||||||
if (!buf)
|
if (got_bytes < chunksize)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user