Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTSP v26 support #257

Merged
merged 6 commits into from
Jan 30, 2017
Merged

HTSP v26 support #257

merged 6 commits into from
Jan 30, 2017

Conversation

Glenn-1990
Copy link
Contributor

@Glenn-1990 Glenn-1990 commented Dec 13, 2016

Htsp v26 support.

@ksooo @Jalle19

Edit: removed WIP

@ksooo
Copy link
Member

ksooo commented Dec 15, 2016

The pvr addon capabilities are requested by Kodi before we can determine the htsp version. That's why there is a setting for now.

The setting should not be nessecary. Yes, on first call of getAddonCapabilites we are not connected (most probably), but addon capabilites are re-read directly after the addon state changes to CONNECTED. => https://github.com/xbmc/xbmc/blob/master/xbmc/pvr/addons/PVRClients.cpp#L1536 If this does not work, it's broken.

@ksooo
Copy link
Member

ksooo commented Dec 15, 2016

"GetTimerTypes" does several htsp version checks, but this is somehow broken.
Htsp version is not determined yet when calling this function. The connection state is still "PVR_CONNECTION_STATE_CONNECTING" then.

Are you sure it does not work? GetTimerTypes should be called not only once, but on demand, for instance everytime timer settings dialog is opened, and there is no caching of the types in Kodi PVR core. So, it should work. However, if there is a call to GetTimerTypes that comes to "early", this could be a bug in Kodi PVR core which has no serious consequences, though. I will look inti this.

@Glenn-1990
Copy link
Contributor Author

@ksooo Good to know that GetTimerTypes gets called every time, that pointed me to problem and solution ;-)

Is rereading the addon settings after connecting a new thing? I always remembered that this was a limitation, I'll see if I can get it working without the setting then :-)

@ksooo
Copy link
Member

ksooo commented Dec 15, 2016

So, both "problems" solved?

Rereading add-on capabilities (not settings, that's different!) is there since day 1 of async connect, means since very early Krypton alphas.

@ksooo
Copy link
Member

ksooo commented Dec 15, 2016

Just looked it up in the code: both addon capabilities and timer types are reread if connection state changes to CONNECTED. So, timer types are not always fetched from the backend, like I said earlier, but only on (re)connect, exactly like addon capabilities.

@Glenn-1990
Copy link
Contributor Author

Oops, closed by accident.

@ksooo Both issues resolved, this async stuff is really an improvement ;-)

@Jalle19
Copy link
Contributor

Jalle19 commented Dec 20, 2016

@Glenn-1990 the "delete channels without services" can be dropped now that you did tvheadend/tvheadend@e73a8b4 right?

@Glenn-1990
Copy link
Contributor Author

@Jalle19 indeed ;-)

@ksooo
Copy link
Member

ksooo commented Dec 24, 2016

@piotrasd may i kindly ask you not to hijack a random PR for completely unrelated feature requests. Thank you.

@Glenn-1990
Copy link
Contributor Author

@ksooo @Jalle19 Updated some commits

@@ -495,6 +495,7 @@ bool CHTSPConnection::SendHello ( void )
bool CHTSPConnection::SendAuth
( const std::string &user, const std::string &pass )
{
uint32_t access, u32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access should be bool

// <= htsp v25, msg present = no access, msg missing = access
// >= htsp v26, msg should be present in any case
if (m_htspVersion <= 25) //
access = msg ? 0 : 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return early end skip the else clause, but it's up to you

access = msg ? 0 : 1;
else
{
if (msg == NULL || (!htsmsg_get_u32(msg, "noaccess", &u32) && u32))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr


/* Log received permissions */
if (!htsmsg_get_u32(msg, "admin", &u32))
Logger::Log(LogLevel::LEVEL_INFO, "admin permissions: %i", u32);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you log these lines with two spaces extra indentation, like we do for demuxer streams? I find it makes the log more readable.

if (!htsmsg_get_u32(msg, "streaming", &u32))
Logger::Log(LogLevel::LEVEL_INFO, "streaming permissions: %i", u32);
if (!htsmsg_get_u32(msg, "dvr", &u32))
Logger::Log(LogLevel::LEVEL_INFO, "dvr permissions: %i", u32);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DVR in uppercase, same below for "dvr connection limit"

if (!htsmsg_get_u32(msg, "limitdvr", &u32))
Logger::Log(LogLevel::LEVEL_INFO, "dvr connection limit: %i", u32);
if (!htsmsg_get_u32(msg, "limitstreaming", &u32))
Logger::Log(LogLevel::LEVEL_INFO, "sreaming connection limit: %i", u32);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo (should be streaming)

if (m_conn.GetProtocol() < 26)
return PVR_ERROR_NOT_IMPLEMENTED;

/* Seems a bit odd */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kodi calls this function to request the play position, although the play position was already transferred to Kodi as a member of PVR_RECORDING.

@@ -1367,7 +1408,7 @@ bool CTvheadend::Connected ( void )
m_asyncState.SetState(ASYNC_CHN);

msg = htsmsg_create_map();
if (Settings::GetInstance().GetAsyncEpg())
if (Settings::GetInstance().GetAsyncEpg() || m_conn.GetProtocol() >= 26)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop this commit now

@@ -598,6 +602,43 @@ PVR_ERROR CTvheadend::RenameRecording ( const PVR_RECORDING &rec )
return SendDvrUpdate(m);
}

PVR_ERROR CTvheadend::SetPlayCount ( const PVR_RECORDING &rec, int playcount )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use playCount in another place, I suggest to use it here too for consistency

return SendDvrUpdate(m);
}

PVR_ERROR CTvheadend::SetPlayPosition ( const PVR_RECORDING &rec, int playposition )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use playPosition when calling this method, I suggest you name this the same for consistency

@Glenn-1990 Glenn-1990 changed the title [WIP] htsp v26 support HTSP v26 support Jan 8, 2017
@Glenn-1990
Copy link
Contributor Author

@Jalle19 @ksooo Updated and removed WIP

Some fixes are preferable for Krypton, should I separate the fixes in another PR apart from the HTSP v26 stuff?

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

Lets finalize this PR first before opening one for Krypton, to prevent unneeded resync.

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

I still had no time to take a closer look at your changes.

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

Have you seen and addressed my comments?

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

At least CTvheadend::GetPlayPosition needs still to be fixed.

Will take a closer look at the rest and comment back as soon as i find some time.

@Glenn-1990
Copy link
Contributor Author

@ksooo Yes I addressed you comments about add-on capabilities and timertypes.

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

What about getplayposition?

@Glenn-1990
Copy link
Contributor Author

@ksooo GetPlayPosition() is working (when on htsp v26 or up) but I'm still not sure if this is how it should be. If you could take a look :-)

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

GetPlayPosition() should not return what came in with rec.iLastPlayedPosition, but obtain and return latest position stored in backend.

@Glenn-1990
Copy link
Contributor Author

Well as we are working async, rec.iLastPlayedPosition will always hold the correct value. We push an Kodi update every time the position on the backend changes.
https://github.com/kodi-pvr/pvr.hts/blob/master/src/Tvheadend.cpp#L1895

But ofc we could also use our local playposition (from m_recordings)?

@ksooo
Copy link
Member

ksooo commented Jan 8, 2017

We push an Kodi update every time the position on the backend changes.

How often is this in worst case? can this cause performance problems? Not sure we actually should do this, especially as we're getting asked (GetPlayPosition) when kodi needs an update!

But ofc we could also use our local playposition (from m_recordings)?

I think we should go for this. "Feels" better.

Copy link
Contributor

@Jalle19 Jalle19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the minor comment this looks good to me

@@ -665,14 +706,20 @@ PVR_ERROR CTvheadend::GetTimerTypes ( PVR_TIMER_TYPE types[], int *size )

/* PVR_Timer.iPreventDuplicateEpisodes values and presentation.*/
static std::vector< std::pair<int, std::string> > deDupValues;
if (deDupValues.size() == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to remove this check? Won't this mean we may accidentally push_back duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work as we do a version check a few lines below, and htspversion = 0 the first time.
It's working for the other methods, so I guess Kodi will reject duplicates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's better to be safe than sorry, we cannot rely on Kodi doing the "right thing". Is there a way to change this to non-static so this thing wouldn't be an issue?

@ksooo
Copy link
Member

ksooo commented Jan 10, 2017

I still want to do a review before we merge this. Will do as soon as I find the time. No need to rush, imo.

@Jalle19
Copy link
Contributor

Jalle19 commented Jan 10, 2017

@ksooo sure

@Glenn-1990
Copy link
Contributor Author

Glenn-1990 commented Jan 10, 2017

How often is this in worst case? can this cause performance problems? Not sure we actually should do this, especially as we're getting asked (GetPlayPosition) when kodi needs an update!
@ksooo Only when a user presses "stop" on other clients.

What's the use of "iLastPlayedPosition" as we have "GetPlayPosition()" ? The API is unclear about it. If we don't need "iLastPlayedPosition", the code can be simplified.

@ksooo
Copy link
Member

ksooo commented Jan 10, 2017

What's the use of "iLastPlayedPosition" as we have "GetPlayPosition()" ? The API is unclear about it. If we don't need "iLastPlayedPosition", the code can be simplified.

I have not invented this API, but I guess GetPlayPosition() is there to have a lightweight method to be able to directly and quickly (and frequently?) pull the play position data for a particular recording. We only have bulk query methods otherwise and refreshing data for all recordings (GetRecordings) might be too heavyweight.

iLastPlayedPosition seems to be there for setting/updating the last played position using Add|UpdateRecording which is not a bulk operation and thus fits performance-wise.

@Jalle19
Copy link
Contributor

Jalle19 commented Jan 10, 2017

@Glenn-1990 @ksooo would it perhaps be a good idea to separate the "Fixed" commits to a separate PR while we grind this one?

@ksooo
Copy link
Member

ksooo commented Jan 11, 2017

+1 for doing separate PR for fixes and features. Makes the review easier.

@@ -217,6 +217,8 @@ PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES* pCapabilities)
pCapabilities->bHandlesInputStream = true;
pCapabilities->bHandlesDemuxing = true;
pCapabilities->bSupportsRecordingEdl = true;
pCapabilities->bSupportsRecordingPlayCount = tvh->GetProtocol() >= 26 ? true : false;
pCapabilities->bSupportsLastPlayedPosition = tvh->GetProtocol() >= 26 ? true : false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two lines look a little bit overcomplicated. Why not just

 pCapabilities->bSupportsRecordingPlayCount = (tvh->GetProtocol() >= 26);
 pCapabilities->bSupportsLastPlayedPosition = (tvh->GetProtocol() >= 26);

@ksooo
Copy link
Member

ksooo commented Jan 25, 2017

@Glenn-1990 good job, thanks. Could you please add changelog and version bump. We are ready to then, imo.

@Jalle19
Copy link
Contributor

Jalle19 commented Jan 25, 2017

+1 from me too if you add the change log entry etc.

@Glenn-1990
Copy link
Contributor Author

Changelog added

@Jalle19
Copy link
Contributor

Jalle19 commented Jan 30, 2017

@ksooo good to go?

@ksooo
Copy link
Member

ksooo commented Jan 30, 2017

Yep, good to go.

Does anything speak against a Krypton backport @Glenn-1990?

@Jalle19 Jalle19 merged commit b290c8c into kodi-pvr:master Jan 30, 2017
@Jalle19
Copy link
Contributor

Jalle19 commented Jan 30, 2017

@ksooo Krypton is still unreleased so everything should be backported to it IMO.

@ksooo
Copy link
Member

ksooo commented Jan 30, 2017

@ksooo Krypton is still unreleased so everything should be backported to it IMO.

Yep, but we need to hurry then, because we want to release Krypton really very soon, @Glenn-1990 ;-)

@Glenn-1990
Copy link
Contributor Author

@ksooo A backport would be nice, maybe someone else can do a runtime test first? Especially the play count and play position stuff.

@ksooo
Copy link
Member

ksooo commented Jan 30, 2017

That's problematic, due to lack of time on my end. If we are not sure that it actually works, no backport now, please.

However, ofc a Krypton PR is welcome. I will test asap.

@Glenn-1990
Copy link
Contributor Author

Under some circumstances the playposition seems to be wrong as Kodi uses "-1" for fully watched. Only affects htsp v26 and up. I'll come up with a PR, already addressed in the Krypton PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants