Hi,
august wrote
>> Setting the parameters is easy: First set the "codec" parameter (codec
>> name as string).
>> Then, set all parameters for that codec.
>
> how do you set a codec parameter?
First you add the stream:
int index = plugin->add_audio_stream(handle->priv, ...);
then you set parameters:
plugin->set_audio_parameter(handle->priv, index, ...); // See example below
Note that these are *per stream* parameters. In the ffmpeg case,
they are just the *codec* and it's parameters. But one should expect
the stream parameters to be arbitrary.
>> Also important is the following: plugins or other modules *never* set
>> their parameters
>> to defaults automatically. They just tell the defaults they like via
>> val_default.
>> For the general plugin parameters, the plugin registry takes care of it.
>> For the per stream
>> parameters (set_[audio|video]_parameter()), you have to do it.
>
> How do I do that?
See below
> ok...I now have a simple print function to print out params:
>
> void print_params( const bg_parameter_info_t * params ) {
> int i = 0;
> int j =0;
^^
Not neccessary
> if (params[i].type == BG_PARAMETER_MULTI_MENU) {
> while(params[i].name ) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The above 2 lines must be swapped. This probably causes the crash.
> //printf("param name: %s longname:%s \n",
> params[i].name, params[i].long_name, params[i].opt,
> params[i].help_string);
> printf("param name: %s \n", params[i].name);
> j = 0;
>
> while(params[i].multi_names[j] &&
> params[i].multi_labels[j]) {
> printf("\tparam
> multi_name: %s ",
> params[i].multi_names[j]);
> printf("\tparam
> multi_label:
> %s \n",
> params[i].multi_labels[j]);
>
> j++;
> }
>
> i++;
> }
> }
> }
>
>
> I then do :
>
>
> if( plugin->max_audio_streams ) {
> audio_params = plugin->get_audio_parameters(h->priv);
> print_params( audio_params);
> }
>
> if (plugin->max_video_streams ) {
> video_params = plugin->get_video_parameters(h->priv);
> print_params(video_params);
> }
The above looks ok.
>
>
> It then crashes with a segfault on default_timescale. Why?
The loop in print_parameters() is wrong (see above).
>
> I can now print out audio and video parameters (except for crash). I
> still cannot figure out how to set parameters. What is
> multi_parameters?
> The doc says "Parameters for each option." But, it does not say to
> which options it is referring.
In the special case of codecs, multi_parameters[i][j] is the
j'th parameter for the i'th codec.
> Also, I can't find where to get_container_parameters() to set the
> container format?
> How do I set, for example, container:AVI ACODEC:ac3 and VCODEC:mp4 ?
These are in the general plugin parameters, you get with get_parameters()
and set with set_parameter().
Again, in the ffmpeg case they allow you to set the container, but
for other plugins, you should expect arbitrary parameters.
I have problems with the terms "codec parameters" and
"container parameters": E.g. for the lame plugin the container and codec
are always the same, so you can configure neither of them. But the lame
plugin still has plenty of parameters :)
> What is the general method here? As a novice, I expect to be able to
> query for available plugins,
bg_plugin_registry_get_num_plugins(...);
bg_plugin_find_by_index(...);
> and then query for the plugin type, and
> then query the plugin type for what I can set on it.
bg_plugin_info_t
> I kind of see
> this is what is going on here, but all of the names and placement of
> functions seems cryptic to me. Can you help me out here?
As I said, there are 2 classes of parameters:
1) Parameters for the whole plugin instance: For some encoders, you
can set the container format here. These are handled through
get_parameters() and set_parameter(). These parameters are available
for *all* types of plugins. For encoders, these parameters must be set
*before* the open() method is called.
2) Per stream parameters. These are supported only in encoders. For some
encoding plugins, you set the codec and codec specific parameters.
Codec parameters are set *after* the stream was added and *before* the
start() method is called. The stream parameters are set with
set_[audio|video]_parameter() and need the *stream index* as additional
argument.
The per-stream parameters are such, that you can e.g. encode 2 audio
streams with different codecs and/or different bitrates. Other APIs
cannot do that at all.
Parameter setting happens like:
bg_parameter_value_t val;
/* Set an int parameter "foo" to 123 */
val.val_i = 123;
plugin->set_parameter(priv, "foo", &val);
/* Set a string parameter "bar" to "blubb" */
val.val_str = "blubb";
plugin->set_parameter(priv, "bar", &val);
/* Set the default value from a parameter info: */
bg_parameter_info_t * param;
plugin->set_parameter(priv, param->name, ¶m->val_default);
One last thing (don't know if that's documented anywhere):
After setting all parameters, you *must* do a terminating call to
set_parameter():
plugin->set_parameter(priv, NULL, NULL);
That's for the plugin to know, that all parameters have sensible
values now.
Hope that brings you further.
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