mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 10:12:20 +00:00
gst/flv/gstflvdemux.c: Refactor _pull_range() logic with checks into a seperate function to make things a bit more re...
Original commit message from CVS: * gst/flv/gstflvdemux.c: (gst_flv_demux_pull_range), (gst_flv_demux_pull_tag), (gst_flv_demux_pull_header): Refactor _pull_range() logic with checks into a seperate function to make things a bit more readable.
This commit is contained in:
parent
f66e8bf233
commit
d411f8d1d7
2 changed files with 38 additions and 39 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-10-09 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/flv/gstflvdemux.c: (gst_flv_demux_pull_range),
|
||||||
|
(gst_flv_demux_pull_tag), (gst_flv_demux_pull_header):
|
||||||
|
Refactor _pull_range() logic with checks into a seperate function
|
||||||
|
to make things a bit more readable.
|
||||||
|
|
||||||
2008-10-09 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2008-10-09 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
* gst/flv/gstflvdemux.c: (gst_flv_demux_chain),
|
* gst/flv/gstflvdemux.c: (gst_flv_demux_chain),
|
||||||
|
|
|
@ -301,6 +301,31 @@ beach:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_flv_demux_pull_range (GstFLVDemux * demux, GstPad * pad, guint64 offset,
|
||||||
|
guint size, GstBuffer ** buffer)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
|
ret = gst_pad_pull_range (pad, offset, size, buffer);
|
||||||
|
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
||||||
|
GST_WARNING_OBJECT (demux, "failed when pulling %d bytes", size);
|
||||||
|
*buffer = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G_UNLIKELY (*buffer && GST_BUFFER_SIZE (*buffer) != size)) {
|
||||||
|
GST_WARNING_OBJECT (demux, "partial pull got %d when expecting %d",
|
||||||
|
GST_BUFFER_SIZE (*buffer), size);
|
||||||
|
gst_buffer_unref (*buffer);
|
||||||
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
|
*buffer = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_flv_demux_pull_tag (GstPad * pad, GstFLVDemux * demux)
|
gst_flv_demux_pull_tag (GstPad * pad, GstFLVDemux * demux)
|
||||||
{
|
{
|
||||||
|
@ -311,20 +336,9 @@ gst_flv_demux_pull_tag (GstPad * pad, GstFLVDemux * demux)
|
||||||
demux->cur_tag_offset = demux->offset;
|
demux->cur_tag_offset = demux->offset;
|
||||||
|
|
||||||
/* Get the first 4 bytes to identify tag type and size */
|
/* Get the first 4 bytes to identify tag type and size */
|
||||||
ret = gst_pad_pull_range (pad, demux->offset, FLV_TAG_TYPE_SIZE, &buffer);
|
if (G_UNLIKELY (gst_flv_demux_pull_range (demux, pad, demux->offset,
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
FLV_TAG_TYPE_SIZE, &buffer) != GST_FLOW_OK))
|
||||||
GST_WARNING_OBJECT (demux, "failed when pulling %d bytes",
|
|
||||||
FLV_TAG_TYPE_SIZE);
|
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
|
||||||
|
|
||||||
if (G_UNLIKELY (buffer && GST_BUFFER_SIZE (buffer) != FLV_TAG_TYPE_SIZE)) {
|
|
||||||
GST_WARNING_OBJECT (demux, "partial pull got %d when expecting %d",
|
|
||||||
GST_BUFFER_SIZE (buffer), FLV_TAG_TYPE_SIZE);
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Identify tag type */
|
/* Identify tag type */
|
||||||
ret = gst_flv_parse_tag_type (demux, GST_BUFFER_DATA (buffer),
|
ret = gst_flv_parse_tag_type (demux, GST_BUFFER_DATA (buffer),
|
||||||
|
@ -336,21 +350,9 @@ gst_flv_demux_pull_tag (GstPad * pad, GstFLVDemux * demux)
|
||||||
demux->offset += FLV_TAG_TYPE_SIZE;
|
demux->offset += FLV_TAG_TYPE_SIZE;
|
||||||
|
|
||||||
/* Pull the whole tag */
|
/* Pull the whole tag */
|
||||||
ret = gst_pad_pull_range (pad, demux->offset, demux->tag_size, &buffer);
|
if (G_UNLIKELY (gst_flv_demux_pull_range (demux, pad, demux->offset,
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
demux->tag_size, &buffer) != GST_FLOW_OK))
|
||||||
GST_WARNING_OBJECT (demux,
|
|
||||||
"failed when pulling %" G_GUINT64_FORMAT " bytes", demux->tag_size);
|
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
|
||||||
|
|
||||||
if (G_UNLIKELY (buffer && GST_BUFFER_SIZE (buffer) != demux->tag_size)) {
|
|
||||||
GST_WARNING_OBJECT (demux,
|
|
||||||
"partial pull got %d when expecting %" G_GUINT64_FORMAT,
|
|
||||||
GST_BUFFER_SIZE (buffer), demux->tag_size);
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (demux->state) {
|
switch (demux->state) {
|
||||||
case FLV_STATE_TAG_VIDEO:
|
case FLV_STATE_TAG_VIDEO:
|
||||||
|
@ -401,19 +403,9 @@ gst_flv_demux_pull_header (GstPad * pad, GstFLVDemux * demux)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
/* Get the first 9 bytes */
|
/* Get the first 9 bytes */
|
||||||
ret = gst_pad_pull_range (pad, demux->offset, FLV_HEADER_SIZE, &buffer);
|
if (G_UNLIKELY (gst_flv_demux_pull_range (demux, pad, demux->offset,
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
FLV_HEADER_SIZE, &buffer) != GST_FLOW_OK))
|
||||||
GST_WARNING_OBJECT (demux, "failed when pulling %d bytes", FLV_HEADER_SIZE);
|
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
|
||||||
|
|
||||||
if (G_UNLIKELY (buffer && GST_BUFFER_SIZE (buffer) != FLV_HEADER_SIZE)) {
|
|
||||||
GST_WARNING_OBJECT (demux, "partial pull got %d when expecting %d",
|
|
||||||
GST_BUFFER_SIZE (buffer), FLV_HEADER_SIZE);
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
ret = GST_FLOW_UNEXPECTED;
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_flv_parse_header (demux, GST_BUFFER_DATA (buffer),
|
ret = gst_flv_parse_header (demux, GST_BUFFER_DATA (buffer),
|
||||||
GST_BUFFER_SIZE (buffer));
|
GST_BUFFER_SIZE (buffer));
|
||||||
|
|
Loading…
Reference in a new issue