matroskadec: don't warn about unknown spherical medata when none is present
[ffmpeg.git] / libavformat / sapenc.c
index 246b7cf..ed3a024 100644 (file)
@@ -37,6 +37,8 @@ struct SAPState {
     int         ann_size;
     URLContext *ann_fd;
     int64_t     last_time;
+
+    const URLProtocol **protocols;
 };
 
 static int sap_write_close(AVFormatContext *s)
@@ -59,6 +61,8 @@ static int sap_write_close(AVFormatContext *s)
         ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);
     }
 
+    av_freep(&sap->protocols);
+
     av_freep(&sap->ann);
     if (sap->ann_fd)
         ffurl_close(sap->ann_fd);
@@ -134,6 +138,13 @@ static int sap_write_header(AVFormatContext *s)
         freeaddrinfo(ai);
     }
 
+    sap->protocols = ffurl_get_protocols(s->protocol_whitelist,
+                                         s->protocol_blacklist);
+    if (!sap->protocols) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+
     contexts = av_mallocz(sizeof(AVFormatContext*) * s->nb_streams);
     if (!contexts) {
         ret = AVERROR(ENOMEM);
@@ -148,7 +159,8 @@ static int sap_write_header(AVFormatContext *s)
                     "?ttl=%d", ttl);
         if (!same_port)
             base_port += 2;
-        ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
+        ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL,
+                         sap->protocols, NULL);
         if (ret) {
             ret = AVERROR(EIO);
             goto fail;
@@ -167,7 +179,7 @@ static int sap_write_header(AVFormatContext *s)
     ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port,
                 "?ttl=%d&connect=1", ttl);
     ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE,
-                     &s->interrupt_callback, NULL);
+                     &s->interrupt_callback, NULL, sap->protocols, NULL);
     if (ret) {
         ret = AVERROR(EIO);
         goto fail;
@@ -245,7 +257,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVFormatContext *rtpctx;
     struct SAPState *sap = s->priv_data;
-    int64_t now = av_gettime();
+    int64_t now = av_gettime_relative();
 
     if (!sap->last_time || now - sap->last_time > 5000000) {
         int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);