| 1870 | } |
| 1871 | |
| 1872 | static void compute_status(HTTPContext *c) |
| 1873 | { |
| 1874 | HTTPContext *c1; |
| 1875 | FFStream *stream; |
| 1876 | char *p; |
| 1877 | time_t ti; |
| 1878 | int i, len; |
| 1879 | ByteIOContext *pb; |
| 1880 | |
| 1881 | if (url_open_dyn_buf(&pb) < 0) { |
| 1882 | /* XXX: return an error ? */ |
| 1883 | c->buffer_ptr = c->buffer; |
| 1884 | c->buffer_end = c->buffer; |
| 1885 | return; |
| 1886 | } |
| 1887 | |
| 1888 | url_fprintf(pb, "HTTP/1.0 200 OK\r\n"); |
| 1889 | url_fprintf(pb, "Content-type: %s\r\n", "text/html"); |
| 1890 | url_fprintf(pb, "Pragma: no-cache\r\n"); |
| 1891 | url_fprintf(pb, "\r\n"); |
| 1892 | |
| 1893 | url_fprintf(pb, "<html><head><title>%s Status</title>\n", program_name); |
| 1894 | if (c->stream->feed_filename[0]) |
| 1895 | url_fprintf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename); |
| 1896 | url_fprintf(pb, "</head>\n<body>"); |
| 1897 | url_fprintf(pb, "<h1>%s Status</h1>\n", program_name); |
| 1898 | /* format status */ |
| 1899 | url_fprintf(pb, "<h2>Available Streams</h2>\n"); |
| 1900 | url_fprintf(pb, "<table cellspacing=0 cellpadding=4>\n"); |
| 1901 | 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"); |
| 1902 | stream = first_stream; |
| 1903 | while (stream != NULL) { |
| 1904 | char sfilename[1024]; |
| 1905 | char *eosf; |
| 1906 | |
| 1907 | if (stream->feed != stream) { |
| 1908 | av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10); |
| 1909 | eosf = sfilename + strlen(sfilename); |
| 1910 | if (eosf - sfilename >= 4) { |
| 1911 | if (strcmp(eosf - 4, ".asf") == 0) |
| 1912 | strcpy(eosf - 4, ".asx"); |
| 1913 | else if (strcmp(eosf - 3, ".rm") == 0) |
| 1914 | strcpy(eosf - 3, ".ram"); |
| 1915 | else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) { |
| 1916 | /* generate a sample RTSP director if |
| 1917 | unicast. Generate an SDP redirector if |
| 1918 | multicast */ |
| 1919 | eosf = strrchr(sfilename, '.'); |
| 1920 | if (!eosf) |
| 1921 | eosf = sfilename + strlen(sfilename); |
| 1922 | if (stream->is_multicast) |
| 1923 | strcpy(eosf, ".sdp"); |
| 1924 | else |
| 1925 | strcpy(eosf, ".rtsp"); |
| 1926 | } |
| 1927 | } |
| 1928 | |
| 1929 | url_fprintf(pb, "<tr><td><a href=\"/%s\">%s</a> ", |
no test coverage detected