Skip to content

Commit

Permalink
[HLS] Handle initial sub playlists with end marker as VOD / seek fixe…
Browse files Browse the repository at this point in the history
…s (tbc)
  • Loading branch information
peak3d committed Aug 16, 2017
1 parent 36354fc commit 2af963b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/mpegts/ES_h264.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ES_h264::ES_h264(uint16_t pes_pid)
m_PPSRawId = -1;
m_fpsRate = 0;
m_fpsScale = 0;
m_recoveryPoint = false;
Reset();
}

Expand Down Expand Up @@ -96,7 +97,6 @@ void ES_h264::Parse(STREAM_PKT* pkt)
size_t pOld = es_parsed, p = es_parsed;
uint32_t startcode = m_StartCode;
bool frameComplete = false;
m_recoveryPoint = false;

while ((p + 3) < es_len)
{
Expand Down Expand Up @@ -180,6 +180,7 @@ void ES_h264::Parse(STREAM_PKT* pkt)
es_parsed = es_consumed;
es_found_frame = false;
es_frame_valid = true;
m_recoveryPoint = false;
}
}

Expand All @@ -190,6 +191,7 @@ void ES_h264::Reset()
m_NeedIFrame = true;
m_NeedSPS = true;
m_NeedPPS = true;
m_recoveryPoint = false;
memset(&m_streamData, 0, sizeof(m_streamData));
}

Expand Down
6 changes: 5 additions & 1 deletion src/TSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,17 @@ bool TSReader::SeekTime(uint64_t timeInTs, bool preceeding)
}

uint64_t lastRecovery(static_cast<uint64_t>(m_startPos));
while (m_pkt.pts == PTS_UNSET || static_cast<uint64_t>(m_pkt.pts) < timeInTs)
while (m_pkt.pts == PTS_UNSET || !preceeding || static_cast<uint64_t>(m_pkt.pts) < timeInTs)
{
uint64_t thisFrameStart(m_AVContext->GetPosition());
if (!ReadPacket())
return false;
if (!hasVideo || m_pkt.recoveryPoint || thisFrameStart == m_startPos)
{
lastRecovery = thisFrameStart;
if (!preceeding && static_cast<uint64_t>(m_pkt.pts) >= timeInTs)
break;
}
}
m_AVContext->GoPosition(lastRecovery, true);

Expand Down
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ class CInputStreamAdaptive
virtual int GetTime() override;
virtual bool CanPauseStream() override;
virtual bool CanSeekStream() override;
virtual bool IsRealTimeStream() override;

std::shared_ptr<Session> GetSession() { return m_session; };

Expand Down Expand Up @@ -2601,6 +2602,11 @@ bool CInputStreamAdaptive::CanSeekStream(void)
return m_session && !m_session->IsLive();
}

bool CInputStreamAdaptive::IsRealTimeStream()
{
return m_session && m_session->IsLive();
}

/*****************************************************************************************************/

CVideoCodecAdaptive::CVideoCodecAdaptive(KODI_HANDLE instance)
Expand Down
2 changes: 2 additions & 0 deletions src/parser/HLSTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ bool HLSTree::prepareRepresentation(Representation *rep, uint64_t segmentId)
else if (line.compare(0, 14, "#EXT-X-ENDLIST") == 0)
{
m_refreshPlayList = false;
if (!segmentId)
has_timeshift_buffer_ = false;
}
}

Expand Down

0 comments on commit 2af963b

Please sign in to comment.