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 VIDEO_RTP_PAYLOAD_ENCODER_NODE_H_INCLUDED 18 #define VIDEO_RTP_PAYLOAD_ENCODER_NODE_H_INCLUDED 19 20 #include <ImsMediaDefine.h> 21 #include <BaseNode.h> 22 #include <ImsMediaVideoUtil.h> 23 24 /** 25 * @brief this class is to decode the Avc/Hevc encoded video rtp payload header and send payload 26 * to next node. 27 * 28 */ 29 class VideoRtpPayloadEncoderNode : public BaseNode 30 { 31 public: 32 VideoRtpPayloadEncoderNode(BaseSessionCallback* callback = nullptr); 33 virtual ~VideoRtpPayloadEncoderNode(); 34 virtual kBaseNodeId GetNodeId(); 35 virtual ImsMediaResult Start(); 36 virtual void Stop(); 37 virtual bool IsRunTime(); 38 virtual bool IsSourceNode(); 39 virtual void SetConfig(void* config); 40 virtual bool IsSameConfig(void* config); 41 virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize, 42 uint32_t nTimestamp, bool bMark, uint32_t nSeqNum, 43 ImsMediaSubType nDataType = MEDIASUBTYPE_UNDEFINED, uint32_t arrivalTime = 0); 44 45 private: 46 bool ResetStartTime(); 47 uint8_t* FindAvcStartCode(uint8_t* pData, uint32_t nDataSize, uint32_t* pnSkipSize = nullptr); 48 uint8_t* FindHevcStartCode(uint8_t* pData, uint32_t nDataSize, uint32_t* pnSkipSize = nullptr); 49 void EncodeAvc(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, bool bMark); 50 /** h.264 start coded has been removed at EncodeAvc() 51 * pData starts with nal unit header */ 52 void EncodeAvcNALUnit(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, bool bMark, 53 uint32_t nNalUnitType); 54 /* encode H.265 RTP payload header */ 55 void EncodeHevc(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, bool bMark); 56 /* encode H.265 RTP payload nal unit header */ 57 void EncodeHevcNALUnit(uint8_t* pData, uint32_t nDataSize, uint32_t nTimeStamp, bool bMark, 58 uint32_t nNalUnitType); 59 60 uint32_t mCodecType; 61 uint32_t mPayloadMode; 62 bool mPrevMark; 63 uint8_t* mBuffer; 64 uint8_t mVPS[MAX_CONFIG_LEN]; 65 uint8_t mSPS[MAX_CONFIG_LEN]; 66 uint8_t mPPS[MAX_CONFIG_LEN]; 67 uint32_t mVPSsize; 68 uint32_t mSpsSize; 69 uint32_t mPpsSize; 70 uint32_t mMaxFragmentUnitSize; 71 }; 72 73 #endif // VIDEO_RTP_PAYLOAD_ENCODER_NODE_H_INCLUDED 74