From d3ed2cddc2cc0975e34d35f05e92ed9197ae602a Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 16 Jul 2020 11:11:00 +0200 Subject: [PATCH 1/2] PVR/inputstream API related code changes --- src/Tvheadend.cpp | 16 +++++++------- src/Tvheadend.h | 6 +++--- src/tvheadend/HTSPDemuxer.cpp | 28 ++++++++++++------------- src/tvheadend/HTSPDemuxer.h | 4 ++-- src/tvheadend/IHTSPDemuxPacketHandler.h | 6 +++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp index bfcd09be..b2445791 100644 --- a/src/Tvheadend.cpp +++ b/src/Tvheadend.cpp @@ -1664,12 +1664,12 @@ kodi::addon::PVRCodec CTvheadend::GetCodecByName(const std::string& codecName) c return kodi::addon::CInstancePVRClient::GetCodecByName(codecName); } -DemuxPacket* CTvheadend::AllocateDemuxPacket(int iDataSize) +DEMUX_PACKET* CTvheadend::AllocateDemuxPacket(int iDataSize) { return kodi::addon::CInstancePVRClient::AllocateDemuxPacket(iDataSize); } -void CTvheadend::FreeDemuxPacket(DemuxPacket* pPacket) +void CTvheadend::FreeDemuxPacket(DEMUX_PACKET* pPacket) { kodi::addon::CInstancePVRClient::FreeDemuxPacket(pPacket); } @@ -3031,9 +3031,9 @@ bool CTvheadend::OpenLiveStream(const kodi::addon::PVRChannel& chn) return m_playingLiveStream; } -DemuxPacket* CTvheadend::DemuxRead() +DEMUX_PACKET* CTvheadend::DemuxRead() { - DemuxPacket* pkt = nullptr; + DEMUX_PACKET* pkt = nullptr; if (m_streamchange) { @@ -3042,7 +3042,7 @@ DemuxPacket* CTvheadend::DemuxRead() * buffer, as we really want to use the currently queued packets for * immediate playback. */ pkt = kodi::addon::CInstancePVRClient::AllocateDemuxPacket(0); - pkt->iStreamId = DMX_SPECIALID_STREAMCHANGE; + pkt->iStreamId = DEMUX_SPECIALID_STREAMCHANGE; m_streamchange = false; return pkt; } @@ -3128,7 +3128,7 @@ PVR_ERROR CTvheadend::GetStreamTimes(kodi::addon::PVRStreamTimes& times) { if (m_playingRecording->GetFilesStart() > 0) { - times.SetPTSEnd((std::time(nullptr) - m_playingRecording->GetFilesStart()) * DVD_TIME_BASE); + times.SetPTSEnd((std::time(nullptr) - m_playingRecording->GetFilesStart()) * STREAM_TIME_BASE); } else { @@ -3137,7 +3137,7 @@ PVR_ERROR CTvheadend::GetStreamTimes(kodi::addon::PVRStreamTimes& times) // recording might actually have started later than scheduled start time (server came up too late etc). times.SetPTSEnd((m_playingRecording->GetStartExtra() * 60 + std::time(nullptr) - m_playingRecording->GetStart()) * - DVD_TIME_BASE); + STREAM_TIME_BASE); } } else @@ -3145,7 +3145,7 @@ PVR_ERROR CTvheadend::GetStreamTimes(kodi::addon::PVRStreamTimes& times) if (m_playingRecording->GetFilesStart() > 0 && m_playingRecording->GetFilesStop() > 0) { times.SetPTSEnd((m_playingRecording->GetFilesStop() - m_playingRecording->GetFilesStart()) * - DVD_TIME_BASE); + STREAM_TIME_BASE); } else { diff --git a/src/Tvheadend.h b/src/Tvheadend.h index bd9f5d14..9dd3acb6 100644 --- a/src/Tvheadend.h +++ b/src/Tvheadend.h @@ -77,8 +77,8 @@ class ATTRIBUTE_HIDDEN CTvheadend : public kodi::addon::CInstancePVRClient, // IHTSPDemuxPacketHandler implementation kodi::addon::PVRCodec GetCodecByName(const std::string& codecName) const override; - DemuxPacket* AllocateDemuxPacket(int iDataSize) override; - void FreeDemuxPacket(DemuxPacket* pPacket) override; + DEMUX_PACKET* AllocateDemuxPacket(int iDataSize) override; + void FreeDemuxPacket(DEMUX_PACKET* pPacket) override; const tvheadend::entity::Channels& GetChannels() const { return m_channels; } @@ -218,7 +218,7 @@ class ATTRIBUTE_HIDDEN CTvheadend : public kodi::addon::CInstancePVRClient, */ bool OpenLiveStream(const kodi::addon::PVRChannel& chn) override; void CloseLiveStream() override; - DemuxPacket* DemuxRead() override; + DEMUX_PACKET* DemuxRead() override; void DemuxFlush() override; void DemuxAbort() override; bool SeekTime(double time, bool backward, double& startpts) override; diff --git a/src/tvheadend/HTSPDemuxer.cpp b/src/tvheadend/HTSPDemuxer.cpp index cf727f54..901d1620 100644 --- a/src/tvheadend/HTSPDemuxer.cpp +++ b/src/tvheadend/HTSPDemuxer.cpp @@ -19,7 +19,7 @@ #include #include -#define TVH_TO_DVD_TIME(x) (static_cast(x) * DVD_TIME_BASE / 1000000.0f) +#define TVH_TO_DVD_TIME(x) (static_cast(x) * STREAM_TIME_BASE / 1000000.0f) #define INVALID_SEEKTIME (-1) #define SPEED_NORMAL (1000) // x1 playback speed @@ -120,11 +120,11 @@ void HTSPDemuxer::Close() Logger::Log(LogLevel::LEVEL_DEBUG, "demux close"); } -DemuxPacket* HTSPDemuxer::Read() +DEMUX_PACKET* HTSPDemuxer::Read() { m_lastUse.store(std::time(nullptr)); - DemuxPacket* pkt = nullptr; + DEMUX_PACKET* pkt = nullptr; if (m_pktBuffer.Pop(pkt, 100)) { Logger::Log(LogLevel::LEVEL_TRACE, "demux read idx :%d pts %lf len %lld", pkt->iStreamId, @@ -140,7 +140,7 @@ void HTSPDemuxer::Flush() { Logger::Log(LogLevel::LEVEL_TRACE, "demux flush"); - DemuxPacket* pkt = nullptr; + DEMUX_PACKET* pkt = nullptr; while (m_pktBuffer.Pop(pkt)) m_demuxPktHdl.FreeDemuxPacket(pkt); } @@ -152,7 +152,7 @@ void HTSPDemuxer::Trim() /* reduce used buffer space to what is needed for DVDPlayer to resume * playback without buffering. This depends on the bitrate, so we don't set * this too small. */ - DemuxPacket* pkt = nullptr; + DEMUX_PACKET* pkt = nullptr; while (m_pktBuffer.Size() > 512 && m_pktBuffer.Pop(pkt)) m_demuxPktHdl.FreeDemuxPacket(pkt); } @@ -468,12 +468,12 @@ void HTSPDemuxer::ProcessRDS(uint32_t idx, const void* bin, size_t binlen) // Update streams. Logger::Log(LogLevel::LEVEL_DEBUG, "demux stream change"); - DemuxPacket* pktSpecial = m_demuxPktHdl.AllocateDemuxPacket(0); - pktSpecial->iStreamId = DMX_SPECIALID_STREAMCHANGE; + DEMUX_PACKET* pktSpecial = m_demuxPktHdl.AllocateDemuxPacket(0); + pktSpecial->iStreamId = DEMUX_SPECIALID_STREAMCHANGE; m_pktBuffer.Push(pktSpecial); } - DemuxPacket* pkt = m_demuxPktHdl.AllocateDemuxPacket(rdslen); + DEMUX_PACKET* pkt = m_demuxPktHdl.AllocateDemuxPacket(rdslen); if (!pkt) return; @@ -527,7 +527,7 @@ void HTSPDemuxer::ParseMuxPacket(htsmsg_t* m) m_streamStat[idx]++; /* Allocate buffer */ - DemuxPacket* pkt = m_demuxPktHdl.AllocateDemuxPacket(binlen); + DEMUX_PACKET* pkt = m_demuxPktHdl.AllocateDemuxPacket(binlen); if (!pkt) return; @@ -545,12 +545,12 @@ void HTSPDemuxer::ParseMuxPacket(htsmsg_t* m) if (!htsmsg_get_s64(m, "dts", &s64)) pkt->dts = TVH_TO_DVD_TIME(s64); else - pkt->dts = DVD_NOPTS_VALUE; + pkt->dts = STREAM_NOPTS_VALUE; if (!htsmsg_get_s64(m, "pts", &s64)) pkt->pts = TVH_TO_DVD_TIME(s64); else - pkt->pts = DVD_NOPTS_VALUE; + pkt->pts = STREAM_NOPTS_VALUE; /* Type (for debug only) */ char type = 0; @@ -698,7 +698,7 @@ bool HTSPDemuxer::AddTVHStream(uint32_t idx, const char* type, htsmsg_field_t* f if (duration > 0) { stream.SetFPSScale(duration); - stream.SetFPSRate(DVD_TIME_BASE); + stream.SetFPSRate(STREAM_TIME_BASE); } } @@ -759,8 +759,8 @@ void HTSPDemuxer::ParseSubscriptionStart(htsmsg_t* m) /* Update streams */ Logger::Log(LogLevel::LEVEL_DEBUG, "demux stream change"); - DemuxPacket* pkt = m_demuxPktHdl.AllocateDemuxPacket(0); - pkt->iStreamId = DMX_SPECIALID_STREAMCHANGE; + DEMUX_PACKET* pkt = m_demuxPktHdl.AllocateDemuxPacket(0); + pkt->iStreamId = DEMUX_SPECIALID_STREAMCHANGE; m_pktBuffer.Push(pkt); /* Source data */ diff --git a/src/tvheadend/HTSPDemuxer.h b/src/tvheadend/HTSPDemuxer.h index 59cc9a13..79af55ad 100644 --- a/src/tvheadend/HTSPDemuxer.h +++ b/src/tvheadend/HTSPDemuxer.h @@ -52,7 +52,7 @@ class HTSPDemuxer bool Open(uint32_t channelId, tvheadend::eSubscriptionWeight weight = tvheadend::SUBSCRIPTION_WEIGHT_NORMAL); void Close(); - DemuxPacket* Read(); + DEMUX_PACKET* Read(); void Trim(); void Flush(); void Abort(); @@ -108,7 +108,7 @@ class HTSPDemuxer mutable std::recursive_mutex m_mutex; HTSPConnection& m_conn; - tvheadend::utilities::SyncedBuffer m_pktBuffer; + tvheadend::utilities::SyncedBuffer m_pktBuffer; std::vector m_streams; std::map m_streamStat; std::atomic m_seektime; diff --git a/src/tvheadend/IHTSPDemuxPacketHandler.h b/src/tvheadend/IHTSPDemuxPacketHandler.h index 33219e01..6e34ccba 100644 --- a/src/tvheadend/IHTSPDemuxPacketHandler.h +++ b/src/tvheadend/IHTSPDemuxPacketHandler.h @@ -8,7 +8,7 @@ #pragma once -#include "kodi/DemuxPacket.h" +#include "kodi/addon-instance/inputstream/DemuxPacket.h" #include "kodi/addon-instance/pvr/Stream.h" namespace tvheadend @@ -23,8 +23,8 @@ class IHTSPDemuxPacketHandler virtual ~IHTSPDemuxPacketHandler() = default; virtual kodi::addon::PVRCodec GetCodecByName(const std::string& codecName) const = 0; - virtual DemuxPacket* AllocateDemuxPacket(int iDataSize) = 0; - virtual void FreeDemuxPacket(DemuxPacket* pPacket) = 0; + virtual DEMUX_PACKET* AllocateDemuxPacket(int iDataSize) = 0; + virtual void FreeDemuxPacket(DEMUX_PACKET* pPacket) = 0; }; } // namespace tvheadend From 72c4cef93d014b2eb1f9d325ee97a752c4498a8c Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 16 Jul 2020 11:15:00 +0200 Subject: [PATCH 2/2] increase version to 8.0.0 (API related) --- pvr.hts/addon.xml.in | 2 +- pvr.hts/changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pvr.hts/addon.xml.in b/pvr.hts/addon.xml.in index 6031abe0..3cd2ae17 100644 --- a/pvr.hts/addon.xml.in +++ b/pvr.hts/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index 1022562e..5d32c456 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -1,3 +1,6 @@ +8.0.0 +- Update PVR API 7.0.2 + 7.2.2 - Fix toggling of HTTP streaming setting