Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
[PVR] Document implict call to CloseXXXStream() before OpenXXXStream() #15479
The PVR API is implicitly calling CloseLiveStream() / CloseRecordedStream() before calling OpenLiveStream() / OpenRecordedStream(). I believe these implicit actions should not take place on behalf of the PVR Client addon.
Motivation and Context
This is a problem if the PVR client is forced to open a stream prior to the actual call to OpenLiveStream() / OpenRecordedStream(). My specific example is that in order to properly support GetChannelStreamProperties() and GetRecordingStreamProperties(), I have to open the stream. The backend I am working with (HDHomeRun DVR) does not expose the proper MIME type via metadata, and in the case of Recordings, I do not know if the stream will be real-time or not until it's been opened and I have examined the HTTP response headers. (HDHomeRun DVR reports Recordings currently in-progress as real-time, for example).
Moving the point where GetXXXStreamProperties() is called so that it occurs after OpenXXXStream is prohibitive and unnecessary. PVR addons can provide Kodi with the proper properties if they are unknown by opening the stream.
Which leads to why this change: Things fall apart because the stream that was opened in GetXXXStreamProperties() is implicitly closed by PVRClient.cpp, and is then opened again. This is wasteful at best, but at worst the properties may be different on the subsequent open (this is unlikely, but possible).
I see no other instance in PVRClient.cpp where another PVR interface method is implicitly invoked by Kodi. I also think that other addons may run into the same problem with Leia, not being able to properly report the MIME type and/or realtime flag unless they open and examine the stream -- and likely coming up with the same solution.
For now, I can reference count the calls to Open/Close as a workaround, but I would appreciate consideration of this PR for future Kodi 18.x releases as it's not technically 'breaking' in nature. Thank you!
How Has This Been Tested?
Tested on Kodi 18.0 Leia, both at the "18.0-Leia" tag commit as well as the current master branch commit at the time the PR was generated. Windows 10, x86 and x64 (non-UWP/store). I verified that CloseLiveStream()/CloseRecordedStream() was invoked the expected number of times (once). I ran into no issues switching channels or changing from Live to Recorded and vice-versa.
Screenshots (if appropriate):
Types of change
I understand, and I appreciate even considering it. I checked the various PVRs and found at least one that on the surface does rely upon this (argustv). If Kodi never explicitly calls CloseLiveStream() for some reason, there is nothing in the addon to protect itself from multiple calls to OpenLiveStream().
If this behavior was intentional that makes me the outlier (again). I'm fine with cancelling/deleting the PR completely, it's very easy to work around. If the PR dies, may I suggest a tweak to the interface documentation in the header file that says Close will be implicitly called just prior to Open()? If that would be OK, I could also just change this PR to do that instead - some suggested verbiage change only?