int find_stream(struct cfg *cf, const char *call_id, const char *from_tag, const char *to_tag, struct rtpp_session **spp) { const char *cp1, *cp2; for (*spp = session_findfirst(cf, call_id); *spp != NULL; *spp = session_findnext(*spp)) { if (strcmp((*spp)->tag, from_tag) == 0) { return 0; } else if (to_tag != NULL) { switch (compare_session_tags((*spp)->tag, to_tag, NULL)) { case 1: /* Exact tag match */ return 1; case 2: /* * Reverse tag match without medianum. Medianum is always * applied to the from tag, verify that. */ cp1 = strrchr((*spp)->tag, ';'); cp2 = strrchr(from_tag, ';'); if (cp2 != NULL && strcmp(cp1, cp2) == 0) return 1; break; default: break; } } } return -1; }
static int handle_record(struct cfg *cf, char *call_id, char *from_tag, char *to_tag) { int nrecorded, idx; struct rtpp_session *spa; nrecorded = 0; for (spa = session_findfirst(cf, call_id); spa != NULL; spa = session_findnext(cf, spa)) { if (compare_session_tags(spa->tag, from_tag, NULL) != 0) { idx = 1; } else if (to_tag != NULL && (compare_session_tags(spa->tag, to_tag, NULL)) != 0) { idx = 0; } else { continue; } nrecorded++; handle_copy(cf, spa, idx, NULL); handle_copy(cf, spa, NOT(idx), NULL); } return (nrecorded == 0 ? -1 : 0); }
int find_stream(struct cfg *cf, const char *call_id, const char *from_tag, const char *to_tag, struct rtpp_session **spp) { const char *cp1, *cp2; //return 1; /* Make sure structure is properly locked */ assert(pthread_mutex_islocked(&cf->glock) == 1); for (*spp = session_findfirst(cf, call_id); *spp != NULL; *spp = session_findnext(cf, *spp)) { if (strcmp((*spp)->tag, from_tag) == 0) { return 1; } else if (to_tag != NULL) { #if 1 switch (compare_session_tags((*spp)->tag, to_tag, NULL)) { case 1: /* Exact tag match */ return 1; case 2: /* * Reverse tag match without medianum. Medianum is always * applied to the from tag, verify that. */ cp1 = strrchr((*spp)->tag, ';'); cp2 = strrchr(from_tag, ';'); if (cp2 != NULL && strcmp(cp1, cp2) == 0) return 1; break; default: break; } #endif } } return -1; }
static int handle_record(struct cfg *cf, struct common_cmd_args *ccap, int record_single_file) { int nrecorded, idx; struct rtpp_session *spa; nrecorded = 0; for (spa = session_findfirst(cf, ccap->call_id); spa != NULL; spa = session_findnext(cf, spa)) { if (compare_session_tags(spa->tag, ccap->from_tag, NULL) != 0) { idx = 1; } else if (ccap->to_tag != NULL && (compare_session_tags(spa->tag, ccap->to_tag, NULL)) != 0) { idx = 0; } else { continue; } if (handle_copy(cf, spa, idx, NULL, record_single_file) == 0) { nrecorded++; } } return (nrecorded == 0 ? -1 : 0); }
static int handle_delete(struct cfg *cf, char *call_id, char *from_tag, char *to_tag, int weak) { int ndeleted; unsigned int medianum; struct rtpp_session *spa, *spb; int cmpr, cmpr1, idx; ndeleted = 0; for (spa = session_findfirst(cf, call_id); spa != NULL;) { medianum = 0; if ((cmpr1 = compare_session_tags(spa->tag, from_tag, &medianum)) != 0) { idx = 1; cmpr = cmpr1; } else if (to_tag != NULL && (cmpr1 = compare_session_tags(spa->tag, to_tag, &medianum)) != 0) { idx = 0; cmpr = cmpr1; } else { spa = session_findnext(spa); continue; } if (weak) spa->weak[idx] = 0; else spa->strong = 0; /* * This seems to be stable from reiterations, the only side * effect is less efficient work. */ if (spa->strong || spa->weak[0] || spa->weak[1]) { rtpp_log_write(RTPP_LOG_INFO, spa->log, "delete: medianum=%u: removing %s flag, seeing flags to" " continue session (strong=%d, weak=%d/%d)", medianum, weak ? ( idx ? "weak[1]" : "weak[0]" ) : "strong", spa->strong, spa->weak[0], spa->weak[1]); /* Skipping to next possible stream for this call */ ++ndeleted; spa = session_findnext(spa); continue; } rtpp_log_write(RTPP_LOG_INFO, spa->log, "forcefully deleting session %u on ports %d/%d", medianum, spa->ports[0], spa->ports[1]); /* Search forward before we do removal */ spb = spa; spa = session_findnext(spa); remove_session(cf, spb); ++ndeleted; if (cmpr != 2) { break; } } if (ndeleted == 0) { return -1; } return 0; }