31#include <dhtnet/ip_utils.h>
39#include <condition_variable>
48 using wt = std::weak_ptr<T>;
49 return !weak.owner_before(wt {}) && !wt {}.owner_before(weak);
56class AudioDeviceGuard;
61using CallMap = std::map<std::string, std::shared_ptr<Call>>;
112 using SubcallSet = std::set<std::shared_ptr<Call>, std::owner_less<std::shared_ptr<Call>>>;
217 virtual std::map<std::string, std::string>
getDetails()
const;
333 stateChangedListeners_.emplace_back(std::move(listener));
357 ? std::chrono::milliseconds::zero()
358 : std::chrono::duration_cast<std::chrono::milliseconds>(clock::now()
380 virtual void muteMedia(
const std::string& mediaType,
bool isMuted) = 0;
408 const std::string& from)
456 using clock = std::chrono::steady_clock;
467 const std::string&
id,
469 const std::map<std::string, std::string>&
details = {});
481 using MsgList = std::list<std::pair<std::map<std::string, std::string>, std::string>>;
496 void checkPendingIM();
504 std::vector<StateListenerCb> stateChangedListeners_ {};
548inline std::shared_ptr<Call>
551 return call.shared_from_this();
bool is_uninitialized(std::weak_ptr< T > const &weak)
virtual bool onhold(OnReadyCb &&cb)=0
Put a call on hold.
virtual LinkType getLinkType() const
int peerConfProtocol_
Supported conference protocol version.
virtual bool offhold(OnReadyCb &&cb)=0
Resume a call from hold state.
std::chrono::steady_clock clock
virtual bool isIceEnabled() const =0
Check wether ICE is enabled for media.
void setPeerDisplayName(const std::string &name)
Set the display name (caller in ingoing) not protected by mutex (when created)
void onTextMessage(std::map< std::string, std::string > &&messages)
virtual void restartMediaSender()=0
MsgList pendingInMessages_
virtual void switchInput(const std::string &={})
virtual void exitConference()=0
const std::string & toUsername() const
Get "To" from the invite.
virtual bool checkMediaChangeRequest(const std::vector< libjami::MediaMap > &remoteMediaList)=0
Check the media of an incoming media change request.
std::string peerNumber_
Number of the peer.
const std::string & getCallId() const
Return a reference on the call id.
virtual void carryingDTMFdigits(char code)=0
Send DTMF.
virtual void transfer(const std::string &to)=0
Transfer a call to specified URI.
virtual bool isCaptureDeviceMuted(const MediaType &mediaType) const =0
virtual bool requestMediaChange(const std::vector< libjami::MediaMap > &mediaList)=0
Make a change request of the current media with the provided media.
std::set< std::shared_ptr< Call >, std::owner_less< std::shared_ptr< Call > > > SubcallSet
CallState getState() const
Get the call state of the call (protected by mutex)
virtual void sendTextMessage(const std::map< std::string, std::string > &messages, const std::string &from)=0
Send a message to a call identified by its callid.
virtual void muteMedia(const std::string &mediaType, bool isMuted)=0
mute/unmute a media of a call
virtual void sendKeyframe(int streamIdx=-1)=0
std::function< void(bool)> OnReadyCb
std::mutex confInfoMutex_
void toUsername(const std::string &username)
Updated by sipvoiplink, corresponds to the "To" in the invite.
virtual std::vector< libjami::MediaMap > currentMediaList() const =0
Retrieve current medias list.
virtual std::shared_ptr< SystemCodecInfo > getAudioCodec() const
void addSubCall(Call &call)
Attach subcall to this instance.
std::weak_ptr< Account > account_
Associate account ID.
CallType
This determines if the call originated from the local user (OUTGOING) or from some remote peer (INCOM...
virtual void answer()=0
Answer the call.
std::string getStateStr() const
virtual void hangup(int reason)=0
Hang up the call.
virtual void monitor() const =0
clock::time_point time_point
std::chrono::milliseconds getCallDuration() const
bool isConferenceParticipant() const
ConnectionState getConnectionState() const
Get the connection state of the call (protected by mutex)
CallType type_
Type of the call.
std::shared_ptr< Conference > getConference() const
Return a reference on the conference id.
std::shared_ptr< Call > parent_
MultiDevice: list of attached subcall.
bool isSubcall() const
Return true if this call instance is a subcall (internal call for multi-device handling)
void sendConfOrder(const Json::Value &root)
virtual void refuse()=0
Refuse incoming call.
virtual std::map< std::string, std::string > getDetails() const
virtual void updateRecState(bool state)=0
Update recording state.
bool isIncoming() const
Tell if the call is incoming.
std::list< std::pair< std::map< std::string, std::string >, std::string > > MsgList
MultiDevice: message waiting to be sent (need a valid subcall)
virtual void peerHungup()
Peer has hung up a call.
std::weak_ptr< Call > weak()
void setPeerNumber(const std::string &number)
Set the peer number (destination on outgoing) not protected by mutex (when created)
ConnectionState
Tell where we're at with the call.
virtual bool hasVideo() const =0
virtual void merge(Call &scall)
Replace current call data with ones from the given subcall.
virtual void answer(const std::vector< libjami::MediaMap > &mediaList)=0
Answer a call with a list of media attributes.
std::string peerDisplayName_
Peer Display Name.
CallType getCallType() const
std::weak_ptr< Conference > conf_
Unique conference ID, used exclusively in case of a conference.
const std::string & getPeerNumber() const
Get the peer number (destination on outgoing) not protected by mutex (when created)
void setIPToIP(bool IPToIP)
std::string getAccountId() const
virtual std::shared_ptr< SystemCodecInfo > getVideoCodec() const
virtual bool toggleRecording()
This method must be implemented for this interface as calls and conferences have different behavior.
MsgList pendingOutMessages_
std::unique_ptr< AudioDeviceGuard > audioGuard
void setConferenceInfo(const std::string &msg)
A Call can be in a conference.
virtual void handleMediaChangeRequest(const std::vector< libjami::MediaMap > &remoteMediaList)=0
Process incoming media change request.
virtual std::vector< MediaAttribute > getMediaAttributeList() const =0
bool setState(CallState call_state, signed code=0)
Set the state of the call (protected by mutex)
const std::string id_
MultiDevice: parent call, nullptr otherwise. Access protected by callMutex_.
CallState callState_
Inactive/Active/Hold/Busy/Error.
ConnectionState connectionState_
Disconnected/Progressing/Trying/Ringing/Connected.
const std::string & getPeerDisplayName() const
Get the peer display name (caller in ingoing) not protected by mutex (when created)
virtual bool attendedTransfer(const std::string &to)=0
Attended transfer.
time_t timestamp_start_
MultiDevice: message received by subcall to merged yet.
virtual void enterConference(std::shared_ptr< Conference > conference)=0
virtual void removeCall()
void sendConfInfo(const std::string &json)
int conferenceProtocolVersion() const
std::vector< std::map< std::string, std::string > > getConferenceInfos() const
bool isIPToIP_
Direct IP-to-IP or classic call.
std::weak_ptr< Account > getAccount() const
virtual std::map< std::string, bool > getAudioStreams() const =0
virtual void answerMediaChangeRequest(const std::vector< libjami::MediaMap > &mediaList, bool isRemote=false)=0
Answer to a media update request.
time_point duration_start_
void addStateListener(StateListenerCb &&listener)
std::function< bool(CallState, ConnectionState, int)> StateListenerCb
std::recursive_mutex callMutex_
Protect every attribute that can be changed by two threads.
std::map< std::string, std::shared_ptr< Call > > CallMap
void emitSignal(Args... args)
std::shared_ptr< Call > getPtr(Call &call)
Obtain a shared smart pointer of instance.
bool is_uninitialized(std::weak_ptr< T > const &weak)
std::vector< std::map< std::string, std::string > > toVectorMapStringString() const