Skip to content

Commit 3ab6300

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "DO NOT MERGE: Support for parsing of "folded" RTSP header values" into ics-mr1
2 parents f0bbc49 + 9a023f1 commit 3ab6300

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

media/libstagefright/rtsp/AAMRAssembler.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::assembleMore(
7979
}
8080

8181
static size_t getFrameSize(bool isWide, unsigned FT) {
82-
static const size_t kFrameSizeNB[8] = {
83-
95, 103, 118, 134, 148, 159, 204, 244
82+
static const size_t kFrameSizeNB[9] = {
83+
95, 103, 118, 134, 148, 159, 204, 244, 39
8484
};
85-
static const size_t kFrameSizeWB[9] = {
86-
132, 177, 253, 285, 317, 365, 397, 461, 477
85+
static const size_t kFrameSizeWB[10] = {
86+
132, 177, 253, 285, 317, 365, 397, 461, 477, 40
8787
};
8888

89+
if (FT == 15) {
90+
return 1;
91+
}
92+
8993
size_t frameSize = isWide ? kFrameSizeWB[FT] : kFrameSizeNB[FT];
9094

9195
// Round up bits to bytes and add 1 for the header byte.
@@ -161,8 +165,8 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
161165

162166
unsigned FT = (toc >> 3) & 0x0f;
163167
if ((toc & 3) != 0
164-
|| (mIsWide && FT > 8)
165-
|| (!mIsWide && FT > 7)) {
168+
|| (mIsWide && FT > 9 && FT != 15)
169+
|| (!mIsWide && FT > 8 && FT != 15)) {
166170
queue->erase(queue->begin());
167171
++mNextExpectedSeqNo;
168172

media/libstagefright/rtsp/ARTSPConnection.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ bool ARTSPConnection::receiveRTSPReponse() {
659659
}
660660

661661
AString line;
662+
ssize_t lastDictIndex = -1;
662663
for (;;) {
663664
if (!receiveLine(&line)) {
664665
break;
@@ -668,7 +669,21 @@ bool ARTSPConnection::receiveRTSPReponse() {
668669
break;
669670
}
670671

671-
LOGV("line: %s", line.c_str());
672+
LOGV("line: '%s'", line.c_str());
673+
674+
if (line.c_str()[0] == ' ' || line.c_str()[0] == '\t') {
675+
// Support for folded header values.
676+
677+
if (lastDictIndex < 0) {
678+
// First line cannot be a continuation of the previous one.
679+
return false;
680+
}
681+
682+
AString &value = response->mHeaders.editValueAt(lastDictIndex);
683+
value.append(line);
684+
685+
continue;
686+
}
672687

673688
ssize_t colonPos = line.find(":");
674689
if (colonPos < 0) {
@@ -681,9 +696,12 @@ bool ARTSPConnection::receiveRTSPReponse() {
681696
key.tolower();
682697

683698
line.erase(0, colonPos + 1);
684-
line.trim();
685699

686-
response->mHeaders.add(key, line);
700+
lastDictIndex = response->mHeaders.add(key, line);
701+
}
702+
703+
for (size_t i = 0; i < response->mHeaders.size(); ++i) {
704+
response->mHeaders.editValueAt(i).trim();
687705
}
688706

689707
unsigned long contentLength = 0;

0 commit comments

Comments
 (0)