Browse code

* Change the default behaviour to start streaming as soon as possible (i.e. no waiting for key frames). * Provide StartSendOnKey paramter for a stream to wait until we get key frames before sending. * Add the codec names into the status page. May help debugging problems.

Originally committed as revision 507 to svn://svn.ffmpeg.org/ffmpeg/trunk

Philip Gladstone authored on 2002/05/17 10:53:28
Showing 1 changed files
... ...
@@ -116,6 +116,7 @@ typedef struct FFStream {
116 116
     AVFormat *fmt;
117 117
     int nb_streams;
118 118
     int prebuffer;      /* Number of millseconds early to start */
119
+    int send_on_key;
119 120
     AVStream *streams[MAX_STREAMS];
120 121
     int feed_streams[MAX_STREAMS]; /* index of streams in the feed */
121 122
     char feed_filename[1024]; /* file name of the feed storage, or
... ...
@@ -768,9 +769,9 @@ static void compute_stats(HTTPContext *c)
768 768
     q += sprintf(q, "<HEAD><TITLE>FFServer Status</TITLE></HEAD>\n<BODY>");
769 769
     q += sprintf(q, "<H1>FFServer Status</H1>\n");
770 770
     /* format status */
771
-    q += sprintf(q, "<H1>Available Streams</H1>\n");
771
+    q += sprintf(q, "<H2>Available Streams</H2>\n");
772 772
     q += sprintf(q, "<TABLE>\n");
773
-    q += sprintf(q, "<TR><TD>Path<TD>Format<TD>Bit rate (kbits/s)<TD>Video<TD>Audio<TD>Feed\n");
773
+    q += sprintf(q, "<TR><Th>Path<Th>Format<Th>Bit rate (kbits/s)<Th COLSPAN=2>Video<Th COLSPAN=2>Audio<Th align=left>Feed\n");
774 774
     stream = first_stream;
775 775
     while (stream != NULL) {
776 776
         char sfilename[1024];
... ...
@@ -793,24 +794,40 @@ static void compute_stats(HTTPContext *c)
793 793
             {
794 794
                 int audio_bit_rate = 0;
795 795
                 int video_bit_rate = 0;
796
+                char *audio_codec_name = "";
797
+                char *video_codec_name = "";
798
+                char *audio_codec_name_extra = "";
799
+                char *video_codec_name_extra = "";
796 800
 
797 801
                 for(i=0;i<stream->nb_streams;i++) {
798 802
                     AVStream *st = stream->streams[i];
803
+                    AVCodec *codec = avcodec_find_encoder(st->codec.codec_id);
799 804
                     switch(st->codec.codec_type) {
800 805
                     case CODEC_TYPE_AUDIO:
801 806
                         audio_bit_rate += st->codec.bit_rate;
807
+                        if (codec) {
808
+                            if (*audio_codec_name)
809
+                                audio_codec_name_extra = "...";
810
+                            audio_codec_name = codec->name;
811
+                        }
802 812
                         break;
803 813
                     case CODEC_TYPE_VIDEO:
804 814
                         video_bit_rate += st->codec.bit_rate;
815
+                        if (codec) {
816
+                            if (*video_codec_name)
817
+                                video_codec_name_extra = "...";
818
+                            video_codec_name = codec->name;
819
+                        }
805 820
                         break;
806 821
                     default:
807 822
                         abort();
808 823
                     }
809 824
                 }
810
-                q += sprintf(q, "<TD> %s <TD> %d <TD> %d <TD> %d", 
825
+                q += sprintf(q, "<TD> %s <TD> %d <TD> %d <TD> %s %s <TD> %d <TD> %s %s", 
811 826
                              stream->fmt->name,
812 827
                              (audio_bit_rate + video_bit_rate) / 1000,
813
-                             video_bit_rate / 1000, audio_bit_rate / 1000);
828
+                             video_bit_rate / 1000, video_codec_name, video_codec_name_extra,
829
+                             audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra);
814 830
                 if (stream->feed) {
815 831
                     q += sprintf(q, "<TD>%s", stream->feed->filename);
816 832
                 } else {
... ...
@@ -820,7 +837,7 @@ static void compute_stats(HTTPContext *c)
820 820
             }
821 821
             break;
822 822
         default:
823
-            q += sprintf(q, "<TD> - <TD> - <TD> - <TD> -\n");
823
+            q += sprintf(q, "<TD> - <TD> - <TD COLSPAN=2> - <TD COLSPAN=2> -\n");
824 824
             break;
825 825
         }
826 826
         stream = stream->next;
... ...
@@ -858,7 +875,7 @@ static void compute_stats(HTTPContext *c)
858 858
 #endif
859 859
 
860 860
     /* connection status */
861
-    q += sprintf(q, "<H1>Connection Status</H1>\n");
861
+    q += sprintf(q, "<H2>Connection Status</H2>\n");
862 862
 
863 863
     q += sprintf(q, "Number of connections: %d / %d<BR>\n",
864 864
                  nb_connections, nb_max_connections);
... ...
@@ -1098,7 +1115,7 @@ static int http_prepare_data(HTTPContext *c)
1098 1098
                              * audio streams (for which every frame is 
1099 1099
                              * typically a key frame). 
1100 1100
                              */
1101
-                            if ((c->got_key_frame + 1) >> c->stream->nb_streams) {
1101
+                            if (!c->stream->send_on_key || ((c->got_key_frame + 1) >> c->stream->nb_streams)) {
1102 1102
                                 goto send_it;
1103 1103
                             }
1104 1104
                         }
... ...
@@ -1716,6 +1733,10 @@ int parse_ffconfig(const char *filename)
1716 1716
             if (stream) {
1717 1717
                 stream->prebuffer = atoi(arg) * 1000;
1718 1718
             }
1719
+        } else if (!strcasecmp(cmd, "StartSendOnKey")) {
1720
+            if (stream) {
1721
+                stream->send_on_key = 1;
1722
+            }
1719 1723
         } else if (!strcasecmp(cmd, "AudioCodec")) {
1720 1724
             get_arg(arg, sizeof(arg), &p);
1721 1725
             audio_id = opt_audio_codec(arg);