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
Add a 'V' query that will return the maximum seek point in seconds within the current track duration for a 'live' radio stream #986
Conversation
…thin the current track duration for a 'live' radio stream.
Just for my understanding: Is And the value would need to be exposed by the protocol handler - which currently would be some select 3rd party plugins only? It might be worth adding a note so this doesn't get removed because no code providing it can be found. The risk is small, but it helps understanding how this works. |
Yes, it is used in the hls and mpeg-dash specifications to describe the most recently available audio chunk/segment available in a dynamic live audio stream.
Yes, that occurred to me, where do you want the note, I have added the item to the cli_api documentation. |
Please add the note next to the code. Thanks! |
Sure, no problem, branch updated. |
I was also initially thinking about that as a flag for webradio to really indicate that this is a really live stream. So it would not be just be initialized by plugins, but LMS would set it to 0 when it's a a true live webradio/content (RP interactive for that matter would not be). Plugins could overwrite it of course. If it's not live, it could be either missing or -1. When it's a live_edge as you describe it, it then as a value > 0 |
Ok, I think I follow. So basically you would like an indicator that shows that it is a continuous infinite stream. Looking back at the forum discussion, I think your original suggestion better meets your needs. I think it got sidetracked by my desire to expose the live edge through LMS How about then, I amend the PR so that we are back to remoteMeta->{live} So a non-zero value means it is live, a value greater than 1 means its a live edge That way it can just be tested for true if the client is not interested in a live edge. |
Yes, although we twist the meaning of the value by saying that 1 is just live and >1 is real edge. We can do that, but it's not my preferred semantic I'd say. I'd rather have : nothing or -1, it's not live, anything else give you the distance from the edge, which is 0 in case of webradios. |
Well, I think its my fault I'm conflating the two purposes that is causing the issue. I think we are always going to have an odd semantic. |
Ok, I really we could have one because the meaning is the same |
OK, I see your logic. I'll update the branch. |
I need to catch up... is the continued discussion one about how to provide the actual value from within the 3rd party plugin, or is it related to this PR? Should there be code in core LMS validating the values returned? Or at least some documentation about what that value is supposed to be for future reference? |
A bit of both: deciding what that item must be and how it should be calculated
Not for validation, but for default values (LMS knows when it's a live radio)
|
I'm going to update this branch as per @philippe44 's description |
Ok, I've updated the Branch. The live_edge 'V' tag query now returns: I have a couple of questions.
|
Slim/Control/Queries.pm
Outdated
$remoteMeta->{V} = -1; | ||
} | ||
} else { # only live if the song has isLive set | ||
$remoteMeta->{V} = $song->isLive() ? 0 : -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't you set that as the default value and override it only if the handler has something to say? Feels easier to read to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fair point.
To your question about use of isLive(), I would agree with you. We should not combine song->isLive() with duration(), because the requestor will have the duration() anyway so isLive() basically tells him either the HTTP response when there is no PH did not give a Content-Length (which is not a perfect indication of live either, as HTTP clearly allows server to no disclose CL) or that the PH clearly said it's a live content, although I may set duration. So that gives 2 independent data point to the requestor to make a decision on how it want to handle that track. Otherwise, it would be masked by the lack of duration() |
Slim/Control/Queries.pm
Outdated
@@ -5010,6 +5011,22 @@ sub _songData { | |||
$remoteMeta->{T} = $remoteMeta->{samplerate}; | |||
$remoteMeta->{I} = $remoteMeta->{samplesize}; | |||
$remoteMeta->{W} = $remoteMeta->{releasetype}; | |||
|
|||
$remoteMeta->{V} = -1; | |||
# Distance from the live edge of live remote stream. -1 is not live, 0 is live at the edge, >0 is distance in seconds from the live edge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use tabs instead of space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops...
Slim/Control/Queries.pm
Outdated
if ( my $client = $request->client ) { | ||
if (my $song = $client->currentSongForUrl($url)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both $client
and $song
are used in other places of this sub. Please put the definition of the two at the top and remove this repeated evaluation of the two values from wherever it's done now (within this sub, eg. line 5017).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document the meaning of live_edge
values as well as the meaning of isLive()
. As this is all outside core LMS we don't have code as reference to replace missing documentation. Thanks!
Yes, indeed, although I was in particular referring to the $song->duration, which, although I find a bit confusing is a bit different to the duration that is returned by the d query tag. The reason I raised it was because the only other place that isLive is used internally, it combines it with the $song->duration(), which for the reason you describe, I found to be flawed. But anyway, I think after you have furthered my understanding I definitely think there is no need for the handler->isLive now, so I will remove that from my branch, and assume that 3rd party handlers will also populate $song->isLive appropriatly. |
I'm not sure I understand your comment about song->isLive overload |
The original forum discussion suggested the 3rd party handler havein its own isLive. I originally had that in the branch. Now we know we are using the song->isLive on its own, then there is no need for it. |
I've updated the branch, hopefully that is more straightforward now and meets requirements. |
Branch updated with @philippe44 's suggestions |
As per the discussion here : https://forums.slimdevices.com/forum/developer-forums/developers/1667479-live-streams-tag
This adds a 'V' : Live_Edge query.
It will contain the maximum seek point in seconds of the currently live radio stream that has a defined duration.
This adds the ability for a client to know what is the maximum available downloadable data.
It also provides the information to a controller to display the maximum seek point.
For Example for the following scenario :
A live radio stream could be streaming a programme that is 2 hours long.
The programme is currently being broadcast live and is 1 hour into the broadcast. The Listener is currently 50 minutes into listening to the programme as they paused for 10 minutes.
The query that contained the tags:dV (duration and live_meta) would return:
result->time : 3000
result->remoteMeta->duration : 7200
result->remoteMeta->live_edge : 3600