summaryrefslogtreecommitdiff
path: root/service/src/com/android/telephony/imsmedia/lib
diff options
context:
space:
mode:
authorbodamnam <bodamnam@google.com>2022-12-13 05:26:36 +0000
committerbodamnam <bodamnam@google.com>2023-03-16 08:54:56 +0000
commitc76acf52eeda27df99ad4324adb7e37853658368 (patch)
tree546a2deae0907fcc83627dc04ebb300c03a03426 /service/src/com/android/telephony/imsmedia/lib
parentd45b64d109da41d4b2dde39b11ccae8d435989c7 (diff)
downloadImsMedia-c76acf52eeda27df99ad4324adb7e37853658368.tar.gz
Improve the text sending performance
1) The TextSourceNode was sending data to the UTF-8 chunk unit, which was slowing down the performance. I remove the logic splits the text string to UTF-8 unit and send the text string as same as it was received to speed up the performance. 2) Remove the own text list and use the member of data queue in base class instead in the TextSourceNode. Bug: 271626757 Test: 1 to 1 MO/MT RTT test case with device, atest ImsMediaNativeTests Change-Id: Ie4ab8e189e4fc231d6b11707f6adae4fa563d936
Diffstat (limited to 'service/src/com/android/telephony/imsmedia/lib')
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h1
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/nodes/BaseNode.h20
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/text/nodes/TextSourceNode.h5
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/nodes/BaseNode.cpp15
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextSourceNode.cpp135
5 files changed, 63 insertions, 113 deletions
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h
index 045051c1..891513dd 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/ImsMediaDefine.h
@@ -360,7 +360,6 @@ enum ImsMediaTextMsgResponse
#define RTT_MAX_CHAR_PER_SEC (30) // ATIS_GTT : 30 characters per second
#define RTT_MAX_UNICODE_UTF8 (4)
#define MAX_RTT_LEN (RTT_MAX_CHAR_PER_SEC * RTT_MAX_UNICODE_UTF8)
-#define T140_MAX_CHUNK (1)
#define PAYLOADENCODER_TEXT_MAX_REDUNDANT_INTERVAL (16383)
struct EventParamOpenSession
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/nodes/BaseNode.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/nodes/BaseNode.h
index 9ca79518..c7270c6b 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/nodes/BaseNode.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/nodes/BaseNode.h
@@ -237,6 +237,26 @@ public:
uint32_t* arrivalTime = nullptr);
/**
+ * @brief This method is to add data frame to the queue in the node
+ *
+ * @param data The data buffer
+ * @param size The size of data
+ * @param timestamp The timestamp of data, it can be milliseconds unit or rtp timestamp unit
+ * @param mark It is true when the data has marker bit set
+ * @param seq The sequence number of data. it is 0 when there is no valid sequence number set
+ * @param subtype The subtype of data stored in the queue. It can be various subtype according
+ * to the characteristics of the given data
+ * @param dataType The additional data type for the video frames
+ * @param arrivalTime The arrival time of the packet
+ * @param index The index of the queue to add, if it is not set, add the frame to the end of
+ * the queue
+ */
+ virtual void AddData(uint8_t* data, uint32_t size, uint32_t timestamp, bool mark, uint32_t seq,
+ ImsMediaSubType subtype = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED,
+ ImsMediaSubType dataType = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED,
+ uint32_t arrivalTime = 0, int32_t index = -1);
+
+ /**
* @brief Deletes the data stored in the front of the data queue
*
*/
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/text/nodes/TextSourceNode.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/text/nodes/TextSourceNode.h
index 5b61a77e..5b690c90 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/text/nodes/TextSourceNode.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/text/nodes/TextSourceNode.h
@@ -45,7 +45,7 @@ public:
void SendRtt(const android::String8* text);
private:
- void SendBOM();
+ void SendBom();
int32_t mCodecType;
int8_t mRedundantLevel;
@@ -54,9 +54,6 @@ private:
int32_t mBitrate;
bool mBomEnabled;
bool mSentBOM;
- std::list<uint32_t> mListTextSourceSize;
- std::list<uint8_t*> mListTextSource;
- uint8_t mTextToSend[MAX_RTT_LEN];
std::mutex mMutex;
};
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/nodes/BaseNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/nodes/BaseNode.cpp
index 6ee0e6b5..70986fac 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/nodes/BaseNode.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/nodes/BaseNode.cpp
@@ -268,6 +268,21 @@ bool BaseNode::GetData(ImsMediaSubType* psubtype, uint8_t** ppData, uint32_t* pn
}
}
+void BaseNode::AddData(uint8_t* data, uint32_t size, uint32_t timestamp, bool mark, uint32_t seq,
+ ImsMediaSubType subtype, ImsMediaSubType dataType, uint32_t arrivalTime, int32_t index)
+{
+ DataEntry entry = DataEntry();
+ entry.pbBuffer = data;
+ entry.nBufferSize = size;
+ entry.nTimestamp = timestamp;
+ entry.bMark = mark;
+ entry.nSeqNum = seq;
+ entry.eDataType = dataType;
+ entry.subtype = subtype;
+ entry.arrivalTime = arrivalTime;
+ index == -1 ? mDataQueue.Add(&entry) : mDataQueue.InsertAt(index, &entry);
+}
+
void BaseNode::DeleteData()
{
mDataQueue.Delete();
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextSourceNode.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextSourceNode.cpp
index 82fc1b58..20a01154 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextSourceNode.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/text/nodes/TextSourceNode.cpp
@@ -30,17 +30,7 @@ TextSourceNode::TextSourceNode(BaseSessionCallback* callback) :
mSentBOM = false;
}
-TextSourceNode::~TextSourceNode()
-{
- while (mListTextSource.size() > 0)
- {
- uint8_t* text = mListTextSource.front();
- delete text;
- mListTextSource.pop_front();
- }
-
- mListTextSourceSize.clear();
-}
+TextSourceNode::~TextSourceNode() {}
kBaseNodeId TextSourceNode::GetNodeId()
{
@@ -49,7 +39,7 @@ kBaseNodeId TextSourceNode::GetNodeId()
ImsMediaResult TextSourceNode::Start()
{
- IMLOGD2("[Start] codec[%d], Redundant Level[%d]", mCodecType, mRedundantLevel);
+ IMLOGD2("[Start] codec[%d], redundant level[%d]", mCodecType, mRedundantLevel);
if (mCodecType == TextConfig::TEXT_CODEC_NONE)
{
@@ -117,52 +107,27 @@ void TextSourceNode::ProcessData()
return;
}
- std::lock_guard<std::mutex> guard(mMutex);
-
- if (mBomEnabled == true && mSentBOM == false)
+ if (mBomEnabled && !mSentBOM)
{
- SendBOM();
+ SendBom();
mSentBOM = true;
}
- uint32_t nLoopCount = 1;
-
- if (mListTextSource.size() >= T140_MAX_CHUNK)
- {
- nLoopCount = T140_MAX_CHUNK;
- }
-
- uint32_t nSendingDataSize = 0;
- memset(mTextToSend, 0, MAX_RTT_LEN);
-
- for (uint32_t i = 0;
- (i < nLoopCount && !mListTextSource.empty() && !mListTextSourceSize.empty()); i++)
- {
- // get first node data
- uint8_t* pData = mListTextSource.front();
- uint32_t nDataSize = mListTextSourceSize.front();
-
- if (pData == nullptr || nDataSize == 0)
- {
- continue;
- }
+ std::lock_guard<std::mutex> guard(mMutex);
- memcpy(mTextToSend + nSendingDataSize, pData, nDataSize);
- nSendingDataSize += nDataSize;
+ ImsMediaSubType subtype = MEDIASUBTYPE_UNDEFINED;
+ ImsMediaSubType datatype = MEDIASUBTYPE_UNDEFINED;
+ uint8_t* data = NULL;
+ uint32_t size = 0;
+ uint32_t timestamp = 0;
+ bool mark = false;
+ uint32_t seq = 0;
- free(pData);
- mListTextSourceSize.pop_front();
- mListTextSource.pop_front();
- }
-
- if (nSendingDataSize > 0)
+ if (GetData(&subtype, &data, &size, &timestamp, &mark, &seq, &datatype))
{
- // send it one char
- IMLOGD_PACKET1(IM_PACKET_LOG_TEXT, "[ProcessData] send[%s]", mTextToSend);
-
mTimeLastSent = ImsMediaTimer::GetTimeInMilliSeconds();
- SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, mTextToSend, nSendingDataSize,
- mTimeLastSent, false, 0);
+ SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, data, size, mTimeLastSent, false, 0);
+ DeleteData();
mRedundantCount = mRedundantLevel;
@@ -178,7 +143,7 @@ void TextSourceNode::ProcessData()
* after the selected buffering time, an empty T140block SHOULD be transmitted. This
* situation is regarded as the beginning of an idle period.
*/
- IMLOGD1("[ProcessData] send empty, nRedCount[%d]", mRedundantCount);
+ IMLOGD1("[ProcessData] send empty, redundant count[%d]", mRedundantCount);
// send default if there is no data to send
SendDataToRearNode(MEDIASUBTYPE_BITSTREAM_T140, nullptr, 0,
ImsMediaTimer::GetTimeInMilliSeconds(), false, 0);
@@ -188,72 +153,26 @@ void TextSourceNode::ProcessData()
void TextSourceNode::SendRtt(const android::String8* text)
{
- if (text == nullptr || text->length() == 0)
+ if (text == NULL || text->length() == 0 || text->length() > MAX_RTT_LEN)
{
IMLOGE0("[SendRtt] invalid data");
return;
}
- IMLOGD2("[SendRtt] size[%u], listSize[%d]", text->length(), mListTextSource.size());
- std::lock_guard<std::mutex> guard(mMutex);
+ IMLOGD2("[SendRtt] size[%u], listSize[%d]", text->length(), mDataQueue.GetCount());
- uint8_t* pData = (uint8_t*)text->string();
- uint32_t nSize = text->length();
- uint32_t nChunkSize = 0;
+ uint8_t tempBuffer[MAX_RTT_LEN] = {'\0'};
+ memcpy(tempBuffer, text->string(), text->length());
- while (nSize > 0)
- {
- // split with UTF-8
- if (pData[0] >= 0xC2 && pData[0] <= 0xDF && nSize >= 2)
- {
- nChunkSize = 2;
- }
- else if (pData[0] >= 0xE0 && pData[0] <= 0xEF && nSize >= 3)
- {
- nChunkSize = 3;
- }
- else if (pData[0] >= 0xF0 && pData[0] <= 0xFF && nSize >= 4)
- {
- nChunkSize = 4;
- }
- else // 1byte
- {
- nChunkSize = 1;
- }
-
- uint8_t* buffer = (uint8_t*)calloc(nChunkSize, sizeof(uint8_t));
-
- if (buffer == nullptr)
- {
- IMLOGE0("[SendRtt] allocated data is null");
- return;
- }
-
- memcpy(buffer, pData, nChunkSize);
- mListTextSource.push_back(buffer);
- mListTextSourceSize.push_back(nChunkSize);
- pData += nChunkSize;
- nSize -= nChunkSize;
- }
+ std::lock_guard<std::mutex> guard(mMutex);
+ AddData(tempBuffer, text->length(), 0, false, 0);
}
-void TextSourceNode::SendBOM()
+void TextSourceNode::SendBom()
{
- const uint32_t sizeofBom = 3;
- uint8_t* buffer = (uint8_t*)calloc(sizeofBom, sizeof(uint8_t));
-
- if (buffer == nullptr)
- {
- IMLOGE0("[SendBOM] allocated data is null");
- return;
- }
-
- // send BOM - The BOM character shall be 0xEFBBBF for UTF-8
- buffer[0] = 0xef;
- buffer[1] = 0xbb;
- buffer[2] = 0xbf;
-
IMLOGD0("[ProcessData] send BOM");
- mListTextSource.push_front(buffer);
- mListTextSourceSize.push_front(sizeofBom);
+ uint8_t bom[3] = {0xEF, 0xBB, 0xBF};
+
+ std::lock_guard<std::mutex> guard(mMutex);
+ AddData(bom, sizeof(bom), 0, false, 0, MEDIASUBTYPE_UNDEFINED, MEDIASUBTYPE_UNDEFINED, 0, 0);
} \ No newline at end of file