1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TEXT_RTP_PAYLOAD_ENCODER_NODE_H
18 #define TEXT_RTP_PAYLOAD_ENCODER_NODE_H
19 
20 #include <BaseNode.h>
21 #include <ImsMediaBitWriter.h>
22 #include <ImsMediaDataQueue.h>
23 
24 class TextRtpPayloadEncoderNode : public BaseNode
25 {
26 public:
27     TextRtpPayloadEncoderNode(BaseSessionCallback* callback = nullptr);
28     virtual ~TextRtpPayloadEncoderNode();
29     virtual kBaseNodeId GetNodeId();
30     virtual ImsMediaResult Start();
31     virtual void Stop();
32     virtual bool IsRunTime();
33     virtual bool IsSourceNode();
34     virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize,
35             uint32_t nTimestamp, bool bMark, uint32_t nSeqNum,
36             ImsMediaSubType nDataType = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED,
37             uint32_t arrivalTime = 0);
38     virtual void SetConfig(void* config);
39     virtual bool IsSameConfig(void* config);
40 
41 private:
42     void EncodeT140(uint8_t* data, uint32_t size, uint32_t timestamp, bool bMark);
43 
44     int32_t mCodecType;
45     int8_t mRedundantPayload;
46     int8_t mRedundantLevel;
47     bool mKeepRedundantLevel;
48     uint8_t mPayload[MAX_RTT_LEN];
49     uint32_t mLastTimestampSent;
50     uint32_t mLastMarkedTime;
51     ImsMediaBitWriter mBWHeader;
52     ImsMediaBitWriter mBWPayload;
53     ImsMediaDataQueue mBufferQueue;
54 };
55 
56 #endif
57