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 JITTER_BUFFER_CONTROL_NODE_H
18 #define JITTER_BUFFER_CONTROL_NODE_H
19 
20 #include <BaseJitterBuffer.h>
21 #include <BaseNode.h>
22 
23 class JitterBufferControlNode : public BaseNode
24 {
25 public:
26     JitterBufferControlNode(
27             BaseSessionCallback* callback = nullptr, ImsMediaType type = IMS_MEDIA_AUDIO);
28     virtual ~JitterBufferControlNode();
29     void SetJitterBufferSize(uint32_t nInit, uint32_t nMin, uint32_t nMax);
30     void Reset();
31     virtual uint32_t GetDataCount();
32     virtual void OnDataFromFrontNode(ImsMediaSubType subtype, uint8_t* pData, uint32_t nDataSize,
33             uint32_t timestamp, bool mark, uint32_t nSeqNum,
34             ImsMediaSubType nDataType = ImsMediaSubType::MEDIASUBTYPE_UNDEFINED,
35             uint32_t arrivalTime = 0);
36     virtual bool GetData(ImsMediaSubType* psubtype, uint8_t** ppData, uint32_t* pnDataSize,
37             uint32_t* ptimestamp, bool* pmark, uint32_t* pnSeqNum,
38             ImsMediaSubType* pnDataType = nullptr, uint32_t* arrivalTime = nullptr);
39     virtual bool GetRedundantFrame(uint32_t lostSeq, uint8_t** ppData = nullptr,
40             uint32_t* pnDataSize = nullptr, bool* hasNextFrame = nullptr,
41             uint8_t* nextFrameFirstByte = nullptr);
42     virtual void DeleteData();
43 
44 private:
45     JitterBufferControlNode(const JitterBufferControlNode& objRHS);
46     JitterBufferControlNode& operator=(const JitterBufferControlNode& objRHS);
47 
48 protected:
49     BaseJitterBuffer* mJitterBuffer;
50     ImsMediaType mMediaType;
51 };
52 
53 #endif