Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.0.0: Implement PVR addon API v6.0.0 #414

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="4.4.17"
version="5.0.0"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
5.0.0
- PVR API v6.0.0 changes implemented

4.4.17
- Fix playback when skipping an in progress recording to real-time.

Expand Down
14 changes: 9 additions & 5 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,6 @@ void CTvheadend::CreateEvent
epg.firstAired = event.GetAired();
epg.iParentalRating = event.GetAge();
epg.iStarRating = event.GetStars();
epg.bNotify = false; /* not supported by tvh */
epg.iSeriesNumber = event.GetSeason();
epg.iEpisodeNumber = event.GetEpisode();
epg.iEpisodePartNumber = event.GetPart();
Expand Down Expand Up @@ -1455,16 +1454,16 @@ void CTvheadend::TransferEvent
}

PVR_ERROR CTvheadend::GetEPGForChannel
( ADDON_HANDLE handle, const PVR_CHANNEL &chn, time_t start, time_t end )
( ADDON_HANDLE handle, int iChannelUid, time_t start, time_t end )
{
htsmsg_field_t *f;

Logger::Log(LogLevel::LEVEL_DEBUG, "get epg channel %d start %ld stop %ld", chn.iUniqueId,
Logger::Log(LogLevel::LEVEL_DEBUG, "get epg channel %d start %ld stop %ld", iChannelUid,
(long long)start, (long long)end);

/* Build message */
htsmsg_t *msg = htsmsg_create_map();
htsmsg_add_u32(msg, "channelId", chn.iUniqueId);
htsmsg_add_u32(msg, "channelId", iChannelUid);
htsmsg_add_s64(msg, "maxTime", end);

/* Send and Wait */
Expand Down Expand Up @@ -1501,7 +1500,7 @@ PVR_ERROR CTvheadend::GetEPGForChannel
}
}
htsmsg_destroy(msg);
Logger::Log(LogLevel::LEVEL_DEBUG, "get epg channel %d events %d", chn.iUniqueId, n);
Logger::Log(LogLevel::LEVEL_DEBUG, "get epg channel %d events %d", iChannelUid, n);

return PVR_ERROR_NO_ERROR;
}
Expand Down Expand Up @@ -2963,6 +2962,11 @@ void CTvheadend::DemuxSpeed ( int speed )
m_dmx_active->Speed(speed);
}

void CTvheadend::DemuxFillBuffer ( bool mode )
{
m_dmx_active->FillBuffer(mode);
}

PVR_ERROR CTvheadend::DemuxCurrentStreams ( PVR_STREAM_PROPERTIES *streams )
{
return m_dmx_active->CurrentStreams(streams);
Expand Down
3 changes: 2 additions & 1 deletion src/Tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CTvheadend
PVR_ERROR DeleteTimer ( const PVR_TIMER &tmr, bool force );
PVR_ERROR UpdateTimer ( const PVR_TIMER &tmr );

PVR_ERROR GetEPGForChannel ( ADDON_HANDLE handle, const PVR_CHANNEL &chn,
PVR_ERROR GetEPGForChannel ( ADDON_HANDLE handle, int iChannelUid,
time_t start, time_t end );
PVR_ERROR SetEPGTimeFrame ( int iDays );

Expand Down Expand Up @@ -212,6 +212,7 @@ class CTvheadend
void DemuxAbort ( void );
bool DemuxSeek ( double time, bool backward, double *startpts );
void DemuxSpeed ( int speed );
void DemuxFillBuffer ( bool mode );
PVR_ERROR DemuxCurrentStreams ( PVR_STREAM_PROPERTIES *streams );
PVR_ERROR DemuxCurrentSignal ( PVR_SIGNAL_STATUS &sig );
PVR_ERROR DemuxCurrentDescramble( PVR_DESCRAMBLE_INFO *info);
Expand Down
9 changes: 7 additions & 2 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties)
return tvh->DemuxCurrentStreams(pProperties);
}

void FillBuffer(bool mode)
{
tvh->DemuxFillBuffer(mode);
}

PVR_ERROR SignalStatus(PVR_SIGNAL_STATUS &signalStatus)
{
return tvh->DemuxCurrentSignal(signalStatus);
Expand Down Expand Up @@ -389,9 +394,9 @@ PVR_ERROR GetChannels(ADDON_HANDLE handle, bool bRadio)
* *************************************************************************/

PVR_ERROR GetEPGForChannel
(ADDON_HANDLE handle, const PVR_CHANNEL &channel, time_t iStart, time_t iEnd)
(ADDON_HANDLE handle, int iChannelUid, time_t iStart, time_t iEnd)
{
return tvh->GetEPGForChannel(handle, channel, iStart, iEnd);
return tvh->GetEPGForChannel(handle, iChannelUid, iStart, iEnd);
}

PVR_ERROR SetEPGTimeFrame(int iDays)
Expand Down
33 changes: 31 additions & 2 deletions src/tvheadend/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,28 @@ void HTSPDemuxer::Speed ( int speed )
if (speed != 0)
speed = 1000;

if (speed != m_subscription.GetSpeed())
if ((speed != m_requestedSpeed || speed == 0) && m_actualSpeed == m_subscription.GetSpeed())
{
m_subscription.SendSpeed(speed);
}

m_requestedSpeed = speed;
}

void HTSPDemuxer::FillBuffer ( bool mode )
{
CLockObject lock(m_conn.Mutex());
if (!m_subscription.IsActive())
return;

int speed = (!mode || IsRealTimeStream()) ? 1000 : 4000;

if (speed != m_requestedSpeed && m_actualSpeed == m_subscription.GetSpeed())
{
m_subscription.SendSpeed(speed);
}

m_requestedSpeed = speed;
}

void HTSPDemuxer::Weight ( enum eSubscriptionWeight weight )
Expand Down Expand Up @@ -297,7 +317,12 @@ bool HTSPDemuxer::IsTimeShifting() const

bool HTSPDemuxer::IsRealTimeStream() const
{
return m_subscription.IsActive();
if (!m_subscription.IsActive())
return false;

/* Handle as real time when reading close to the EOF (10 secs) */
CLockObject lock(m_mutex);
return (m_timeshiftStatus.shift < 10000000);
}

PVR_ERROR HTSPDemuxer::GetStreamTimes(PVR_STREAM_TIMES *times) const
Expand Down Expand Up @@ -785,6 +810,10 @@ void HTSPDemuxer::ParseSubscriptionSpeed ( htsmsg_t *m )
int32_t s32;
if (!htsmsg_get_s32(m, "speed", &s32))
Logger::Log(LogLevel::LEVEL_TRACE, "recv speed %d", s32);


CLockObject lock(m_conn.Mutex());
m_actualSpeed = s32 * 10;
}

void HTSPDemuxer::ParseSubscriptionGrace ( htsmsg_t *m )
Expand Down
3 changes: 3 additions & 0 deletions src/tvheadend/HTSPDemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class HTSPDemuxer
void Abort();
bool Seek(double time, bool backwards, double *startpts);
void Speed(int speed);
void FillBuffer(bool mode);
void Weight(tvheadend::eSubscriptionWeight weight);

PVR_ERROR CurrentStreams(PVR_STREAM_PROPERTIES *streams);
Expand Down Expand Up @@ -131,6 +132,8 @@ class HTSPDemuxer
std::atomic<time_t> m_lastUse;
std::atomic<time_t> m_startTime;
uint32_t m_rdsIdx;
int32_t m_requestedSpeed = 1000;
int32_t m_actualSpeed = 1000;
};

} // namespace tvheadend