Skip to content

Remove global static non const variables #767

@pabuhler

Description

@pabuhler

Currently there are sever global static variables that can make using libsrtp from multiple sub projects problematic. All non const variables should be removed.

Current known ones include crypto_kernel, srtp_event_handler, srtp_err_report_handler & debug modules.
There are two options for removing them:

  1. Add them all as members of srtp_t so they are created and managed per srtp_t.
  2. Add them to a new libsrtp_t that can be then shared between a select number of srtp_t.

The first option is nice in that it cleans up the API, there will no longer need to be srtp_int() / srtp_shutdown(). The downside is that there will be duplication and a crypto kernel will effectively be initialized for each srtp_t created. The initialization may not be too expensive but the self test are. To prevent some of the over head the self test can be initially disabled and a explicit srtp_self_test() can be used if validation is required.

The second option requires there to be a new layer to the API that must be call before each srtp_t is created and requires the application to manage the libsrtp_t. It has the benefit of only needing to initialize and self test the crypto kernel once.

There is maybe a third options that combines the two, where it is either possible to create a libsrtp_t that can be shared with by many srtp_t's or a srtp_t can create it's own libsrtp_t if one was not provided.

The initial proposal is to go with option 1, removing the need for srtp_init() / srtp_shutdown(). The self test will be disabled by default but a srtp_verify_self() will be added.

The event handler can easily be moved to srtp_t. The debugging is less critical but it should be possible to also move it to a srtp_t.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions