[SCM] kodi-pvr-hts/master: Merge pull request #155 from perexg/timeshift-master
tiber-guest at users.alioth.debian.org
tiber-guest at users.alioth.debian.org
Fri Nov 4 23:23:35 UTC 2016
demuxer - flush packet queue also on speed changes
demuxer - Seek - set m_seekTime variable to zero before Wait()
muxer - flush the queued packets with wrong pts on seek
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4dc398ff1337ec61dea38685719108f1cd20f7b0
X-Git-Newrev: eeb9f109b792b5b66740aea6291e663647df0b4a
The following commit has been merged in the master branch:
commit 0b7c65cff4b6ef0a2e847f063fa24e4431b8dfb4
Merge: 358eda1067f14a68ed18a18a9b9003ccf52546cc 7449ad39f4e62db354d261fc9c24f9ebfd11dfbc
Author: Sam Stenvall <Jalle19 at users.noreply.github.com>
Date: Thu Jan 28 21:16:25 2016 +0200
Merge pull request #155 from perexg/timeshift-master
Timeshift: Seeking fixes
diff --combined src/HTSPDemuxer.cpp
index a13030b,65226c3..451858b
--- a/src/HTSPDemuxer.cpp
+++ b/src/HTSPDemuxer.cpp
@@@ -34,7 -34,8 +34,8 @@@ using namespace tvheadend::utilities
CHTSPDemuxer::CHTSPDemuxer ( CHTSPConnection &conn )
: m_conn(conn), m_pktBuffer((size_t)-1),
m_seekTime(INVALID_SEEKTIME),
- m_subscription(conn)
+ m_subscription(conn),
+ m_seeking(false), m_speedChange(false)
{
m_lastUse = 0;
}
@@@ -78,6 -79,8 +79,8 @@@ void CHTSPDemuxer::Abort0 ( void
CLockObject lock(m_mutex);
m_streams.Clear();
m_streamStat.clear();
+ m_seeking = false;
+ m_speedChange = false;
}
@@@ -159,21 -162,28 +162,28 @@@ bool CHTSPDemuxer::See
if (!m_subscription.IsActive())
return false;
- if (!m_subscription.SendSeek(time))
+ m_seeking = true;
+ if (!m_subscription.SendSeek(time)) {
+ m_seeking = false;
return false;
+ }
/* Wait for time */
+ m_seekTime = 0;
if (!m_seekCond.Wait(m_conn.Mutex(), m_seekTime, Settings::GetInstance().GetResponseTimeout()))
{
Logger::Log(LogLevel::LEVEL_ERROR, "failed to get subscriptionSeek response");
+ m_seeking = false;
+ Flush(); /* try to resync */
return false;
}
+ m_seeking = false;
if (m_seekTime == INVALID_SEEKTIME)
return false;
/* Store */
- *startpts = TVH_TO_DVD_TIME(m_seekTime);
+ *startpts = TVH_TO_DVD_TIME(m_seekTime - 1);
Logger::Log(LogLevel::LEVEL_TRACE, "demux seek startpts = %lf", *startpts);
return true;
@@@ -184,6 -194,10 +194,10 @@@ void CHTSPDemuxer::Speed ( int speed
CLockObject lock(m_conn.Mutex());
if (!m_subscription.IsActive())
return;
+ if (speed != m_subscription.GetSpeed() && (speed < 0 || speed >= 4000)) {
+ m_speedChange = true;
+ Flush();
+ }
m_subscription.SendSpeed(speed);
}
@@@ -231,17 -245,6 +245,17 @@@ void CHTSPDemuxer::SetStreamingProfile(
m_subscription.SetProfile(profile);
}
+bool CHTSPDemuxer::IsRealTimeStream() const
+{
+ if (GetTimeshiftTime() == 0)
+ return true;
+
+ if (GetTimeshiftBufferEnd() - GetTimeshiftTime() < 10)
+ return true;
+
+ return false;
+}
+
/* **************************************************************************
* Parse incoming data
* *************************************************************************/
@@@ -284,7 -287,7 +298,7 @@@ void CHTSPDemuxer::ParseMuxPacket ( hts
size_t binlen;
DemuxPacket *pkt;
char _unused(type) = 0;
- int iStreamId;
+ int iStreamId, ignore;
/* Ignore packets while switching channels */
if (!m_subscription.IsActive())
@@@ -339,11 -342,17 +353,17 @@@
if (!type)
type = '_';
- Logger::Log(LogLevel::LEVEL_TRACE, "demux pkt idx %d:%d type %c pts %lf len %lld",
- idx, pkt->iStreamId, type, pkt->pts, (long long)binlen);
+ ignore = m_seeking || m_speedChange;
+
+ Logger::Log(LogLevel::LEVEL_TRACE, "demux pkt idx %d:%d type %c pts %lf len %lld%s",
+ idx, pkt->iStreamId, type, pkt->pts, (long long)binlen,
+ ignore ? " IGNORE" : "");
/* Store */
- m_pktBuffer.Push(pkt);
+ if (!ignore)
+ m_pktBuffer.Push(pkt);
+ else
+ PVR->FreeDemuxPacket(pkt);
}
void CHTSPDemuxer::ParseSubscriptionStart ( htsmsg_t *m )
@@@ -517,8 -526,10 +537,10 @@@ void CHTSPDemuxer::ParseSubscriptionSki
if (htsmsg_get_s64(m, "time", &s64)) {
m_seekTime = INVALID_SEEKTIME;
} else {
- m_seekTime = s64;
+ m_seekTime = s64 < 0 ? 1 : s64 + 1; /* it must not be zero! */
+ Flush(); /* flush old packets (with wrong pts) */
}
+ m_seeking = false;
m_seekCond.Broadcast();
}
@@@ -527,6 -538,10 +549,10 @@@ void CHTSPDemuxer::ParseSubscriptionSpe
uint32_t u32;
if (!htsmsg_get_u32(m, "speed", &u32))
Logger::Log(LogLevel::LEVEL_TRACE, "recv speed %d", u32);
+ if (m_speedChange) {
+ Flush();
+ m_speedChange = false;
+ }
}
void CHTSPDemuxer::ParseQueueStatus ( htsmsg_t *_unused(m) )
diff --combined src/Tvheadend.h
index c00e6ef,e794716..cd54c52
--- a/src/Tvheadend.h
+++ b/src/Tvheadend.h
@@@ -265,7 -265,6 +265,7 @@@ public
return m_lastUse;
return 0;
}
+ bool IsRealTimeStream() const;
/**
* Tells each demuxer to use the specified profile for new subscriptions
@@@ -274,13 -273,15 +274,15 @@@
void SetStreamingProfile(const std::string &profile);
private:
- P8PLATFORM::CMutex m_mutex;
+ P8PLATFORM::CMutex m_mutex;
CHTSPConnection &m_conn;
- P8PLATFORM::SyncedBuffer<DemuxPacket*> m_pktBuffer;
+ P8PLATFORM::SyncedBuffer<DemuxPacket*> m_pktBuffer;
ADDON::XbmcStreamProperties m_streams;
std::map<int,int> m_streamStat;
int64_t m_seekTime;
P8PLATFORM::CCondition<volatile int64_t> m_seekCond;
+ bool m_seeking;
+ bool m_speedChange;
tvheadend::status::SourceInfo m_sourceInfo;
tvheadend::status::Quality m_signalInfo;
tvheadend::status::TimeshiftStatus m_timeshiftStatus;
@@@ -569,7 -570,6 +571,7 @@@ public
int64_t DemuxGetTimeshiftTime() const;
int64_t DemuxGetTimeshiftBufferStart() const;
int64_t DemuxGetTimeshiftBufferEnd() const;
+ bool DemuxIsRealTimeStream() const;
/*
* VFS (pass-thru)
--
kodi-pvr-hts packaging
More information about the pkg-multimedia-commits
mailing list