Closed
Bug 859199
Opened 12 years ago
Closed 11 years ago
Load GStreamer at runtime on Linux
Categories
(Core :: Audio/Video, defect)
Tracking
()
RESOLVED
FIXED
mozilla24
People
(Reporter: eflores, Assigned: eflores)
References
Details
Attachments
(1 file, 4 obsolete files)
19.68 KB,
patch
|
alessandro.d
:
review+
|
Details | Diff | Splinter Review |
Loading the GStreamer libraries at runtime will let us ship with --enable-gstreamer on Linux by default.
Assignee | ||
Comment 1•12 years ago
|
||
This patch loads the GStreamer libraries at runtime, so one shouldn't need to have GStreamer installed to run it.
This only works with GStreamer 0.10 for the meantime.
Attachment #734463 -
Flags: review?(alessandro.d)
Assignee | ||
Comment 2•12 years ago
|
||
Assignee | ||
Comment 3•12 years ago
|
||
I am sometimes silly.
Attachment #734463 -
Attachment is obsolete: true
Attachment #734463 -
Flags: review?(alessandro.d)
Attachment #734464 -
Flags: review?(alessandro.d)
Assignee | ||
Comment 4•12 years ago
|
||
Assignee | ||
Comment 5•12 years ago
|
||
Aaaand one more try push with it actually on:
https://tbpl.mozilla.org/?tree=Try&rev=f2557f16bf52
Assignee | ||
Comment 6•12 years ago
|
||
Oops, doesn't look like the try servers have the gstreamer-devel packages yet.
Depends on: 855492
Comment 7•12 years ago
|
||
An alternative might be to make the gstreamer implementation an XPCOM component, link gstreamer normally to it, and then gracefully handle the failure to load the XPCOM component.
Comment 8•12 years ago
|
||
What is the advantage of doing that?
Comment 9•12 years ago
|
||
Instead of the whole patch you have there, the load handling is simply an |if (!component) return;|
The patch hardcodes the functions needed. I assume if new functions are needed, they need to be explicitly added to the list. That's not exactly nice.
Comment 10•12 years ago
|
||
Essentially, this is what XPCOM is for: dynamically adding libraries.
Assignee | ||
Comment 11•12 years ago
|
||
/me starts reading XPCOM manual
Comment 12•12 years ago
|
||
Basically:
* Continue to link gstreamer statically to content/media/gstreamer/
* Make content/media/gstreamer/ a proper XPCOM component (instead of a statically linked lib)
* The API will be the same functions as in DecoderTraits, just as IDL.
* Do the same for the other platform implementations
* Change the implementation of DecoderTraits to
* attempt to load the platform implementations
* if the load succeeds, store the reference to the component in the DecoderTraits class
* the functions in the DecoderTraits class call the above implementation API
Granted, that would be a larger change. I had thought that gstreamer implementation and DecoderTraits was already using XPCOM. I'd definitely recommend it in the mid term, because that's what XPCOM is for - dynamically plug in implementations, and handle the lack of them.
Comment 13•12 years ago
|
||
I've asked roc for comment, whether he thinks that's a good idea or not.
We should not use XPCOM here. XPCOM requires IDL and a lot of other goop that we don't want.
(In reply to Ben Bucksch (:BenB) from comment #9)
> Instead of the whole patch you have there, the load handling is simply an
> |if (!component) return;|
No it's not, because you need to write all the extra code to create the XPCOM component.
> The patch hardcodes the functions needed. I assume if new functions are
> needed, they need to be explicitly added to the list. That's not exactly
> nice.
With XPCOM you need to add them to the IDL and the component. It's not better. In fact it's worse, because you have the extra IDL layer and you have to write your interfaces using the horrible XPCOM conventions (everything returns nsresult, etc).
XPCOM should basically never be used.
Comment 15•12 years ago
|
||
OK, nevermind, then.
Comment 16•12 years ago
|
||
Comment on attachment 734464 [details] [diff] [review]
Patch Numero Dos
Review of attachment 734464 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/gstreamer/GStreamerLoader.cpp
@@ +37,5 @@
> + return true;
> + }
> +
> + void *handles[] = {
> + dlopen("libgstreamer-0.10.so", RTLD_NOW | RTLD_LOCAL),
That's not going to work unless the -dev packages are installed on the user machine. You need libgstreamer-0.10.so.0. You may also want to add libgstreamer-1.0.so.0, provided the APIs we use are compatible. Likewise for the other libs.
(BTW, an XPCOM component wouldn't allow to depend on multiple versions of gstreamer)
Assignee | ||
Comment 17•12 years ago
|
||
I wasn't aware of that convention. Will change.
gstreamer 1.0 is unfortunately not ABI compatible. We can sort that out at a later time though. Just want to get this out the door first.
Comment 18•12 years ago
|
||
Edwin, have you tried to make this work on Mac? At the very least on mac it should change the shlib suffix to .dylib.
Also, have you considered making the gst backend a MPAPI plugin? I think MPAPI plugins are dlopened, so maybe we could keep linking to gst and let firefox handle the failure at loading the plugin if it can't resolve gst symbols.
Assignee | ||
Comment 19•12 years ago
|
||
(In reply to Alessandro Decina from comment #18)
> Edwin, have you tried to make this work on Mac? At the very least on mac it
> should change the shlib suffix to .dylib.
Will do.
> Also, have you considered making the gst backend a MPAPI plugin? I think
> MPAPI plugins are dlopened, so maybe we could keep linking to gst and let
> firefox handle the failure at loading the plugin if it can't resolve gst
> symbols.
Yes, I've considered that, but for now this is the `patch of least resistance'. There is not much reason to switch it to MPAPI until uptake of GStreamer 1.0 (to the exclusion of 0.10) starts (and therefore we have to deal with proper fragmentation). Of course, I'm not sure what kind of time frame that would imply...
Assignee | ||
Comment 20•12 years ago
|
||
On Mac we're going to include gstreamer as part of the build and statically link against that, so this patch keeps the current behaviour as it is on that platform.
Attachment #734464 -
Attachment is obsolete: true
Attachment #734464 -
Flags: review?(alessandro.d)
Attachment #744332 -
Flags: review?(alessandro.d)
Comment 21•12 years ago
|
||
Doesn't seem to compile for me on mac using clang:
$ clang -v
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
0:00.19 /usr/bin/make -C content/media/gstreamer -j8 -s
0:00.30 GStreamerLoader.cpp
0:00.58 In file included from /Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerLoader.cpp:117:
0:00.58 [1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerFunctionList.h:9:10: [0m[0;1;31merror: [0m[1mredefinition of 'gst_app_sink_get_type'[0m
0:00.58 GST_FUNC(gst_app_sink_get_type)
0:00.58 [0;1;32m ^
0:00.58 [0m[1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerLoader.cpp:115:40: [0m[0;1;30mnote: [0mexpanded from macro 'GST_FUNC'[0m
0:00.58 #define GST_FUNC(func) typeof(::func)* func;
0:00.58 [0;1;32m ^
0:00.58 [0m[1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerFunctionList.h:9:10: [0m[0;1;30mnote: [0mprevious definition is here[0m
0:00.58 GST_FUNC(gst_app_sink_get_type)
0:00.58 [0;1;32m ^
0:00.58 [0m[1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerLoader.cpp:17:40: [0m[0;1;30mnote: [0mexpanded from macro 'GST_FUNC'[0m
0:00.58 #define GST_FUNC(func) typeof(::func)* func;
0:00.58 [0;1;32m ^
0:00.58 [0mIn file included from /Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerLoader.cpp:117:
0:00.58 [1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerFunctionList.h:10:10: [0m[0;1;31merror: [0m[1mredefinition of 'gst_app_sink_pull_buffer'[0m
0:00.58 GST_FUNC(gst_app_sink_pull_buffer)
0:00.58 [0;1;32m ^
0:00.58 [0m[1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerLoader.cpp:115:40: [0m[0;1;30mnote: [0mexpanded from macro 'GST_FUNC'[0m
0:00.58 #define GST_FUNC(func) typeof(::func)* func;
0:00.58 [0;1;32m ^
0:00.58 [0m[1m/Users/alessandro/src/git/mozilla-central/content/media/gstreamer/GStreamerFunctionList.h:10:10: [0m[0;1;30mnote: [0mprevious definition is here[0m
0:00.58 GST_FUNC(gst_app_sink_pull_buffer)
[snip]
Assignee | ||
Comment 22•12 years ago
|
||
Sigh. I must have put up the patch from the wrong computer. I'll put up the right one when I'm in the office next.
Assignee | ||
Comment 23•12 years ago
|
||
Seems to be the correct patch. Builds fine for me on OSX 8 with clang 4.1.
Comment 24•12 years ago
|
||
(In reply to Edwin Flores [:eflores] [:edwin] from comment #23)
> Seems to be the correct patch. Builds fine for me on OSX 8 with clang 4.1.
You're right, I must have done something wrong fixing local conflicts when I tried the last time. The code looks ok and I can confirm it works on mac.
I don't have a linux box to test this though. Is gst deployed on the mozilla infrastructure yet?
Assignee | ||
Comment 25•12 years ago
|
||
(In reply to Alessandro Decina from comment #24)
> I don't have a linux box to test this though. Is gst deployed on the mozilla
> infrastructure yet?
Yes, we now have the gstreamer-devel packages on our try servers. Unfortunately, centos lags quite a bit so it's only 0.10.29. There are a couple of things that the gstreamer backend uses that aren't in 0.10.29, so I'll have to take a look at fixing those things before we can look at landing this. Sigh.
Comment 26•12 years ago
|
||
(In reply to Edwin Flores [:eflores] [:edwin] from comment #25)
> (In reply to Alessandro Decina from comment #24)
> > I don't have a linux box to test this though. Is gst deployed on the mozilla
> > infrastructure yet?
>
> Yes, we now have the gstreamer-devel packages on our try servers.
> Unfortunately, centos lags quite a bit so it's only 0.10.29. There are a
> couple of things that the gstreamer backend uses that aren't in 0.10.29, so
> I'll have to take a look at fixing those things before we can look at
> landing this. Sigh.
Ah... do you already know what those are?
Assignee | ||
Comment 27•12 years ago
|
||
(In reply to Alessandro Decina from comment #26)
> Ah... do you already know what those are?
gst_buffer_get_qdata
gst_buffer_set_qdata
gst_element_factory_list_filter
gst_element_factory_list_get_elements
gst_structure_take_value
Comment 28•12 years ago
|
||
I think https://bugzilla.mozilla.org/show_bug.cgi?id=856308 took care of take_value and get and set _qdata.
Doing without the factory list API will be annoying though :/
Assignee | ||
Comment 29•12 years ago
|
||
That landed a while ago; looks like it might have missed a couple of things, or just wasn't working with anything that old.
I've asked whether we can get non-centos packages on the build boxes in the hope that we can get a more modern gstreamer to work with; we should have an answer in the next day.
Comment 30•12 years ago
|
||
Comment on attachment 744332 [details] [diff] [review]
Patch v3
Review of attachment 744332 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/gstreamer/GStreamerLoader.cpp
@@ +44,5 @@
> + dlopen("libgstreamer-0.10.so.0", RTLD_NOW | RTLD_LOCAL),
> + dlopen("libgstapp-0.10.so.0", RTLD_NOW | RTLD_LOCAL),
> + dlopen("libgstbase-0.10.so.0", RTLD_NOW | RTLD_LOCAL),
> + dlopen("libgstvideo-0.10.so.0", RTLD_NOW | RTLD_LOCAL)
> + };
Before doing that, you should try to get dlsym(RTLD_DEFAULT, "gst_version"). That will return a pointer if gstreamer is already loaded because it is a dependency of something else we're loading. You don't want to dlopen if gstreamer is already loaded. And if it's not the right version, you don't want to use it either.
@@ +54,5 @@
> + }
> +
> +#define GST_FUNC(symbol) \
> + for (size_t i = 0; i < sizeof(handles) / sizeof (handles[0]); i++) { \
> + symbol = (typeof(symbol))dlsym(handles[i], #symbol); \
It would be better to directly load symbols from the right handle instead of enumerating.
Attachment #744332 -
Flags: feedback-
Assignee | ||
Comment 31•12 years ago
|
||
(In reply to Alessandro Decina from comment #28)
> I think https://bugzilla.mozilla.org/show_bug.cgi?id=856308 took care of
> take_value and get and set _qdata.
Oops, looks like you're right about these.
Assignee | ||
Comment 32•11 years ago
|
||
(In reply to Mike Hommey (high latency until June 25) [:glandium] from comment #30)
> It would be better to directly load symbols from the right handle instead of
> enumerating.
Seems like a lot more ugliness in some already pretty ugly code to save an insignificant amount of time in a function that will only ever be run once per instance of the browser.
Assignee | ||
Comment 33•11 years ago
|
||
Attachment #744332 -
Attachment is obsolete: true
Attachment #744332 -
Flags: review?(alessandro.d)
Attachment #757800 -
Flags: review?(alessandro.d)
Attachment #757800 -
Flags: feedback?(mh+mozilla)
Comment 34•11 years ago
|
||
(In reply to Edwin Flores [:eflores] [:edwin] from comment #32)
> (In reply to Mike Hommey (high latency until June 25) [:glandium] from
> comment #30)
> > It would be better to directly load symbols from the right handle instead of
> > enumerating.
>
> Seems like a lot more ugliness in some already pretty ugly code to save an
> insignificant amount of time in a function that will only ever be run once
> per instance of the browser.
That's not really uglier:
#define LIBGSTREAMER 0
#define LIBGSTAPP 1
#define LIBGSTVIDEO 2
GST_FUNC(LIBGSTAPP, gst_app_sink_get_type)
(...)
#define GST_FUNC(lib, symbol) do { symbol = dlsym(handles[lib], #symbol); } while(0);
Comment 35•11 years ago
|
||
Comment on attachment 757800 [details] [diff] [review]
Patch v4
Review of attachment 757800 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/gstreamer/GStreamerLoader.cpp
@@ +89,5 @@
> +fail:
> +
> + for (size_t i = 0; i < sizeof(handles) / sizeof(handles[0]); i++) {
> + if (handles[i]) {
> + dlclose(handles[i]);
You probably don't want to dlclose(RTLD_DEFAULT)
Attachment #757800 -
Flags: feedback?(mh+mozilla)
Assignee | ||
Comment 36•11 years ago
|
||
Addressed comment 34 and comment 35.
Attachment #757800 -
Attachment is obsolete: true
Attachment #757800 -
Flags: review?(alessandro.d)
Attachment #758829 -
Flags: review?(alessandro.d)
Comment 37•11 years ago
|
||
Comment on attachment 758829 [details] [diff] [review]
Patch v5
Review of attachment 758829 [details] [diff] [review]:
-----------------------------------------------------------------
r+, with again the only reserve that i'm only able to test this on mac
Attachment #758829 -
Flags: review?(alessandro.d) → review+
Assignee | ||
Comment 38•11 years ago
|
||
Comment 39•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in
before you can comment on or make changes to this bug.
Description
•