[02/10] hls: Return all packets from a previous variant before moving on to the next one

Message ID 1375038091-92151-2-git-send-email-martin@martin.st
State Committed
Commit eb33ba04e03d9f36e23fffd442510c824be709c3
Headers show

Commit Message

Martin Storsjö July 28, 2013, 7:01 p.m.
This serves as a safeguard; normally we want to use the dts
comparison to interleave packets from all active variants. If that
dts comparison for some reason doesn't work as intended, make sure
that all packets in all variants for a certain sequence number have
been returned before moving on to the next one.
---
 libavformat/hls.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Luca Barbato July 28, 2013, 8:11 p.m. | #1
On 28/07/13 21:01, Martin Storsjö wrote:
> This serves as a safeguard; normally we want to use the dts
> comparison to interleave packets from all active variants. If that
> dts comparison for some reason doesn't work as intended, make sure
> that all packets in all variants for a certain sequence number have
> been returned before moving on to the next one.
> ---
>  libavformat/hls.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Might be squashed with 8?
Martin Storsjö July 28, 2013, 8:12 p.m. | #2
On Sun, 28 Jul 2013, Luca Barbato wrote:

> On 28/07/13 21:01, Martin Storsjö wrote:
>> This serves as a safeguard; normally we want to use the dts
>> comparison to interleave packets from all active variants. If that
>> dts comparison for some reason doesn't work as intended, make sure
>> that all packets in all variants for a certain sequence number have
>> been returned before moving on to the next one.
>> ---
>>  libavformat/hls.c |    7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>
> Might be squashed with 8?

Kinda, but they're different ideas from different authors, so I'd rather 
keep them separated.

// Martin

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 0d691ec..464faee 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -638,10 +638,13 @@  start:
                 }
             }
         }
-        /* Check if this stream has the packet with the lowest dts */
+        /* Check if this stream still is on an earlier segment number, or
+         * has the packet with the lowest dts */
         if (var->pkt.data) {
             if (minvariant < 0 ||
-                var->pkt.dts < c->variants[minvariant]->pkt.dts)
+                var->cur_seq_no <  c->variants[minvariant]->cur_seq_no ||
+               (var->cur_seq_no == c->variants[minvariant]->cur_seq_no &&
+                var->pkt.dts    <  c->variants[minvariant]->pkt.dts))
                 minvariant = i;
         }
     }