source: qutecom-2.2/wengophone/src/model/phonecall/PhoneCall.h @ 522:e32fb126022b

Last change on this file since 522:e32fb126022b was 522:e32fb126022b, checked in by laurent@…, 3 years ago

remove wenbox

File size: 5.9 KB
Line 
1/*
2 * WengoPhone, a voice over Internet phone
3 * Copyright (C) 2004-2007  Wengo
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#ifndef OWPHONECALL_H
21#define OWPHONECALL_H
22
23#include "SipAddress.h"
24
25#include <sipwrapper/EnumTone.h>
26#include <sipwrapper/EnumPhoneCallState.h>
27#include <sipwrapper/CodecList.h>
28
29#include <util/Event.h>
30#include <util/List.h>
31#include <util/NonCopyable.h>
32
33#include <string>
34
35#include <pixertool/pixertool.h>
36
37class WebcamVideoFrame;
38class PhoneCallState;
39class IPhoneLine;
40class ConferenceCall;
41
42/**
43 * Class that holds informations about a current phone call.
44 *
45 * A phone call is associated with a PhoneLine.
46 *
47 * @ingroup model
48 * @author Tanguy Krotoff
49 */
50class PhoneCall : NonCopyable {
51public:
52
53        /**
54         * The state of the PhoneCall has changed.
55         *
56         * @param sender this class
57         * @param status new status
58         */
59        Event<void (PhoneCall & sender, EnumPhoneCallState::PhoneCallState status)> stateChangedEvent;
60
61        /**
62         * A video frame has been received from the network.
63         *
64         * @param sender this class
65         * @param remoteVideoFrame remote video frame
66         * @param localVideoFrame local video frame from the webcam
67         */
68        Event<void (PhoneCall & sender, piximage * remoteVideoFrame, piximage * localVideoFrame)> videoFrameReceivedEvent;
69
70        /**
71         * Creates a new PhoneCall given a PhoneLine.
72         *
73         * @param phoneLine PhoneLine associated with this PhoneCall
74         * @param sipAddress caller/callee/peer SIP address
75         */
76        PhoneCall(IPhoneLine & phoneLine, const SipAddress & sipAddress);
77
78        ~PhoneCall();
79
80        /**
81         * @see IPhoneLine::acceptCall()
82         */
83        void accept();
84
85        /**
86         * @see IPhoneLine::resumeCall()
87         */
88        void resume();
89
90        /**
91         * @see IPhoneLine::holdCall()
92         */
93        void hold();
94
95        /**
96         * @see IPhoneLine::closeCall()
97         */
98        void close();
99
100        /**
101         * @see IPhoneLine::blindTransfer()
102         */
103        void blindTransfer(const std::string & sipAddress);
104
105        /**
106         * @see IPhoneLine::playSoundFile()
107         */
108        void playSoundFile(const std::string & soundFile);
109
110        /**
111         * @see IPhoneLine::getAudioCodecUsed()
112         */
113        CodecList::AudioCodec getAudioCodecUsed();
114
115        /**
116         * @see IPhoneLine::getVideoCodecUsed()
117         */
118        CodecList::VideoCodec getVideoCodecUsed();
119
120        /**
121         * Video frame received.
122         *
123         * @param remoteVideoFrame received
124         * @param localWebcam local webcam
125         */
126        void videoFrameReceived(piximage * remoteVideoFrame, piximage * localVideoFrame);
127
128        /**
129         * Changes the state of this PhoneCall.
130         *
131         * @param state state code corresponding to the new PhoneCall state
132         */
133        void setState(EnumPhoneCallState::PhoneCallState state);
134
135        /**
136         * Gets the current state of this PhoneCall.
137         *
138         * @return state of this PhoneCall
139         */
140        EnumPhoneCallState::PhoneCallState getState() const;
141
142        /**
143         * Sets the call id associated with this PhoneCall.
144         *
145         * Should only be called by PhoneLine.
146         *
147         * @param callId call id of this PhoneCall
148         */
149        void setCallId(int callId) {
150                _callId = callId;
151        }
152
153        /**
154         * Gets the call id of this PhoneCall.
155         *
156         * @return call id of this PhoneCall
157         */
158        int getCallId() const {
159                return _callId;
160        }
161
162        /**
163         * Gets the caller/callee/peer SIP address associated with this PhoneCall.
164         *
165         * @return caller/callee/peer SIP address
166         */
167        const SipAddress & getPeerSipAddress() const {
168                return _sipAddress;
169        }
170
171        /**
172         * Gets the PhoneLine associated with this PhoneCall.
173         *
174         * @return phone line
175         */
176        IPhoneLine & getPhoneLine() const {
177                return _phoneLine;
178        }
179
180        /**
181         * Gets the duration of the call in seconds
182         *
183         * @return duration of the call or -1 if not call duration
184         */
185        int getDuration() const {
186                return _duration;
187        }
188
189        /**
190         * Gets the conference associated with this call.
191         *
192         * @return ConferenceCall or NULL if this call is not associated with a conference
193         */
194        ConferenceCall * getConferenceCall() const {
195                return _conferenceCall;
196        }
197
198        /**
199         * Gets the phone call type (audio or video).
200         *
201         * @return true if this call is a video call; false otherwise
202         */
203        bool isVideoEnabled() const {
204                return _videoEnabled;
205        }
206
207        /**
208         * @return True if the call is encrypted
209         */
210        bool isCallEncrypted() const;
211
212        /**
213         * Sets the conference associated with this call.
214         *
215         * Internal method, used only by ConferenceCall and PhoneLine.
216         *
217         * @param conferenceCall conference
218         */
219        void setConferenceCall(ConferenceCall * conferenceCall) {
220                _conferenceCall = conferenceCall;
221        }
222
223private:
224
225        void applyState(EnumPhoneCallState::PhoneCallState state);
226
227        /** PhoneLine associated with this PhoneCall. */
228        IPhoneLine & _phoneLine;
229
230        /** Call id of this PhoneCall. */
231        int _callId;
232
233        /** Caller/callee/peer SIP address. */
234        SipAddress _sipAddress;
235
236        /** Current state of this PhoneCall. */
237        PhoneCallState * _state;
238
239        /** Defines the vector of PhoneCallState. */
240        typedef List < PhoneCallState * > PhoneCallStates;
241
242        /** List of PhoneCallState. */
243        PhoneCallStates _phoneCallStateList;
244
245        /** Call duration in seconds. */
246        int _duration;
247
248        /** If the PhoneCall should be held. */
249        bool _holdRequest;
250
251        /** If the PhoneCall should be resumed. */
252        bool _resumeRequest;
253
254        /** Conference associated with this call. */
255        ConferenceCall * _conferenceCall;
256
257        /** If this PhoneCall has been rejected as an incoming call. */
258        bool _callRejected;
259
260        /** Computes the PhoneCall duration. */
261        int _timeStart;
262
263        /** If this call is a video call or an audio call. */
264        bool _videoEnabled;
265};
266
267#endif  //OWPHONECALL_H
Note: See TracBrowser for help on using the repository browser.