diff options
author | Bodam Nam <bodamnam@google.com> | 2023-04-06 07:39:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-04-06 07:39:50 +0000 |
commit | 3cf487ecf694e32c508046b98e9701edfc88d4df (patch) | |
tree | f8d52b4e2743fe56f3080856efb079a7f38b89ab | |
parent | 2a830cf2777b9275726f37b4155877759fe0044e (diff) | |
parent | 4ecaf6596c9439bf5e40859cf0cc40e256b7aa22 (diff) | |
download | ImsMedia-3cf487ecf694e32c508046b98e9701edfc88d4df.tar.gz |
Merge "Fix to handle empty redundant payload in RTT decoder" into udc-dev
3 files changed, 42 insertions, 74 deletions
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/TextJitterBuffer.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/TextJitterBuffer.cpp index beb1d015..9ed07c0a 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/TextJitterBuffer.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/TextJitterBuffer.cpp @@ -32,11 +32,9 @@ void TextJitterBuffer::Reset() } void TextJitterBuffer::Add(ImsMediaSubType subtype, uint8_t* buffer, uint32_t size, - uint32_t timestamp, bool mark, uint32_t seqNum, ImsMediaSubType dataType, + uint32_t timestamp, bool mark, uint32_t seqNum, ImsMediaSubType /*dataType*/, uint32_t arrivalTime) { - (void)dataType; - IMLOGD_PACKET6(IM_PACKET_LOG_JITTER, "[Add] seq[%u], mark[%u], TS[%u], size[%u], lastPlayedSeq[%u], arrivalTime[%u]", seqNum, mark, timestamp, size, mLastPlayedSeqNum, arrivalTime); @@ -64,11 +62,6 @@ void TextJitterBuffer::Add(ImsMediaSubType subtype, uint8_t* buffer, uint32_t si if (mDataQueue.GetCount() == 0) // jitter buffer is empty { mDataQueue.Add(&currEntry); - - if (!mFirstFrameReceived) - { - mFirstFrameReceived = true; - } } else { @@ -169,6 +162,11 @@ void TextJitterBuffer::Delete() return; } + if (!mFirstFrameReceived) + { + mFirstFrameReceived = true; + } + mLastPlayedSeqNum = pEntry->nSeqNum; mLastPlayedTimestamp = pEntry->nTimestamp; mDataQueue.Delete(); diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRendererNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRendererNode.cpp index 628248cc..254081d1 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRendererNode.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRendererNode.cpp @@ -114,20 +114,6 @@ void TextRendererNode::ProcessData() "[ProcessData] size[%u], TS[%u], mark[%u], seq[%u], last seq[%u]", size, timestamp, mark, seq, mLastPlayedSeq); - // ignore empty t.140 - if (size == 0) - { - mLastPlayedSeq = (uint16_t)seq; - DeleteData(); - break; - } - - if (data == nullptr) - { - IMLOGD0("[ProcessData] invalid data"); - break; - } - if (mFirstFrameReceived) { // detect lost packet diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRtpPayloadDecoderNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRtpPayloadDecoderNode.cpp index 284311e2..901f88c6 100644 --- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRtpPayloadDecoderNode.cpp +++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextRtpPayloadDecoderNode.cpp @@ -118,10 +118,10 @@ void TextRtpPayloadDecoderNode::DecodeT140(uint8_t* data, uint32_t size, ImsMedi if (subtype == MEDIASUBTYPE_BITSTREAM_T140 || subtype == MEDIASUBTYPE_BITSTREAM_T140_RED) { - std::list<uint32_t> lstTSOffset; - std::list<uint32_t> lstLength; - uint32_t nReadByte = 0; - uint32_t nRedCount = 0; + std::list<uint32_t> listTimestampOffset; + std::list<uint32_t> listLength; + uint32_t readByte = 0; + uint16_t redundantCount = 0; mBitReader.SetBuffer(data, size); @@ -136,7 +136,6 @@ void TextRtpPayloadDecoderNode::DecodeT140(uint8_t* data, uint32_t size, ImsMedi */ // Primary Data Only - // Red header + primary header = 5 byte if (subtype == MEDIASUBTYPE_BITSTREAM_T140) { SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, data, size, timestamp, mark, seq); @@ -144,69 +143,54 @@ void TextRtpPayloadDecoderNode::DecodeT140(uint8_t* data, uint32_t size, ImsMedi } // Redundant data included - while (mBitReader.Read(1) == 1) // Rendundancy bit + while (mBitReader.Read(1) == 1) // redundant flag bit { - uint32_t nPT = mBitReader.Read(7); // T140 payload type - uint32_t nTSOffset = mBitReader.Read(14); - uint32_t nLen = mBitReader.Read(10); + uint32_t payloadType = mBitReader.Read(7); // T140 payload type + uint32_t timestampOffset = mBitReader.Read(14); + uint32_t length = mBitReader.Read(10); - lstTSOffset.push_back(nTSOffset); // timestamp offset - lstLength.push_back(nLen); // block length + listTimestampOffset.push_back(timestampOffset); // timestamp offset + listLength.push_back(length); // block length - IMLOGD_PACKET3(IM_PACKET_LOG_PH, "[DecodeT140] nPT[%u], nTSOffset[%u], nLen[%u]", nPT, - nTSOffset, nLen); - nReadByte += 4; - nRedCount++; + IMLOGD_PACKET3(IM_PACKET_LOG_PH, "[DecodeT140] PT[%u], TSOffset[%u], size[%u]", + payloadType, timestampOffset, length); + readByte += 4; + redundantCount++; } mBitReader.Read(7); // T140 payload type (111) - nReadByte += 1; + readByte += 1; // redundant data - while (lstTSOffset.size() > 0) + while (listTimestampOffset.size() > 0) { - uint32_t nRedTimestamp = 0; - uint32_t nRedLength = 0; - - nRedTimestamp = lstTSOffset.front(); - nRedLength = lstLength.front(); - - if (nRedLength > 0) - { - uint32_t nRedSeqNum = 0; - // here should compare mPayload size red length - mBitReader.ReadByteBuffer(mPayload, nRedLength * 8); - nReadByte += nRedLength; - - if (seq < nRedCount) - { - nRedSeqNum = seq + 0xffff - nRedCount; // round trip - } - else - { - nRedSeqNum = seq - nRedCount; - } - - IMLOGD_PACKET3(IM_PACKET_LOG_PH, - "[DecodeT140] nRedTimestamp[%u], nRedLength[%u], nRedSeqNum[%u]", - timestamp - nRedTimestamp, nRedLength, nRedSeqNum); - SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, mPayload, nRedLength, - timestamp - nRedTimestamp, mark, nRedSeqNum); - } - - nRedCount--; - lstTSOffset.pop_front(); - lstLength.pop_front(); + uint32_t redundantTimestamp = listTimestampOffset.front(); + uint32_t redundantLength = listLength.front(); + + // read redundant payload + mBitReader.ReadByteBuffer(mPayload, redundantLength * 8); + readByte += redundantLength; + + uint16_t redundantSeqNum = seq - redundantCount; + + IMLOGD_PACKET3(IM_PACKET_LOG_PH, "[DecodeT140] red TS[%u], size[%u], seq[%u]", + timestamp - redundantTimestamp, redundantLength, redundantSeqNum); + SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, mPayload, redundantLength, + timestamp - redundantTimestamp, mark, redundantSeqNum); + + redundantCount--; + listTimestampOffset.pop_front(); + listLength.pop_front(); } // primary data - if (size - nReadByte > 0) + if (size - readByte > 0) { - mBitReader.ReadByteBuffer(mPayload, (size - nReadByte) * 8); + mBitReader.ReadByteBuffer(mPayload, (size - readByte) * 8); } SendDataToRearNode( - MEDIASUBTYPE_BITSTREAM_T140, mPayload, (size - nReadByte), timestamp, mark, seq); + MEDIASUBTYPE_BITSTREAM_T140, mPayload, (size - readByte), timestamp, mark, seq); } else { |