aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/mate/mate.h13
-rw-r--r--plugins/mate/mate_runtime.c22
-rw-r--r--plugins/mate/mate_setup.c19
-rw-r--r--plugins/mate/mate_util.c4
4 files changed, 48 insertions, 10 deletions
diff --git a/plugins/mate/mate.h b/plugins/mate/mate.h
index c7f2932d4e..c27853bd71 100644
--- a/plugins/mate/mate.h
+++ b/plugins/mate/mate.h
@@ -121,7 +121,9 @@
#define KEYWORD_NOTREE "NoTree"
#define KEYWORD_PDUTREE "PduTree"
#define KEYWORD_FRAMETREE "FrameTree"
-
+#define KEYWORD_GOPEXPIRATION "GopExpiration"
+#define KEYWORD_GOPIDLETIMEOUT "GopIdleTimeout"
+#define KEYWORD_GOPLIFETIME "GopLifetime"
#define KEYWORD_DEBUGFILENAME "Debug_File"
#define KEYWORD_DBG_GENERAL "Debug_General"
@@ -183,6 +185,7 @@ typedef struct _mate_cfg_item {
/* common to gop and gog */
+ float expiration;
int hfid_start_time;
int hfid_stop_time;
int hfid_last_time;
@@ -194,6 +197,8 @@ typedef struct _mate_cfg_item {
guint8* show_pdu_tree;
gboolean show_times;
gboolean drop_gop;
+ float idle_timeout;
+ float lifetime;
int hfid_gop_pdu;
int hfid_gop_num_pdus;
@@ -203,7 +208,6 @@ typedef struct _mate_cfg_item {
/* gog */
gboolean gop_as_subtree;
LoAL* keys;
- float expiration;
int hfid_gog_num_of_gops;
int hfid_gog_gop;
@@ -223,6 +227,9 @@ typedef struct _mate_config {
avpl_replace_mode replace_mode;
gboolean gop_as_subtree;
+ float gop_expiration;
+ float gop_idle_timeout;
+ float gop_lifetime;
guint8* accept;
guint8* reject;
@@ -307,6 +314,8 @@ struct _mate_item {
int num_of_after_release_pdus; /* how many pdus have arrived since it's been released */
guint8* gop_key; /* used by gop */
mate_pdu* last_pdu; /* last pdu in pdu's list */
+ float time_to_die;
+ float time_to_timeout;
/* } gop; */
/* struct _gog { */
diff --git a/plugins/mate/mate_runtime.c b/plugins/mate/mate_runtime.c
index be2610d52c..cdd0db22d9 100644
--- a/plugins/mate/mate_runtime.c
+++ b/plugins/mate/mate_runtime.c
@@ -215,7 +215,7 @@ static mate_gop* new_gop(mate_cfg_gop* cfg, mate_pdu* pdu, guint8* key) {
gop->last_pdu = pdu;
gop->gop_key = key;
gop->start_time = rd->now;
-
+ gop->time_to_die = cfg->lifetime > 0.0 ? cfg->lifetime + rd->now : (float) -1.0 ;
pdu->gop = gop;
pdu->next = NULL;
pdu->is_start = TRUE;
@@ -466,6 +466,7 @@ static void analize_pdu(mate_pdu* pdu) {
apply_transforms(pdu);
+ /* is there a gop type for this pdu type? */
cfg = g_hash_table_lookup(mc->gops_by_pduname,pdu->cfg->name);
if (!cfg) return;
@@ -476,6 +477,8 @@ static void analize_pdu(mate_pdu* pdu) {
dbg_print (dbg_gop,3,dbg_facility,"analize_pdu: got candidate key\n");
+ /* does the pdu matches the prematch candidate key for the gop type? */
+
gopkey_match = new_avpl_exact_match("",pdu->avpl,candidate_gop_key_match, TRUE);
if (gopkey_match) {
@@ -493,11 +496,21 @@ static void analize_pdu(mate_pdu* pdu) {
delete_avpl(is_start,FALSE);
}
- g_hash_table_lookup_extended(cfg->gop_index,gop_key,(gpointer*)&orig_gop_key,(gpointer*)&gop);
+ g_hash_table_lookup_extended(cfg->gop_index,(gconstpointer)gop_key,(gpointer*)&orig_gop_key,(gpointer*)&gop);
if ( gop ) {
g_free(gop_key);
+ /* is the gop dead ? */
+ if ( ! gop->released &&
+ ( ( gop->cfg->lifetime > 0.0 && gop->time_to_die >= rd->now) ||
+ ( gop->cfg->idle_timeout > 0.0 && gop->time_to_timeout >= rd->now) ) ) {
+ gop->released = TRUE;
+ if (gop->gog) gop->gog->num_of_released_gops++;
+ }
+
+ /* TODO: is the gop expired? */
+
gop_key = orig_gop_key;
dbg_print (dbg_gop,2,dbg_facility,"analize_pdu: got gop: %s\n",gop_key);
@@ -539,7 +552,10 @@ static void analize_pdu(mate_pdu* pdu) {
}
}
- if ( gop ) gop->num_of_pdus++;
+ if ( gop ) {
+ gop->num_of_pdus++;
+ gop->time_to_timeout = cfg->idle_timeout > 0.0 ? cfg->idle_timeout + rd->now : (float) -1.0 ;
+ }
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: merge with key\n");
diff --git a/plugins/mate/mate_setup.c b/plugins/mate/mate_setup.c
index 8a77022500..cb4cbaeefb 100644
--- a/plugins/mate/mate_setup.c
+++ b/plugins/mate/mate_setup.c
@@ -569,6 +569,9 @@ static gboolean config_settings(AVPL*avpl) {
matecfg->gog_expiration = extract_named_float(avpl, KEYWORD_GOGEXPIRE,matecfg->gog_expiration);
+ matecfg->gop_expiration = extract_named_float(avpl, KEYWORD_GOPEXPIRATION,matecfg->gop_expiration);
+ matecfg->gop_idle_timeout = extract_named_float(avpl, KEYWORD_GOPIDLETIMEOUT,matecfg->gop_idle_timeout);
+ matecfg->gop_lifetime = extract_named_float(avpl, KEYWORD_GOPLIFETIME,matecfg->gop_lifetime);
matecfg->discard_pdu_attributes = extract_named_bool(avpl, KEYWORD_DISCARDPDU,matecfg->discard_pdu_attributes);
matecfg->drop_pdu = extract_named_bool(avpl, KEYWORD_DROPPDU,matecfg->drop_pdu);
matecfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,matecfg->drop_gop);
@@ -731,7 +734,10 @@ static gboolean config_gop(AVPL* avpl) {
cfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,matecfg->drop_gop);
cfg->show_pdu_tree = extract_named_str(avpl, KEYWORD_SHOWPDUTREE, matecfg->show_pdu_tree);
cfg->show_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,matecfg->show_times);
-
+ cfg->expiration = extract_named_float(avpl, KEYWORD_GOPEXPIRATION,matecfg->gop_expiration);
+ cfg->idle_timeout = extract_named_float(avpl, KEYWORD_GOPIDLETIMEOUT,matecfg->gop_idle_timeout);
+ cfg->lifetime = extract_named_float(avpl, KEYWORD_GOPLIFETIME,matecfg->gop_lifetime);
+
cfg->key = avpl;
return TRUE;
@@ -803,7 +809,10 @@ static gboolean config_gopextra(AVPL* avpl) {
cfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,cfg->drop_gop);
cfg->show_pdu_tree = extract_named_str(avpl, KEYWORD_SHOWPDUTREE, cfg->show_pdu_tree);
cfg->show_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,cfg->show_times);
-
+ cfg->expiration = extract_named_float(avpl, KEYWORD_GOPEXPIRATION,cfg->expiration);
+ cfg->idle_timeout = extract_named_float(avpl, KEYWORD_GOPIDLETIMEOUT,cfg->idle_timeout);
+ cfg->lifetime = extract_named_float(avpl, KEYWORD_GOPLIFETIME,cfg->lifetime);
+
merge_avpl(cfg->extra,avpl,TRUE);
return TRUE;
@@ -891,6 +900,7 @@ static gboolean config_gogextra(AVPL* avpl) {
return TRUE;
}
+#define true_false_str(v) ((v) ? "TRUE" : "FALSE")
static void print_xxx_transforms(mate_cfg_item* cfg) {
guint8* tr_name;
@@ -956,7 +966,10 @@ static void print_gop_config(gpointer k _U_ , gpointer v, gpointer p _U_) {
gopdef = g_string_new("Action=GopDef; ");
show_pdu_tree = cfg->show_pdu_tree ? "TRUE" : "FALSE";
- g_string_sprintfa(gopdef,"Name=%s; ShowPduTree=%s;",cfg->name,show_pdu_tree);
+ g_string_sprintfa(gopdef,"Name=%s; ShowPduTree=%s; ShowGopTimes=%s; "
+ "GopExpiration=%f; GopIdleTimeout=%f GopLifetime=%f;",
+ cfg->name,show_pdu_tree,true_false_str(cfg->show_times),
+ cfg->expiration,cfg->idle_timeout,cfg->lifetime);
if (cfg->key) {
avplstr = avpl_to_str(cfg->key);
diff --git a/plugins/mate/mate_util.c b/plugins/mate/mate_util.c
index 43c3cb9aeb..4b1ce16696 100644
--- a/plugins/mate/mate_util.c
+++ b/plugins/mate/mate_util.c
@@ -136,7 +136,7 @@ guint8* scs_subscribe(SCS_collection* c, guint8* s) {
size_t len = 0;
GMemChunk* chunk = NULL;
- g_hash_table_lookup_extended(c->hash,s,(gpointer*)&orig,(gpointer*)&ip);
+ g_hash_table_lookup_extended(c->hash,(gconstpointer)s,(gpointer*)&orig,(gpointer*)&ip);
if (ip) {
(*ip)++;
@@ -187,7 +187,7 @@ void scs_unsubscribe(SCS_collection* c, guint8* s) {
size_t len = 0xffff;
GMemChunk* chunk = NULL;
- g_hash_table_lookup_extended(c->hash,s,(gpointer*)&orig,(gpointer*)&ip);
+ g_hash_table_lookup_extended(c->hash,(gconstpointer)s,(gpointer*)&orig,(gpointer*)&ip);
if (ip) {
if (*ip == 0) {