Chained ogg served by icecast and mpd should demux properly now. Fixes issue2337
Unified · Split
| @@ -164,6 +164,7 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial) · 163 unmodified lines | ||
| 164 | 164 | os->bufsize = DECODER_BUFFER_SIZE; |
| 165 | 165 | os->buf = av_malloc(os->bufsize); |
| 166 | 166 | os->header = -1; |
| 167 | + os->page_begin = 1; | |
| 167 | 168 | |
| 168 | 169 | st = av_new_stream (s, idx); |
| 169 | 170 | if (!st) |
| @@ -241,12 +242,27 @@ ogg_read_page (AVFormatContext * s, int *str) · 71 unmodified lines | ||
| 241 | 242 | |
| 242 | 243 | idx = ogg_find_stream (ogg, serial); |
| 243 | 244 | if (idx < 0){ |
| 245 | + for (i = 0; i < ogg->nstreams; i++) { | |
| 246 | + if (!ogg->streams[i].page_begin) { | |
| 247 | + int n; | |
| 248 | + | |
| 249 | + for (n = 0; n < ogg->nstreams; n++) { | |
| 250 | + av_free(ogg->streams[n].buf); | |
| 251 | + av_free(ogg->streams[n].private); | |
| 252 | + } | |
| 253 | + ogg->curidx = -1; | |
| 254 | + ogg->nstreams = 0; | |
| 255 | + break; | |
| 256 | + } | |
| 257 | + } | |
| 244 | 258 | idx = ogg_new_stream (s, serial); |
| 245 | 259 | if (idx < 0) |
| 246 | 260 | return -1; |
| 247 | 261 | } |
| 248 | 262 | |
| 249 | 263 | os = ogg->streams + idx; |
| 264 | + if (!(flags & OGG_FLAG_BOS)) | |
| 265 | + os->page_begin = 0; | |
| 250 | 266 | os->page_pos = avio_tell(bc) - 27; |
| 251 | 267 | |
| 252 | 268 | if(os->psize > 0) |
| @@ -75,6 +75,7 @@ struct ogg_stream { · 74 unmodified lines | ||
| 75 | 75 | int incomplete; ///< whether we're expecting a continuation in the next page |
| 76 | 76 | int page_end; ///< current packet is the last one completed in the page |
| 77 | 77 | int keyframe_seek; |
| 78 | + int page_begin; ///< set to 1 if the stream only received a begin-of-stream packet, otherwise 0 | |
| 78 | 79 | void *private; |
| 79 | 80 | }; |
| 80 | 81 | |