diff options
-rw-r--r-- | addons/chan_ooh323.c | 19 | ||||
-rw-r--r-- | addons/ooh323c/src/context.c | 1 | ||||
-rw-r--r-- | addons/ooh323c/src/memheap.c | 11 | ||||
-rw-r--r-- | addons/ooh323c/src/ooCalls.c | 3 | ||||
-rw-r--r-- | addons/ooh323c/src/ooCapability.c | 8 | ||||
-rw-r--r-- | addons/ooh323c/src/ooGkClient.c | 3 | ||||
-rw-r--r-- | addons/ooh323c/src/ooh245.c | 2 | ||||
-rw-r--r-- | addons/ooh323c/src/ooq931.c | 6 | ||||
-rw-r--r-- | bridges/bridge_softmix.c | 34 | ||||
-rw-r--r-- | formats/format_pcm.c | 41 | ||||
-rw-r--r-- | main/Makefile | 3 | ||||
-rw-r--r-- | res/Makefile | 3 |
12 files changed, 72 insertions, 62 deletions
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c index ffdbf6721..b456796d7 100644 --- a/addons/chan_ooh323.c +++ b/addons/chan_ooh323.c @@ -1281,7 +1281,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(ast); char *callToken = (char *)NULL; - int res = -1; + int res = -1, rres; if (!p) return -1; @@ -1328,11 +1328,9 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d case AST_CONTROL_PROGRESS: if (ast_channel_state(ast) != AST_STATE_UP) { if (!p->progsent) { + rres = ooManualProgress(callToken); if (gH323Debug) { - ast_debug(1, "Sending manual progress for %s, res = %u\n", callToken, - ooManualProgress(callToken)); - } else { - ooManualProgress(callToken); + ast_debug(1, "Sending manual progress for %s, res = %u\n", callToken, rres); } p->progsent = 1; } @@ -1341,12 +1339,9 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d case AST_CONTROL_RINGING: if (ast_channel_state(ast) == AST_STATE_RING || ast_channel_state(ast) == AST_STATE_RINGING) { if (!p->alertsent) { + rres = ooManualRingback(callToken); if (gH323Debug) { - ast_debug(1, "Sending manual ringback for %s, res = %u\n", - callToken, - ooManualRingback(callToken)); - } else { - ooManualRingback(callToken); + ast_debug(1, "Sending manual ringback for %s, res = %u\n", callToken, rres); } p->alertsent = 1; } @@ -5053,9 +5048,7 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p) ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context); } p->faxdetected = 1; - if (dfr) { - ast_frfree(dfr); - } + ast_frfree(dfr); return &ast_null_frame; } } diff --git a/addons/ooh323c/src/context.c b/addons/ooh323c/src/context.c index bc3db4387..c1e2003a2 100644 --- a/addons/ooh323c/src/context.c +++ b/addons/ooh323c/src/context.c @@ -164,6 +164,7 @@ OOCTXT* newContext () /* ASN1CRTFREE0 (pctxt); */ ast_free(pctxt); pctxt = 0; + return (pctxt); } pctxt->flags |= ASN1DYNCTXT; } diff --git a/addons/ooh323c/src/memheap.c b/addons/ooh323c/src/memheap.c index 4bcbd7a3d..4020261bb 100644 --- a/addons/ooh323c/src/memheap.c +++ b/addons/ooh323c/src/memheap.c @@ -623,7 +623,7 @@ void memHeapFreePtr (void** ppvMemHeap, void* mem_p) } } } - if (!ISLAST (pElem) && ISFREE (GETNEXT (pElem))) { + if (pElem && !ISLAST (pElem) && ISFREE (GETNEXT (pElem))) { OSMemElemDescr* nextelem_p = GETNEXT (pElem); /* +1 because the OSMemElemDescr has size ONE unit (8 bytes) */ @@ -638,7 +638,7 @@ void memHeapFreePtr (void** ppvMemHeap, void* mem_p) } /* correct the prevOff field of next element */ - if (!ISLAST (pElem)) { + if (pElem && !ISLAST (pElem)) { OSMemElemDescr* nextelem_p = GETNEXT (pElem); pElem_prevOff (nextelem_p) = QOFFSETOF (nextelem_p, pElem); } @@ -686,7 +686,7 @@ static void initNewFreeElement (OSMemBlk* pMemBlk, } pNextElem = GETNEXT (pNewElem); - if (ISFREE (pNextElem)) { + if (pNextElem && ISFREE (pNextElem)) { /* if the next elem is free, then unite them together */ @@ -820,7 +820,7 @@ void* memHeapRealloc (void** ppvMemHeap, void* mem_p, int nbytes_) /* look for free element after pElem */ pNextElem = GETNEXT (pElem); - if (ISFREE (pNextElem)) { + if (pNextElem && ISFREE (pNextElem)) { /* +1 'cos sizeof (OSMemElemDescr) == 1 unit */ sumSize += pElem_nunits (pNextElem) + 1; freeMem++; @@ -1062,7 +1062,7 @@ void memHeapAddRef (void** ppvMemHeap) void memHeapRelease (void** ppvMemHeap) { OSMemHeap** ppMemHeap = (OSMemHeap**)ppvMemHeap; - OSMemHeap* pMemHeap = *ppMemHeap; + OSMemHeap* pMemHeap; if (ppMemHeap != 0 && *ppMemHeap != 0 && --(*ppMemHeap)->refCnt == 0) { OSMemLink* pMemLink, *pMemLink2; @@ -1080,6 +1080,7 @@ void memHeapRelease (void** ppvMemHeap) } if ((*ppMemHeap)->flags & RT_MH_FREEHEAPDESC) { + pMemHeap = *ppMemHeap; ast_mutex_destroy(&pMemHeap->pLock); ast_free(*ppMemHeap); } diff --git a/addons/ooh323c/src/ooCalls.c b/addons/ooh323c/src/ooCalls.c index 3097c6d28..15ab3258f 100644 --- a/addons/ooh323c/src/ooCalls.c +++ b/addons/ooh323c/src/ooCalls.c @@ -805,8 +805,7 @@ int ooAddMediaInfo(OOH323CallData *call, OOMediaInfo mediaInfo) if(!call) { - OOTRACEERR3("Error:Invalid 'call' param for ooAddMediaInfo.(%s, %s)\n", - call->callType, call->callToken); + OOTRACEERR1("Error:Invalid 'call' param for ooAddMediaInfo.\n"); return OO_FAILED; } newMediaInfo = (OOMediaInfo*) memAlloc(call->pctxt, sizeof(OOMediaInfo)); diff --git a/addons/ooh323c/src/ooCapability.c b/addons/ooh323c/src/ooCapability.c index 731478346..0796c46bf 100644 --- a/addons/ooh323c/src/ooCapability.c +++ b/addons/ooh323c/src/ooCapability.c @@ -62,8 +62,6 @@ int ooCapabilityEnableDTMFCISCO /*Dynamic RTP payload type range is from 96 - 127 */ if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127) gcDynamicRTPPayloadType = dynamicRTPPayloadType; - else - call->dtmfcodec = dynamicRTPPayloadType; } else{ call->dtmfmode |= OO_CAP_DTMF_CISCO; @@ -623,8 +621,7 @@ int ooCapabilityAddT38Capability else pctxt = call->pctxt; epCap = (ooH323EpCapability*)memAllocZ(pctxt, sizeof(ooH323EpCapability)); - params = (OOCapParams*) memAlloc(pctxt, sizeof(OOCapParams)); - memset(params, 0 , sizeof(OOCapParams)); + params = (OOCapParams*) memAllocZ(pctxt, sizeof(OOCapParams)); if(!epCap || !params) { OOTRACEERR1("ERROR: Memory - ooCapabilityAddT38Capability - " @@ -808,8 +805,7 @@ void* ooCapabilityCreateDTMFCapability(int cap, int dtmfcodec, OOCTXT *pctxt) } memset(pATECap, 0, sizeof(H245AudioTelephonyEventCapability)); pATECap->dynamicRTPPayloadType = dtmfcodec; - events = (char*)memAlloc(pctxt, strlen("0-16")+1); - memset(events, 0, strlen("0-16")+1); + events = (char*)memAllocZ(pctxt, strlen("0-16")+1); if(!events) { OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - events\n"); diff --git a/addons/ooh323c/src/ooGkClient.c b/addons/ooh323c/src/ooGkClient.c index a307f4eef..0168ee7de 100644 --- a/addons/ooh323c/src/ooGkClient.c +++ b/addons/ooh323c/src/ooGkClient.c @@ -2332,9 +2332,8 @@ int ooGkClientSendIRR pIRR->m.perCallInfoPresent = TRUE; perCallInfo = - (H225InfoRequestResponse_perCallInfo_element *)memAlloc(pctxt, + (H225InfoRequestResponse_perCallInfo_element *)memAllocZ(pctxt, sizeof(H225InfoRequestResponse_perCallInfo_element)); - memset(perCallInfo, 0, sizeof(H225InfoRequestResponse_perCallInfo_element)); if(!perCallInfo) { diff --git a/addons/ooh323c/src/ooh245.c b/addons/ooh323c/src/ooh245.c index adff91790..fe8ff28e0 100644 --- a/addons/ooh323c/src/ooh245.c +++ b/addons/ooh323c/src/ooh245.c @@ -356,7 +356,6 @@ int ooSendTermCapMsg(OOH323CallData *call) /* pctxt = &gH323ep.msgctxt; */ pctxt = call->msgctxt; ph245msg->msgType = OOTerminalCapabilitySet; - memset(request, 0, sizeof(H245RequestMessage)); if(request == NULL) { OOTRACEERR3("ERROR: No memory allocated for request message (%s, %s)\n", @@ -364,6 +363,7 @@ int ooSendTermCapMsg(OOH323CallData *call) return OO_FAILED; } + memset(request, 0, sizeof(H245RequestMessage)); request->t = T_H245RequestMessage_terminalCapabilitySet; request->u.terminalCapabilitySet = (H245TerminalCapabilitySet*) memAlloc(pctxt, sizeof(H245TerminalCapabilitySet)); diff --git a/addons/ooh323c/src/ooq931.c b/addons/ooh323c/src/ooq931.c index 1ca361c2c..01a8e4aaf 100644 --- a/addons/ooh323c/src/ooq931.c +++ b/addons/ooh323c/src/ooq931.c @@ -2439,8 +2439,10 @@ int ooH323HandleCallFwdRequest(OOH323CallData *call) alias = call->pCallFwdData->aliases; while(alias) { - pNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases)); - pNewAlias->value = (char*) memAlloc(pctxt, strlen(alias->value)+1); + pNewAlias = (ooAliases*) memAllocZ(pctxt, sizeof(ooAliases)); + if (pNewAlias) { + pNewAlias->value = (char*) memAllocZ(pctxt, strlen(alias->value)+1); + } if(!pNewAlias || !pNewAlias->value) { OOTRACEERR3("Error:Memory - ooH323HandleCallFwdRequest - " diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c index f0a3fb42d..ed88b7cd5 100644 --- a/bridges/bridge_softmix.c +++ b/bridges/bridge_softmix.c @@ -1318,6 +1318,12 @@ static void remb_collect_report(struct ast_bridge *bridge, struct ast_bridge_cha break; } } + + /* After the report is integrated we reset this to 0 in case they stop producing + * REMB reports. + */ + sc->remb.br_mantissa = 0; + sc->remb.br_exp = 0; } static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc) @@ -1328,20 +1334,18 @@ static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct s return; } - /* If we have a new bitrate then use it for the REMB, if not we use the previous - * one until we know otherwise. This way the bitrate doesn't drop to 0 all of a sudden. + /* We always do this calculation as even when the bitrate is zero the browser + * still prefers it to be accurate instead of lying. */ - if (sc->remb_collector->bitrate) { - sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate; - sc->remb_collector->feedback.remb.br_exp = 0; + sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->bitrate; + sc->remb_collector->feedback.remb.br_exp = 0; - /* The mantissa only has 18 bits available, so while it exceeds them we bump - * up the exp. - */ - while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) { - sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1; - sc->remb_collector->feedback.remb.br_exp++; - } + /* The mantissa only has 18 bits available, so while it exceeds them we bump + * up the exp. + */ + while (sc->remb_collector->feedback.remb.br_mantissa > 0x3ffff) { + sc->remb_collector->feedback.remb.br_mantissa = sc->remb_collector->feedback.remb.br_mantissa >> 1; + sc->remb_collector->feedback.remb.br_exp++; } for (i = 0; i < AST_VECTOR_SIZE(&bridge_channel->stream_map.to_bridge); ++i) { @@ -2062,6 +2066,7 @@ static void softmix_bridge_stream_topology_changed(struct ast_bridge *bridge, st struct ast_bridge_channel *participant; struct ast_vector_int media_types; int nths[AST_MEDIA_TYPE_END] = {0}; + int idx; switch (bridge->softmix.video_mode.mode) { case AST_BRIDGE_VIDEO_MODE_NONE: @@ -2080,7 +2085,10 @@ static void softmix_bridge_stream_topology_changed(struct ast_bridge *bridge, st * When channels end up getting added back in they'll reuse their existing * collector and won't need to allocate a new one (unless they were just added). */ - AST_VECTOR_RESET(&softmix_data->remb_collectors, ao2_cleanup); + for (idx = 0; idx < AST_VECTOR_SIZE(&softmix_data->remb_collectors); ++idx) { + ao2_cleanup(AST_VECTOR_GET(&softmix_data->remb_collectors, idx)); + AST_VECTOR_REPLACE(&softmix_data->remb_collectors, idx, NULL); + } /* First traversal: re-initialize all of the participants' stream maps */ AST_LIST_TRAVERSE(&bridge->channels, participant, entry) { diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 35612c964..4e846d7cf 100644 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -91,10 +91,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext) return NULL; } s->fr.datalen = res; - if (ast_format_cmp(s->fmt->format, ast_format_g722) == AST_FORMAT_CMP_EQUAL) - *whennext = s->fr.samples = res * 2; - else - *whennext = s->fr.samples = res; + *whennext = s->fr.samples = res; return &s->fr; } @@ -410,16 +407,11 @@ static int au_rewrite(struct ast_filestream *s, const char *comment) static int au_seek(struct ast_filestream *fs, off_t sample_offset, int whence) { off_t min, max, cur; - long offset = 0, bytes; + long offset = 0; struct au_desc *desc = fs->_private; min = desc->hdr_size; - if (ast_format_cmp(fs->fmt->format, ast_format_g722) == AST_FORMAT_CMP_EQUAL) - bytes = sample_offset / 2; - else - bytes = sample_offset; - if ((cur = ftello(fs->f)) < 0) { ast_log(AST_LOG_WARNING, "Unable to determine current position in au filestream %p: %s\n", fs, strerror(errno)); return -1; @@ -436,11 +428,11 @@ static int au_seek(struct ast_filestream *fs, off_t sample_offset, int whence) } if (whence == SEEK_SET) - offset = bytes + min; + offset = sample_offset + min; else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) - offset = bytes + cur; + offset = sample_offset + cur; else if (whence == SEEK_END) - offset = max - bytes; + offset = max - sample_offset; if (whence != SEEK_FORCECUR) { offset = (offset > max) ? max : offset; @@ -479,6 +471,23 @@ static off_t au_tell(struct ast_filestream *fs) return offset - desc->hdr_size; } +static struct ast_frame *g722_read(struct ast_filestream *s, int *whennext) +{ + struct ast_frame *f = pcm_read(s, whennext); + *whennext = s->fr.samples = (*whennext * 2); + return f; +} + +static int g722_seek(struct ast_filestream *fs, off_t sample_offset, int whence) +{ + return pcm_seek(fs, sample_offset / 2, whence); +} + +static off_t g722_tell(struct ast_filestream *fs) +{ + return pcm_tell(fs) * 2; +} + static struct ast_format_def alaw_f = { .name = "alaw", .exts = "alaw|al|alw", @@ -510,10 +519,10 @@ static struct ast_format_def g722_f = { .name = "g722", .exts = "g722", .write = pcm_write, - .seek = pcm_seek, + .seek = g722_seek, .trunc = pcm_trunc, - .tell = pcm_tell, - .read = pcm_read, + .tell = g722_tell, + .read = g722_read, .buf_size = (BUF_SIZE * 2) + AST_FRIENDLY_OFFSET, }; diff --git a/main/Makefile b/main/Makefile index bef70e966..393ad1aa4 100644 --- a/main/Makefile +++ b/main/Makefile @@ -135,7 +135,8 @@ endif $(ECHO_PREFIX) echo " [FLEX] $< -> $@" $(CMD_PREFIX) $(FLEX) -o $@ ast_expr2.fl $(CMD_PREFIX) sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix - $(CMD_PREFIX) echo "#include \"asterisk.h\"" > $@ + $(CMD_PREFIX) echo "#define ASTMM_LIBC ASTMM_REDIRECT" > $@ + $(CMD_PREFIX) echo "#include \"asterisk.h\"" >> $@ $(CMD_PREFIX) echo >> $@ $(CMD_PREFIX) cat $@.fix >> $@ $(CMD_PREFIX) rm $@.fix diff --git a/res/Makefile b/res/Makefile index ecaa03d3c..ec3417b35 100644 --- a/res/Makefile +++ b/res/Makefile @@ -45,7 +45,8 @@ endif $(ECHO_PREFIX) echo " [FLEX] $< -> $@" $(CMD_PREFIX) (cd ael; $(FLEX) ael.flex) $(CMD_PREFIX) sed 's@#if __STDC_VERSION__ >= 199901L@#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L@' $@ > $@.fix - $(CMD_PREFIX) echo "#include \"asterisk.h\"" > $@ + $(CMD_PREFIX) echo "#define ASTMM_LIBC ASTMM_REDIRECT" > $@ + $(CMD_PREFIX) echo "#include \"asterisk.h\"" >> $@ $(CMD_PREFIX) echo >> $@ $(CMD_PREFIX) cat $@.fix >> $@ $(CMD_PREFIX) rm $@.fix |