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(uint8_t* pData, uint32_t nDataSize, uint32_t nTimestamp); 42 void EncodePayloadEvs(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp); 43 uint32_t CheckPaddingNecessity(uint32_t nTotalSize); 44 45 int32_t mCodecType; 46 bool mOctetAligned; 47 int8_t mPtime; 48 uint8_t mPayload[MAX_AUDIO_PAYLOAD_SIZE]; 49 bool mFirstFrame; 50 uint32_t mTimestamp; 51 uint32_t mMaxNumOfFrame; 52 uint32_t mCurrNumOfFrame; 53 uint32_t mCurrFramePos; 54 uint32_t mTotalPayloadSize; 55 ImsMediaBitWriter mBWHeader; 56 ImsMediaBitWriter mBWPayload; 57 kEvsBandwidth mEvsBandwidth; 58 kEvsCodecMode mEvsCodecMode; 59 int8_t mEvsOffset; 60 int8_t mSendCMR; 61 kEvsBitrate mEvsMode; 62 int32_t mCoreEvsMode; 63 kRtpPyaloadHeaderMode mEvsPayloadHeaderMode; 64 }; 65 66 #endif 67