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 BASE_SESSION_H
18 #define BASE_SESSION_H
19 
20 #include <BaseSessionCallback.h>
21 #include <RtpConfig.h>
22 #include <MediaQualityThreshold.h>
23 #include <stdint.h>
24 
25 class BaseSession : public BaseSessionCallback
26 {
27 public:
28     BaseSession();
29     virtual ~BaseSession();
30 
31     /** Set the session id */
32     void setSessionId(const int32_t sessionId);
33 
34     /** Set the local socket file descriptor for rtp and rtcp */
35     void setLocalEndPoint(const int32_t rtpFd, const int32_t rtcpFd);
36 
37     /** Get the local rtp socket file descriptor */
38     int32_t getLocalRtpFd();
39 
40     /** Get the local rtcp socket file descriptor */
41     int32_t getLocalRtcpFd();
42 
43     /**
44      * @brief Called when the BaseSessionCallback SendEvent invoked.
45      *
46      * @param type The ImsMediaType type defined in ImsMediaDefine.h
47      * @param param1 The parameter to set
48      * @param param2 The parameter to set
49      */
50     virtual void onEvent(int32_t type, uint64_t param1, uint64_t param2);
51 
52     /**
53      * @brief Sets the media quality threshold parameters of the session to get media quality
54      * notifications.
55      */
56     void setMediaQualityThreshold(const MediaQualityThreshold& threshold);
57 
58 protected:
59     /**
60      * @brief get the stream state
61      * @return SessionState state defined by the stream state, check #SessionState
62      */
63     virtual SessionState getState() = 0;
64     /**
65      * @brief Create and start stream graph instance. if the graph is already existed, then update
66      *        graph with the RtpConfig
67      *
68      * @param config The parameters to operate nodes in the StreamGraph.
69      * @return ImsMediaResult result of create or start graph. If the result has no error, it
70      *         returns RESULT_SUCCESS. check #ImsMediaDefine.h.
71      */
72     virtual ImsMediaResult startGraph(RtpConfig* config) = 0;
73 
74     int mSessionId;
75     int mRtpFd;
76     int mRtcpFd;
77     MediaQualityThreshold mThreshold;
78     int mState;
79 };
80 
81 #endif