UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
pdb.h File Reference
#include "tv.h"
Include dependency graph for pdb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pdb_e
 

Typedefs

typedef void(* decoder_state_deleter_t) (void *)
 
typedef void * pdb_iter_t
 

Functions

int pdb_add (struct pdb *db, uint32_t ssrc)
 
void pdb_destroy (struct pdb **db)
 
void pdb_destroy_item (struct pdb_e *item)
 
struct pdb_e * pdb_get (struct pdb *db, uint32_t ssrc)
 
struct pdb * pdb_init (volatile int *delay_ms)
 
void pdb_iter_done (pdb_iter_t *it)
 
struct pdb_e * pdb_iter_init (struct pdb *db, pdb_iter_t *it)
 
struct pdb_e * pdb_iter_next (pdb_iter_t *it)
 
int pdb_remove (struct pdb *db, uint32_t ssrc, struct pdb_e **item)
 

Typedef Documentation

◆ decoder_state_deleter_t

typedef void(* decoder_state_deleter_t) (void *)

Deletes decoder for participant when the participant is deleted

Definition at line 70 of file pdb.h.

◆ pdb_iter_t

typedef void* pdb_iter_t

Definition at line 106 of file pdb.h.

Function Documentation

◆ pdb_add()

int pdb_add ( struct pdb * db,
uint32_t ssrc )

Definition at line 299 of file pdb.c.

300{
301 /* Add an item to the participant database, indexed by ssrc. */
302 /* Returns 0 on success, 1 if the participant is already in */
303 /* the database, 2 for other failures. */
304 pdb_node_t *x;
305 struct pdb_e *i;
306
307 pdb_validate(db);
308 x = pdb_search(db->root, ssrc);
309 if (x != NULL) {
310 debug_msg("Item already exists - ssrc %x\n", ssrc);
311 return 1;
312 }
313
314 i = pdb_create_item(ssrc, db->delay_ms);
315 if (i == NULL) {
316 debug_msg("Unable to create database entry - ssrc %x\n", ssrc);
317 return 2;
318 }
319
320 x = (pdb_node_t *) malloc(sizeof(pdb_node_t));
321 x->key = ssrc;
322 x->data = i;
323 x->parent = NULL;
324 x->left = NULL;
325 x->right = NULL;
327 pdb_insert_node(db, x);
328 debug_msg("Added participant %x\n", ssrc);
329 return 0;
330}
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
Definition debug.h:92
static struct pdb_e * pdb_create_item(uint32_t ssrc, volatile int *delay_ms)
Definition pdb.c:277
#define BTREE_NODE_MAGIC
Definition pdb.c:96
static void pdb_validate(struct pdb *t)
Definition pdb.c:119
static pdb_node_t * pdb_search(pdb_node_t *x, uint32_t key)
Definition pdb.c:163
static void pdb_insert_node(struct pdb *tree, pdb_node_t *z)
Definition pdb.c:175
Definition pdb.h:72
uint32_t ssrc
Definition pdb.h:73
volatile int * delay_ms
Definition pdb.c:88
pdb_node_t * root
Definition pdb.c:85
struct s_pdb_node * left
Definition pdb.c:79
uint32_t key
Definition pdb.c:76
struct s_pdb_node * parent
Definition pdb.c:78
struct s_pdb_node * right
Definition pdb.c:80
void * data
Definition pdb.c:77
uint32_t magic
Definition pdb.c:81

References BTREE_NODE_MAGIC, s_pdb_node::data, debug_msg, pdb::delay_ms, s_pdb_node::key, s_pdb_node::left, s_pdb_node::magic, s_pdb_node::parent, pdb_create_item(), pdb_insert_node(), pdb_search(), pdb_validate(), s_pdb_node::right, pdb::root, and pdb_e::ssrc.

Referenced by initialize_audio_network(), rtp_video_rxtx::initialize_network(), process_sdes(), rtp_recv_callback(), and vidcap_rtsp_init().

Here is the call graph for this function:

◆ pdb_destroy()

void pdb_destroy ( struct pdb ** db)

Definition at line 256 of file pdb.c.

257{
258 struct pdb *db = *db_p;
259
260 pdb_validate(db);
261 if (db->root != NULL) {
262 pdb_iter_t it;
263 struct pdb_e *cp = pdb_iter_init(db, &it);
264 while (cp != NULL) {
265 struct pdb_e *item = NULL;
266 pdb_remove(db, cp->ssrc, &item);
267 cp = pdb_iter_next(&it);
269 }
270 pdb_iter_done(&it);
271 }
272
273 free(db);
274 *db_p = NULL;
275}
void pdb_iter_done(pdb_iter_t *it)
Definition pdb.c:412
struct pdb_e * pdb_iter_next(pdb_iter_t *it)
Definition pdb.c:402
struct pdb_e * pdb_iter_init(struct pdb *db, pdb_iter_t *it)
Definition pdb.c:393
void pdb_destroy_item(struct pdb_e *item)
Definition pdb.c:370
int pdb_remove(struct pdb *db, uint32_t ssrc, struct pdb_e **item)
Definition pdb.c:346
void * pdb_iter_t
Definition pdb.h:106
Definition hd-rum.c:27
Definition pdb.c:84

References pdb_destroy_item(), pdb_iter_done(), pdb_iter_init(), pdb_iter_next(), pdb_remove(), pdb_validate(), pdb::root, and pdb_e::ssrc.

Referenced by rtp_video_rxtx::~rtp_video_rxtx(), audio_done(), and audio_init().

Here is the call graph for this function:

◆ pdb_destroy_item()

void pdb_destroy_item ( struct pdb_e * item)

Definition at line 370 of file pdb.c.

371{
372 if (item) {
373 free(item->sdes_cname);
374 free(item->sdes_name);
375 free(item->sdes_email);
376 free(item->sdes_phone);
377 free(item->sdes_loc);
378 free(item->sdes_tool);
379 free(item->sdes_note);
380 if (item->decoder_state_deleter && item->decoder_state) {
381 item->decoder_state_deleter(item->decoder_state);
382 }
383 pbuf_destroy(item->playout_buffer);
384 tfrc_done(item->tfrc_state);
385 free(item);
386 }
387}
void pbuf_destroy(struct pbuf *playout_buf)
Definition pbuf.c:195
void tfrc_done(struct tfrc *state)
Definition tfrc.c:415

References pbuf_destroy(), and tfrc_done().

Referenced by pdb_destroy(), and rtp_recv_callback().

Here is the call graph for this function:

◆ pdb_get()

struct pdb_e * pdb_get ( struct pdb * db,
uint32_t ssrc )

Definition at line 332 of file pdb.c.

333{
334 /* Return a pointer to the item indexed by ssrc, or NULL if */
335 /* the item is not present in the database. */
336 pdb_node_t *x;
337
338 pdb_validate(db);
339 x = pdb_search(db->root, ssrc);
340 if (x != NULL) {
341 return x->data;
342 }
343 return NULL;
344}

References s_pdb_node::data, pdb_search(), pdb_validate(), pdb::root, and pdb_e::ssrc.

Referenced by process_sdes(), and rtp_recv_callback().

Here is the call graph for this function:

◆ pdb_init()

struct pdb * pdb_init ( volatile int * delay_ms)
Parameters
delay_msdelay to be added to playback. Main reason is to give user a possibility to sync audio and video.

Definition at line 244 of file pdb.c.

245{
246 struct pdb *db = malloc(sizeof(struct pdb));
247 if (db != NULL) {
248 db->magic = PDB_MAGIC;
249 db->count = 0;
250 db->root = NULL;
251 db->delay_ms = delay_ms;
252 }
253 return db;
254}
#define PDB_MAGIC
Definition pdb.c:72
int count
Definition pdb.c:87
uint32_t magic
Definition pdb.c:86

References pdb::count, pdb::delay_ms, pdb::magic, PDB_MAGIC, and pdb::root.

Referenced by rtp_video_rxtx::rtp_video_rxtx(), audio_init(), and vidcap_rtsp_init().

◆ pdb_iter_done()

◆ pdb_iter_init()

struct pdb_e * pdb_iter_init ( struct pdb * db,
pdb_iter_t * it )

Definition at line 393 of file pdb.c.

394{
395 if (db->root == NULL) {
396 return NULL; /* The database is empty */
397 }
398 *it = (pdb_node_t *) pdb_min(db->root);
399 return ((pdb_node_t *) *it)->data;
400}
static pdb_node_t * pdb_min(pdb_node_t *x)
Definition pdb.c:135

References s_pdb_node::data, pdb_min(), and pdb::root.

Referenced by audio_receiver_process_message(), audio_receiver_thread(), pdb_destroy(), ultragrid_rtp_video_rxtx::receiver_loop(), ultragrid_rtp_video_rxtx::receiver_process_messages(), ultragrid_rtp_video_rxtx::remove_display_from_decoders(), and vidcap_rtsp_thread().

Here is the call graph for this function:

◆ pdb_iter_next()

struct pdb_e * pdb_iter_next ( pdb_iter_t * it)

Definition at line 402 of file pdb.c.

403{
404 assert(*it != NULL);
405 *it = (pdb_node_t *)pdb_successor((pdb_node_t *)*it);
406 if (*it == NULL) {
407 return NULL;
408 }
409 return ((pdb_node_t *) *it)->data;
410}
static pdb_node_t * pdb_successor(pdb_node_t *x)
Definition pdb.c:146

References s_pdb_node::data, and pdb_successor().

Referenced by audio_receiver_process_message(), audio_receiver_thread(), pdb_destroy(), ultragrid_rtp_video_rxtx::receiver_loop(), ultragrid_rtp_video_rxtx::receiver_process_messages(), ultragrid_rtp_video_rxtx::remove_display_from_decoders(), and vidcap_rtsp_thread().

Here is the call graph for this function:

◆ pdb_remove()

int pdb_remove ( struct pdb * db,
uint32_t ssrc,
struct pdb_e ** item )

Definition at line 346 of file pdb.c.

347{
348 /* Remove the item indexed by ssrc. Return zero on success. */
349 pdb_node_t *x;
350
351 pdb_validate(db);
352 x = pdb_search(db->root, ssrc);
353 if (x == NULL) {
354 debug_msg("Item not on tree - ssrc %ul\n", ssrc);
355 *item = NULL;
356 return 1;
357 }
358
359 /* Note value that gets freed is not necessarily the the same as node
360 * that gets removed from tree since there is an optimization to avoid
361 * pointer updates in tree which means sometimes we just copy key and
362 * data from one node to another.
363 */
364 *item = x->data;
365 x = pdb_delete_node(db, x);
366 free(x);
367 return 0;
368}
static pdb_node_t * pdb_delete_node(struct pdb *tree, pdb_node_t *z)
Definition pdb.c:204

References s_pdb_node::data, debug_msg, pdb_delete_node(), pdb_search(), pdb_validate(), pdb::root, and pdb_e::ssrc.

Referenced by pdb_destroy(), and rtp_recv_callback().

Here is the call graph for this function: