Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ include_directories(${KODI_INCLUDE_DIR}/.. # Hack way with "/..", need bigger Ko
set(DEPLIBS ${JSONCPP_LIBRARIES})

set(OCTONET_SOURCES src/addon.cpp
src/OctonetData.cpp
src/Socket.cpp
src/rtsp_client.cpp)
src/OctonetData.cpp)

set(OCTONET_HEADERS src/addon.h
src/OctonetData.h
src/Socket.h
src/rtsp_client.hpp)
src/OctonetData.h)

addon_version(pvr.octonet OCTONET)
add_definitions(-DOCTONET_VERSION=${OCTONET_VERSION})
Expand Down
59 changes: 59 additions & 0 deletions build-install-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then
echo "Usage: $0 <XBMC-SRC-DIR>" >&2
exit 1
fi

if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Error: Script only for use on MacOSX" >&2
exit 1
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ "$1" = /* ]]
then
#absolute path
SCRIPT_DIR=""
else
#relative
SCRIPT_DIR="$SCRIPT_DIR/"
fi

BINARY_ADDONS_TARGET_DIR="$1/tools/depends/target/binary-addons"
MACOSX_BINARY_ADDONS_TARGET_DIR=""
KODI_ADDONS_DIR="$HOME/Library/Application Support/Kodi/addons"
ADDON_NAME=`basename -s .git \`git config --get remote.origin.url\``

if [ ! -d "$BINARY_ADDONS_TARGET_DIR" ]; then
echo "Error: Could not find binary addons directory at: $BINARY_ADDONS_TARGET_DIR" >&2
exit 1
fi

for DIR in "$BINARY_ADDONS_TARGET_DIR/"macosx*; do
if [ -d "${DIR}" ]; then
MACOSX_BINARY_ADDONS_TARGET_DIR="${DIR}"
break
fi
done

if [ -z "$MACOSX_BINARY_ADDONS_TARGET_DIR" ]; then
echo "Error: Could not find binary addons build directory at: $BINARY_ADDONS_TARGET_DIR/macosx*" >&2
exit 1
fi

if [ ! -d "$KODI_ADDONS_DIR" ]; then
echo "Error: Kodi addons dir does not exist at: $KODI_ADDONS_DIR" >&2
exit 1
fi

cd "$MACOSX_BINARY_ADDONS_TARGET_DIR"
make

XBMC_BUILD_ADDON_INSTALL_DIR=$(cd "$SCRIPT_DIR$1/addons/$ADDON_NAME" 2> /dev/null && pwd -P)
rm -rf "$KODI_ADDONS_DIR/$ADDON_NAME"
echo "Removed previous addon build from: $KODI_ADDONS_DIR"
cp -rf "$XBMC_BUILD_ADDON_INSTALL_DIR" "$KODI_ADDONS_DIR"
echo "Copied new addon build to: $KODI_ADDONS_DIR"
6 changes: 4 additions & 2 deletions pvr.octonet/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.octonet"
version="20.3.0"
version="21.0.0"
name="Digital Devices Octopus NET Client"
provider-name="digitaldevices">
<requires>@ADDON_DEPENDS@</requires>
<requires>@ADDON_DEPENDS@
<import addon="inputstream.ffmpegdirect" minversion="21.0.0"/>
Comment thread
ksooo marked this conversation as resolved.
</requires>
<extension
point="kodi.pvrclient"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
Expand Down
4 changes: 4 additions & 0 deletions pvr.octonet/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
v21.0.0
- Change add-on to use inputstream.ffmpegdirect which also enables timeshifting
- Fix jsoncpp deprecation warnings
- Add build script for mac
38 changes: 38 additions & 0 deletions pvr.octonet/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,41 @@ msgstr ""
msgctxt "#30001"
msgid "Could not load chanellist"
msgstr ""

msgctxt "#30002"
msgid "Timeshift"
msgstr ""

msgctxt "#30003"
msgid "Enable timeshift"
msgstr ""

msgctxt "#30004"
msgid "- Modify inputstream.ffmpegdirect settings..."
msgstr ""

msgctxt "#30005"
msgid "Inputstream settings"
msgstr ""

#empty strings from id 30006 to 30599

msgctxt "#30600"
msgid "The IP/address of the octonet server. Note that in case of an address, the protocol (http://) has to be omitted."
msgstr ""

msgctxt "#30601"
msgid "General settings required by the add-on."
msgstr ""

msgctxt "#30602"
msgid "Timeshift settings for pausing/rewinding and fast-forwarding live streams."
msgstr ""

msgctxt "#30603"
msgid "Enable the timeshift feature."
msgstr ""

msgctxt "#30604"
msgid "Open settings dialog for inputstream.ffmpegdirect for modification of timeshift and other settings."
msgstr ""
25 changes: 23 additions & 2 deletions pvr.octonet/resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings version="1">
<section id="pvr.octonet">
<category id="main" label="128" help="-1">
<category id="main" label="128" help="30601">
<group id="1" label="-1">
<!-- Octonet Server Address -->
<setting id="octonetAddress" type="string" label="30000" help="-1">
<setting id="octonetAddress" type="string" label="30000" help="30600">
<level>0</level>
<default></default>
<constraints>
Expand All @@ -14,5 +14,26 @@
</setting>
</group>
</category>
<category id="timeshift" label="30002" help="30602">
<group id="1" label="30002">
<setting id="timeshiftEnabled" type="boolean" label="30003" help="30603">
<level>0</level>
<default>false</default>
<control type="toggle" />
</setting>
</group>
<group id="2" label="30005">
<setting id="ffmpegdirectSettings" type="action" label="30004" help="30604">
<level>0</level>
<data>Addon.OpenSettings(inputstream.ffmpegdirect)</data>
<dependencies>
<dependency type="enable" setting="timeshiftEnabled" operator="is">true</dependency>
</dependencies>
<control type="button" format="action">
<close>true</close>
</control>
</setting>
</group>
</category>
</section>
</settings>
72 changes: 31 additions & 41 deletions src/OctonetData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "OctonetData.h"

#include "rtsp_client.hpp"

#include <json/json.h>
#include <kodi/Filesystem.h>
#include <kodi/General.h>
Expand All @@ -23,34 +21,23 @@
#endif

OctonetData::OctonetData(const std::string& octonetAddress,
bool enableTimeshift,
const kodi::addon::IInstanceInfo& instance)
: kodi::addon::CInstancePVRClient(instance)
{
m_serverAddress = octonetAddress;
m_enableTimeshift = enableTimeshift;
m_channels.clear();
m_groups.clear();
m_lastEpgLoad = 0;

if (!LoadChannelList())
kodi::QueueFormattedNotification(QUEUE_ERROR, kodi::addon::GetLocalizedString(30001).c_str(),
m_channels.size());

/*
// Currently unused, as thread was already present before with
// p8platform, by remove of them was it added as C++11 thread way.
kodi::Log(ADDON_LOG_INFO, "%s Starting separate client update thread...", __func__);
m_running = true;
m_thread = std::thread([&] { Process(); });
*/
}

OctonetData::~OctonetData(void)
{
/*
m_running = false;
if (m_thread.joinable())
m_thread.join();
*/
}

PVR_ERROR OctonetData::GetCapabilities(kodi::addon::PVRCapabilities& capabilities)
Expand Down Expand Up @@ -127,9 +114,11 @@ bool OctonetData::LoadChannelList()
f.Close();

Json::Value root;
Json::Reader reader;
JSONCPP_STRING err;
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());

if (!reader.parse(jsonContent, root, false))
if (!reader->parse(jsonContent.c_str(), jsonContent.c_str() + jsonContent.length(), &root, &err))
return false;

const Json::Value groupList = root["GroupList"];
Expand Down Expand Up @@ -215,9 +204,11 @@ bool OctonetData::LoadEPG(void)
f.Close();

Json::Value root;
Json::Reader reader;
JSONCPP_STRING err;
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());

if (!reader.parse(jsonContent, root, false))
if (!reader->parse(jsonContent.c_str(), jsonContent.c_str() + jsonContent.length(), &root, &err))
return false;

const Json::Value eventList = root["EventList"];
Expand Down Expand Up @@ -254,11 +245,6 @@ bool OctonetData::LoadEPG(void)
return true;
}

void OctonetData::Process()
{
return;
}

PVR_ERROR OctonetData::GetChannelsAmount(int& amount)
{
amount = m_channels.size();
Expand Down Expand Up @@ -287,6 +273,25 @@ PVR_ERROR OctonetData::GetChannels(bool radio, kodi::addon::PVRChannelsResultSet
return PVR_ERROR_NO_ERROR;
}

PVR_ERROR OctonetData::GetChannelStreamProperties(const kodi::addon::PVRChannel& channelinfo, std::vector<kodi::addon::PVRStreamProperty>& properties)
{
properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.ffmpegdirect");
properties.emplace_back("inputstream.ffmpegdirect.is_realtime_stream", "true");
properties.emplace_back("inputstream.ffmpegdirect.open_mode", "ffmpeg");
if (m_enableTimeshift)
{
// This property is required to support timeshifting for Radio channels
properties.emplace_back("inputstream-player", "videodefaultplayer");
properties.emplace_back("inputstream.ffmpegdirect.stream_mode", "timeshift");
}
properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "video/x-mpegts");
properties.emplace_back(PVR_STREAM_PROPERTY_STREAMURL, GetUrl(channelinfo.GetUniqueId()));

kodi::Log(ADDON_LOG_INFO, "Playing channel - name: %s, url: %s, and using inputstream.ffmpegdirect", GetName(channelinfo.GetUniqueId()).c_str(), GetUrl(channelinfo.GetUniqueId()).c_str());

return PVR_ERROR_NO_ERROR;
}

PVR_ERROR OctonetData::GetEPGForChannel(int channelUid,
time_t start,
time_t end,
Expand Down Expand Up @@ -435,23 +440,8 @@ OctonetGroup* OctonetData::FindGroup(const std::string& name)
return &group;
}

return nullptr;
}
kodi::Log(ADDON_LOG_ERROR, "Could not find group: %s, in available groups from the server");

/* PVR stream handling */
/* entirely unused, as we use standard RTSP+TS mux, which can be handlded by
* Kodi core */
bool OctonetData::OpenLiveStream(const kodi::addon::PVRChannel& channelinfo)
{
return rtsp_open(GetName(channelinfo.GetUniqueId()), GetUrl(channelinfo.GetUniqueId()));
}

int OctonetData::ReadLiveStream(unsigned char* pBuffer, unsigned int iBufferSize)
{
return rtsp_read(pBuffer, iBufferSize);
return nullptr;
}

void OctonetData::CloseLiveStream()
{
rtsp_close();
}
12 changes: 3 additions & 9 deletions src/OctonetData.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ATTR_DLL_LOCAL OctonetData : public kodi::addon::CInstancePVRClient
{
public:
OctonetData(const std::string& octonetAddress,
bool enableTimeshift,
const kodi::addon::IInstanceInfo& instance);
~OctonetData() override;

Expand All @@ -66,19 +67,14 @@ class ATTR_DLL_LOCAL OctonetData : public kodi::addon::CInstancePVRClient
PVR_ERROR GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& results) override;
PVR_ERROR GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group,
kodi::addon::PVRChannelGroupMembersResultSet& results) override;
PVR_ERROR GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties) override;

PVR_ERROR GetEPGForChannel(int channelUid,
time_t start,
time_t end,
kodi::addon::PVREPGTagsResultSet& results) override;

bool OpenLiveStream(const kodi::addon::PVRChannel& channelinfo) override;
int ReadLiveStream(unsigned char* buffer, unsigned int size) override;
void CloseLiveStream() override;

protected:
void Process();

const std::string& GetUrl(int id) const;
const std::string& GetName(int id) const;

Expand All @@ -91,11 +87,9 @@ class ATTR_DLL_LOCAL OctonetData : public kodi::addon::CInstancePVRClient

private:
std::string m_serverAddress;
bool m_enableTimeshift = false;
std::vector<OctonetChannel> m_channels;
std::vector<OctonetGroup> m_groups;

time_t m_lastEpgLoad;

std::atomic<bool> m_running = {false};
std::thread m_thread;
};
Loading