Fixed another dereference in the RTSP code.

Removed a useless variable.

Changed an unnecessary looping assignment to a simple assignment suggested by
Maksym.

Added fixes and tweaks suggested by Maksym Veremeyenko [[email protected]] and
Clément B.
---
 ffmpeg.c   |    1 +
 ffserver.c |   21 ++++++++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index c99c4de..0cbb5e9 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -627,6 +627,7 @@ static int read_ffserver_streams(AVFormatContext *s, const 
char *filename)
         return err;
     /* copy stream format */
     s->nb_streams = 0;
+    s->streams = av_mallocz(sizeof(AVStream *) * ic->nb_streams);
     for(i=0;i<ic->nb_streams;i++) {
         AVStream *st;
         AVCodec *codec;
diff --git a/ffserver.c b/ffserver.c
index b4613af..b95a854 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2229,11 +2229,11 @@ static int http_prepare_data(HTTPContext *c)
         av_metadata_set2(&c->fmt_ctx.metadata, "copyright", 
c->stream->copyright, 0);
         av_metadata_set2(&c->fmt_ctx.metadata, "title"    , c->stream->title   
 , 0);
 
+        c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * 
c->stream->nb_streams);
+
         for(i=0;i<c->stream->nb_streams;i++) {
-            AVStream *st;
             AVStream *src;
-            st = av_mallocz(sizeof(AVStream));
-            c->fmt_ctx.streams[i] = st;
+            c->fmt_ctx.streams[i] = av_mallocz(sizeof(AVStream));
             /* if file or feed, then just take streams from FFStream struct */
             if (!c->stream->feed ||
                 c->stream->feed == c->stream)
@@ -2241,9 +2241,9 @@ static int http_prepare_data(HTTPContext *c)
             else
                 src = c->stream->feed->streams[c->stream->feed_streams[i]];
 
-            *st = *src;
-            st->priv_data = 0;
-            st->codec->frame_number = 0; /* XXX: should be done in
+            *(c->fmt_ctx.streams[i]) = *src;
+            c->fmt_ctx.streams[i]->priv_data = 0;
+            c->fmt_ctx.streams[i]->codec->frame_number = 0; /* XXX: should be 
done in
                                            AVStream, not in codec */
         }
         /* set output format parameters */
@@ -3385,6 +3385,9 @@ static int rtp_new_av_stream(HTTPContext *c,
     if (!st)
         goto fail;
     ctx->nb_streams = 1;
+    ctx->streams = av_mallocz(sizeof(AVStream *) * ctx->nb_streams);
+    if (!ctx->streams)
+      goto fail;
     ctx->streams[0] = st;
 
     if (!c->stream->feed ||
@@ -3765,11 +3768,7 @@ static void build_feed_streams(void)
             }
             s->oformat = feed->fmt;
             s->nb_streams = feed->nb_streams;
-            for(i=0;i<s->nb_streams;i++) {
-                AVStream *st;
-                st = feed->streams[i];
-                s->streams[i] = st;
-            }
+            s->streams = feed->streams;
             av_set_parameters(s, NULL);
             if (av_write_header(s) < 0) {
                 http_log("Container doesn't supports the required 
parameters\n");
-- 
1.7.3.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to