aboutsummaryrefslogtreecommitdiffstats
path: root/rtp.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-22 21:52:22 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-22 21:52:22 +0000
commit08c400b688b9fb5a7a89f1889911657990b14894 (patch)
tree5bb6c3f46300903d73c8dcebc5cd9102d5fccded /rtp.c
parent5beec02e41397712dc0cdbc235baacca64f6c8fb (diff)
Use caller's negotiated values when possible.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2526 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-xrtp.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/rtp.c b/rtp.c
index 5ebaf582e..9e6395bb6 100755
--- a/rtp.c
+++ b/rtp.c
@@ -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) {