Skip to content

Commit

Permalink
Kodi 18 adaptation.
Browse files Browse the repository at this point in the history
  • Loading branch information
srg70 committed Mar 15, 2019
1 parent 5fd1cb2 commit b485d7b
Show file tree
Hide file tree
Showing 17 changed files with 873 additions and 591 deletions.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,42 @@ src/guid.cpp
src/playlist_cache.cpp
)

set(IPTV_HEADERS
src/direct_buffer.h
src/plist_buffer.h
src/input_buffer.h
src/addon.h
src/edem_player.h
src/edem_pvr_client.h
src/helpers.h
src/timeshift_buffer.h
src/puzzle_pvr_client.h
src/neutral_sorting.h
src/cache_buffer.h
src/ott_player.h
src/ott_pvr_client.h
src/plist_buffer_delegate.h
src/puzzle_tv.h
src/pvr_client_base.h
src/pvr_client_types.h
src/sovok_pvr_client.h
src/sovok_tv.h
src/ttv_player.h
src/ttv_pvr_client.h
src/playlist_cache.hpp
src/Playlist.hpp
src/HttpEngine.hpp
src/ActionQueue.hpp
src/simple_cyclic_buffer.hpp
src/memory_cache_buffer.hpp
src/XMLTV_loader.hpp
src/globals.hpp
src/TimersEngine.hpp
src/file_cache_buffer.hpp
src/ActionQueueTypes.hpp
src/client_core_base.hpp
src/guid.hpp
)

build_addon(pvr.puzzle.tv IPTV DEPLIBS)

Expand Down
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Source: kodi-pvr-puzzletv
Priority: extra
Maintainer: Sergey Shramchenko <sergey.shramchenko@gmail.com>
Build-Depends: debhelper (>= 9.0.0), cmake, kodi-pvr-dev,
libkodiplatform-dev (>= 16.0.0), kodi-addon-dev, zlib1g-dev
Build-Depends: debhelper (>= 9.0.0), cmake, libkodiplatform-dev (>= 16.0.0), kodi-addon-dev, zlib1g-dev
Standards-Version: 3.9.4
Section: libs

Expand Down
4 changes: 2 additions & 2 deletions debian/kodi-pvr-puzzletv.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
usr/lib/*/addons/pvr.puzzle.tv/pvr.puzzle.tv.so* usr/lib/kodi/addons/pvr.puzzle.tv
usr/share/kodi/addons/pvr.puzzle.tv
usr/lib/*
usr/share/*
1,081 changes: 644 additions & 437 deletions pvr.puzzle.tv.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions pvr.puzzle.tv/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="pvr.puzzle.tv" version="0.8.16" name="PVR Puzzle TV" provider-name="srg70">
<requires>
<c-pluff version="0.1"/>
<import addon="xbmc.pvr" version="5.2.1"/>
</requires>
<requires>@ADDON_DEPENDS@</requires>
<extension
point="xbmc.pvrclient"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_US">Kodi PVR addon for IPTV support. Designed to agregate IPTV servise from different providers.</summary>
<summary lang="ru_RU">Kodi PVR аддон для поддержки IPTV. Позволяет интегрировать IPTV-услуги разных провайдеров</summary>
<description lang="en_US">Puzzle TV PVR Client supports streaming of Live TV, listening to Radio channels and EPG from service providers using dedicated API. Addon designed to be extandable. Currenly only Sovok TV provider is supported. </description>
<description lang="ru_RU">Интерфейс для IPTV. Поддерживает просмотр потокового ТВ, прослушивание радиоканалов и работу с электронным телегидом от поствщиков услуг, используя специализированный интерфейс. Есть возможность расширения. Пока поддерживается только Sovok TV провайдер.</description>
<description lang="en_US">Puzzle TV PVR Client supports streaming of Live TV, listening to Radio channels and EPG from service providers using dedicated API. Addon designed to be extandable.</description>
<description lang="ru_RU">Интерфейс для IPTV. Поддерживает просмотр потокового ТВ, прослушивание радиоканалов и работу с электронным телегидом от поствщиков услуг, используя специализированный интерфейс. Есть возможность расширения.</description>
<disclaimer lang="en_US">This is unstable software! The authors are in no way responsible for failed playings, incorrect EPG times, wasted hours, or any other undesirable effects.</disclaimer>
<disclaimer lang="ru_RU">Это нестабильная программа! Авторы не несут ответственности за неудачные воспроизведение, неверные время EPG, потраченное время и прочие нежелательные эффекты.</disclaimer>
<platform>@PLATFORM@</platform>
Expand Down
83 changes: 30 additions & 53 deletions src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "ttv_pvr_client.h"
#include "xbmc_pvr_dll.h"
#include "p8-platform/util/util.h"
#include "kodi/xbmc_addon_cpp_dll.h"
#include "TimersEngine.hpp"

#ifdef TARGET_WINDOWS
Expand Down Expand Up @@ -130,16 +129,6 @@ extern "C" {
Globals::Cleanup();
}

bool ADDON_HasSettings()
{
return true;
}

unsigned int ADDON_GetSettings(ADDON_StructSetting ***sSet)
{
return m_DataSource->GetSettings(sSet);
}

ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
{
if (strcmp(settingName, "provider_type") == 0) {
Expand All @@ -156,15 +145,6 @@ extern "C" {
}


void ADDON_FreeSettings()
{
m_DataSource->FreeSettings();
}

void ADDON_Stop()
{
}

/***********************************************************
* PVR Client AddOn specific public library functions
***********************************************************/
Expand Down Expand Up @@ -197,28 +177,6 @@ extern "C" {
{
}

const char* GetPVRAPIVersion(void)
{
static const char *strApiVersion = XBMC_PVR_API_VERSION;
return strApiVersion;
}

const char* GetMininumPVRAPIVersion(void)
{
static const char *strMinApiVersion = XBMC_PVR_MIN_API_VERSION;
return strMinApiVersion;
}

const char* GetGUIAPIVersion(void)
{
return ""; // GUI API not used
}

const char* GetMininumGUIAPIVersion(void)
{
return ""; // GUI API not used
}

PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES* pCapabilities)
{
return m_DataSource->GetAddonCapabilities(pCapabilities);
Expand All @@ -232,7 +190,7 @@ extern "C" {

const char *GetBackendVersion(void)
{
static std::string strBackendVersion = XBMC_PVR_API_VERSION;
static std::string strBackendVersion = STR(IPTV_VERSION);
return strBackendVersion.c_str();
}

Expand Down Expand Up @@ -284,11 +242,6 @@ extern "C" {
return m_DataSource->SwitchChannel(channel);
}

PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties)
{
return PVR_ERROR_NOT_IMPLEMENTED;
}

int GetChannelGroupsAmount(void)
{
return m_DataSource->GetChannelGroupsAmount();
Expand Down Expand Up @@ -344,6 +297,11 @@ extern "C" {
}

// ******* RECORDING ******/

PVR_ERROR GetStreamReadChunkSize(int* chunksize)
{
return m_DataSource->GetStreamReadChunkSize(chunksize);
}
int GetRecordingsAmount(bool deleted)
{
return m_DataSource->GetRecordingsAmount(deleted);
Expand Down Expand Up @@ -387,7 +345,15 @@ extern "C" {
return m_DataSource->LengthRecordedStream();
}

/** T I M E R S **/
PVR_ERROR IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable)
{
return m_DataSource->IsEPGTagRecordable(tag, bIsRecordable);
}

/********************************************************************************/
/********************************* T I M E R S **********************************/
/********************************************************************************/

PVR_ERROR AddTimer(const PVR_TIMER &timer)
{
return m_timersEngine ? m_timersEngine->AddTimer (timer) : PVR_ERROR_FAILED;
Expand Down Expand Up @@ -415,11 +381,16 @@ extern "C" {

PVR_ERROR GetTimerTypes(PVR_TIMER_TYPE types[], int *size) { return PVR_ERROR_NOT_IMPLEMENTED; }

/** UNUSED API FUNCTIONS */
/********************************************************************************/
/**************************** UNUSED API FUNCTIONS ******************************/
/********************************************************************************/

const char * GetLiveStreamURL(const PVR_CHANNEL &channel) { return ""; }
PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetChannelStreamProperties(const PVR_CHANNEL* channel, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount) { return PVR_ERROR_NOT_IMPLEMENTED; }

PVR_ERROR OpenDialogChannelScan(void) { return PVR_ERROR_NOT_IMPLEMENTED; }

PVR_ERROR DeleteChannel(const PVR_CHANNEL &channel) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR DeleteChannel(const PVR_CHANNEL &channel) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR RenameChannel(const PVR_CHANNEL &channel) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR MoveChannel(const PVR_CHANNEL &channel) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR OpenDialogChannelSettings(const PVR_CHANNEL &channel) { return PVR_ERROR_NOT_IMPLEMENTED; }
Expand All @@ -433,7 +404,6 @@ extern "C" {
PVR_ERROR GetRecordingEdl(const PVR_RECORDING&, PVR_EDL_ENTRY[], int*) { return PVR_ERROR_NOT_IMPLEMENTED; };
void DemuxAbort(void) {}
DemuxPacket* DemuxRead(void) { return NULL; }
unsigned int GetChannelSwitchDelay(void) { return 0; }
bool IsTimeshifting(void) { return false; }
bool IsRealTimeStream(void) { return true; }
void PauseStream(bool bPaused) {}
Expand All @@ -445,4 +415,11 @@ extern "C" {
PVR_ERROR UndeleteRecording(const PVR_RECORDING& recording) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR DeleteAllRecordingsFromTrash() { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR SetEPGTimeFrame(int) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetDescrambleInfo(PVR_DESCRAMBLE_INFO*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR SetRecordingLifetime(const PVR_RECORDING*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetStreamTimes(PVR_STREAM_TIMES *times) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetEPGTagEdl(const EPG_TAG* epgTag, PVR_EDL_ENTRY edl[], int *size) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetEPGTagStreamProperties(const EPG_TAG* tag, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetRecordingStreamProperties(const PVR_RECORDING* recording, PVR_NAMED_VALUE* properties, unsigned int* iPropertiesCount){ return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR IsEPGTagPlayable(const EPG_TAG* tag, bool* bIsPlayable) { return PVR_ERROR_NOT_IMPLEMENTED; }
}
19 changes: 17 additions & 2 deletions src/addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#ifndef __Iptv_Pvr_Addoin_h__
#define __Iptv_Pvr_Addoin_h__

#include "kodi/AddonBase.h"
#include "xbmc_addon_types.h"
#include "xbmc_pvr_types.h"

Expand All @@ -46,9 +47,7 @@ class IPvrIptvDataSource : public ITimersEngineDelegate
virtual ADDON_STATUS Init(PVR_PROPERTIES* pvrprops) = 0;
virtual ADDON_STATUS GetStatus() = 0;

virtual int GetSettings(ADDON_StructSetting ***sSet) = 0;
virtual ADDON_STATUS SetSetting(const char *settingName, const void *settingValue) = 0;
virtual void FreeSettings() = 0;

// virtual const char *GetBackendName(void) = 0;
virtual PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES* pCapabilities) = 0;
Expand Down Expand Up @@ -77,10 +76,12 @@ class IPvrIptvDataSource : public ITimersEngineDelegate
virtual PVR_ERROR DeleteRecording(const PVR_RECORDING &recording) = 0;
virtual bool OpenRecordedStream(const PVR_RECORDING &recording) = 0;
virtual void CloseRecordedStream(void) = 0;
virtual PVR_ERROR GetStreamReadChunkSize(int* chunksize) = 0;
virtual int ReadRecordedStream(unsigned char *pBuffer, unsigned int iBufferSize) = 0;
virtual long long SeekRecordedStream(long long iPosition, int iWhence /* = SEEK_SET */) = 0;
virtual long long PositionRecordedStream(void) = 0;
virtual long long LengthRecordedStream(void) = 0;
virtual PVR_ERROR IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable) = 0;

virtual PVR_ERROR CallMenuHook(const PVR_MENUHOOK &menuhook, const PVR_MENUHOOK_DATA &item) = 0;

Expand All @@ -102,4 +103,18 @@ class ITimersEngine

};

class PuzzleTvAddon : public ::kodi::addon::CAddonBase
{
public:
virtual ~PuzzleTvAddon() override;

virtual ADDON_STATUS Create() override;

virtual ADDON_STATUS GetStatus() override;

virtual ADDON_STATUS SetSetting(const std::string& settingName, const ::kodi::CSettingValue& settingValue) override;


};

#endif /* __Iptv_Pvr_Addoin_h__ */
2 changes: 1 addition & 1 deletion src/client_core_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ namespace PvrClient{
tag.iUniqueBroadcastId = id;
entry.FillEpgTag(tag);
}
PVR->EpgEventStateChange(&tag, entry.ChannelId, EPG_EVENT_UPDATED);
PVR->EpgEventStateChange(&tag, EPG_EVENT_UPDATED);

}

Expand Down
1 change: 0 additions & 1 deletion src/edem_pvr_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <algorithm>
#include <ctime>
#include "p8-platform/util/util.h"
#include "kodi/xbmc_addon_cpp_dll.h"

#include "timeshift_buffer.h"
#include "direct_buffer.h"
Expand Down
64 changes: 42 additions & 22 deletions src/file_cache_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#endif

#include <algorithm>
#include "kodi/kodi_vfs_utils.hpp"
#include "kodi/libXBMC_addon.h"
#include "kodi/Filesystem.h"
#include "file_cache_buffer.hpp"
#include "libXBMC_addon.h"
#include "helpers.h"
Expand Down Expand Up @@ -252,11 +253,17 @@ namespace Buffers
static int64_t CalculateDataSize(const std::string& bufferCacheDir)
{
int64_t result = 0;
std::vector<CVFSDirEntry> files;
VFSUtils::GetDirectory(XBMC, bufferCacheDir, "*.bin", files);
for (auto& f : files) {
if(!f.IsFolder())
result += f.Size();
VFSDirEntry* files;
unsigned int num_files;
if(XBMC->GetDirectory(bufferCacheDir.c_str(), "*.bin", &files, &num_files)) {
for (int i = 0; i < num_files; ++i) {
const VFSDirEntry& f = files[i];
if(!f.folder)
result += f.size;
}
XBMC->FreeDirectory(files, num_files);
} else {
LogError( "Failed obtain content of FileCacheBuffer folder %s", bufferCacheDir.c_str());
}
return result;
}
Expand All @@ -272,26 +279,39 @@ namespace Buffers
}
Init();
// Load *.bin files
std::vector<CVFSDirEntry> files;
VFSUtils::GetDirectory(XBMC, m_bufferDir, "*.bin", files);
// run "neutral sorting" on files list
struct cvf_alphanum_less : public std::binary_function<CVFSDirEntry, CVFSDirEntry, bool>
{
bool operator()(const CVFSDirEntry& left, const CVFSDirEntry& right) const
{
return doj::alphanum_comp(left.Path(), right.Path()) < 0;
VFSDirEntry* files;
std::vector<const VFSDirEntry*> binFiles;
unsigned int num_files;
if(XBMC->GetDirectory(bufferCacheDir.c_str(), "*.bin", &files, &num_files)) {
for (int i = 0; i < num_files; ++i) {
const VFSDirEntry& f = files[i];
if(!f.folder)
binFiles.push_back(&f);
}
} neutral_sorter;
std::sort(files.begin(), files.end(), neutral_sorter);
for (auto& f : files) {
if(!f.IsFolder()) {
ChunkFilePtr newChunk = new CAddonFile(f.Path().c_str(), m_autoDelete);
m_length += f.Size();
m_ChunkFileSwarm.push_back(ChunkFileSwarm::value_type(newChunk));
m_ReadChunks.push_back(newChunk);
// run "neutral sorting" on files list
struct cvf_alphanum_less : public std::binary_function<const VFSDirEntry*, const VFSDirEntry*, bool>
{
bool operator()(const VFSDirEntry*& left, const VFSDirEntry*& right) const
{
return doj::alphanum_comp(left->path, right->path) < 0;
}
} neutral_sorter;
std::sort(binFiles.begin(), binFiles.end(), neutral_sorter);
for (auto& f : binFiles) {
if(!f->folder) {
ChunkFilePtr newChunk = new CAddonFile(f->path, m_autoDelete);
m_length += f->size;
m_ChunkFileSwarm.push_back(ChunkFileSwarm::value_type(newChunk));
m_ReadChunks.push_back(newChunk);
}
}

XBMC->FreeDirectory(files, num_files);
} else {
LogError( "Failed obtain content of FileCacheBuffer folder %s", bufferCacheDir.c_str());
}


}

void FileCacheBuffer::Init() {
Expand Down
Loading

0 comments on commit b485d7b

Please sign in to comment.