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

Switch BaseSrc to AppSrc #4

Merged
merged 2 commits into from May 16, 2018
Merged

Switch BaseSrc to AppSrc #4

merged 2 commits into from May 16, 2018

Conversation

@Manishearth
Copy link
Member

Manishearth commented May 9, 2018

I'm not sure which one we plan to choose so both are still implemented here and not cleaned up too much.

r? @ferjm

cc @sdroege

@@ -368,3 +369,56 @@ pub fn register() {
let type_ = register_type(AudioSrcStatic);
gst::Element::register(None, "servoaudiosrc", 0, type_);
}

pub fn app_src_oscillator() -> Result<gst::Element, ()> {
let src = gst::ElementFactory::make("appsrc", None).ok_or(())?;

This comment has been minimized.

@sdroege

sdroege May 10, 2018

Contributor

One general comment: with appsrc you have less control over e.g. format (caps) negotiation. You set a single caps and then produce that, there's no easy way to check what downstream wants, reconfigure when downstream changes, etc.

So if you need that, for example to always produce the format that downstream can handle and downstream can change, then this might be suboptimal. It depends on what you need, and where/who is defining the format that is to be produced

src.set_caps(&info.to_caps().unwrap());
src.set_property_format(gst::Format::Time);
src.set_max_bytes(1);
src.set_property_block(true);

This comment has been minimized.

@sdroege

sdroege May 10, 2018

Contributor

These two properties are unnecessary with the way how you fill the appsrc. None of this will ever happen: your callback below is only called when data is needed. These properties only make sense if the filling of the appsrc happens driven by something else, e.g. another thread that just pushes buffers into the appsrc

sample_offset += n_samples;

}
let _ = app.push_buffer(buffer);

This comment has been minimized.

@sdroege

sdroege May 10, 2018

Contributor

You probably want to handle errors here

This comment has been minimized.

@Manishearth

Manishearth May 10, 2018

Author Member

is there a way to put the element in an error state?

This comment has been minimized.

@Manishearth

Manishearth May 10, 2018

Author Member

I'm not sure what the model for handling errors should be here

This comment has been minimized.

@sdroege

sdroege May 10, 2018

Contributor

You'd check the return value of pushing but appsrc should already convert errors into an error message on the bus. You would then handle those error messages
But if an error is returned from pushing, you might want to stop processing for example

If your code itself produces an error, you could post an error message yourself. Check the appsrc example in gstreamer-rs, iirc it does that

I'll put a link to code here in a few hours when I'm back home

This comment has been minimized.

@Manishearth

Manishearth May 10, 2018

Author Member

well, we already stop processing here, since this is the last action in the callback.

This comment has been minimized.

@sdroege

sdroege May 10, 2018

Contributor

Right, but a future version of this code might do more things :) Anyway, ignore this comment for the time being then

@philn
Copy link
Collaborator

philn commented May 10, 2018

I don't really see the benefit of using appsrc for this :)

@Manishearth
Copy link
Member Author

Manishearth commented May 10, 2018

Yeah, it was mostly something Fernando wanted to try out.

@Manishearth Manishearth force-pushed the Manishearth:appsrc branch from b9785b1 to 04e6403 May 10, 2018
@ferjm
Copy link
Member

ferjm commented May 10, 2018

Yeah, it was mostly something Fernando wanted to try out.

Thank you Manish. I wanted to look into using appsrc mostly because @sdroege suggested it, mentioning that it would make our lifes easier :). And because this is what WebKit uses for their WebAudio backend. So it seemed like something worth investigating.

I'm afraid that I couldn't look into the details and the differences of basesrc vs appsrc before my leave, so I am not in a good position to make the call here right now :. I'll have to defer to what you learned in the process of writing this patch and to @sdroege's and @philn's expertise.

I'm back from my leave on Monday, so we can chat about this in person.

@Manishearth
Copy link
Member Author

Manishearth commented May 10, 2018

@ferjm
Copy link
Member

ferjm commented May 10, 2018

It would be wonderful if you could start the implementation of the NodeEngine abstraction that you suggested and/or the mechanism to feed servo-media with them from script.

@Manishearth
Copy link
Member Author

Manishearth commented May 10, 2018

@sdroege
Copy link
Contributor

sdroege commented May 11, 2018

I wanted to look into using appsrc mostly because @sdroege suggested it, mentioning that it would make our lives easier :).

It depends on what your exact requirements are. The main possible disadvantage for this use-case is that dynamic reconfiguration of the caps (i.e. the raw audio format) based on what downstream wants is not easily possible. If you don't need that (e.g. have a fixed format, only need to decide based on downstream once, or changes are always triggered by your code) then appsrc probably makes your life easier. As seen with this PR, much less code for the same behaviour.

@ferjm
Copy link
Member

ferjm commented May 11, 2018

Thank you Sebastian. I think we don't need dynamic reconfiguration of the caps.

@sdroege
Copy link
Contributor

sdroege commented May 11, 2018

If you want, we can all together go through your requirements next week when you're back :) But for starters going with appsrc should be fine, it can still easily be changed at a later time. Just means transplanting the sample creation code into slightly different code.

@ferjm ferjm force-pushed the Manishearth:appsrc branch from 04e6403 to 10a9577 May 15, 2018
@ferjm ferjm merged commit ae4a5d1 into servo:master May 16, 2018
Manishearth pushed a commit to Manishearth/media that referenced this pull request Jan 25, 2019
hacky support for other side of RTC
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.