Skip to content

Commit

Permalink
Support setting progam number in stream properties for MPTS streams, c…
Browse files Browse the repository at this point in the history
…loses kodi-pvr#195, cloases kodi-pvr#208, close kodi-pvr#219
  • Loading branch information
phunkyfish committed May 27, 2019
1 parent 9b5340e commit 2b9cc05
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Enigma2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/Enigma2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 27 additions & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 corect 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", __FUNCTION__, channel->strChannelName, strStreamProgramNumber.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)
Expand Down Expand Up @@ -639,7 +666,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; }
PVR_ERROR OpenDialogChannelScan(void) { return PVR_ERROR_NOT_IMPLEMENTED; }
Expand Down

0 comments on commit 2b9cc05

Please sign in to comment.