mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
matroska: refactor code common to matroskademux and matroskaparse
Move the following function to matroska-read-common.[ch] from matroska-demux.c and matroska-parse.c: - gst_matroska_{demux,parse}_tracknumber_unique https://bugzilla.gnome.org/show_bug.cgi?id=650877
This commit is contained in:
parent
0aa35a6bcc
commit
1a6e658444
4 changed files with 23 additions and 36 deletions
|
@ -495,23 +495,6 @@ gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_matroska_demux_tracknumber_unique (GstMatroskaDemux * demux, guint64 num)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_assert (demux->common.src->len == demux->common.num_streams);
|
||||
for (i = 0; i < demux->common.src->len; i++) {
|
||||
GstMatroskaTrackContext *context = g_ptr_array_index (demux->common.src,
|
||||
i);
|
||||
|
||||
if (context->num == num)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
||||
{
|
||||
|
@ -572,7 +555,8 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
|||
GST_ERROR_OBJECT (demux, "Invalid TrackNumber 0");
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
} else if (!gst_matroska_demux_tracknumber_unique (demux, num)) {
|
||||
} else if (!gst_matroska_read_common_tracknumber_unique (&demux->common,
|
||||
num)) {
|
||||
GST_ERROR_OBJECT (demux, "TrackNumber %" G_GUINT64_FORMAT
|
||||
" is not unique", num);
|
||||
ret = GST_FLOW_ERROR;
|
||||
|
|
|
@ -384,23 +384,6 @@ gst_matroska_parse_reset (GstElement * element)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_matroska_parse_tracknumber_unique (GstMatroskaParse * parse, guint64 num)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_assert (parse->common.src->len == parse->common.num_streams);
|
||||
for (i = 0; i < parse->common.src->len; i++) {
|
||||
GstMatroskaTrackContext *context = g_ptr_array_index (parse->common.src,
|
||||
i);
|
||||
|
||||
if (context->num == num)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml)
|
||||
{
|
||||
|
@ -454,7 +437,8 @@ gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml)
|
|||
GST_ERROR_OBJECT (parse, "Invalid TrackNumber 0");
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
} else if (!gst_matroska_parse_tracknumber_unique (parse, num)) {
|
||||
} else if (!gst_matroska_read_common_tracknumber_unique (&parse->common,
|
||||
num)) {
|
||||
GST_ERROR_OBJECT (parse, "TrackNumber %" G_GUINT64_FORMAT
|
||||
" is not unique", num);
|
||||
ret = GST_FLOW_ERROR;
|
||||
|
|
|
@ -1038,3 +1038,20 @@ gst_matroska_read_common_read_track_encodings (GstMatroskaReadCommon * common,
|
|||
|
||||
return gst_matroska_decode_content_encodings (context->encodings);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon * common,
|
||||
guint64 num)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_assert (common->src->len == common->num_streams);
|
||||
for (i = 0; i < common->src->len; i++) {
|
||||
GstMatroskaTrackContext *context = g_ptr_array_index (common->src, i);
|
||||
|
||||
if (context->num == num)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
|
|||
GstFlowReturn gst_matroska_read_common_read_track_encodings (
|
||||
GstMatroskaReadCommon * common, GstEbmlRead * ebml,
|
||||
GstMatroskaTrackContext * context);
|
||||
gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon *
|
||||
common, guint64 num);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue