1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 04:45:33 +00:00

demux: merge functions

This commit is contained in:
wm4 2013-07-08 01:02:45 +02:00
parent 8a46d4c49f
commit 50808bab8d

View File

@ -267,22 +267,25 @@ static demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
return d;
}
static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer,
enum stream_type type,
int stream_index,
int demuxer_id)
struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
{
if (demuxer->num_streams > MAX_SH_STREAMS || stream_index > MAX_SH_STREAMS) {
if (demuxer->num_streams > MAX_SH_STREAMS) {
mp_msg(MSGT_DEMUXER, MSGL_WARN, "Too many streams.");
return NULL;
}
int demuxer_id = 0;
for (int n = 0; n < demuxer->num_streams; n++) {
if (demuxer->streams[n]->type == type)
demuxer_id++;
}
struct sh_stream *sh = talloc_struct(demuxer, struct sh_stream, {
.type = type,
.demuxer = demuxer,
.index = demuxer->num_streams,
.demuxer_id = demuxer_id, // may be overwritten by demuxer
.stream_index = stream_index,
.stream_index = demuxer->num_streams,
.opts = demuxer->opts,
});
MP_TARRAY_APPEND(demuxer, demuxer->streams, demuxer->num_streams, sh);
@ -321,17 +324,6 @@ static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer,
return sh;
}
// This is what "modern" demuxers are supposed to use.
struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
{
int num = 0;
for (int n = 0; n < demuxer->num_streams; n++) {
if (demuxer->streams[n]->type == type)
num++;
}
return new_sh_stream_id(demuxer, type, demuxer->num_streams, num);
}
static void free_sh_stream(struct sh_stream *sh)
{
}