Hi,
august wrote:
> I just want to load plugins to encode video/audio. How do I do that?
> It is not obvious to me from the code.
>
> I can see that bg_search_file_read gets a file path. But, I don't
> know what is supposed to be in "config.xml" or why I even bother loading
> it?
Of course it only makes sense if you saved the registry before.
The first time a program is started, bg_search_file_read() returns NULL,
but if the program exits, it will save the registry for later usage.
> Do I even need to do this step?
In theory not, but then the registry is built by dlopen()ing the
each module, which takes some time.
>> You can use any other path for this of course.
>>
>>>> 2. Create a plugin registry
>>> I see I am supposed to do something like:
>>> section = bg_cfg_registry_find_section(config_reg, "plugins");
>>> plug_reg = bg_plugin_registry_create(section);
>>>
>>> what is a bg_cfg_section_t ?
>> A section is a like a "directory" in the config registry. It can contain
>> parameters (name-value pairs) and subsections.
>> In all my applications I have a section "plugins". It contains
>> one subsection for each plugin.
>
>
> what is a config registry?
It's a data structure, which stores the complete configuration of an
application. As I said before, the data is split into sections.
Each gmerlin module (plugins and internal things) has a corresponding
bg_cfg_section_t.
My configuration system needs some work to get it running (create and load
the registry etc). But inside the plugins, it becomes extremely simple.
Plugins *only* need to tell, which parameters they support and provide
a set_parameter() function. Everything else (storing parameters, restoring
saved values etc.) is done by the core.
>> Passing the "plugins" section to the plugin registry has the advantage,
>
> What is a plugin registry? How does it get built?
The plugin registry is a data stucture which stores information about all
available gmerlin plugins. It caches the necessary information about
each plugin along with the file modification time of the .so files, so
the program doesn't have to dlopen() all the modules at each start.
In theory you can use plugins directly by dlopening the modules, but then
you have to take care about many things. That's why I have the registry,
which does all that for me.
> Where do I find the encoders registry?
See below how to find the encoder plugins from the registry.
> I will try to cobble together a simple tutorial or something if that
> helps. But, first I need to understand what these things do. I
> cannot find any sort of overview anywhere. Can you explain a little
> more, or point me to where I can read about it?
>
>
>> Once you created a plugin registry, you can get the available encoders
>> with:
>>
>> const bg_plugin_info_t * info;
>>
>> int num =
>> bg_plugin_registry_get_num_plugins(plugin_reg,
>> BG_PLUGIN_ENCODER_AUDIO |
>> BG_PLUGIN_ENCODER_VIDEO |
>> BG_PLUGIN_ENCODER,
>> BG_PLUGIN_FILE);
>>
>> for(i = 0; i < num; i++)
>> {
>> info = bg_plugin_find_by_index(plugin_reg, i,
>> BG_PLUGIN_ENCODER_AUDIO |
>> BG_PLUGIN_ENCODER_VIDEO |
>> BG_PLUGIN_ENCODER,
>> BG_PLUGIN_FILE);
>> }
>
>
> This starts to make a little sense, but I am still blurry on how to make
> the plugin_reg.
>
> I assume from the bg_plugin_info_t, I can see if it is "ogg/theora" or
> "x264", etc? No?
Yes, the plugin info has "name" and "long_name" fields.
name is for internal use, long_name is for human use and is translatable.
The actual loading happens then with bg_plugin_load(). It returns a handle,
which corresponds to an instance of the plugin. For an encoder, this step will
look like:
bg_plugin_handle_t * h;
bg_encoder_plugin_t * plugin; // Contains function pointers for encoding
h = bg_plugin_load(plugin_reg, info);
/* h->plugin is of type bg_plugin_common_t, so we must cast it */
plugin = (bg_encoder_plugin_t*)(h->plugin);
Then you can call the encoding functions with h->priv as first argument.
Burkhard
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Gmerlin-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gmerlin-general