Skip to content

Comments

Extend the Player API with the set_rate function#168

Merged
ferjm merged 1 commit intoservo:masterfrom
georgeroman:player_api_set_rate
Dec 13, 2018
Merged

Extend the Player API with the set_rate function#168
ferjm merged 1 commit intoservo:masterfrom
georgeroman:player_api_set_rate

Conversation

@georgeroman
Copy link
Contributor

No description provided.

@ceyusa
Copy link
Contributor

ceyusa commented Nov 30, 2018

related with servo/servo#22293

@ceyusa
Copy link
Contributor

ceyusa commented Nov 30, 2018

keep in mind that some media cannot be played at different rates, and player will return an error via connect_error()

right now all the player's error are handled equally: the player stops. We might want something different. Perhaps we should check if there's an error right after the rate set. Or better yet, check the media info from player and verify if the stream is seekable, if it's seekable, then the rate change is possible.

@sdroege
Copy link
Contributor

sdroege commented Nov 30, 2018

I would also suggest that based on your requirements we extend the player error API to actually give useful details.

Copy link
Contributor

@ferjm ferjm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

The code looks good, but I'd like us to apply @ceyusa's suggestion about checking if the stream is seekable before changing the playback rate.

We are already getting the stream's media info and converting it to our own metadata format. We will need to add an is_seekable there and set it according to the PlayerMediaInfo.is_seekable() result.

@ferjm
Copy link
Contributor

ferjm commented Nov 30, 2018

I would also suggest that based on your requirements we extend the player error API to actually give useful details.

I filed #169 to track that work

@georgeroman
Copy link
Contributor Author

Ok, so I added the requested changes but I have one question. What should be done in the case where last_metadata is not available? In this case how could I check if the media is seekable since last_metadata is None?
Currently, I'm just returning Ok(()) in this case:
https://github.com/servo/media/pull/168/files#diff-1d803d24b8ea49dbfeb827b92c7f9c28R153

@ferjm
Copy link
Contributor

ferjm commented Nov 30, 2018

If last_metadata is not available is because the player has not started playing. In that case, we can store the value in the PlayerInner struct. And set the rate when we get the media info here if the stream is seekable.

We do something similar with input_size and stream_type.

@georgeroman
Copy link
Contributor Author

I added the requested changes.

@ferjm
Copy link
Contributor

ferjm commented Dec 5, 2018

And set the rate when we get the media info here if the stream is seekable.

I think you missed this last part. We still need to set the stored rate when we get the media info.

@georgeroman
Copy link
Contributor Author

Yeah, it looks like I missed that. Now I modified the code accordingly.

Copy link
Contributor

@ferjm ferjm left a comment

Choose a reason for hiding this comment

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

Thanks! The changes look good. However, this seems to be making the simple_player test panic. I am not sure why yet.

@georgeroman
Copy link
Contributor Author

Shouldn't the rate change event be handled using connect_property_rate_notify?

@ferjm
Copy link
Contributor

ferjm commented Dec 13, 2018

Sorry for the late reply here. Last week was a bit busy for many Mozillians :)

Shouldn't the rate change event be handled using connect_property_rate_notify?

Yes, it may be good to expose a Player event based on this signal, so we can trigger the ratechange event more accurately.

However, this seems to be making the simple_player test panic. I am not sure why yet.

The problem was that the test was buggy. I fixed it in #173, so rebasing on top of master should make this PR pass the tests as well.

.player
.connect_property_rate_notify(move |_| {
let inner = inner_clone.lock().unwrap();
inner.player.set_rate(inner.rate);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the right place to set the rate property. IIUC this event is triggered whenever the rate property changes, so we are effectively creating a loop here (unless GStreamer controls this somehow).

You are probably observing the simple_player test pass after this change because this event is never triggered (?).

I think the right place to set the rate is when we get the media info and we are able to check if the stream is seekable, as we were doing previously.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it makes sense, I didn't fully understand what was happening there but I got it now. Ok, so I modified the rate update as it was previously done.

}

pub fn set_rate(&mut self, rate: f64) -> Result<(), BackendError> {
self.rate = rate;
Copy link
Contributor

Choose a reason for hiding this comment

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

One final change, let's add this comment here:

This method may be called before the player setup is done, so we safe the rate value and set it once the player is ready and after getting the media info

@ferjm ferjm merged commit f56c8e5 into servo:master Dec 13, 2018
@ferjm
Copy link
Contributor

ferjm commented Dec 13, 2018

Thanks!

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.

4 participants