Skip to content
Snippets Groups Projects
Commit e221a967 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

Clarify SIPCall class header


SIPCall API's is huge (~50 methods) and not easy to maintain
(related APIs seem to be spread over the file).
Some of them seem not even related to SIP!

The patch tries to cleanup a bit the code and sort API's to emphasize
relationships in those API.

List of changes:
- code cleanup (pragma once, fix comments, no extra indent)
- API sorting:
  - class management (ctors/dtor/...)
  - overridden methods
  - SIP related
  - Non-SIP related

This last block shows good candidates for refactoring.
This will be done later.

Change-Id: I235892c9a1118575a3b31c2f6854c32bf8b74aaf
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 4d42ed49
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __SIPCALL_H__
#define __SIPCALL_H__
#pragma once
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -65,105 +64,50 @@ class SIPCall : public Call
public:
static const char* const LINK_TYPE;
protected:
/**
* Constructor (protected)
* @param id The call identifier
* @param type The type of the call. Could be Incoming
* Outgoing
*/
SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType type);
public:
/**
* Destructor
*/
~SIPCall();
protected:
/**
* Return the SDP's manager of this call
* Constructor (protected)
* @param id The call identifier
* @param type The type of the call. Could be Incoming or Outgoing
*/
Sdp& getSDP() {
return *sdp_;
}
SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType type);
public: // overridden
const char* getLinkType() const override {
return LINK_TYPE;
}
/**
* Returns a pointer to the AudioRtpSession object
*/
AudioRtpSession& getAVFormatRTP() const {
return *avformatrtp_;
}
#ifdef RING_VIDEO
/**
* Returns a pointer to the VideoRtp object
*/
video::VideoRtpSession& getVideoRtp () {
return *videortp_;
}
#endif
/**
* The invite session to be reused in case of transfer
*/
struct InvSessionDeleter {
void operator()(pjsip_inv_session*) const noexcept;
};
std::unique_ptr<pjsip_inv_session, InvSessionDeleter> inv;
void setSecure(bool sec);
bool isSecure() const {
return srtpEnabled_;
}
void setCallMediaLocal(const pj_sockaddr& localIP);
void generateMediaPorts();
void setContactHeader(pj_str_t *contact);
void setTransport(const std::shared_ptr<SipTransport>& t);
inline SipTransport* getTransport() {
return transport_.get();
}
void sendSIPInfo(const char *const body, const char *const subtype);
void answer() override;
void hangup(int reason) override;
void refuse() override;
void transfer(const std::string& to) override;
bool attendedTransfer(const std::string& to) override;
bool onhold() override;
bool offhold() override;
void switchInput(const std::string& resource) override;
void peerHungup() override;
void carryingDTMFdigits(char code) override;
void sendTextMessage(const std::map<std::string, std::string>& messages,
const std::string& from) override;
void removeCall() override;
void muteMedia(const std::string& mediaType, bool isMuted) override;
void restartMediaSender() override;
void restartMediaReceiver() override;
bool useVideoCodec(const AccountVideoCodecInfo* codec) const override;
virtual std::map<std::string, std::string> getDetails() const override;
bool initIceTransport(bool master, unsigned channel_num=4) override;
SIPAccountBase& getSIPAccount() const;
void updateSDPFromSTUN();
public: // SIP related
/**
* Return the SDP's manager of this call
*/
Sdp& getSDP() {
return *sdp_;
}
/**
* Tell the user that the call is ringing
......@@ -189,41 +133,79 @@ class SIPCall : public Call
*/
void onClosed();
void setupLocalSDPFromIce();
bool startIce();
void startAllMedia();
void onReceiveOffer(const pjmedia_sdp_session *offer);
void onMediaUpdate();
void onReceiveOffer(const pjmedia_sdp_session *offer);
void setContactHeader(pj_str_t *contact);
void openPortsUPnP();
void setTransport(const std::shared_ptr<SipTransport>& t);
void muteMedia(const std::string& mediaType, bool isMuted) override;
inline SipTransport* getTransport() {
return transport_.get();
}
void restartMediaSender() override;
void sendSIPInfo(const char *const body, const char *const subtype);
void restartMediaReceiver() override;
SIPAccountBase& getSIPAccount() const;
bool useVideoCodec(const AccountVideoCodecInfo* codec) const override;
void updateSDPFromSTUN();
virtual std::map<std::string, std::string> getDetails() const override;
void setupLocalSDPFromIce();
bool initIceTransport(bool master, unsigned channel_num=4) override;
/**
* Give peer SDP to the call for handling
* @param sdp pointer on PJSIP sdp structure, could be nullptr (acts as no-op in such case)
*/
void setRemoteSdp(const pjmedia_sdp_session* sdp);
void terminateSipSession(int status);
void setPeerRegistredName(const std::string& name) {
peerRegistredName_ = name;
/**
* The invite session to be reused in case of transfer
*/
struct InvSessionDeleter {
void operator()(pjsip_inv_session*) const noexcept;
};
std::unique_ptr<pjsip_inv_session, InvSessionDeleter> inv;
public: // NOT SIP RELATED (good candidates to be moved elsewhere)
/**
* Returns a pointer to the AudioRtpSession object
*/
AudioRtpSession& getAVFormatRTP() const {
return *avformatrtp_;
}
#ifdef RING_VIDEO
/**
* Give peer SDP to the call for handling
* @param sdp pointer on PJSIP sdp structure, could be nullptr (acts as no-op in such case)
* Returns a pointer to the VideoRtp object
*/
void setRemoteSdp(const pjmedia_sdp_session* sdp);
video::VideoRtpSession& getVideoRtp () {
return *videortp_;
}
#endif
void setSecure(bool sec);
bool isSecure() const {
return srtpEnabled_;
}
void setCallMediaLocal(const pj_sockaddr& localIP);
void generateMediaPorts();
bool startIce();
void startAllMedia();
void openPortsUPnP();
void setPeerRegistredName(const std::string& name) {
peerRegistredName_ = name;
}
private:
NON_COPYABLE(SIPCall);
......@@ -241,10 +223,10 @@ class SIPCall : public Call
int SIPSessionReinvite();
void merge(Call& call) override; // only called by Call
std::vector<IceCandidate> getAllRemoteCandidates();
void merge(Call& call) override; // not public - only called by Call
std::unique_ptr<AudioRtpSession> avformatrtp_;
#ifdef RING_VIDEO
......@@ -290,5 +272,3 @@ inline std::shared_ptr<SIPCall> getPtr(SIPCall& call)
}
} // namespace ring
#endif // __SIPCALL_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment