xref: /OK3568_Linux_fs/external/rockit/tgi/sdk/include/RTTaskNodeContext.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2020 Rockchip Electronics Co. LTD
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Licensed under the Apache License, Version 2.0 (the "License");
5*4882a593Smuzhiyun  * you may not use this file except in compliance with the License.
6*4882a593Smuzhiyun  * You may obtain a copy of the License at
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *      http://www.apache.org/licenses/LICENSE-2.0
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Unless required by applicable law or agreed to in writing, software
11*4882a593Smuzhiyun  * distributed under the License is distributed on an "AS IS" BASIS,
12*4882a593Smuzhiyun  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4882a593Smuzhiyun  * See the License for the specific language governing permissions and
14*4882a593Smuzhiyun  * limitations under the License.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  */
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #ifndef SRC_RT_TASK_TASK_GRAPH_RTTASKNODECONTEXT_H_
19*4882a593Smuzhiyun #define SRC_RT_TASK_TASK_GRAPH_RTTASKNODECONTEXT_H_
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #include <string>
22*4882a593Smuzhiyun #include <vector>
23*4882a593Smuzhiyun #include <list>
24*4882a593Smuzhiyun #include <memory>
25*4882a593Smuzhiyun #include <map>
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include "rt_header.h"
28*4882a593Smuzhiyun #include "rt_metadata.h"
29*4882a593Smuzhiyun #include "RTStreamInfo.h"
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun class RTMediaBuffer;
32*4882a593Smuzhiyun class RTBufferListener;
33*4882a593Smuzhiyun class RTOutputStreamShared;
34*4882a593Smuzhiyun class RTMediaBufferPool;
35*4882a593Smuzhiyun class RTTaskNodeStat;
36*4882a593Smuzhiyun class RTTaskNodeContext {
37*4882a593Smuzhiyun  public:
38*4882a593Smuzhiyun     explicit RTTaskNodeContext(
39*4882a593Smuzhiyun             std::string nodeName,
40*4882a593Smuzhiyun             INT32 nodeId,
41*4882a593Smuzhiyun             std::vector<RTStreamInfo *> *inputInfos,
42*4882a593Smuzhiyun             std::vector<RTStreamInfo *> *outputInfos);
43*4882a593Smuzhiyun     ~RTTaskNodeContext();
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun     RTTaskNodeContext(const RTTaskNodeContext&) = delete;
46*4882a593Smuzhiyun     RTTaskNodeContext& operator=(const RTTaskNodeContext&) = delete;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun     RT_RET              prepareForRun(RtMetaData* options);
49*4882a593Smuzhiyun     RT_RET              cleanupAfterRun();
50*4882a593Smuzhiyun 
nodeName()51*4882a593Smuzhiyun     const std::string&  nodeName() const { return mNodeName; }
nodeId()52*4882a593Smuzhiyun     INT32               nodeId() const { return mNodeId; }
suspend()53*4882a593Smuzhiyun     void                suspend() { mSuspend = true; }
resume()54*4882a593Smuzhiyun     void                resume() { mSuspend = false; }
55*4882a593Smuzhiyun     RT_RET              flush();
isSuspend()56*4882a593Smuzhiyun     bool                isSuspend() { return mSuspend; }
options()57*4882a593Smuzhiyun     RtMetaData*         options() { return mOptions; }
58*4882a593Smuzhiyun     void                sendInterrupt(std::string reason);
59*4882a593Smuzhiyun     void                cancelInterrupt(std::string reason);
60*4882a593Smuzhiyun     void                setOutputBufferListener(RTBufferListener *listener);
61*4882a593Smuzhiyun     void                setMaxBatchPrcoessSize(INT32 maxBatchSize);
62*4882a593Smuzhiyun     INT32               getMaxBatchPrcoessSize();
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun     RTStreamInfo*       getInputInfo(std::string streamType = "none");
65*4882a593Smuzhiyun     RTStreamInfo*       getOutputInfo(std::string streamType = "none");
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun     RT_RET              getPackets(std::list<RTMediaBuffer *> *packets, std::string streamType = "none");
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun     RT_BOOL             hasInputStream(std::string streamType = "none");
70*4882a593Smuzhiyun     RT_BOOL             hasOutputStream(std::string streamType = "none");
71*4882a593Smuzhiyun     INT32               inputQueueSize(std::string streamType = "none");
72*4882a593Smuzhiyun     RT_BOOL             inputIsEmpty(std::string streamType = "none");
73*4882a593Smuzhiyun     RT_BOOL             outputIsEmpty(std::string streamType = "none");
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun     RTMediaBuffer*      inputHeadBuffer(std::string streamType = "none");
76*4882a593Smuzhiyun     RTMediaBuffer*      dequeInputBuffer(std::string streamType = "none");
77*4882a593Smuzhiyun     RT_RET              queueInputBuffer(RTMediaBuffer *packet, std::string streamTpye = "none");
78*4882a593Smuzhiyun     RTMediaBuffer*      dequeOutputBuffer(RT_BOOL block = RT_TRUE,
79*4882a593Smuzhiyun                                            UINT32 size = 0,
80*4882a593Smuzhiyun                                            std::string streamType = "none");
81*4882a593Smuzhiyun     RT_RET              queueOutputBuffer(RTMediaBuffer *packet, std::string streamType = "none");
82*4882a593Smuzhiyun     RT_RET              getBufferStat(RTTaskNodeStat *stat);
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun     RT_RET              reallocOutputBuffers(INT32 wantSize, std::string streamType = "none");
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun     RT_RET              attachOutStreamPool(RTMediaBufferPool *pool, std::string streamType = "none");
87*4882a593Smuzhiyun     RT_RET              detachOutStreamPool(std::string streamType = "none");
88*4882a593Smuzhiyun     RT_RET              pollOutputBuffer(RT_BOOL block = RT_TRUE,
89*4882a593Smuzhiyun                                           UINT32 size = 0,
90*4882a593Smuzhiyun                                           std::string streamType = "none");
91*4882a593Smuzhiyun     INT32               getOutputBufferSize(std::string streamType = "none");
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun     RT_RET              dump();
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun  private:
96*4882a593Smuzhiyun     std::vector<RTMediaBuffer *>*   inputs(std::string streamType = "none");
97*4882a593Smuzhiyun     RTOutputStreamShared*           outputs(std::string streamType = "none");
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun  private:
100*4882a593Smuzhiyun     std::map<std::string, std::vector<RTMediaBuffer *>> mInputs;
101*4882a593Smuzhiyun     std::map<std::string, RTOutputStreamShared *>       mOutputs;
102*4882a593Smuzhiyun     RtMetaData                     *mOptions;
103*4882a593Smuzhiyun     INT32                           mNodeId;
104*4882a593Smuzhiyun     std::string                     mNodeName;
105*4882a593Smuzhiyun     bool                            mSuspend = false;
106*4882a593Smuzhiyun     INT32                           mMaxBatchProcessSize = 4;
107*4882a593Smuzhiyun     std::vector<RTStreamInfo *>    *mInputInfos;
108*4882a593Smuzhiyun     std::vector<RTStreamInfo *>    *mOutputInfos;
109*4882a593Smuzhiyun     RtMutex                         mInputMutex;
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun #endif  // SRC_RT_TASK_TASK_GRAPH_RTTASKNODECONTEXT_H_
113*4882a593Smuzhiyun 
114