* situation where a new audio stream spawn (identified with a new serial) and
* must replace the previous one (track switch).
*/
-static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic,
+static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic, int page_size,
int probing)
{
struct ogg *ogg = s->priv_data;
}
/* Check for codecs */
- codec = ogg_find_codec(magic, 8);
+ codec = ogg_find_codec(magic, page_size);
if (!codec && !probing) {
av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n");
return AVERROR_INVALIDDATA;
}
- /* We only have a single stream anyway, so if there's a new stream with
- * a different codec just replace it */
os = &ogg->streams[0];
+ if (os->codec != codec)
+ return AVERROR(EINVAL);
+
os->serial = serial;
os->codec = codec;
os->serial = serial;
if (idx < 0)
av_free(readout_buf);
avio_seek(bc, start_pos, SEEK_SET);
+ *sid = -1;
return 0;
}
if (idx < 0)
av_free(readout_buf);
avio_seek(bc, start_pos, SEEK_SET);
+ *sid = -1;
return 0;
}
/* CRC is correct so we can be 99% sure there's an actual change here */
if (idx < 0) {
if (data_packets_seen(ogg))
- idx = ogg_replace_stream(s, serial, readout_buf, probing);
+ idx = ogg_replace_stream(s, serial, readout_buf, size, probing);
else
idx = ogg_new_stream(s, serial);
ogg->page_pos = -1;
while (!ogg_read_page(s, &i, 1)) {
- if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
+ if (i >= 0 && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
ogg->streams[i].codec) {
s->streams[i]->duration =
ogg_gptopts(s, i, ogg->streams[i].granule, NULL);
return 0;
}
-AVInputFormat ff_ogg_demuxer = {
+const AVInputFormat ff_ogg_demuxer = {
.name = "ogg",
.long_name = NULL_IF_CONFIG_SMALL("Ogg"),
.priv_data_size = sizeof(struct ogg),