• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AUDIO_RTP_PAYLOAD_ENCODER_NODE_H
18 #define AUDIO_RTP_PAYLOAD_ENCODER_NODE_H
19 
20 #include <BaseNode.h>
21 #include <ImsMediaBitWriter.h>
22 
23 class AudioRtpPayloadEncoderNode : public BaseNode
24 {
25 public:
26     AudioRtpPayloadEncoderNode(BaseSessionCallback* callback = nullptr);
27     virtual ~AudioRtpPayloadEncoderNode();
28     virtual kBaseNodeId GetNodeId();
29     virtual ImsMediaResult Start();
30     virtual void Stop();
31     virtual bool IsRunTime();
32     virtual bool IsSourceNode();
33     virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize,
34             uint32_t nTimestamp, bool bMark, uint32_t nSeqNum,
35             ImsMediaSubType nDataType = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED,
36             uint32_t arrivalTime = 0);
37     virtual void SetConfig(void* config);
38     virtual bool IsSameConfig(void* config);
39 
40 private:
41     void EncodePayloadAmr(
42             uint8_t* pData, uint32_t nDataSize, uint32_t nTimestamp, uint32_t arrivalTime);
43     void EncodePayloadEvs(
44             uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, uint32_t arrivalTime);
45     uint32_t CheckPaddingNecessity(uint32_t nTotalSize);
46 
47     int32_t mCodecType;
48     bool mOctetAligned;
49     int8_t mPtime;
50     uint8_t mPayload[MAX_AUDIO_PAYLOAD_SIZE];
51     bool mFirstFrame;
52     uint32_t mTimestamp;
53     uint32_t mMaxNumOfFrame;
54     uint32_t mCurrNumOfFrame;
55     uint32_t mCurrFramePos;
56     uint32_t mTotalPayloadSize;
57     ImsMediaBitWriter mBWHeader;
58     ImsMediaBitWriter mBWPayload;
59     kEvsBandwidth mEvsBandwidth;
60     kEvsCodecMode mEvsCodecMode;
61     int8_t mEvsOffset;
62     int8_t mSendCMR;
63     kEvsBitrate mEvsMode;
64     int32_t mCoreEvsMode;
65     kRtpPayloadHeaderMode mEvsPayloadHeaderMode;
66 };
67 
68 #endif
69