ffserver: reindent compute_status()

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
pull/101/head
Reynaldo H. Verdejo Pinochet 10 years ago
parent 907101eb83
commit 9e55130a9d
  1. 66
      ffserver.c

@ -1774,6 +1774,7 @@ static void compute_status(HTTPContext *c)
stream = stream->next; stream = stream->next;
continue; continue;
} }
av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10); av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10);
eosf = sfilename + strlen(sfilename); eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) { if (eosf - sfilename >= 4) {
@ -1800,6 +1801,7 @@ static void compute_status(HTTPContext *c)
avio_printf(pb, "<td align=right> %d <td align=right> ", avio_printf(pb, "<td align=right> %d <td align=right> ",
stream->conns_served); stream->conns_served);
fmt_bytecount(pb, stream->bytes_served); fmt_bytecount(pb, stream->bytes_served);
switch(stream->stream_type) { switch(stream->stream_type) {
case STREAM_TYPE_LIVE: { case STREAM_TYPE_LIVE: {
int audio_bit_rate = 0; int audio_bit_rate = 0;
@ -1812,6 +1814,7 @@ static void compute_status(HTTPContext *c)
for(i=0;i<stream->nb_streams;i++) { for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id); AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec->codec_type) { switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
audio_bit_rate += st->codec->bit_rate; audio_bit_rate += st->codec->bit_rate;
@ -1836,11 +1839,15 @@ static void compute_status(HTTPContext *c)
abort(); abort();
} }
} }
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",
stream->fmt->name, avio_printf(pb, "<td align=center> %s <td align=right> %d "
stream->bandwidth, "<td align=right> %d <td> %s %s <td align=right> "
video_bit_rate / 1000, video_codec_name, video_codec_name_extra, "%d <td> %s %s",
audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra); stream->fmt->name, stream->bandwidth,
video_bit_rate / 1000, video_codec_name,
video_codec_name_extra, audio_bit_rate / 1000,
audio_codec_name, audio_codec_name_extra);
if (stream->feed) if (stream->feed)
avio_printf(pb, "<td>%s", stream->feed->filename); avio_printf(pb, "<td>%s", stream->feed->filename);
else else
@ -1849,7 +1856,8 @@ static void compute_status(HTTPContext *c)
} }
break; break;
default: default:
avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n"); avio_printf(pb, "<td align=center> - <td align=right> - "
"<td align=right> - <td><td align=right> - <td>\n");
break; break;
} }
stream = stream->next; stream = stream->next;
@ -1858,10 +1866,12 @@ static void compute_status(HTTPContext *c)
stream = config.first_stream; stream = config.first_stream;
while (stream) { while (stream) {
if (stream->feed != stream) { if (stream->feed != stream) {
stream = stream->next; stream = stream->next;
continue; continue;
} }
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename); avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) { if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid); avio_printf(pb, "Running as pid %d.\n", stream->pid);
@ -1881,9 +1891,9 @@ static void compute_status(HTTPContext *c)
char cpuperc[10]; char cpuperc[10];
char cpuused[64]; char cpuused[64];
if (fscanf(pid_stat, "%9s %63s", cpuperc, if (fscanf(pid_stat, "%9s %63s", cpuperc, cpuused) == 2) {
cpuused) == 2) { avio_printf(pb, "Currently using %s%% of the cpu. "
avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n", "Total time used %s.\n",
cpuperc, cpuused); cpuperc, cpuused);
} }
fclose(pid_stat); fclose(pid_stat);
@ -1893,7 +1903,10 @@ static void compute_status(HTTPContext *c)
avio_printf(pb, "<p>"); avio_printf(pb, "<p>");
} }
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");
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");
for (i = 0; i < stream->nb_streams; i++) { for (i = 0; i < stream->nb_streams; i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
@ -1906,21 +1919,27 @@ static void compute_status(HTTPContext *c)
switch(st->codec->codec_type) { switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
type = "audio"; type = "audio";
snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate); snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz",
st->codec->channels, st->codec->sample_rate);
break; break;
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
type = "video"; type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height, snprintf(parameters, sizeof(parameters),
st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num); "%dx%d, q=%d-%d, fps=%d", st->codec->width,
st->codec->height, st->codec->qmin, st->codec->qmax,
st->codec->time_base.den / st->codec->time_base.num);
break; break;
default: default:
abort(); abort();
} }
avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters); avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d"
"<td>%s<td>%s\n",
i, type, st->codec->bit_rate/1000,
codec ? codec->name : "", parameters);
} }
avio_printf(pb, "</table>\n");
avio_printf(pb, "</table>\n");
stream = stream->next; stream = stream->next;
} }
@ -1934,7 +1953,8 @@ static void compute_status(HTTPContext *c)
current_bandwidth, config.max_bandwidth); current_bandwidth, config.max_bandwidth);
avio_printf(pb, "<table>\n"); avio_printf(pb, "<table>\n");
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"); 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");
c1 = first_http_ctx; c1 = first_http_ctx;
i = 0; i = 0;
while (c1) { while (c1) {
@ -1953,13 +1973,11 @@ static void compute_status(HTTPContext *c)
i++; i++;
p = inet_ntoa(c1->from_addr.sin_addr); p = inet_ntoa(c1->from_addr.sin_addr);
avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>", avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s"
i, "<td align=right>",
c1->stream ? c1->stream->filename : "", i, c1->stream ? c1->stream->filename : "",
c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", p,
p, c1->protocol, http_state[c1->state]);
c1->protocol,
http_state[c1->state]);
fmt_bytecount(pb, bitrate); fmt_bytecount(pb, bitrate);
avio_printf(pb, "<td align=right>"); avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8); fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);

Loading…
Cancel
Save