Use caller's negotiated values when possible.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2526 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-03-22 21:52:22 +00:00
parent b19cb95257
commit 2a16a0a30c

25
rtp.c
View File

@@ -663,14 +663,19 @@ void ast_rtp_get_current_formats(struct ast_rtp* rtp,
}
}
struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt) {
struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt)
{
struct rtpPayloadType result;
if (pt < 0 || pt > MAX_RTP_PT) {
struct rtpPayloadType result;
result.isAstFormat = result.code = 0;
return result; // bogus payload type
}
/* Gotta use our static one, since that's what we sent against */
return static_RTP_PT[pt];
/* Start with the negotiated codecs */
result = rtp->current_RTP_PT[pt];
/* If it doesn't exist, check our static RTP type list, just in case */
if (!result.code)
result = static_RTP_PT[pt];
return result;
}
int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code) {
@@ -684,6 +689,18 @@ int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code) {
return rtp->rtp_lookup_code_cache_result;
}
/* Check the dynamic list first */
for (pt = 0; pt < MAX_RTP_PT; ++pt) {
if (rtp->current_RTP_PT[pt].code == code &&
rtp->current_RTP_PT[pt].isAstFormat == isAstFormat) {
rtp->rtp_lookup_code_cache_isAstFormat = isAstFormat;
rtp->rtp_lookup_code_cache_code = code;
rtp->rtp_lookup_code_cache_result = pt;
return pt;
}
}
/* Then the static list */
for (pt = 0; pt < MAX_RTP_PT; ++pt) {
if (static_RTP_PT[pt].code == code &&
static_RTP_PT[pt].isAstFormat == isAstFormat) {