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_DECODER_NODE_H 18 #define AUDIO_RTP_PAYLOAD_DECODER_NODE_H 19 20 #include <ImsMediaDefine.h> 21 #include <BaseNode.h> 22 #include <ImsMediaBitReader.h> 23 #include <ImsMediaBitWriter.h> 24 25 /** 26 * @brief this class is to decode the AMR/AMR-WB/EVS encoded rtp payload header and 27 * send payload to next node. 28 * 29 */ 30 class AudioRtpPayloadDecoderNode : public BaseNode 31 { 32 public: 33 AudioRtpPayloadDecoderNode(BaseSessionCallback* callback = nullptr); 34 virtual ~AudioRtpPayloadDecoderNode(); 35 virtual kBaseNodeId GetNodeId(); 36 virtual ImsMediaResult Start(); 37 virtual void Stop(); 38 virtual bool IsRunTime(); 39 virtual bool IsSourceNode(); 40 virtual void SetConfig(void* config); 41 virtual bool IsSameConfig(void* config); 42 virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize, 43 uint32_t nTimestamp, bool bMark, uint32_t nSeqNum, 44 ImsMediaSubType nDataType = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED, 45 uint32_t arrivalTime = 0); 46 47 private: 48 void DecodePayloadAmr(uint8_t* pData, uint32_t nDataSize, uint32_t nTimestamp, uint32_t nSeqNum, 49 uint32_t arrivalTime); 50 void DecodePayloadEvs(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, bool bMark, 51 uint32_t nSeqNum, uint32_t arrivalTime); 52 bool ProcessCMRForEVS(kRtpPayloadHeaderMode eEVSPayloadHeaderMode, kEvsCmrCodeType cmr_t, 53 kEvsCmrCodeDefine cmr_d); 54 55 private: 56 int32_t mCodecType; 57 bool mOctetAligned; 58 uint8_t mPayload[MAX_AUDIO_PAYLOAD_SIZE]; 59 std::list<uint32_t> mListFrameType; 60 ImsMediaBitReader mBitReader; 61 ImsMediaBitWriter mBitWriter; 62 uint32_t mPrevCMR; 63 int32_t mEvsBandwidth; 64 kEvsCodecMode mEvsCodecMode; 65 kRtpPayloadHeaderMode mEvsPayloadHeaderMode; 66 kEvsBitrate mEvsMode; 67 int32_t mCoreEvsMode; 68 int8_t mEvsOffset; 69 int32_t EvsChAOffset; 70 }; 71 72 #endif 73