]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_xiph.c
dashenc: Fix writing of timelines that don't start at t=0
[ffmpeg] / libavformat / rtpdec_xiph.c
index db39462f4a38c90116c0f9fbed1aeba0f7995a04..9e4fbc52f2db26b12e84cbf72e3ce42cea86860f 100644 (file)
@@ -27,6 +27,7 @@
  * @author Josh Allmann <joshua.allmann@gmail.com>
  */
 
+#include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
 #include "libavutil/base64.h"
 #include "libavcodec/bytestream.h"
@@ -70,6 +71,16 @@ static void xiph_free_context(PayloadContext * data)
     av_free(data);
 }
 
+static av_cold int xiph_vorbis_init(AVFormatContext *ctx, int st_index,
+                                    PayloadContext *data)
+{
+    if (st_index < 0)
+        return 0;
+    ctx->streams[st_index]->need_parsing = AVSTREAM_PARSE_HEADERS;
+    return 0;
+}
+
+
 static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                               AVStream *st, AVPacket *pkt, uint32_t *timestamp,
                               const uint8_t *buf, int len, uint16_t seq,
@@ -295,7 +306,8 @@ parse_packed_headers(const uint8_t * packed_headers,
     return 0;
 }
 
-static int xiph_parse_fmtp_pair(AVStream* stream,
+static int xiph_parse_fmtp_pair(AVFormatContext *s,
+                                AVStream* stream,
                                 PayloadContext *xiph_data,
                                 char *attr, char *value)
 {
@@ -310,7 +322,7 @@ static int xiph_parse_fmtp_pair(AVStream* stream,
         } else if (!strcmp(value, "YCbCr-4:4:4")) {
             codec->pix_fmt = AV_PIX_FMT_YUV444P;
         } else {
-            av_log(codec, AV_LOG_ERROR,
+            av_log(s, AV_LOG_ERROR,
                    "Unsupported pixel format %s\n", attr);
             return AVERROR_INVALIDDATA;
         }
@@ -349,12 +361,12 @@ static int xiph_parse_fmtp_pair(AVStream* stream,
                     (decoded_packet, decoded_packet + packet_size, codec,
                     xiph_data);
             } else {
-                av_log(codec, AV_LOG_ERROR,
+                av_log(s, AV_LOG_ERROR,
                        "Out of memory while decoding SDP configuration.\n");
                 result = AVERROR(ENOMEM);
             }
         } else {
-            av_log(codec, AV_LOG_ERROR, "Packet too large\n");
+            av_log(s, AV_LOG_ERROR, "Packet too large\n");
             result = AVERROR_INVALIDDATA;
         }
         av_free(decoded_packet);
@@ -371,7 +383,7 @@ static int xiph_parse_sdp_line(AVFormatContext *s, int st_index,
         return 0;
 
     if (av_strstart(line, "fmtp:", &p)) {
-        return ff_parse_fmtp(s->streams[st_index], data, p,
+        return ff_parse_fmtp(s, s->streams[st_index], data, p,
                              xiph_parse_fmtp_pair);
     }
 
@@ -392,6 +404,7 @@ RTPDynamicProtocolHandler ff_vorbis_dynamic_handler = {
     .enc_name         = "vorbis",
     .codec_type       = AVMEDIA_TYPE_AUDIO,
     .codec_id         = AV_CODEC_ID_VORBIS,
+    .init             = xiph_vorbis_init,
     .parse_sdp_a_line = xiph_parse_sdp_line,
     .alloc            = xiph_new_context,
     .free             = xiph_free_context,