|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef _CC_SIPCCCALL_H |
|
6 #define _CC_SIPCCCALL_H |
|
7 |
|
8 #include "CC_Call.h" |
|
9 |
|
10 #include <map> |
|
11 |
|
12 #if defined(__cplusplus) && __cplusplus >= 201103L |
|
13 typedef struct Timecard Timecard; |
|
14 #else |
|
15 #include "timecard.h" |
|
16 #endif |
|
17 |
|
18 #include "common/Wrapper.h" |
|
19 #include "common/csf_common.h" |
|
20 #include "mozilla/Mutex.h" |
|
21 #include "base/lock.h" |
|
22 |
|
23 namespace CSF |
|
24 { |
|
25 struct StreamInfo |
|
26 { |
|
27 // a bit of overkill having a structure just for video, but we may have other properties later |
|
28 bool isVideo; |
|
29 }; |
|
30 typedef std::map<int, StreamInfo> StreamMapType; |
|
31 |
|
32 DECLARE_NS_PTR(CC_SIPCCCallMediaData); |
|
33 |
|
34 class CC_SIPCCCallMediaData |
|
35 { |
|
36 public: |
|
37 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CC_SipCCCAllMediaData) |
|
38 CC_SIPCCCallMediaData(): |
|
39 remoteWindow(nullptr), |
|
40 streamMapMutex("CC_SIPCCCallMediaData"), |
|
41 audioMuteState(false), |
|
42 videoMuteState(false), |
|
43 volume(-1){} |
|
44 CC_SIPCCCallMediaData(VideoWindowHandle remoteWindow, |
|
45 bool audioMuteState, bool videoMuteState, int volume): |
|
46 remoteWindow(remoteWindow), |
|
47 streamMapMutex("CC_SIPCCCallMediaData"), |
|
48 audioMuteState(audioMuteState), |
|
49 videoMuteState(videoMuteState), |
|
50 volume(volume) {} |
|
51 VideoWindowHandle remoteWindow; |
|
52 ExternalRendererHandle extRenderer; |
|
53 VideoFormat videoFormat; |
|
54 mozilla::Mutex streamMapMutex; |
|
55 StreamMapType streamMap; |
|
56 bool audioMuteState; |
|
57 bool videoMuteState; |
|
58 int volume; |
|
59 private: |
|
60 CC_SIPCCCallMediaData(const CC_SIPCCCallMediaData&); |
|
61 CC_SIPCCCallMediaData& operator=(const CC_SIPCCCallMediaData&); |
|
62 }; |
|
63 |
|
64 DECLARE_NS_PTR(CC_SIPCCCall); |
|
65 class CC_SIPCCCall : public CC_Call |
|
66 { |
|
67 |
|
68 CSF_DECLARE_WRAP(CC_SIPCCCall, cc_call_handle_t); |
|
69 private: |
|
70 cc_call_handle_t callHandle; |
|
71 CC_SIPCCCall (cc_call_handle_t aCallHandle); |
|
72 CC_SIPCCCallMediaDataPtr pMediaData; |
|
73 std::string peerconnection; // The peerconnection handle |
|
74 |
|
75 public: |
|
76 virtual inline std::string toString() { |
|
77 std::string result; |
|
78 char tmpString[11]; |
|
79 csf_sprintf(tmpString, sizeof(tmpString), "%X", callHandle); |
|
80 result = tmpString; |
|
81 return result; |
|
82 }; |
|
83 |
|
84 virtual void setRemoteWindow (VideoWindowHandle window); |
|
85 virtual int setExternalRenderer(VideoFormat vFormat, ExternalRendererHandle renderer); |
|
86 virtual void sendIFrame(); |
|
87 |
|
88 virtual CC_CallInfoPtr getCallInfo (); |
|
89 |
|
90 virtual bool originateCall (cc_sdp_direction_t video_pref, const std::string & digits); |
|
91 virtual bool answerCall (cc_sdp_direction_t video_pref); |
|
92 virtual bool hold (cc_hold_reason_t reason); |
|
93 virtual bool resume (cc_sdp_direction_t video_pref); |
|
94 virtual bool endCall(); |
|
95 virtual bool sendDigit (cc_digit_t digit); |
|
96 virtual bool backspace(); |
|
97 virtual bool redial (cc_sdp_direction_t video_pref); |
|
98 virtual bool initiateCallForwardAll(); |
|
99 virtual bool endConsultativeCall(); |
|
100 virtual bool conferenceStart (cc_sdp_direction_t video_pref); |
|
101 virtual bool conferenceComplete (CC_CallPtr otherLog, cc_sdp_direction_t video_pref); |
|
102 virtual bool transferStart (cc_sdp_direction_t video_pref); |
|
103 virtual bool transferComplete (CC_CallPtr otherLeg, |
|
104 cc_sdp_direction_t video_pref); |
|
105 virtual bool cancelTransferOrConferenceFeature(); |
|
106 virtual bool directTransfer (CC_CallPtr target); |
|
107 virtual bool joinAcrossLine (CC_CallPtr target); |
|
108 virtual bool blfCallPickup (cc_sdp_direction_t video_pref, const std::string & speed); |
|
109 virtual bool select(); |
|
110 virtual bool updateVideoMediaCap (cc_sdp_direction_t video_pref); |
|
111 virtual bool sendInfo (const std::string & infopackage, const std::string & infotype, const std::string & infobody); |
|
112 virtual bool muteAudio(); |
|
113 virtual bool unmuteAudio(); |
|
114 virtual bool muteVideo(); |
|
115 virtual bool unmuteVideo(); |
|
116 virtual void addStream(int streamId, bool isVideo); |
|
117 virtual void removeStream(int streamId); |
|
118 virtual bool setVolume(int volume); |
|
119 virtual void originateP2PCall (cc_sdp_direction_t video_pref, const std::string & digits, const std::string & ip); |
|
120 virtual void createOffer(cc_media_constraints_t *constraints, Timecard *); |
|
121 virtual void createAnswer(cc_media_constraints_t *constraints, Timecard *); |
|
122 virtual void setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *); |
|
123 virtual void setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *); |
|
124 virtual void setPeerConnection(const std::string& handle); |
|
125 virtual const std::string& getPeerConnection() const; |
|
126 virtual void addStream(cc_media_stream_id_t stream_id, |
|
127 cc_media_track_id_t track_id, |
|
128 cc_media_type_t media_type, |
|
129 cc_media_constraints_t *constraints); |
|
130 virtual void removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type); |
|
131 virtual CC_SIPCCCallMediaDataPtr getMediaData(); |
|
132 virtual void addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *); |
|
133 |
|
134 private: |
|
135 virtual bool setAudioMute(bool mute); |
|
136 virtual bool setVideoMute(bool mute); |
|
137 |
|
138 mozilla::Mutex m_lock; |
|
139 }; |
|
140 |
|
141 } |
|
142 |
|
143 |
|
144 #endif |