Permalink
Browse files

Remove and ignore streams containing no segments.

Some streams (France 24) ; have one stream that contains no segment whatsoever in one of the backup stream. So remove it after parsing it.
Unfortunately, that particular stream marks the over playback as VOD. Ideally we should ignore all tags from a stream that is going to be deleted. TODO
  • Loading branch information...
1 parent 8e324c6 commit d613b99a86788d9b5782c0048f8dbc5b3e61bf00 @jyavenard jyavenard committed May 20, 2012
@@ -1396,7 +1396,7 @@ class PlaylistWorker : public MThread
/* Parse HLS m3u8 content. */
err = m_parent->ParseM3U8(&buffer, streams);
}
- m_parent->AlignStreams(streams);
+ m_parent->SanitizeStreams(streams);
return err;
}
@@ -2292,7 +2292,7 @@ int HLSRingBuffer::ChooseSegment(int stream)
* Streams may not be all starting at the same sequence number, so attempt
* to align their starting sequence
*/
-void HLSRingBuffer::AlignStreams(StreamsList *streams)
+void HLSRingBuffer::SanitizeStreams(StreamsList *streams)
{
// no lock is required as, at this stage, no threads have either been started
// or we are working on a stream list unique to PlaylistWorker
@@ -2303,9 +2303,16 @@ void HLSRingBuffer::AlignStreams(StreamsList *streams)
QMap<int,int> idstart;
int count = streams->size();
// Find the highest starting sequence for each stream
- for (int n = 0; n < count; n++)
+ for (int n = count - 1 ; n >= 0; n--)
{
HLSStream *hls = GetStream(n, streams);
+ if (hls->NumSegments() == 0)
+ {
+ streams->removeAt(n);
+ count--;
+ continue; // remove it
+ }
+
int id = hls->Id();
int start = hls->StartSequence();
if (!idstart.contains(id))
@@ -2324,8 +2331,6 @@ void HLSRingBuffer::AlignStreams(StreamsList *streams)
HLSStream *hls = GetStream(n, streams);
int id = hls->Id();
int seq = hls->StartSequence();
- if (hls->NumSegments() == 0)
- continue; // Invalid streams
int newstart= idstart.value(id);
int todrop = newstart - seq;
if (todrop == 0)
@@ -2382,12 +2387,12 @@ bool HLSRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
return false;
}
+ SanitizeStreams();
+
/* HLS standard doesn't provide any guaranty about streams
being sorted by bitrate, so we sort them, higher bitrate being first */
qSort(m_streams.begin(), m_streams.end(), HLSStream::IsGreater);
- AlignStreams();
-
// if we want as close to live. We should be selecting a further segment
// m_live ? ChooseSegment(0) : 0;
m_startup = 0;
@@ -91,7 +91,7 @@ class HLSRingBuffer : public RingBuffer
int NumSegments(void) const;
int ChooseSegment(int stream);
int64_t SizeMedia(void) const;
- void AlignStreams(StreamsList *streams = NULL);
+ void SanitizeStreams(StreamsList *streams = NULL);
// private member variables
QString m_m3u8; // M3U8 url

0 comments on commit d613b99

Please sign in to comment.