From 218416b03beddb750f6d637dbcb4c4ac5c67c6e4 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Mon, 27 May 2019 22:06:10 +0100 Subject: [PATCH] Support setting progam number in stream properties for MPTS streams, closes #195, cloases #208, close #219 --- src/Enigma2.cpp | 4 ++++ src/Enigma2.h | 1 + src/client.cpp | 28 +++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Enigma2.cpp b/src/Enigma2.cpp index 708102d2..195bfb92 100755 --- a/src/Enigma2.cpp +++ b/src/Enigma2.cpp @@ -483,6 +483,10 @@ const std::string Enigma2::GetLiveStreamURL(const PVR_CHANNEL &channelinfo) return m_channels.GetChannel(channelinfo.iUniqueId)->GetStreamURL(); } +const int Enigma2::GetChannelStreamProgramNumber(const PVR_CHANNEL &channelinfo) +{ + return m_channels.GetChannel(channelinfo.iUniqueId)->GetStreamProgramNumber(); +} /** * GetStreamURL() reads out a stream-URL from a M3U-file. diff --git a/src/Enigma2.h b/src/Enigma2.h index 01865fb7..ea38e503 100644 --- a/src/Enigma2.h +++ b/src/Enigma2.h @@ -83,6 +83,7 @@ class Enigma2 : public P8PLATFORM::CThread, public enigma2::IConnectionListener bool OpenLiveStream(const PVR_CHANNEL &channelinfo); void CloseLiveStream(); const std::string GetLiveStreamURL(const PVR_CHANNEL &channelinfo); + const int GetChannelStreamProgramNumber(const PVR_CHANNEL &channelinfo); unsigned int GetRecordingsAmount(); PVR_ERROR GetRecordings(ADDON_HANDLE handle); PVR_ERROR DeleteRecording(const PVR_RECORDING &recinfo); diff --git a/src/client.cpp b/src/client.cpp index b2e9ca49..3d5bda28 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -338,6 +338,33 @@ PVR_ERROR GetChannels(ADDON_HANDLE handle, bool bRadio) * Live Streams **************************************************************************/ +PVR_ERROR GetChannelStreamProperties(const PVR_CHANNEL* channel, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount) +{ + // + // We only use this function to set the program number which comes with every Enigma2 channel. For providers that + // use MPTS it allows the FFMPEG Demux to identify the correct Program/PID. + // + + if (!channel || !properties || !iPropertiesCount) + return PVR_ERROR_SERVER_ERROR; + + if (*iPropertiesCount < 1) + return PVR_ERROR_INVALID_PARAMETERS; + + if (!enigma || !enigma->IsConnected()) + return PVR_ERROR_SERVER_ERROR; + + std::string strStreamProgramNumber = std::to_string(enigma->GetChannelStreamProgramNumber(*channel)); + + Logger::Log(LEVEL_NOTICE, "%s - for channel: %s, set Stream Program Number to %s - %s", __FUNCTION__, channel->strChannelName, strStreamProgramNumber.c_str(), enigma->GetLiveStreamURL(*channel).c_str()); + + strncpy(properties[0].strName, "program", sizeof(properties[0].strName) - 1); + strncpy(properties[0].strValue, strStreamProgramNumber.c_str(), sizeof(properties[0].strValue) - 1); + *iPropertiesCount = 1; + + return PVR_ERROR_NO_ERROR; +} + PVR_ERROR GetStreamReadChunkSize(int* chunksize) { if (!chunksize) @@ -634,7 +661,6 @@ PVR_ERROR UpdateTimer(const PVR_TIMER &timer) /** UNUSED API FUNCTIONS */ PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties) { return PVR_ERROR_NOT_IMPLEMENTED; } -PVR_ERROR GetChannelStreamProperties(const PVR_CHANNEL*, PVR_NAMED_VALUE*, unsigned int*) { return PVR_ERROR_NOT_IMPLEMENTED; } void DemuxAbort(void) { return; } DemuxPacket* DemuxRead(void) { return nullptr; } void FillBuffer(bool mode) {}