- clang format + naming improved

This commit is contained in:
2026-09-03 10:03:42 +03:00
parent 249e614def
commit e166bae1ea
204 changed files with 20621 additions and 21019 deletions
+257 -259
View File
@@ -49,365 +49,363 @@ class ResipSession;
enum SessionInfo
{
SessionInfo_RemoteSipAddress, // remote sip address
SessionInfo_ReceivedTraffic, // amount of received traffic in session in bytes
SessionInfo_SentTraffic, // amount of sent traffic in session in bytes
SessionInfo_PacketLoss, // lost packets counter; returns number of 1/1000 fractions (0.1%)
SessionInfo_AudioPeer, // remote peer rtp address in text
SessionInfo_AudioCodec, // selected audio codec as text
SessionInfo_DtmfInterface, // Pointer to DtmfQueue class; returned as void*
SessionInfo_IceState,
SessionInfo_NetworkMos,
SessionInfo_PvqaMos,
SessionInfo_PvqaReport,
SessionInfo_SentRtp,
SessionInfo_SentRtcp,
SessionInfo_ReceivedRtp,
SessionInfo_ReceivedRtcp,
SessionInfo_LostRtp,
SessionInfo_DroppedRtp,
SessionInfo_Duration,
SessionInfo_Jitter,
SessionInfo_Rtt,
SessionInfo_BitrateSwitchCounter, // It is for AMR codecs only
SessionInfo_RemotePeer,
SessionInfo_SSRC,
SessionInfo_CngCounter, // For AMR codecs only
SessionInfo_ReceivedRtpTraffic // amount of received RTP traffic in bytes, RTCP excluded
SessionInfo_RemoteSipAddress, // remote sip address
SessionInfo_ReceivedTraffic, // amount of received traffic in session in bytes
SessionInfo_SentTraffic, // amount of sent traffic in session in bytes
SessionInfo_PacketLoss, // lost packets counter; returns number of 1/1000 fractions (0.1%)
SessionInfo_AudioPeer, // remote peer rtp address in text
SessionInfo_AudioCodec, // selected audio codec as text
SessionInfo_DtmfInterface, // Pointer to DtmfQueue class; returned as void*
SessionInfo_IceState,
SessionInfo_NetworkMos,
SessionInfo_PvqaMos,
SessionInfo_PvqaReport,
SessionInfo_SentRtp,
SessionInfo_SentRtcp,
SessionInfo_ReceivedRtp,
SessionInfo_ReceivedRtcp,
SessionInfo_LostRtp,
SessionInfo_DroppedRtp,
SessionInfo_Duration,
SessionInfo_Jitter,
SessionInfo_Rtt,
SessionInfo_BitrateSwitchCounter, // It is for AMR codecs only
SessionInfo_RemotePeer,
SessionInfo_SSRC,
SessionInfo_CngCounter, // For AMR codecs only
SessionInfo_ReceivedRtpTraffic // amount of received RTP traffic in bytes, RTCP excluded
};
class Session :
public SocketSink,
public ice::StageHandler
class Session : public SocketSink, public ice::StageHandler
{
public:
class Command
{
public:
virtual void run(Session& s) = 0;
};
// Describes ice stream/component
struct IceInfo
{
IceInfo()
:mStreamId(-1)
class Command
{
mPort4 = mPort6 = 0;
mComponentId.mRtp = mComponentId.mRtcp = -1;
}
public:
virtual void run(Session& s) = 0;
};
RtpPair<int> mComponentId;
int mStreamId;
unsigned short mPort4;
unsigned short mPort6;
};
// Describes ice stream/component
struct IceInfo
{
IceInfo() : mStreamId(-1)
{
mPort4 = mPort6 = 0;
mComponentId.mRtp = mComponentId.mRtcp = -1;
}
// Describes media stream (audio/video) in session
class Stream
{
public:
Stream();
~Stream();
RtpPair<int> mComponentId;
int mStreamId;
unsigned short mPort4;
unsigned short mPort6;
};
void setProvider(PDataProvider provider);
PDataProvider provider();
// Describes media stream (audio/video) in session
class Stream
{
public:
Stream();
~Stream();
void setSocket4(const RtpPair<PDatagramSocket>& socket);
RtpPair<PDatagramSocket>& socket4();
void setProvider(PDataProvider provider);
PDataProvider provider();
void setSocket6(const RtpPair<PDatagramSocket>& socket);
RtpPair<PDatagramSocket>& socket6();
void setSocket4(const RtpPair<PDatagramSocket>& socket);
RtpPair<PDatagramSocket>& socket4();
void setIceInfo(const IceInfo& info);
IceInfo iceInfo() const;
void setSocket6(const RtpPair<PDatagramSocket>& socket);
RtpPair<PDatagramSocket>& socket6();
// rtcpAttr/rtcpMuxAttr signals about corresponding sip attribute in offer/answer from remote peer
bool rtcpAttr() const;
void setRtcpAttr(bool value);
void setIceInfo(const IceInfo& info);
IceInfo iceInfo() const;
bool rtcpMuxAttr() const;
void setRtcpMuxAttr(bool value);
// rtcpAttr/rtcpMuxAttr signals about corresponding sip attribute in offer/answer from remote peer
bool rtcpAttr() const;
void setRtcpAttr(bool value);
protected:
// Provider for corresponding stream
PDataProvider mProvider;
bool rtcpMuxAttr() const;
void setRtcpMuxAttr(bool value);
// Socket for stream
RtpPair<PDatagramSocket> mSocket4, mSocket6;
protected:
// Provider for corresponding stream
PDataProvider mProvider;
bool mRtcpAttr;
bool mRtcpMuxAttr;
IceInfo mIceInfo;
};
// Socket for stream
RtpPair<PDatagramSocket> mSocket4, mSocket6;
Session(PAccount account);
virtual ~Session();
bool mRtcpAttr;
bool mRtcpMuxAttr;
IceInfo mIceInfo;
};
// Starts call to specified peer
void start(const std::string& peer);
Session(PAccount account);
virtual ~Session();
// Stops call
void stop();
// Starts call to specified peer
void start(const std::string& peer);
// Accepts call
void accept();
// Stops call
void stop();
// Rejects call
void reject(int code);
// Accepts call
void accept();
enum class InfoOptions
{
Standard = 0,
Detailed = 1,
};
// Rejects call
void reject(int code);
void getSessionInfo(InfoOptions options, VariantMap& result);
enum class InfoOptions
{
Standard = 0,
Detailed = 1,
};
// Returns integer identifier of the session; it is unique amongst all session in application
int id() const;
void getSessionInfo(InfoOptions options, VariantMap& result);
// Returns owning account
PAccount account();
// Returns integer identifier of the session; it is unique amongst all session in application
int id() const;
typedef std::map<std::string, std::string> UserHeaders;
void setUserHeaders(const UserHeaders& headers);
// Returns owning account
PAccount account();
// Called when new media data are available for this session
void onReceivedData(PDatagramSocket socket, InternetAddress& src, const void* receivedPtr, unsigned receivedSize);
typedef std::map<std::string, std::string> UserHeaders;
void setUserHeaders(const UserHeaders& headers);
// Called when new candidate is gathered
void onCandidateGathered(ice::Stack* stack, void* tag, const char* address);
// Called when new media data are available for this session
void onReceivedData(PDatagramSocket socket, InternetAddress& src, const void* receivedPtr, unsigned receivedSize);
// Called when connectivity check is finished
void onCheckFinished(ice::Stack* stack, void* tag, const char* checkDescription);
// Called when new candidate is gathered
void onCandidateGathered(ice::Stack* stack, void* tag, const char* address);
// Called when ICE candidates are gathered - with success or timeout.
void onGathered(ice::Stack* stack, void* tag);
// Called when connectivity check is finished
void onCheckFinished(ice::Stack* stack, void* tag, const char* checkDescription);
// Called when ICE connectivity check is good at least for one of required streams
void onSuccess(ice::Stack* stack, void* tag);
// Called when ICE candidates are gathered - with success or timeout.
void onGathered(ice::Stack* stack, void* tag);
// Called when ICE connectivity check is failed for all of required streams
void onFailed(ice::Stack* stack, void* tag);
// Called when ICE connectivity check is good at least for one of required streams
void onSuccess(ice::Stack* stack, void* tag);
// Called when ICE stack detects network change during the call
void onNetworkChange(ice::Stack* stack, void* tag);
// Called when ICE connectivity check is failed for all of required streams
void onFailed(ice::Stack* stack, void* tag);
// Fills SDP according to ICE and provider's data
void buildSdp(resip::SdpContents& sdp, SdpDirection sdpDirection);
// Called when ICE stack detects network change during the call
void onNetworkChange(ice::Stack* stack, void* tag);
// Searches provider by its local port number
PDataProvider findProviderByPort(int family, unsigned short port);
// Fills SDP according to ICE and provider's data
void buildSdp(resip::SdpContents& sdp, SdpDirection sdpDirection);
// Add provider to internal list
void addProvider(PDataProvider provider);
PDataProvider providerAt(int index);
int getProviderCount();
// Searches provider by its local port number
PDataProvider findProviderByPort(int family, unsigned short port);
void setUserAgent(UserAgent* agent);
UserAgent* userAgent();
// Add provider to internal list
void addProvider(PDataProvider provider);
PDataProvider providerAt(int index);
int getProviderCount();
// Pauses and resumes all providers; updates states
void pause();
void resume();
void refreshMediaPath();
void setUserAgent(UserAgent* agent);
UserAgent* userAgent();
// Processes new sdp from offer. Returns response code (200 is ok, 488 bad codec, 503 internal error).
// There are passing string objects by value; this is correct; this values will modified on the stack.
int processSdp(uint64_t version, bool iceAvailable, std::string icePwd, const std::string iceUfrag,
std::string remoteIp, const resip::SdpContents::Session::MediumContainer& media);
// Pauses and resumes all providers; updates states
void pause();
void resume();
void refreshMediaPath();
// Session ID
int mSessionId;
// Processes new sdp from offer. Returns response code (200 is ok, 488 bad codec, 503 internal error).
// There are passing string objects by value; this is correct; this values will modified on the stack.
int processSdp(uint64_t version, bool iceAvailable, std::string icePwd, const std::string iceUfrag,
std::string remoteIp, const resip::SdpContents::Session::MediumContainer& media);
// Media streams collection
std::vector<Stream> mStreamList;
// Session ID
int mSessionId;
// Smart pointer to ICE stack. Actually stack is created in CreateICEStack() method
std::shared_ptr<ice::Stack> mIceStack;
// Media streams collection
std::vector<Stream> mStreamList;
// Pointer to owner user agent instance
UserAgent* mUserAgent;
// Smart pointer to ICE stack. Actually stack is created in CreateICEStack() method
std::shared_ptr<ice::Stack> mIceStack;
// Remote peer SIP address
resip::NameAddr mRemotePeer;
// Pointer to owner user agent instance
UserAgent* mUserAgent;
// Mutex to protect this instance
Mutex mGuard;
// Remote peer SIP address
resip::NameAddr mRemotePeer;
// SDP's origin version for sending
int mOriginVersion;
uint64_t mRemoteOriginVersion;
// Mutex to protect this instance
Mutex mGuard;
// SDP's session version
int mSessionVersion;
// SDP's origin version for sending
int mOriginVersion;
uint64_t mRemoteOriginVersion;
// Marks if this session does not need OnNewSession event
bool mAcceptedByEngine;
bool mAcceptedByUser;
// SDP's session version
int mSessionVersion;
// Invite session handle
resip::InviteSessionHandle mInviteHandle;
// Marks if this session does not need OnNewSession event
bool mAcceptedByEngine;
bool mAcceptedByUser;
// Dialog set object pointer
ResipSession* mResipSession;
// Invite session handle
resip::InviteSessionHandle mInviteHandle;
// Reference counter
int mRefCount;
// Dialog set object pointer
ResipSession* mResipSession;
enum
{
Initiator = 1,
Acceptor = 2
};
// Reference counter
int mRefCount;
// Specifies session role - caller (Initiator) or callee (Acceptor)
volatile int mRole;
enum
{
Initiator = 1,
Acceptor = 2
};
// Marks if candidates are gather already
volatile bool mGatheredCandidates;
// Specifies session role - caller (Initiator) or callee (Acceptor)
volatile int mRole;
// Marks if OnTerminated event was called already on session
volatile bool mTerminated;
// Marks if candidates are gather already
volatile bool mGatheredCandidates;
// User friend remote peer's sip address
std::string mRemoteAddress;
// Marks if OnTerminated event was called already on session
volatile bool mTerminated;
// Application specific data
void* mTag;
// Used to count number of transistions to Connected state and avoid multiple onEstablished events.
int mOfferAnswerCounter;
// User friend remote peer's sip address
std::string mRemoteAddress;
// List of turn prefixes related to sessioj
std::vector<int> mTurnPrefixList;
// Application specific data
void* mTag;
// True if user agent has to send offer
bool mHasToSendOffer;
// Used to count number of transistions to Connected state and avoid multiple onEstablished events.
int mOfferAnswerCounter;
// True if user agent has to enqueue offer after ice gather finished
bool mSendOfferUpdateAfterIceGather;
// List of turn prefixes related to sessioj
std::vector<int> mTurnPrefixList;
// Related sip account
PAccount mAccount;
// True if user agent has to send offer
bool mHasToSendOffer;
// User headers for INVITE transaction
UserHeaders mUserHeaders;
// True if user agent has to enqueue offer after ice gather finished
bool mSendOfferUpdateAfterIceGather;
std::string remoteAddress() const;
void setRemoteAddress(const std::string& address);
// Related sip account
PAccount mAccount;
void* tag();
void setTag(void* tag);
int sessionId();
int increaseSdpVersion();
int addRef();
int release();
// User headers for INVITE transaction
UserHeaders mUserHeaders;
// Deletes providers and media sockets
void clearProvidersAndSockets();
std::string remoteAddress() const;
void setRemoteAddress(const std::string& address);
// Deletes providers
void clearProviders();
void* tag();
void setTag(void* tag);
int sessionId();
int increaseSdpVersion();
int addRef();
int release();
// Helper method to find audio provider for active sip stream
AudioProvider* findProviderForActiveAudio();
// Deletes providers and media sockets
void clearProvidersAndSockets();
void processCommandList();
void addCommand(Command* cmd);
void enqueueOffer();
void processQueuedOffer();
static int generateId();
static std::atomic_int IdGenerator;
static std::atomic_int InstanceCounter;
// Deletes providers
void clearProviders();
// Helper method to find audio provider for active sip stream
AudioProvider* findProviderForActiveAudio();
void processCommandList();
void addCommand(Command* cmd);
void enqueueOffer();
void processQueuedOffer();
static int generateId();
static std::atomic_int IdGenerator;
static std::atomic_int InstanceCounter;
};
typedef std::shared_ptr<Session> PSession;
/////////////////////////////////////////////////////////////////////////////////
//
// Classes that provide the mapping between Application Data and DUM
// Classes that provide the mapping between Application Data and DUM
// dialogs/dialogsets
//
//
// The DUM layer creates an AppDialog/AppDialogSet object for inbound/outbound
// SIP Request that results in Dialog creation.
//
//
/////////////////////////////////////////////////////////////////////////////////
class ResipSessionAppDialog : public resip::AppDialog
{
public:
ResipSessionAppDialog(resip::HandleManager& ham);
virtual ~ResipSessionAppDialog();
ResipSessionAppDialog(resip::HandleManager& ham);
virtual ~ResipSessionAppDialog();
};
class ResipSession: public resip::AppDialogSet
class ResipSession : public resip::AppDialogSet
{
friend class UserAgent;
friend class Account;
friend class UserAgent;
friend class Account;
public:
enum Type
{
Type_None,
Type_Registration,
Type_Subscription,
Type_Call,
Type_Auto
};
static std::atomic_int InstanceCounter;
enum Type
{
Type_None,
Type_Registration,
Type_Subscription,
Type_Call,
Type_Auto
};
static std::atomic_int InstanceCounter;
ResipSession(resip::DialogUsageManager& dum);
virtual ~ResipSession();
virtual resip::AppDialog* createAppDialog(const resip::SipMessage& msg);
virtual std::shared_ptr<resip::UserProfile> selectUASUserProfile(const resip::SipMessage& msg);
void setType(Type type);
Type type();
Session* session();
void setSession(Session* session);
UserAgent* ua();
void setUa(UserAgent* ua);
// Used for subscriptions/messages
int sessionId();
// Used for subscriptions/messages
void* tag() const;
void setTag(void* tag);
ResipSession(resip::DialogUsageManager& dum);
virtual ~ResipSession();
virtual resip::AppDialog* createAppDialog(const resip::SipMessage& msg);
virtual std::shared_ptr<resip::UserProfile> selectUASUserProfile(const resip::SipMessage& msg);
// Used for subscriptions/messages
std::string remoteAddress() const;
void setRemoteAddress(std::string address);
void setType(Type type);
Type type();
void runTerminatedEvent(Type type, int code = 0, int reason = 0);
Session* session();
void setSession(Session* session);
void setUASProfile(const std::shared_ptr<resip::UserProfile>& profile);
UserAgent* ua();
void setUa(UserAgent* ua);
// Used for subscriptions/messages
int sessionId();
// Used for subscriptions/messages
void* tag() const;
void setTag(void* tag);
// Used for subscriptions/messages
std::string remoteAddress() const;
void setRemoteAddress(std::string address);
void runTerminatedEvent(Type type, int code = 0, int reason = 0);
void setUASProfile(const std::shared_ptr<resip::UserProfile>& profile);
protected:
bool mTerminated;
UserAgent* mUserAgent;
Type mType;
Session* mSession;
int mSessionId;
std::string mRemoteAddress;
void* mTag;
bool mOnWatchingStartSent;
std::shared_ptr<resip::UserProfile> mUASProfile;
bool mTerminated;
UserAgent* mUserAgent;
Type mType;
Session* mSession;
int mSessionId;
std::string mRemoteAddress;
void* mTag;
bool mOnWatchingStartSent;
std::shared_ptr<resip::UserProfile> mUASProfile;
};
class ResipSessionFactory : public resip::AppDialogSetFactory
{
public:
ResipSessionFactory(UserAgent* agent);
virtual resip::AppDialogSet* createAppDialogSet(resip::DialogUsageManager& dum, const resip::SipMessage& msg);
ResipSessionFactory(UserAgent* agent);
virtual resip::AppDialogSet* createAppDialogSet(resip::DialogUsageManager& dum, const resip::SipMessage& msg);
protected:
UserAgent* mAgent;
};
UserAgent* mAgent;
};
#endif