30#include <dhtnet/ip_utils.h>
31#include <asio/steady_timer.hpp>
45 using wt = std::weak_ptr<T>;
46 return !weak.owner_before(wt {}) && !wt {}.owner_before(weak);
53class AudioDeviceGuard;
58using CallMap = std::map<std::string, std::shared_ptr<Call>>;
93 using SubcallSet = std::set<std::shared_ptr<Call>, std::owner_less<std::shared_ptr<Call>>>;
210 virtual std::map<std::string, std::string>
getDetails()
const;
322 stateChangedListeners_.emplace_back(std::move(listener));
346 ? std::chrono::milliseconds::zero()
347 : std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() -
duration_start_);
375 virtual void muteMedia(
const std::string& mediaType,
bool isMuted) = 0;
406 virtual std::shared_ptr<SystemCodecInfo>
getAudioCodec()
const {
return {}; }
407 virtual std::shared_ptr<SystemCodecInfo>
getVideoCodec()
const {
return {}; }
440 using clock = std::chrono::steady_clock;
461 using MsgList = std::list<std::pair<std::map<std::string, std::string>, std::string>>;
476 void checkPendingIM();
484 std::vector<StateListenerCb> stateChangedListeners_ {};
530inline std::shared_ptr<Call>
533 return call.shared_from_this();
bool is_uninitialized(std::weak_ptr< T > const &weak)
virtual LinkType getLinkType() const
asio::steady_timer timeoutTimer_
int peerConfProtocol_
Supported conference protocol version.
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.
std::string getStateStr() const
virtual void hangup(int reason)=0
Hang up the call.
virtual void monitor() const =0
ConnectionState
Tell where we're at with the call.
clock::time_point time_point
std::chrono::milliseconds getCallDuration() const
virtual bool hold(OnReadyCb &&cb)=0
Hold call.
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.
virtual std::map< std::string, bool > getRemoteAudioStreams() const =0
Return a map of audio stream IDs to their remote (peer-side) muted state.
void setPeerNumber(const std::string &number)
Set the peer number (destination on outgoing) not protected by mutex (when created)
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.
virtual void removeCall(int code=0)
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
CallType
This determines if the call originated from the local user (OUTGOING) or from some remote peer (INCOM...
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)
virtual bool resume(OnReadyCb &&cb)=0
Resume call from hold state.
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
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.
static bool is_uninitialized(std::weak_ptr< T > const &weak)
std::vector< std::map< std::string, std::string > > toVectorMapStringString() const