[FFmpeg-devel] [patch] error codes for http/tcp

Michael Niedermayer michaelni
Fri Jul 27 14:14:07 CEST 2007


Hi

On Thu, Jul 26, 2007 at 06:47:57PM -0400, Ronald S. Bultje wrote:
[...]
> Having built, it appears to work. I'm having trouble finding a
> >known-good HTTP stream to test with, made harder because my ffplay does
> >not appear to produce audio at the moment (probably a transitory issue),
> >but both the system-installed and the patched versions of ffplay produce
> >a video window with the one stream I've managed to track down so far -
> >which unfortunately displays only black even when played in MPlayer, so
> >it's hard to be sure that it's really working correctly.
> 
> 
> you can use some of the gstreamer samples as http streams, e.g.
> http://gstreamer.freedesktop.org/media/small/benow.mp3
> 
> However,
> >just to be complete, I decided to try something not even an address,
> >http://fnord/ - and the installed copy failed cleanly but the patched
> >copy segfaulted. ffplay_g does not appear to contain line-number
> >information, but here's a backtrace anyway.
> >
> >==
> >#0  0x080c5d86 in resolve_host (sin_addr=0xb712d36c, hostname=0xb712cee8
> >"fnord", h_errnop=0xb712d384) at os_support.c:75
> 
> 
> Hm, that's not supposed to happen according to the manpage. Anyway, easily
> worked around, patched version should fix this. Just to make sure, can you
> confirm that there are no compiler warnings when compiling os_support.c?
> 
> Ronald

[...]
> Index: ffmpeg/libavformat/avformat.h
> ===================================================================
> --- ffmpeg.orig/libavformat/avformat.h	2007-07-26 09:01:09.000000000 -0400
> +++ ffmpeg/libavformat/avformat.h	2007-07-26 09:01:16.000000000 -0400
> @@ -858,7 +858,7 @@
>                             struct tm *dt);
>  
>  struct in_addr;
> -int resolve_host(struct in_addr *sin_addr, const char *hostname);
> +int resolve_host(struct in_addr *sin_addr, const char *hostname, int *h_errnop);
>  
>  void url_split(char *proto, int proto_size,
>                 char *authorization, int authorization_size,

> Index: ffmpeg/ffserver.c
> ===================================================================
> --- ffmpeg.orig/ffserver.c	2007-07-26 09:01:09.000000000 -0400
> +++ ffmpeg/ffserver.c	2007-07-26 09:01:16.000000000 -0400
> @@ -298,6 +298,22 @@
>  
>  static FILE *logfile = NULL;
>  
> +static const char *h_strerror(int error_code)
> +{
> +    switch (error_code) {
> +        case HOST_NOT_FOUND:
> +            return "Unknown host";
> +        case NO_DATA:
> +            return "The requested name is valid but does not have an IP address";
> +        case NO_RECOVERY:
> +            return "A non-recoverable name server error occurred";
> +        case TRY_AGAIN:
> +            return "A temporary error occurred on the name server; please try again";
> +        default:
> +            return "Unknown error";
> +    }
> +}
> +
>  static void __attribute__ ((format (printf, 1, 2))) http_log(const char *fmt, ...)
>  {
>      va_list ap;
> @@ -3787,7 +3803,7 @@
>      char cmd[64];
>      char arg[1024];
>      const char *p;
> -    int val, errors, line_num;
> +    int val, errors, line_num, herr;
>      FFStream **last_stream, *stream, *redirect;
>      FFStream **last_feed, *feed;
>      AVCodecContext audio_enc, video_enc;
> @@ -3833,9 +3849,9 @@
>              my_http_addr.sin_port = htons(val);
>          } else if (!strcasecmp(cmd, "BindAddress")) {
>              get_arg(arg, sizeof(arg), &p);
> -            if (resolve_host(&my_http_addr.sin_addr, arg) != 0) {
> -                fprintf(stderr, "%s:%d: Invalid host/IP address: %s\n",
> -                        filename, line_num, arg);
> +            if (resolve_host(&my_http_addr.sin_addr, arg, &herr) != 0) {
> +                fprintf(stderr, "%s:%d: Invalid host/IP address %s: %s\n",
> +                        filename, line_num, arg, h_strerror(herr));
>                  errors++;
>              }
>          } else if (!strcasecmp(cmd, "NoDaemon")) {

well, either resolve_host() is a private function to avformat in which case
ffserver cant use it or its a public function in which case it needs an av
prefix and a major version bump

also the changes to ffserver should be in a seperate patch ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070727/f441d370/attachment.pgp>



More information about the ffmpeg-devel mailing list