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

Extend the Player API with the set_rate function #168

Merged
merged 1 commit into from Dec 13, 2018
Merged

Conversation

@georgeroman
Copy link
Contributor

georgeroman commented Nov 29, 2018

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
Member

ferjm left a comment

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
Member

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

georgeroman commented Nov 30, 2018

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
Member

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

georgeroman commented Dec 3, 2018

I added the requested changes.

@ferjm
Copy link
Member

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

georgeroman commented Dec 5, 2018

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

@ferjm
ferjm approved these changes Dec 5, 2018
Copy link
Member

ferjm left a comment

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

georgeroman commented Dec 8, 2018

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

@ferjm
Copy link
Member

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);

This comment has been minimized.

Copy link
@ferjm

ferjm Dec 13, 2018

Member

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.

This comment has been minimized.

Copy link
@georgeroman

georgeroman Dec 13, 2018

Author Contributor

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.

@@ -145,6 +149,18 @@ impl PlayerInner {
Ok(())
}

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

This comment has been minimized.

Copy link
@ferjm

ferjm Dec 13, 2018

Member

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 approved these changes Dec 13, 2018
@ferjm ferjm merged commit f56c8e5 into servo:master Dec 13, 2018
1 check was pending
1 check was pending
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@ferjm
Copy link
Member

ferjm commented Dec 13, 2018

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.