[vlc-commits] commit: stream_filter/httplive.c: do not crash on seeking (Jean-Paul Saman )

git at videolan.org git at videolan.org
Fri Nov 26 16:55:14 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Fri Nov 26 16:28:07 2010 +0100| [0c7c4caa281c95b5250570fdc2274f545b09ded1] | committer: Jean-Paul Saman 

stream_filter/httplive.c: do not crash on seeking

After the adaptive bandwidth changes seeking could end up in a segment
that is not available. Each segment is downloaded once and after switching
to higher or lower bandwidth segments downloaded for previous bandwidths
will not be deleted or downloaded. The later is to be fixed.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c7c4caa281c95b5250570fdc2274f545b09ded1
---

 modules/stream_filter/httplive.c |   44 +++++++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 0ff5ede..ae4ece2 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -61,7 +61,7 @@ vlc_module_end()
 typedef struct segment_s
 {
     int         sequence;   /* unique sequence number */
-    int         length;     /* segment duration (ms) */
+    int         length;     /* segment duration (seconds) */
     uint64_t    size;       /* segment size in bytes */
 
     vlc_url_t   url;
@@ -1475,23 +1475,39 @@ static int segment_Seek(stream_t *s, uint64_t pos)
             return VLC_EGENERIC;
 
         vlc_mutex_lock(&segment->lock);
-        length += segment->size;
-        uint64_t size = segment->size -segment->data->i_buffer;
-        if (size > 0)
+        if (segment->data)
         {
-            segment->data->i_buffer += size;
-            segment->data->p_buffer -= size;
-        }
+            length += segment->size;
+            uint64_t size = segment->size -segment->data->i_buffer;
+            if (size > 0)
+            {
+                segment->data->i_buffer += size;
+                segment->data->p_buffer -= size;
+            }
+
+            if (!b_found && (pos <= length))
+            {
+                uint64_t used = length - pos;
+                segment->data->i_buffer -= used;
+                segment->data->p_buffer += used;
 
-        if (!b_found && (pos <= length))
+                count = p_sys->segment;
+                p_sys->segment = n;
+                b_found = true;
+            }
+        }
+        else
         {
-            uint64_t used = length - pos;
-            segment->data->i_buffer -= used;
-            segment->data->p_buffer += used;
+            /* FIXME: seeking is weird when seeking in segments
+               that have not been downloaded yet */
+            length += segment->length * hls->bandwidth;
 
-            count = p_sys->segment;
-            p_sys->segment = n;
-            b_found = true;
+            if (!b_found && (pos <= length))
+            {
+                count = p_sys->segment;
+                p_sys->segment = n;
+                b_found = true;
+            }
         }
         vlc_mutex_unlock(&segment->lock);
     }



More information about the vlc-commits mailing list