[FFmpeg-cvslog] r24752 - in trunk/libavformat: rtsp.c rtsp.h

aurel subversion
Tue Aug 10 01:00:14 CEST 2010


Author: aurel
Date: Tue Aug 10 01:00:13 2010
New Revision: 24752

Log:
get ride of MAX_STREAMS limit in RTSP

Modified:
   trunk/libavformat/rtsp.c
   trunk/libavformat/rtsp.h

Modified: trunk/libavformat/rtsp.c
==============================================================================
--- trunk/libavformat/rtsp.c	Tue Aug 10 00:58:54 2010	(r24751)
+++ trunk/libavformat/rtsp.c	Tue Aug 10 01:00:13 2010	(r24752)
@@ -1611,12 +1611,18 @@ redirect:
 static int rtsp_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
 {
+    RTSPState *rt = s->priv_data;
     int ret;
 
     ret = ff_rtsp_connect(s);
     if (ret)
         return ret;
 
+    rt->real_setup_cache = av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
+    if (!rt->real_setup_cache)
+        return AVERROR(ENOMEM);
+    rt->real_setup = rt->real_setup_cache + s->nb_streams * sizeof(*rt->real_setup);
+
     if (ap->initial_pause) {
          /* do not start immediately */
     } else {
@@ -1835,13 +1841,12 @@ static int rtsp_read_packet(AVFormatCont
 
     if (rt->server_type == RTSP_SERVER_REAL) {
         int i;
-        enum AVDiscard cache[MAX_STREAMS];
 
         for (i = 0; i < s->nb_streams; i++)
-            cache[i] = s->streams[i]->discard;
+            rt->real_setup[i] = s->streams[i]->discard;
 
         if (!rt->need_subscription) {
-            if (memcmp (cache, rt->real_setup_cache,
+            if (memcmp (rt->real_setup, rt->real_setup_cache,
                         sizeof(enum AVDiscard) * s->nb_streams)) {
                 snprintf(cmd, sizeof(cmd),
                          "Unsubscribe: %s\r\n",
@@ -1857,7 +1862,7 @@ static int rtsp_read_packet(AVFormatCont
         if (rt->need_subscription) {
             int r, rule_nr, first = 1;
 
-            memcpy(rt->real_setup_cache, cache,
+            memcpy(rt->real_setup_cache, rt->real_setup,
                    sizeof(enum AVDiscard) * s->nb_streams);
             rt->last_subscription[0] = 0;
 
@@ -1969,6 +1974,8 @@ static int rtsp_read_close(AVFormatConte
     ff_rtsp_close_streams(s);
     ff_rtsp_close_connections(s);
     ff_network_close();
+    rt->real_setup = NULL;
+    av_freep(&rt->real_setup_cache);
     return 0;
 }
 

Modified: trunk/libavformat/rtsp.h
==============================================================================
--- trunk/libavformat/rtsp.h	Tue Aug 10 00:58:54 2010	(r24751)
+++ trunk/libavformat/rtsp.h	Tue Aug 10 01:00:13 2010	(r24752)
@@ -267,7 +267,11 @@ typedef struct RTSPState {
 
     /** stream setup during the last frame read. This is used to detect if
      * we need to subscribe or unsubscribe to any new streams. */
-    enum AVDiscard real_setup_cache[MAX_STREAMS];
+    enum AVDiscard *real_setup_cache;
+
+    /** current stream setup. This is a temporary buffer used to compare
+     * current setup to previous frame setup. */
+    enum AVDiscard *real_setup;
 
     /** the last value of the "SET_PARAMETER Subscribe:" RTSP command.
      * this is used to send the same "Unsubscribe:" if stream setup changed,



More information about the ffmpeg-cvslog mailing list