Skip to content

Commit

Permalink
Implement multi-stream recordings
Browse files Browse the repository at this point in the history
Enable API changes for multiple recording stream . Allow optional Kodi extraction of thumbnails
  • Loading branch information
emveepee committed Dec 19, 2024
1 parent 9bf83f5 commit 90ddc3d
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 53 deletions.
15 changes: 15 additions & 0 deletions pvr.nextpvr/resources/instance-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
<popup>false</popup>
</control>
</setting>
<setting help="302720" id="multistream" label="30220" type="boolean">
<level>2</level>
<default>false</default>
<control type="toggle"/>
</setting>
</group>
</category>
<category help="" id="advanced5" label="30175">
Expand Down Expand Up @@ -220,6 +225,16 @@
<default>false</default>
<control type="toggle"/>
</setting>
<setting help="30719" id="poster" label="30219" type="boolean">
<level>2</level>
<default>true</default>
<control type="toggle"/>
<dependencies>
<dependency type="visible">
<condition operator="is" setting="multistream">true</condition>
</dependency>
</dependencies>
</setting>
<setting help="30693" id="separateseasons" label="30193" type="boolean">
<level>2</level>
<default>false</default>
Expand Down
16 changes: 16 additions & 0 deletions pvr.nextpvr/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,19 @@ msgstr ""
msgctxt "#30218"
msgid "Repeating (all episodes)"
msgstr ""

msgctxt "#30219"
msgid "Download recording poster"
msgstr ""

msgctxt "#30719"
msgid "Download backend poster or extract thumbnail from recording"
msgstr ""

msgctxt "#30220"
msgid "Enable multi-stream recordings"
msgstr ""

msgctxt "#30720"
msgid "Extract extra recording metadata from backend"
msgstr ""
12 changes: 11 additions & 1 deletion src/InstanceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ void InstanceSettings::ReadFromAddon()

m_comskip = ReadBoolSetting("comskip", true);

enum eHeartbeat m_heartbeat = ReadEnumSetting<eHeartbeat>("heartbeat", eHeartbeat::Default);
m_multiStream = ReadBoolSetting("multistream", false);
if (m_multiStream)
m_recordingPoster = ReadBoolSetting("poster", true);

c: enum eHeartbeat m_heartbeat = ReadEnumSetting<eHeartbeat>("heartbeat", eHeartbeat::Default);

if (m_heartbeat == eHeartbeat::Default)
m_heartbeatInterval = DEFAULT_HEARTBEAT;
Expand Down Expand Up @@ -323,6 +327,12 @@ ADDON_STATUS InstanceSettings::SetValue(const std::string& settingName, const ko
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_separateSeasons, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "showroot")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_showRoot, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "comskip")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_comskip, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "poster")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_recordingPoster, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "multistream")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_multiStream, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "genrestring")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_genreString, ADDON_STATUS_NEED_SETTINGS, ADDON_STATUS_OK);
else if (settingName == "host_mac")
Expand Down
2 changes: 2 additions & 0 deletions src/InstanceSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace NextPVR
int m_timeoutWOL = 0;
bool m_connectionConfirmed = false;
bool m_backendResume = true;
bool m_multiStream = false;

//General
int m_backendVersion = 0;
Expand Down Expand Up @@ -113,6 +114,7 @@ namespace NextPVR
bool m_showRoot = false;
int m_chunkRecording = 32;
bool m_comskip = true;
bool m_recordingPoster = true;

//Timers
int m_defaultPrePadding = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/Recordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Recordings::Recordings(const std::shared_ptr<InstanceSettings>& settings, Reques

}



PVR_ERROR Recordings::GetRecordingsAmount(bool deleted, int& amount)
{
// need something more optimal, but this will do for now...
Expand Down Expand Up @@ -320,8 +318,9 @@ bool Recordings::UpdatePvrRecording(const tinyxml2::XMLNode* pRecordingNode, kod
buffer.clear();
XMLUtils::GetString(pRecordingNode, "id", buffer);
tag.SetRecordingId(buffer);
bool series = ParseNextPVRSubtitle(pRecordingNode, tag);

if (ParseNextPVRSubtitle(pRecordingNode, tag))
if (series)
{
if (m_settings->m_separateSeasons && multipleSeasons && tag.GetSeriesNumber() != PVR_RECORDING_INVALID_SERIES_EPISODE)
{
Expand Down Expand Up @@ -439,7 +438,8 @@ bool Recordings::UpdatePvrRecording(const tinyxml2::XMLNode* pRecordingNode, kod
else
artworkPath = kodi::tools::StringUtils::Format("%s/service?method=channel.show.artwork&name=%s", m_settings->m_urlBase, name.c_str());
tag.SetFanartPath(artworkPath + "&prefer=fanart");
tag.SetThumbnailPath(artworkPath + "&prefer=poster");
if (m_settings->m_recordingPoster || status == "Failed" || tag.GetSizeInBytes() == 0 || tag.GetChannelType() == PVR_RECORDING_CHANNEL_TYPE_RADIO)
tag.SetThumbnailPath(artworkPath + "&prefer=poster");
}
if (XMLUtils::GetAdditiveString(pRecordingNode->FirstChildElement("genres"), "genre", EPG_STRING_TOKEN_SEPARATOR, buffer, true))
{
Expand Down Expand Up @@ -539,7 +539,7 @@ bool Recordings::ParseNextPVRSubtitle(const tinyxml2::XMLNode *pRecordingNode, k

PVR_ERROR Recordings::DeleteRecording(const kodi::addon::PVRRecording& recording)
{
if (recording.GetRecordingTime() < time(nullptr) && recording.GetRecordingTime() + recording.GetDuration() > time(nullptr))
if (recording.GetRecordingTime() < time(nullptr) && recording.GetDuration() > 0 && recording.GetRecordingTime() + recording.GetDuration() > time(nullptr))
return PVR_ERROR_RECORDING_RUNNING;

const std::string request = "recording.delete&recording_id=" + recording.GetRecordingId();
Expand Down
20 changes: 11 additions & 9 deletions src/buffers/RecordingBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ int RecordingBuffer::Duration(void)
if (m_recordingTime)
{
std::unique_lock<std::mutex> lock(m_mutex);
int diff = static_cast<int>(time(nullptr) - m_recordingTime) - 15;
if (diff > m_Duration)
int currentDuration = static_cast<int>(time(nullptr) - m_recordingTime) - 15;
if (currentDuration > m_Duration)
{
tinyxml2::XMLDocument doc;
if (m_request.DoMethodRequest("recording.list&recording_id=" + m_recordingID, doc) == tinyxml2::XML_SUCCESS)
Expand All @@ -43,38 +43,40 @@ int RecordingBuffer::Duration(void)

if (status != "Recording")
{
diff = m_Duration;
currentDuration = m_Duration;
m_recordingTime = 0;
}
else
{
// see what happens in one minute;
m_Duration += 60;
}
}
}
else if (diff > 0)
else if (currentDuration > 0)
{
m_isLive = true;
diff += 15;
currentDuration += 15;
}
else
{
// no longer in-progress
m_isLive = false;
diff = 0;
currentDuration = 0;
}
return diff;
return currentDuration;
}
else
{
return m_Duration;
}
}

bool RecordingBuffer::Open(const std::string inputUrl, const kodi::addon::PVRRecording& recording)
bool RecordingBuffer::Open(const std::string inputUrl, const kodi::addon::PVRRecording& recording, int64_t streamId)
{
m_Duration = recording.GetDuration();

kodi::Log(ADDON_LOG_DEBUG, "RecordingBuffer::Open %d %lld", recording.GetDuration(), recording.GetRecordingTime());
kodi::Log(ADDON_LOG_DEBUG, "RecordingBuffer::Open %d %lld streamId %d", recording.GetDuration(), recording.GetRecordingTime(), streamId);
if (recording.GetDuration() + recording.GetRecordingTime() > time(nullptr))
{
m_recordingTime = recording.GetRecordingTime() + m_settings->m_serverTimeOffset;
Expand Down
4 changes: 2 additions & 2 deletions src/buffers/RecordingBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ namespace timeshift {
return PVR_ERROR_NO_ERROR;
}

bool Open(const std::string inputUrl, const kodi::addon::PVRRecording& recording);
bool Open(const std::string inputUrl, const kodi::addon::PVRRecording& recording, int64_t streamId);

std::atomic<bool> m_isLive;

// recording start time
time_t m_recordingTime;
time_t m_recordingTime = 0;
};
}
Loading

0 comments on commit 90ddc3d

Please sign in to comment.