Skip to content

Commit

Permalink
Merge pull request #134 from AlwinEsch/Matrix-change
Browse files Browse the repository at this point in the history
[Matrix] API change update / cleanups
  • Loading branch information
AlwinEsch authored Apr 24, 2020
2 parents 2b4e270 + 33f2cb7 commit b61f2d2
Show file tree
Hide file tree
Showing 29 changed files with 750 additions and 1,081 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![License: GPL v2+](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](LICENSE.md)
[![License: GPL-2.0-or-later](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](LICENSE.md)
[![Build Status](https://travis-ci.org/kodi-pvr/pvr.stalker.svg?branch=Matrix)](https://travis-ci.org/kodi-pvr/pvr.stalker/branches)
[![Build Status](https://dev.azure.com/teamkodi/kodi-pvr/_apis/build/status/kodi-pvr.pvr.stalker?branchName=Matrix)](https://dev.azure.com/teamkodi/kodi-pvr/_build/latest?definitionId=71&branchName=Matrix)
[![Build Status](https://jenkins.kodi.tv/view/Addons/job/kodi-pvr/job/pvr.stalker/job/Matrix/badge/icon)](https://jenkins.kodi.tv/blue/organizations/jenkins/kodi-pvr%2Fpvr.stalker/branches/)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5120/badge.svg)](https://scan.coverity.com/projects/5120)

# Stalker PVR
Stalker Middleware PVR client addon for [Kodi] (https://kodi.tv)
Stalker Middleware PVR client addon for [Kodi](https://kodi.tv)

## Build instructions

Expand All @@ -19,5 +19,5 @@ Stalker Middleware PVR client addon for [Kodi] (https://kodi.tv)

##### Useful links

* [Kodi's PVR user support] (https://forum.kodi.tv/forumdisplay.php?fid=167)
* [Kodi's PVR development support] (https://forum.kodi.tv/forumdisplay.php?fid=136)
* [Kodi's PVR user support](https://forum.kodi.tv/forumdisplay.php?fid=167)
* [Kodi's PVR development support](https://forum.kodi.tv/forumdisplay.php?fid=136)
4 changes: 2 additions & 2 deletions pvr.stalker/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.stalker"
version="4.1.5"
version="4.1.6"
name="Stalker Client"
provider-name="Jamal Edey">
<requires>@ADDON_DEPENDS@</requires>
Expand Down Expand Up @@ -160,7 +160,7 @@
<disclaimer lang="zh_CN">这是不稳定版的软件!作者不对录像失败、错误定时造成时间浪费或其它不良影响负责。</disclaimer>
<disclaimer lang="zh_TW">這是測試版軟體!其原創作者並無法對於以下情況負責,包含:錄影失敗,不正確的定時設定,多餘時數,或任何產生的其它不良影響...</disclaimer>
<platform>@PLATFORM@</platform>
<license>GPL-2.0+</license>
<license>GPL-2.0-or-later</license>
<source>https://github.com/kodi-pvr/pvr.stalker</source>
<forum>https://forum.kodi.tv/forumdisplay.php?fid=234</forum>
<assets>
Expand Down
6 changes: 6 additions & 0 deletions pvr.stalker/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v4.1.6:
- Update PVR API 6.4.0
- Correct license name on addon.xml
- Change source license to use SPDX
- Minor cleanups

v4.1.5
- Update PVR API 6.3.0

Expand Down
175 changes: 81 additions & 94 deletions src/CWatchdog.cpp
Original file line number Diff line number Diff line change
@@ -1,94 +1,81 @@
/*
* Copyright (C) 2015, 2016 Jamal Edey
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kodi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/

#include "CWatchdog.h"

#include "client.h"

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#define usleep(usec) Sleep((DWORD)(usec)/1000)
#else
#include <unistd.h>
#endif

using namespace ADDON;
using namespace SC;

CWatchdog::CWatchdog(uint32_t interval, SAPI *api, std::function<void(SError)> errorCallback)
: m_interval(interval), m_api(api), m_errorCallback(errorCallback), m_threadActive(false) {
}

CWatchdog::~CWatchdog() {
Stop();
}

void CWatchdog::Start() {
m_threadActive = true;
m_thread = std::thread([this] {
Process();
});
}

void CWatchdog::Stop() {
m_threadActive = false;
if (m_thread.joinable())
m_thread.join();
}

void CWatchdog::Process() {
XBMC->Log(LOG_DEBUG, "%s: start", __FUNCTION__);

int curPlayType;
int eventActiveId;
Json::Value parsed;
SError ret;
unsigned int target(m_interval * 1000);
unsigned int count;

while (m_threadActive) {
// hardcode values for now
curPlayType = 1; // tv
eventActiveId = 0;

ret = m_api->WatchdogGetEvents(curPlayType, eventActiveId, parsed);
if (ret != SERROR_OK) {
XBMC->Log(LOG_ERROR, "%s: WatchdogGetEvents failed", __FUNCTION__);

if (m_errorCallback != nullptr)
m_errorCallback(ret);
}

// ignore the result. don't confirm events (yet)

parsed.clear();

count = 0;
while (count < target) {
usleep(100000);
if (!m_threadActive)
break;
count += 100;
}
}

XBMC->Log(LOG_DEBUG, "%s: stop", __FUNCTION__);
}
/*
* Copyright (C) 2015-2020 Team Kodi (https://kodi.tv)
* Copyright (C) 2015, 2016 Jamal Edey
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
*/

#include "CWatchdog.h"

#include "client.h"

#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#define usleep(usec) Sleep((DWORD)(usec)/1000)
#else
#include <unistd.h>
#endif

using namespace ADDON;
using namespace SC;

CWatchdog::CWatchdog(uint32_t interval, SAPI *api, std::function<void(SError)> errorCallback)
: m_interval(interval), m_api(api), m_errorCallback(errorCallback), m_threadActive(false) {
}

CWatchdog::~CWatchdog() {
Stop();
}

void CWatchdog::Start() {
m_threadActive = true;
m_thread = std::thread([this] {
Process();
});
}

void CWatchdog::Stop() {
m_threadActive = false;
if (m_thread.joinable())
m_thread.join();
}

void CWatchdog::Process() {
XBMC->Log(LOG_DEBUG, "%s: start", __FUNCTION__);

int curPlayType;
int eventActiveId;
Json::Value parsed;
SError ret;
unsigned int target(m_interval * 1000);
unsigned int count;

while (m_threadActive) {
// hardcode values for now
curPlayType = 1; // tv
eventActiveId = 0;

ret = m_api->WatchdogGetEvents(curPlayType, eventActiveId, parsed);
if (ret != SERROR_OK) {
XBMC->Log(LOG_ERROR, "%s: WatchdogGetEvents failed", __FUNCTION__);

if (m_errorCallback != nullptr)
m_errorCallback(ret);
}

// ignore the result. don't confirm events (yet)

parsed.clear();

count = 0;
while (count < target) {
usleep(100000);
if (!m_threadActive)
break;
count += 100;
}
}

XBMC->Log(LOG_DEBUG, "%s: stop", __FUNCTION__);
}
86 changes: 37 additions & 49 deletions src/CWatchdog.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
#pragma once

/*
* Copyright (C) 2015, 2016 Jamal Edey
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kodi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/

#include <thread>
#include <functional>

#include "SAPI.h"

namespace SC {
class CWatchdog {
public:
CWatchdog(unsigned int interval, SAPI *api, std::function<void(SError)> errorCallback);

virtual ~CWatchdog();

virtual void Start();

virtual void Stop();

private:
void Process();

unsigned int m_interval;
SAPI *m_api;
std::function<void(SError)> m_errorCallback;
bool m_threadActive;
std::thread m_thread;
};
}
/*
* Copyright (C) 2015-2020 Team Kodi (https://kodi.tv)
* Copyright (C) 1015, 2016 Jamal Edey
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
*/

#pragma once

#include <thread>
#include <functional>

#include "SAPI.h"

namespace SC {
class CWatchdog {
public:
CWatchdog(unsigned int interval, SAPI *api, std::function<void(SError)> errorCallback);

virtual ~CWatchdog();

virtual void Start();

virtual void Stop();

private:
void Process();

unsigned int m_interval;
SAPI *m_api;
std::function<void(SError)> m_errorCallback;
bool m_threadActive;
std::thread m_thread;
};
}

21 changes: 4 additions & 17 deletions src/ChannelManager.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
/*
* Copyright (C) 2016 Jamal Edey
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kodi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Copyright (C) 2015-2020 Team Kodi (https://kodi.tv)
* Copyright (C) 2016 Jamal Edey
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
*/

#include "ChannelManager.h"
Expand Down
25 changes: 6 additions & 19 deletions src/ChannelManager.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
#pragma once

/*
* Copyright (C) 2016 Jamal Edey
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kodi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Copyright (C) 2015-2020 Team Kodi (https://kodi.tv)
* Copyright (C) 2016 Jamal Edey
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSE.md for more information.
*/

#pragma once

#include "base/ChannelManager.h"
#include "Error.h"
#include "SAPI.h"
Expand Down
Loading

0 comments on commit b61f2d2

Please sign in to comment.