Hi,

august wrote
>
>> You pass the plugin registry because the encoder needs to load plugins.
>> The section however will be *not* the same section you pass to the
>> plugin registry in bg_plugin_registry_create(). See below.
>
>
>> Then you need to build the parameters, which describe this encoder
>> setup:
>>
>> bg_parameter_info_t * enc_parameters =
>> bg_plugin_registry_create_encoder_parameters(plugin_reg,
>>                                              stream_mask,
>>                                              plugin_mask);
>
> Is this just one set of parameters?  What ends up in there?  Is it an
> array of parameters for format/audio codec/video codec?

Look at the encoder configuration of the recorder, it's built from
the enc_parameters. It contains the menus for the encoding plugins
and several checkbuttons, where you can write audio into a separate
file etc.

>> Then you need a section, which contains the parameter values. The
>> parameter values are taken from what is saved in the config registry:
>>
>> bg_cfg_section_t * encoder_section =
>> bg_encoder_section_get_from_registry(plugin_reg,
>>                                      enc_parameters,
>>                                      stream_mask,
>>                                      plugin_mask);
>
> Ok, so I see I use the enc_parameters to get a section.  What is
> actually going on here?

It sets up the parameters for encoding. In particular it fills the
multi_names and multi_labels etc. from the actually installed plugins.

This whole thing was developed such, that the core *never* has to care,
which plugins are actually installed, so we build this stuff at runtime.

> Is the following correct?
> A registry is a collection of sections, right?

A config registry, yes.

>From include/registry_private.h:

struct bg_cfg_registry_s
  {
  bg_cfg_section_t * sections; /* Chained list of toplevel sections */
  };

> And a section is a collection of parameters?

Yes, but it can also contain subsections.

> A config registry is a collection of configuration sections/parameters,
>   right?

A config registry contains just the toplevel sections. If can't contain
parameters at the toplevel.

> A plugin registry is a collection of existing plugin sections with
> default parameters?  Or, does it contain the paramater ranges too?

It's a collection of bg_plugin_info_t's
And for each plugin it knows where to find the config section.

The parameters are in the following members of bg_plugin_info_t:

/* Per instance parameters, existing for all plugins */
bg_parameter_info_t * parameters;

/* Per stream parameters, exist only for encoders */
bg_parameter_info_t * audio_parameters;
bg_parameter_info_t * video_parameters;
bg_parameter_info_t * subtitle_text_parameters;
bg_parameter_info_t * subtitle_overlay_parameters;

The bg_parameter_info_t contains both the range (val_min, val_max, for
numeric parameters) and a default value (val_default).

> Why do I create a plugin registry from a section in the config registry
> with :
>
>       section = bg_cfg_registry_find_section(config_reg, "plugins");
>    plugin_reg = bg_plugin_registry_create(section);

Because the plugin registry calls set_parameter() with the values taken
from the config section when a plugin is loaded.

This makes sure, that all plugins loaded with bg_plugin_load() have
the internal variables set such they at least don't crash.

>
>
>
>
>
> I then go on and do as you say:
>
> const int stream_mask = BG_STREAM_AUDIO | BG_STREAM_VIDEO;
> const int plugin_mask = BG_PLUGIN_FILE  | BG_PLUGIN_BROADCAST ;

Correct
>
>
> enc_parameters = bg_plugin_registry_create_encoder_parameters(
>               plugin_reg,
>               stream_mask, plugin_mask);
>
Correct
>
> encoder_section = bg_encoder_section_get_from_registry(plugin_reg,
>               enc_parameters,
>               stream_mask,
>               plugin_mask);
Correct
>
> encoder = bg_encoder_create( plugin_reg, encoder_section, NULL,
>               stream_mask, plugin_mask);
Correct
>
> if ( bg_encoder_open( encoder, "testvideo", NULL,  NULL)) {
>
>  // What is the return value for bg_encoder_add_*_stream?
>  // is it the stream index or 0 for no errors?

The stream index. You should remember them and pass them to
the encode() functions.

>  astream = bg_encoder_add_audio_stream(encoder, NULL, &aformat, 0);
>  vstream = bg_encoder_add_video_stream(encoder, &vformat, 1);

I think the last argument for bg_encoder_add_video_stream() should
also be zero. It's only needed if streams are written to separate files.
Then they get names like testvideo_audio01.mp3, testvideo_video01.avi.

>  // at this point both astream and vstream = 0
>  //  Is that right?

Yes, stream indices are counted for audio and video separately.

>
>  bg_encoder_start(encoder);

Would be wise to check if bg_encoder_start() returns 1.
0 means error.

>  // I then get and check the in and out formats to see if they are ok
>  bg_encoder_get_audio_format(encoder, astream, &aformat_out);
>  bg_encoder_get_video_format(encoder, vstream, &vformat_out);
>
>  // I check the formats with
>  // gavl_audio_formats_equal (&aformat, &aformat_out)
>  // gavl_video_formats_equal (&vformat, &vformat_out)
>  // they are equal so I continue

If not, you can make gavl converters.

>  // create audio and video frames
>
>  aframe_out = gavl_audio_frame_create ( &aformat_out );
>  vframe_out = gavl_video_frame_create_nopad ( &vformat_out );

>  for (m=0; m < NUMBER_OF_FRAMES; m++) {
>
>          // generate audio video content with some sine waave
>
>               // then  write the data
>               bg_encoder_write_audio_frame(encoder, aframe_out, 0);
>
>               // I can write the audio frame...but the I get a segfault
>               // when I write the video frame
>               bg_encoder_write_video_frame(encoder, vframe_out, 1);
>
>  }
>
> }
>

Did you test that?

Burkhard


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Gmerlin-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gmerlin-general

Reply via email to