Skip to content

Commit

Permalink
Merge pull request #463 from AlwinEsch/Matrix-change
Browse files Browse the repository at this point in the history
[Matrix] API update
  • Loading branch information
ksooo authored Oct 29, 2020
2 parents 5b45197 + 72c4cef commit bc5d4b1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 31 deletions.
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="7.2.2"
version="8.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 @@
8.0.0
- Update PVR API 7.0.2

7.2.2
- Fix toggling of HTTP streaming setting

Expand Down
16 changes: 8 additions & 8 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
{
Expand All @@ -3137,15 +3137,15 @@ 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
{
if (m_playingRecording->GetFilesStart() > 0 && m_playingRecording->GetFilesStop() > 0)
{
times.SetPTSEnd((m_playingRecording->GetFilesStop() - m_playingRecording->GetFilesStart()) *
DVD_TIME_BASE);
STREAM_TIME_BASE);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/Tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions src/tvheadend/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cstring>
#include <ctime>

#define TVH_TO_DVD_TIME(x) (static_cast<double>(x) * DVD_TIME_BASE / 1000000.0f)
#define TVH_TO_DVD_TIME(x) (static_cast<double>(x) * STREAM_TIME_BASE / 1000000.0f)

#define INVALID_SEEKTIME (-1)
#define SPEED_NORMAL (1000) // x1 playback speed
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions src/tvheadend/HTSPDemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -108,7 +108,7 @@ class HTSPDemuxer

mutable std::recursive_mutex m_mutex;
HTSPConnection& m_conn;
tvheadend::utilities::SyncedBuffer<DemuxPacket*> m_pktBuffer;
tvheadend::utilities::SyncedBuffer<DEMUX_PACKET*> m_pktBuffer;
std::vector<kodi::addon::PVRStreamProperties> m_streams;
std::map<int, int> m_streamStat;
std::atomic<SubscriptionSeekTime*> m_seektime;
Expand Down
6 changes: 3 additions & 3 deletions src/tvheadend/IHTSPDemuxPacketHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit bc5d4b1

Please sign in to comment.