summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-02-07 16:06:39 +0100
committerchriszero <zerov83@gmail.com>2015-02-07 16:06:39 +0100
commit886aa7f168ebdc922864aeee432735ba48dde55b (patch)
treeaeff64c746c48a275616194d347b82c055ec7c3f
parent2cabbc7e52769a897f72521bea1feaacf2981bf3 (diff)
downloadvdr-plugin-plex-886aa7f168ebdc922864aeee432735ba48dde55b.tar.gz
vdr-plugin-plex-886aa7f168ebdc922864aeee432735ba48dde55b.tar.bz2
Implements resizing of the ringbuffer if a segment is bigger than the estimate.
-rw-r--r--hlsPlayer.cpp23
-rw-r--r--hlsPlayer.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/hlsPlayer.cpp b/hlsPlayer.cpp
index a6c0e6b..8feb8f0 100644
--- a/hlsPlayer.cpp
+++ b/hlsPlayer.cpp
@@ -278,6 +278,10 @@ bool cHlsSegmentLoader::DoLoad(void)
std::string segmentUri = GetSegmentUri(m_lastLoadedSegment++);
result = LoadSegment(segmentUri);
}
+ } else {
+ if(nextSegmentSize >= m_ringBufferSize) {
+ ResizeRingbuffer(nextSegmentSize + MEGABYTE(1));
+ }
}
m_bufferFilled = result;
} else {
@@ -339,6 +343,25 @@ void cHlsSegmentLoader::Ping(void)
}
}
+void cHlsSegmentLoader::ResizeRingbuffer(int newsize)
+{
+ hlsMutex.Lock();
+ isyslog("[plex] %s, Oldsize: %d, Newsize: %d", __FUNCTION__, m_ringBufferSize, newsize);
+ //Create new Ringbuffer
+ cRingBufferLinear* newBuffer = new cRingBufferLinear(newsize, 2*TS_SIZE);
+ // Copy old data
+ int count = 0;
+ uchar* pData = m_pRingbuffer->Get(count);
+ newBuffer->Put(pData, count);
+ // delete old buffer
+ delete m_pRingbuffer;
+ m_pRingbuffer = NULL;
+ // assing new buffer
+ m_pRingbuffer = newBuffer;
+ m_ringBufferSize = newsize;
+ hlsMutex.Unlock();
+}
+
//--- cHlsPlayer
cHlsPlayer::cHlsPlayer(std::string startm3u8, plexclient::Video* Video, int offset)
diff --git a/hlsPlayer.h b/hlsPlayer.h
index 12bea70..111a367 100644
--- a/hlsPlayer.h
+++ b/hlsPlayer.h
@@ -48,6 +48,7 @@ private:
bool LoadSegment(std::string uri);
int EstimateSegmentSize();
bool LoadLists(void);
+ void ResizeRingbuffer(int newsize);
protected: