Revision d9d86e00

View differences:

ffserver.c
1861 1861

  
1862 1862
    for (s = suffix; count >= 100000 && s[1]; count /= 1000, s++);
1863 1863

  
1864
    url_fprintf(pb, "%"PRId64"%c", count, *s);
1864
    avio_printf(pb, "%"PRId64"%c", count, *s);
1865 1865
}
1866 1866

  
1867 1867
static void compute_status(HTTPContext *c)
......
1880 1880
        return;
1881 1881
    }
1882 1882

  
1883
    url_fprintf(pb, "HTTP/1.0 200 OK\r\n");
1884
    url_fprintf(pb, "Content-type: %s\r\n", "text/html");
1885
    url_fprintf(pb, "Pragma: no-cache\r\n");
1886
    url_fprintf(pb, "\r\n");
1883
    avio_printf(pb, "HTTP/1.0 200 OK\r\n");
1884
    avio_printf(pb, "Content-type: %s\r\n", "text/html");
1885
    avio_printf(pb, "Pragma: no-cache\r\n");
1886
    avio_printf(pb, "\r\n");
1887 1887

  
1888
    url_fprintf(pb, "<html><head><title>%s Status</title>\n", program_name);
1888
    avio_printf(pb, "<html><head><title>%s Status</title>\n", program_name);
1889 1889
    if (c->stream->feed_filename[0])
1890
        url_fprintf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename);
1891
    url_fprintf(pb, "</head>\n<body>");
1892
    url_fprintf(pb, "<h1>%s Status</h1>\n", program_name);
1890
        avio_printf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename);
1891
    avio_printf(pb, "</head>\n<body>");
1892
    avio_printf(pb, "<h1>%s Status</h1>\n", program_name);
1893 1893
    /* format status */
1894
    url_fprintf(pb, "<h2>Available Streams</h2>\n");
1895
    url_fprintf(pb, "<table cellspacing=0 cellpadding=4>\n");
1896
    url_fprintf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
1894
    avio_printf(pb, "<h2>Available Streams</h2>\n");
1895
    avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n");
1896
    avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
1897 1897
    stream = first_stream;
1898 1898
    while (stream != NULL) {
1899 1899
        char sfilename[1024];
......
1921 1921
                }
1922 1922
            }
1923 1923

  
1924
            url_fprintf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
1924
            avio_printf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
1925 1925
                         sfilename, stream->filename);
1926
            url_fprintf(pb, "<td align=right> %d <td align=right> ",
1926
            avio_printf(pb, "<td align=right> %d <td align=right> ",
1927 1927
                        stream->conns_served);
1928 1928
            fmt_bytecount(pb, stream->bytes_served);
1929 1929
            switch(stream->stream_type) {
......
1962 1962
                            abort();
1963 1963
                        }
1964 1964
                    }
1965
                    url_fprintf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
1965
                    avio_printf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
1966 1966
                                 stream->fmt->name,
1967 1967
                                 stream->bandwidth,
1968 1968
                                 video_bit_rate / 1000, video_codec_name, video_codec_name_extra,
1969 1969
                                 audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra);
1970 1970
                    if (stream->feed)
1971
                        url_fprintf(pb, "<td>%s", stream->feed->filename);
1971
                        avio_printf(pb, "<td>%s", stream->feed->filename);
1972 1972
                    else
1973
                        url_fprintf(pb, "<td>%s", stream->feed_filename);
1974
                    url_fprintf(pb, "\n");
1973
                        avio_printf(pb, "<td>%s", stream->feed_filename);
1974
                    avio_printf(pb, "\n");
1975 1975
                }
1976 1976
                break;
1977 1977
            default:
1978
                url_fprintf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
1978
                avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
1979 1979
                break;
1980 1980
            }
1981 1981
        }
1982 1982
        stream = stream->next;
1983 1983
    }
1984
    url_fprintf(pb, "</table>\n");
1984
    avio_printf(pb, "</table>\n");
1985 1985

  
1986 1986
    stream = first_stream;
1987 1987
    while (stream != NULL) {
1988 1988
        if (stream->feed == stream) {
1989
            url_fprintf(pb, "<h2>Feed %s</h2>", stream->filename);
1989
            avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
1990 1990
            if (stream->pid) {
1991
                url_fprintf(pb, "Running as pid %d.\n", stream->pid);
1991
                avio_printf(pb, "Running as pid %d.\n", stream->pid);
1992 1992

  
1993 1993
#if defined(linux) && !defined(CONFIG_NOCUTILS)
1994 1994
                {
......
2007 2007

  
2008 2008
                        if (fscanf(pid_stat, "%10s %64s", cpuperc,
2009 2009
                                   cpuused) == 2) {
2010
                            url_fprintf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
2010
                            avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
2011 2011
                                         cpuperc, cpuused);
2012 2012
                        }
2013 2013
                        fclose(pid_stat);
......
2015 2015
                }
2016 2016
#endif
2017 2017

  
2018
                url_fprintf(pb, "<p>");
2018
                avio_printf(pb, "<p>");
2019 2019
            }
2020
            url_fprintf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
2020
            avio_printf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
2021 2021

  
2022 2022
            for (i = 0; i < stream->nb_streams; i++) {
2023 2023
                AVStream *st = stream->streams[i];
......
2040 2040
                default:
2041 2041
                    abort();
2042 2042
                }
2043
                url_fprintf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
2043
                avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
2044 2044
                        i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
2045 2045
            }
2046
            url_fprintf(pb, "</table>\n");
2046
            avio_printf(pb, "</table>\n");
2047 2047

  
2048 2048
        }
2049 2049
        stream = stream->next;
2050 2050
    }
2051 2051

  
2052 2052
    /* connection status */
2053
    url_fprintf(pb, "<h2>Connection Status</h2>\n");
2053
    avio_printf(pb, "<h2>Connection Status</h2>\n");
2054 2054

  
2055
    url_fprintf(pb, "Number of connections: %d / %d<br>\n",
2055
    avio_printf(pb, "Number of connections: %d / %d<br>\n",
2056 2056
                 nb_connections, nb_max_connections);
2057 2057

  
2058
    url_fprintf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
2058
    avio_printf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
2059 2059
                 current_bandwidth, max_bandwidth);
2060 2060

  
2061
    url_fprintf(pb, "<table>\n");
2062
    url_fprintf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
2061
    avio_printf(pb, "<table>\n");
2062
    avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
2063 2063
    c1 = first_http_ctx;
2064 2064
    i = 0;
2065 2065
    while (c1 != NULL) {
......
2078 2078

  
2079 2079
        i++;
2080 2080
        p = inet_ntoa(c1->from_addr.sin_addr);
2081
        url_fprintf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
2081
        avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
2082 2082
                    i,
2083 2083
                    c1->stream ? c1->stream->filename : "",
2084 2084
                    c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
......
2086 2086
                    c1->protocol,
2087 2087
                    http_state[c1->state]);
2088 2088
        fmt_bytecount(pb, bitrate);
2089
        url_fprintf(pb, "<td align=right>");
2089
        avio_printf(pb, "<td align=right>");
2090 2090
        fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);
2091
        url_fprintf(pb, "<td align=right>");
2091
        avio_printf(pb, "<td align=right>");
2092 2092
        fmt_bytecount(pb, c1->data_count);
2093
        url_fprintf(pb, "\n");
2093
        avio_printf(pb, "\n");
2094 2094
        c1 = c1->next;
2095 2095
    }
2096
    url_fprintf(pb, "</table>\n");
2096
    avio_printf(pb, "</table>\n");
2097 2097

  
2098 2098
    /* date */
2099 2099
    ti = time(NULL);
2100 2100
    p = ctime(&ti);
2101
    url_fprintf(pb, "<hr size=1 noshade>Generated at %s", p);
2102
    url_fprintf(pb, "</body>\n</html>\n");
2101
    avio_printf(pb, "<hr size=1 noshade>Generated at %s", p);
2102
    avio_printf(pb, "</body>\n</html>\n");
2103 2103

  
2104 2104
    len = url_close_dyn_buf(pb, &c->pb_buffer);
2105 2105
    c->buffer_ptr = c->pb_buffer;
......
2812 2812
        break;
2813 2813
    }
2814 2814

  
2815
    url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", error_number, str);
2816
    url_fprintf(c->pb, "CSeq: %d\r\n", c->seq);
2815
    avio_printf(c->pb, "RTSP/1.0 %d %s\r\n", error_number, str);
2816
    avio_printf(c->pb, "CSeq: %d\r\n", c->seq);
2817 2817

  
2818 2818
    /* output GMT time */
2819 2819
    ti = time(NULL);
2820 2820
    tm = gmtime(&ti);
2821 2821
    strftime(buf2, sizeof(buf2), "%a, %d %b %Y %H:%M:%S", tm);
2822
    url_fprintf(c->pb, "Date: %s GMT\r\n", buf2);
2822
    avio_printf(c->pb, "Date: %s GMT\r\n", buf2);
2823 2823
}
2824 2824

  
2825 2825
static void rtsp_reply_error(HTTPContext *c, enum RTSPStatusCode error_number)
2826 2826
{
2827 2827
    rtsp_reply_header(c, error_number);
2828
    url_fprintf(c->pb, "\r\n");
2828
    avio_printf(c->pb, "\r\n");
2829 2829
}
2830 2830

  
2831 2831
static int rtsp_parse_request(HTTPContext *c)
......
2970 2970
static void rtsp_cmd_options(HTTPContext *c, const char *url)
2971 2971
{
2972 2972
//    rtsp_reply_header(c, RTSP_STATUS_OK);
2973
    url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK");
2974
    url_fprintf(c->pb, "CSeq: %d\r\n", c->seq);
2975
    url_fprintf(c->pb, "Public: %s\r\n", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE");
2976
    url_fprintf(c->pb, "\r\n");
2973
    avio_printf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK");
2974
    avio_printf(c->pb, "CSeq: %d\r\n", c->seq);
2975
    avio_printf(c->pb, "Public: %s\r\n", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE");
2976
    avio_printf(c->pb, "\r\n");
2977 2977
}
2978 2978

  
2979 2979
static void rtsp_cmd_describe(HTTPContext *c, const char *url)
......
3014 3014
        return;
3015 3015
    }
3016 3016
    rtsp_reply_header(c, RTSP_STATUS_OK);
3017
    url_fprintf(c->pb, "Content-Base: %s/\r\n", url);
3018
    url_fprintf(c->pb, "Content-Type: application/sdp\r\n");
3019
    url_fprintf(c->pb, "Content-Length: %d\r\n", content_length);
3020
    url_fprintf(c->pb, "\r\n");
3017
    avio_printf(c->pb, "Content-Base: %s/\r\n", url);
3018
    avio_printf(c->pb, "Content-Type: application/sdp\r\n");
3019
    avio_printf(c->pb, "Content-Length: %d\r\n", content_length);
3020
    avio_printf(c->pb, "\r\n");
3021 3021
    avio_write(c->pb, content, content_length);
3022 3022
    av_free(content);
3023 3023
}
......
3163 3163
    /* now everything is OK, so we can send the connection parameters */
3164 3164
    rtsp_reply_header(c, RTSP_STATUS_OK);
3165 3165
    /* session ID */
3166
    url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3166
    avio_printf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3167 3167

  
3168 3168
    switch(rtp_c->rtp_protocol) {
3169 3169
    case RTSP_LOWER_TRANSPORT_UDP:
3170 3170
        rtp_port = rtp_get_local_rtp_port(rtp_c->rtp_handles[stream_index]);
3171 3171
        rtcp_port = rtp_get_local_rtcp_port(rtp_c->rtp_handles[stream_index]);
3172
        url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
3172
        avio_printf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
3173 3173
                    "client_port=%d-%d;server_port=%d-%d",
3174 3174
                    th->client_port_min, th->client_port_max,
3175 3175
                    rtp_port, rtcp_port);
3176 3176
        break;
3177 3177
    case RTSP_LOWER_TRANSPORT_TCP:
3178
        url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
3178
        avio_printf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
3179 3179
                    stream_index * 2, stream_index * 2 + 1);
3180 3180
        break;
3181 3181
    default:
3182 3182
        break;
3183 3183
    }
3184 3184
    if (setup.transport_option[0] != '\0')
3185
        url_fprintf(c->pb, ";%s", setup.transport_option);
3186
    url_fprintf(c->pb, "\r\n");
3185
        avio_printf(c->pb, ";%s", setup.transport_option);
3186
    avio_printf(c->pb, "\r\n");
3187 3187

  
3188 3188

  
3189
    url_fprintf(c->pb, "\r\n");
3189
    avio_printf(c->pb, "\r\n");
3190 3190
}
3191 3191

  
3192 3192

  
......
3248 3248
    /* now everything is OK, so we can send the connection parameters */
3249 3249
    rtsp_reply_header(c, RTSP_STATUS_OK);
3250 3250
    /* session ID */
3251
    url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3252
    url_fprintf(c->pb, "\r\n");
3251
    avio_printf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3252
    avio_printf(c->pb, "\r\n");
3253 3253
}
3254 3254

  
3255 3255
static void rtsp_cmd_pause(HTTPContext *c, const char *url, RTSPMessageHeader *h)
......
3273 3273
    /* now everything is OK, so we can send the connection parameters */
3274 3274
    rtsp_reply_header(c, RTSP_STATUS_OK);
3275 3275
    /* session ID */
3276
    url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3277
    url_fprintf(c->pb, "\r\n");
3276
    avio_printf(c->pb, "Session: %s\r\n", rtp_c->session_id);
3277
    avio_printf(c->pb, "\r\n");
3278 3278
}
3279 3279

  
3280 3280
static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPMessageHeader *h)
......
3296 3296
    /* now everything is OK, so we can send the connection parameters */
3297 3297
    rtsp_reply_header(c, RTSP_STATUS_OK);
3298 3298
    /* session ID */
3299
    url_fprintf(c->pb, "Session: %s\r\n", session_id);
3300
    url_fprintf(c->pb, "\r\n");
3299
    avio_printf(c->pb, "Session: %s\r\n", session_id);
3300
    avio_printf(c->pb, "\r\n");
3301 3301
}
3302 3302

  
3303 3303

  
libavformat/avio.h
430 430
#define URL_EOF (-1)
431 431
attribute_deprecated int url_fgetc(AVIOContext *s);
432 432
attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
433
#ifdef __GNUC__
434
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
435
#else
436
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...);
437
#endif
433 438
/**
434 439
 * @}
435 440
 */
......
513 518

  
514 519
/** @warning currently size is limited */
515 520
#ifdef __GNUC__
516
int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
521
int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
517 522
#else
518
int url_fprintf(AVIOContext *s, const char *fmt, ...);
523
int avio_printf(AVIOContext *s, const char *fmt, ...);
519 524
#endif
520 525

  
521 526
#if FF_API_OLD_AVIO
libavformat/aviobuf.c
381 381
{
382 382
    return ffio_set_buf_size(s, buf_size);
383 383
}
384
int url_fprintf(AVIOContext *s, const char *fmt, ...)
385
{
386
    va_list ap;
387
    char buf[4096];
388
    int ret;
389

  
390
    va_start(ap, fmt);
391
    ret = vsnprintf(buf, sizeof(buf), fmt, ap);
392
    va_end(ap);
393
    avio_write(s, buf, strlen(buf));
394
    return ret;
395
}
384 396
#endif
385 397

  
386 398
int avio_put_str(AVIOContext *s, const char *str)
......
913 925
}
914 926

  
915 927
#if CONFIG_MUXERS
916
int url_fprintf(AVIOContext *s, const char *fmt, ...)
928
int avio_printf(AVIOContext *s, const char *fmt, ...)
917 929
{
918 930
    va_list ap;
919 931
    char buf[4096];
libavformat/ffmetaenc.c
73 73
        AVChapter *ch = s->chapters[i];
74 74
        avio_write(s->pb, ID_CHAPTER, sizeof(ID_CHAPTER) - 1);
75 75
        avio_w8(s->pb, '\n');
76
        url_fprintf(s->pb, "TIMEBASE=%d/%d\n", ch->time_base.num, ch->time_base.den);
77
        url_fprintf(s->pb, "START=%"PRId64"\n", ch->start);
78
        url_fprintf(s->pb, "END=%"PRId64"\n",   ch->end);
76
        avio_printf(s->pb, "TIMEBASE=%d/%d\n", ch->time_base.num, ch->time_base.den);
77
        avio_printf(s->pb, "START=%"PRId64"\n", ch->start);
78
        avio_printf(s->pb, "END=%"PRId64"\n",   ch->end);
79 79
        write_tags(s->pb, ch->metadata);
80 80
    }
81 81

  

Also available in: Unified diff