a-mediastreamer2  5.2.0

Initialize mediastreamer2

When using mediastreamer2, your first task is to initialize the library:

~~~~~~~{.c} #include <mediastreamer2/mscommon.h>

int i;

i=ms_init(); if (i!=0) return -1; ~~~~~~

Mediastreamer2 provides internal components which are called filters. Those filters must be linked together so that OUTPUT from one filter is sent to INPUT of the other filters.

Usually, filters are used for processing audio or video data. They could capture data, play/draw data, encode/decode data, mix data (conference), transform data (echo canceller). One of the most important filter is the RTP filters that are able to send and receive RTP data.

Graph sample

If you are using mediastreamer2, you probably want to do Voice Over IP and get a graph providing a 2 way communication. This 2 graphs are very simple:

This first graph shows the filters needed to capture data from a sound card, encode them and send it through an RTP session.

             AUDIO    ->    ENCODER   ->   RTP
            CAPTURE   ->              ->  SENDER

This second graph shows the filters needed to receive data from an RTP session decode it and send it to the playback device.

        RTP      ->    DECODER   ->   DTMF       ->   AUDIO
       RECEIVER  ->              ->  GENERATION  ->  PLAYBACK

Code to initiate the filters of the Graph sample

Note that the NULL/error checks are not done for better reading. To build the graph, you'll need some information: you need to select the sound card and of course have an RTP session created with oRTP.

~~~~~~~{.c} MSSndCard *sndcard; sndcard=ms_snd_card_manager_get_default_card(ms_snd_card_manager_get());

/* audio capture filter