We study the Mediastreamer2 VoIP engine. Part 12

Article material taken from my zen channel .



In the last article , I promised to consider the issue of estimating the load on the ticker and ways to deal with excessive computing load in the media streamer. But I decided that it would be more logical to cover the debugging issues of craft filters associated with moving data and only then consider performance optimization issues.


Debugging craft filters


After we examined the mechanism for moving data in a media streamer in a previous article, it would be logical to talk about the dangers lurking in it. One of the features of the "data flow" principle is that the allocation of memory from the heap occurs in the filters that are located at the source of the data stream, and the filters located at the end of the stream path make the memory free and return to the heap. In addition, the creation of new data and its destruction can occur somewhere at intermediate points. In the general case, freeing the memory is performed by the wrong filter that created the data block.


, , , , . β€” , . , , β€” / .


, , ( ). "" "" . , . . "" , MS_TEE , . , : ms_free(). , , .. "". ( ) .


"" , . β€” . , . , , , "" , .


?


, top , .


, - , . , . , , ..


( ). Valgrind ( ) gcc MemorySanitizer - . , , .



, , . "" , , , . , , .


"" , , .


, . , .



. .



, F1...F4, , . , . , , N- . , MS_VOID_SOURCE. β€” . . .. .


, , , , "" , , . . , , . β€” , . - .


voidsourse:


, , , . , ( ). , . , , , "" . , . "" , . ( ). "" , .


-


. :


/*  iso_filter.h    . */

#ifndef iso_filter_h
#define iso_filter_h

/*   . */
#include <mediastreamer2/msfilter.h>

#define MY_ISO_FILTER_ID 1024

extern MSFilterDesc iso_filter_desc;

#endif

:


/*  iso_filter.c    . */

#include "iso_filter.h"

    static void
iso_init (MSFilter * f)
{
}
    static void
iso_uninit (MSFilter * f)
{
}

    static void
iso_process (MSFilter * f)
{
    mblk_t *im;

    while ((im = ms_queue_get (f->inputs[0])) != NULL)
    {
        ms_queue_put (f->outputs[0], copymsg (im));
        freemsg (im);
    }
}

static MSFilterMethod iso_methods[] = {
    {0, NULL}
};

MSFilterDesc iso_filter_desc = {
    MY_ISO_FILTER_ID,
    "iso_filter",
    "A filter that reads from input and copy to its output.",
    MS_FILTER_OTHER,
    NULL,
    1,
    1,
    iso_init,
    NULL,
    iso_process,
    NULL,
    iso_uninit,
    iso_methods
};

MS_FILTER_DESC_EXPORT (iso_desc)


, , ", ". . :


OrtpMemoryFunctions reserv;
OrtpMemoryFunctions my;

reserv.malloc_fun = ortp_malloc;
reserv.realloc_fun = ortp_realloc;
reserv.free_fun = ortp_free;

my.malloc_fun = &my_malloc;
my.realloc_fun = &my_realloc;
my.free_fun = &my_free;

ortp_set_memory_functions(&my);

, , . .


, . , , .


In the next article, we will consider the issue of estimating the load on the ticker and ways to deal with excessive computing load in the media streamer.


All Articles