summaryrefslogtreecommitdiffstats
path: root/voip/jni/rtp/GsmCodec.cpp
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2011-09-06 14:18:37 -0700
committerChia-chi Yeh <chiachi@android.com>2011-09-06 14:34:44 -0700
commit35d05dcba1e829782813b6ec21afceb5cffc22e6 (patch)
tree4f5287ebc5edea42a12ff4f772c5574f57cf2542 /voip/jni/rtp/GsmCodec.cpp
parent1ed7a407fafe50b1eb0878f560bb0618706e4e82 (diff)
downloadframeworks_base-35d05dcba1e829782813b6ec21afceb5cffc22e6.zip
frameworks_base-35d05dcba1e829782813b6ec21afceb5cffc22e6.tar.gz
frameworks_base-35d05dcba1e829782813b6ec21afceb5cffc22e6.tar.bz2
RTP: support payloads with larger packetization interval.
RFC 3551 section 4.2 said that a receiver should accept packets representing between 0 and 200ms of audio data. Now we add the ability to decode multiple frames in a payload as long as the jitter buffer is not full. This change covers G711, GSM, and GSM-EFR. AMR will be added later. Bug: 3029736 Change-Id: Ifd194596766d14f02177925c58432cd620e44dd7
Diffstat (limited to 'voip/jni/rtp/GsmCodec.cpp')
-rw-r--r--voip/jni/rtp/GsmCodec.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/voip/jni/rtp/GsmCodec.cpp b/voip/jni/rtp/GsmCodec.cpp
index 8d2286e..61dfdc9 100644
--- a/voip/jni/rtp/GsmCodec.cpp
+++ b/voip/jni/rtp/GsmCodec.cpp
@@ -44,7 +44,7 @@ public:
}
int encode(void *payload, int16_t *samples);
- int decode(int16_t *samples, void *payload, int length);
+ int decode(int16_t *samples, int count, void *payload, int length);
private:
gsm mEncode;
@@ -57,13 +57,17 @@ int GsmCodec::encode(void *payload, int16_t *samples)
return 33;
}
-int GsmCodec::decode(int16_t *samples, void *payload, int length)
+int GsmCodec::decode(int16_t *samples, int count, void *payload, int length)
{
- if (length == 33 &&
- gsm_decode(mDecode, (unsigned char *)payload, samples) == 0) {
- return 160;
+ unsigned char *bytes = (unsigned char *)payload;
+ int n = 0;
+ while (n + 160 <= count && length >= 33 &&
+ gsm_decode(mDecode, bytes, &samples[n]) == 0) {
+ n += 160;
+ length -= 33;
+ bytes += 33;
}
- return -1;
+ return n;
}
} // namespace