[FFmpeg-cvslog] libavformat: Make protocols pass URLContext as log context where available

Martin Storsjö git at videolan.org
Thu Apr 21 03:40:32 CEST 2011


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Apr 20 11:40:29 2011 +0200| [c60112f26873afafb55d24cc50a0e93ad9411373] | committer: Martin Storsjö

libavformat: Make protocols pass URLContext as log context where available

Since the libavformat major bump, URLContext contains an AVClass,
making it a usable log context.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c60112f26873afafb55d24cc50a0e93ad9411373
---

 libavformat/applehttpproto.c |   10 +++++-----
 libavformat/gopher.c         |    2 +-
 libavformat/http.c           |    4 ++--
 libavformat/tcp.c            |    4 ++--
 libavformat/udp.c            |    8 ++++----
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c
index 8a9bcb1..37b289a 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/applehttpproto.c
@@ -195,7 +195,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
         av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl));
         av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
     } else {
-        av_log(NULL, AV_LOG_ERROR, "Unsupported url %s\n", uri);
+        av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
         ret = AVERROR(EINVAL);
         goto fail;
     }
@@ -218,7 +218,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
     }
 
     if (s->n_segments == 0) {
-        av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
+        av_log(h, AV_LOG_WARNING, "Empty playlist\n");
         ret = AVERROR(EIO);
         goto fail;
     }
@@ -258,7 +258,7 @@ retry:
                 return ret;
     }
     if (s->cur_seq_no < s->start_seq_no) {
-        av_log(NULL, AV_LOG_WARNING,
+        av_log(h, AV_LOG_WARNING,
                "skipping %d segments ahead, expired from playlist\n",
                s->start_seq_no - s->cur_seq_no);
         s->cur_seq_no = s->start_seq_no;
@@ -274,12 +274,12 @@ retry:
         goto retry;
     }
     url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
-    av_log(NULL, AV_LOG_DEBUG, "opening %s\n", url);
+    av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
     ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ);
     if (ret < 0) {
         if (url_interrupt_cb())
             return AVERROR_EXIT;
-        av_log(NULL, AV_LOG_WARNING, "Unable to open %s\n", url);
+        av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
         s->cur_seq_no++;
         goto retry;
     }
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index 1d38cd2..79d1feb 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -50,7 +50,7 @@ static int gopher_connect(URLContext *h, const char *path)
             if (!path) return AVERROR(EINVAL);
             break;
         default:
-            av_log(NULL, AV_LOG_WARNING,
+            av_log(h, AV_LOG_WARNING,
                    "Gopher protocol type '%c' not supported yet!\n",
                    *path);
             return AVERROR(EINVAL);
diff --git a/libavformat/http.c b/libavformat/http.c
index 190f844..7d59152 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -70,7 +70,7 @@ void ff_http_set_headers(URLContext *h, const char *headers)
     int len = strlen(headers);
 
     if (len && strcmp("\r\n", headers + len - 2))
-        av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
+        av_log(h, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
 
     av_strlcpy(s->headers, headers, sizeof(s->headers));
 }
@@ -232,7 +232,7 @@ static int process_line(URLContext *h, char *line, int line_count,
          * don't abort until all headers have been parsed. */
         if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) {
             end += strspn(end, SPACE_CHARS);
-            av_log(NULL, AV_LOG_WARNING, "HTTP error %d %s\n",
+            av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
                    s->http_code, end);
             return -1;
         }
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 0cb3ae3..ced1038 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -64,7 +64,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     snprintf(portstr, sizeof(portstr), "%d", port);
     ret = getaddrinfo(hostname, portstr, &hints, &ai);
     if (ret) {
-        av_log(NULL, AV_LOG_ERROR,
+        av_log(h, AV_LOG_ERROR,
                "Failed to resolve hostname %s: %s\n",
                hostname, gai_strerror(ret));
         return AVERROR(EIO);
@@ -119,7 +119,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
         optlen = sizeof(ret);
         getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
         if (ret != 0) {
-            av_log(NULL, AV_LOG_ERROR,
+            av_log(h, AV_LOG_ERROR,
                    "TCP connection to %s:%d failed: %s\n",
                    hostname, port, strerror(ret));
             goto fail;
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 76e3f1a..932eb19 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -266,7 +266,7 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri)
                 if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr,
                             s->dest_addr_len)) {
                     s->is_connected = 0;
-                    av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
+                    av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
                     return AVERROR(EIO);
                 }
             }
@@ -410,7 +410,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
         /* limit the tx buf size to limit latency */
         tmp = s->buffer_size;
         if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
-            av_log(NULL, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
+            av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
             goto fail;
         }
     } else {
@@ -418,14 +418,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
          * avoid losing data on OSes that set this too low by default. */
         tmp = s->buffer_size;
         if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
-            av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
+            av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
         }
         /* make the socket non-blocking */
         ff_socket_nonblock(udp_fd, 1);
     }
     if (s->is_connected) {
         if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) {
-            av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
+            av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
             goto fail;
         }
     }



More information about the ffmpeg-cvslog mailing list