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 #include <BaseSession.h>
18 #include <ImsMediaTrace.h>
19 #include <ImsMediaEventHandler.h>
20 #include <string.h>
21 #include <ImsMediaNetworkUtil.h>
22 
BaseSession()23 BaseSession::BaseSession() :
24         mRtpFd(-1),
25         mRtcpFd(-1),
26         mState(kSessionStateClosed)
27 {
28 }
29 
~BaseSession()30 BaseSession::~BaseSession()
31 {
32     if (mRtpFd != -1)
33     {
34         IMLOGD0("[~BaseSession] close rtp fd");
35         ImsMediaNetworkUtil::closeSocket(mRtpFd);
36     }
37 
38     if (mRtcpFd != -1)
39     {
40         IMLOGD0("[~BaseSession] close rtcp fd");
41         ImsMediaNetworkUtil::closeSocket(mRtcpFd);
42     }
43 }
44 
setSessionId(int sessionId)45 void BaseSession::setSessionId(int sessionId)
46 {
47     mSessionId = sessionId;
48 }
49 
setLocalEndPoint(int rtpFd,int rtcpFd)50 void BaseSession::setLocalEndPoint(int rtpFd, int rtcpFd)
51 {
52     IMLOGI2("[setLocalEndPoint] rtpFd[%d], rtcpFd[%d]", rtpFd, rtcpFd);
53     mRtpFd = rtpFd;
54     mRtcpFd = rtcpFd;
55 }
56 
getLocalRtpFd()57 int32_t BaseSession::getLocalRtpFd()
58 {
59     return mRtpFd;
60 }
61 
getLocalRtcpFd()62 int32_t BaseSession::getLocalRtcpFd()
63 {
64     return mRtcpFd;
65 }
66 
onEvent(int32_t type,uint64_t param1,uint64_t param2)67 void BaseSession::onEvent(int32_t type, uint64_t param1, uint64_t param2)
68 {
69     IMLOGI3("[onEvent] type[%d], param1[%d], param2[%d]", type, param1, param2);
70 }
71 
setMediaQualityThreshold(const MediaQualityThreshold & threshold)72 void BaseSession::setMediaQualityThreshold(const MediaQualityThreshold& threshold)
73 {
74     IMLOGI0("[setMediaQualityThreshold]");
75     mThreshold = threshold;
76 }