[server] / trunk / server / src / dialogicchannel.h Repository:
ViewVC logotype

Annotation of /trunk/server/src/dialogicchannel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 942 - (view) (download)

1 : jtarlton 625 /*
2 :     * This file is part of Project DiaStar Server.
3 :     *
4 :     * More information about this project can be found at:
5 :     * http://www.projectdiastar.org.
6 :     *
7 : jtarlton 824 * Copyright (C) 2009,2010 Dialogic Corp.
8 : jtarlton 625 *
9 :     * This program is free software; you can redistribute it and/or
10 :     * modify it under the terms of the GNU General Public License
11 :     * as published by the Free Software Foundation; either version 2
12 :     * of the License, or (at your option) any later version.
13 :     *
14 :     * This program is distributed in the hope that it will be useful,
15 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     * GNU General Public License for more details.
18 :     *
19 :     * You should have received a copy of the GNU General Public License
20 :     * along with this program; if not, write to the Free Software
21 :     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 :     * 02110-1301, USA.
23 :     * Alternatively see <http://www.gnu.org/licenses/>.
24 :     * Or see the LICENSE file included within the source tree.
25 :     *
26 :     */
27 :    
28 :     /*!
29 :     * \file dialogicchannel.h
30 : jtarlton 847 * \brief Manages the resources for a single call channel.
31 : jtarlton 625 * \author Antony Martin <antony.martin@dialogic.com>
32 :     * \author John Tarlton <john.tarlton@dialogic.com>
33 :     * \version 30-MAR-2009
34 :     */
35 :    
36 :     #ifndef _DIALOGICCHANNEL_H
37 :     #define _DIALOGICCHANNEL_H
38 :    
39 :     /*-------------------------------- Dependencies ------------------------------*/
40 :    
41 :     #include <string>
42 :    
43 :     #include "channelmanager.h"
44 :     #include "ipinfo.h"
45 :    
46 :     #include "voxdevice.h"
47 :     #include "ipmdevice.h"
48 :     #include "mmdevice.h"
49 :     #include "m3gdevice.h"
50 :     #include "gcisdndevice.h"
51 :     #include "gciptboard.h"
52 : jtarlton 820 #include "gciptdevice.h"
53 : jtarlton 625 #include "confdevice.h"
54 :     #include "confpartydevice.h"
55 : jtarlton 820 #include "mediastatemachine.h"
56 : jtarlton 625
57 :     /*----------------------------------------------------------------------------*/
58 :    
59 :     /*!
60 : jtarlton 834 * \struct Player
61 :     * \brief data for playing media.
62 : jtarlton 820 */
63 :     struct Player
64 :     {
65 :     /* request
66 :     */
67 :     std::string audioFile;
68 :     std::string audioEncoding;
69 :     std::string videoFile;
70 :     std::string videoEncoding;
71 : jtarlton 932 unsigned int videoSize; /* width */
72 :     unsigned int videoFps; /* eVIDEO_FRAMESPERSEC */
73 : jtarlton 820 int repeatCount;
74 : jtarlton 858 std::string overlay;
75 : jtarlton 820
76 :     /* response
77 :     */
78 : jtarlton 858 std::string reason;
79 : jtarlton 832 unsigned int duration;
80 : jtarlton 820 };
81 :    
82 :     /*!
83 : jtarlton 834 * \struct Recorder
84 :     * \brief data for recording media.
85 : jtarlton 820 */
86 :     struct Recorder
87 :     {
88 :     /* request
89 :     */
90 :     std::string audioFile;
91 :     std::string audioEncoding;
92 :     std::string videoFile;
93 :     std::string videoEncoding;
94 : jtarlton 932 unsigned int videoSize; /* width */
95 :     unsigned int videoFps; /* eVIDEO_FRAMESPERSEC */
96 : jtarlton 820 bool beep;
97 : jtarlton 832 unsigned int maxTime;
98 : jtarlton 820
99 :     /* response
100 :     */
101 :     std::string reason;
102 : jtarlton 832 unsigned int duration;
103 : jtarlton 820 };
104 :    
105 :     /*!
106 : jtarlton 625 * \class DialogicChannel
107 :     * A channel manages the resources for a single call leg.
108 :     */
109 :     class DialogicChannel : public Channel
110 :     {
111 :     public:
112 :    
113 :     /*!
114 :     * ctor. ISDN
115 :     */
116 : jtarlton 657 DialogicChannel( DialogicChannelManager& channelMgr,
117 :     GcIsdnDevice* gc,
118 : jtarlton 820 IpmDevice* ipm );
119 : jtarlton 625
120 :     /*!
121 : jtarlton 903 * ctor. H324 (ISDN)
122 :     */
123 :     DialogicChannel( DialogicChannelManager& channelMgr,
124 : jtarlton 912 StateMachine& sm,
125 : jtarlton 903 GcIsdnDevice* gc,
126 :     M3gDevice* m3g,
127 :     IpmDevice* ipm );
128 :    
129 :     /*!
130 : jtarlton 625 * ctor. SIP
131 :     */
132 : jtarlton 657 DialogicChannel( DialogicChannelManager& channelMgr,
133 : jtarlton 820 StateMachine& sm,
134 : jtarlton 657 GcIptDevice* gc,
135 : jtarlton 820 IpmDevice* ipm );
136 : jtarlton 625
137 :     /*!
138 :     * ctor. CONF
139 :     */
140 : jtarlton 657 DialogicChannel( DialogicChannelManager& channelMgr,
141 : jtarlton 820 StateMachine& sm,
142 : jtarlton 657 ConfDevice* confDevice,
143 : jtarlton 625 ConfPartyDevice* confParty,
144 : jtarlton 820 IpmDevice* ipm );
145 : jtarlton 625
146 :     /*!
147 : jtarlton 820 * dtor
148 :     */
149 :     virtual ~DialogicChannel();
150 :    
151 :     /*!
152 :     * Get the channel manager object.
153 :     */
154 :     DialogicChannelManager& getChannelMgr() const { return channelMgr_; }
155 :    
156 :     /*!
157 : jtarlton 625 * Get the signalling protocol.
158 :     */
159 :     virtual Protocol getProtocol() const { return protocol_; }
160 :    
161 :     /*!
162 : jtarlton 908 * Test if this is an inbound call.
163 :     */
164 :     bool isInBound() const { return direction_ == DIRECTION_INBOUND; }
165 :    
166 :     /*!
167 :     * Test if this is an outbound call.
168 :     */
169 :     bool isOutBound() const { return direction_ == DIRECTION_OUTBOUND; }
170 :    
171 :     /*!
172 : jtarlton 625 * Get the ipm device associated with this channel.
173 :     */
174 :     IpmDevice* getIpmDevice() const { return ipmDevice_; }
175 :    
176 :     /*!
177 :     * Get the GC device associated with this channel.
178 :     */
179 :     GcDevice* getGcDevice() const { return gcDevice_; }
180 :    
181 :     /*!
182 : jtarlton 903 * Get the M3g device associated with this channel.
183 :     */
184 :     M3gDevice* getM3gDevice() const { return m3gDevice_; }
185 :    
186 :     /*!
187 : jtarlton 625 * Get the MM device associated with this channel.
188 :     */
189 :     MmDevice* getMmDevice() const { return mmDevice_; }
190 :    
191 :     /*!
192 : jtarlton 693 * Set the MM device associated with this channel.
193 :     */
194 :     void setMmDevice( MmDevice* mm ) { mmDevice_ = mm; }
195 :    
196 :     /*!
197 : jtarlton 625 * Get the conference party device associated with this channel.
198 :     */
199 :     ConfPartyDevice* getConfPartyDevice() const { return confParty_; }
200 :    
201 :     /*!
202 :     * Get the conference device associated with this channel.
203 :     */
204 :     ConfDevice* getConfDevice() const { return confDevice_; }
205 :    
206 :     /*!
207 : jtarlton 826 * Get the channel the this one is bridge to.
208 :     */
209 :     Channel* getOtherChannel() const { return other_channel_; }
210 :    
211 :     /*!
212 : jtarlton 625 * Make an outbound call.
213 :     * \param local_number - caller's number
214 :     * \param local_name - caller's name
215 :     * \param remote_number - callee's number
216 :     * \param cpa - set true to enable call progress analysis.
217 :     */
218 :     virtual bool makeCall( const std::string& local_number,
219 :     const std::string& local_name,
220 :     const std::string& remote_number,
221 :     bool cpa );
222 :    
223 :     /*!
224 :     * Hangup the current call.
225 :     * \param cause - reason the call is being cleared
226 :     */
227 :     virtual bool hangup( int cause );
228 :    
229 :     /*!
230 :     * Accept the current call.
231 :     */
232 :     virtual bool accept();
233 :    
234 :     /*!
235 :     * Answer the current call.
236 :     */
237 :     virtual bool answer();
238 :    
239 :     /*!
240 :     * Send dtmf digits inband using the vox device.
241 :     */
242 :     virtual bool sendDtmf( const std::string& dtmf );
243 :    
244 :     /*!
245 : jtarlton 752 * Enable tone event notications.
246 :     */
247 :     virtual bool enableToneEvents();
248 :    
249 :     /*!
250 :     * Disable tone event notications.
251 :     */
252 :     virtual bool disableToneEvents();
253 :    
254 :     /*!
255 : jtarlton 625 * Play media to an established call using the mm device.
256 :     * \param audio_uri - audio file.
257 :     * \param video_uri - video file.
258 : jtarlton 760 * \param overlay - overlay content.
259 : jtarlton 625 * \param stop_digits - termination digits.
260 :     * \param lang - language
261 : jtarlton 688 * \param repeat_count - repetitions, use INT_MAX for infinite.
262 : jtarlton 625 */
263 :     virtual bool play( const std::string& audio_uri,
264 :     const std::string& video_uri,
265 : jtarlton 760 const std::string& overlay,
266 : jtarlton 625 const std::string& stop_digits,
267 : jtarlton 688 const std::string& lang,
268 :     int repeat_count );
269 : jtarlton 625
270 :     /*!
271 :     * Record media from an established call using the mm device.
272 :     * \param audio_uri - audio file.
273 :     * \param video_uri - video file.
274 :     * \param stop_digits - termination digits.
275 :     * \param lang - language
276 : jtarlton 663 * \param beep - if true, play a tone when recording starts.
277 : jtarlton 832 * \param maxTime - max length of recording in ms, use 0 for unlimited.
278 : jtarlton 625 */
279 :     virtual bool record( const std::string& audio_uri,
280 :     const std::string& video_uri,
281 :     const std::string& stop_digits,
282 : jtarlton 663 const std::string& lang,
283 : jtarlton 832 bool beep,
284 :     unsigned int maxTime );
285 : jtarlton 625
286 :     /*!
287 :     * Stop the current play or record operation.
288 :     */
289 :     virtual bool stop();
290 :    
291 :     /*!
292 : jtarlton 822 * Generate a video overlay.
293 :     * \param overlay - overlay content.
294 :     */
295 :     bool requestOverlay( const std::string& overlay );
296 :    
297 :     /*!
298 : jtarlton 625 * Create a half-duplex media bridge from the external device of this channel
299 :     * to the external device of another channel.
300 :     * \param other_channel - channel to bridge to.
301 :     */
302 :     virtual bool bridge( Channel* other_channel );
303 :    
304 :     /*!
305 : jtarlton 754 * Unbridge the external media device of this channel from the external media
306 :     * device of another channel and restore the connection to the internal device.
307 :     */
308 :     virtual bool unbridge();
309 :    
310 :     /*!
311 : jtarlton 625 * Test if a dtmf digit is a stop digit for the current play/record operation.
312 :     * \param dtmf - digit to test.
313 :     */
314 :     virtual bool isStopDigit( char dtmf ) const;
315 :    
316 :     /*!
317 :     * Start streaming media to the client.
318 :     */
319 :     virtual bool startMedia();
320 :    
321 :     /*!
322 :     * Stop streaming media to the client.
323 :     */
324 :     virtual bool stopMedia();
325 :    
326 :     /*!
327 :     * Test if this is a video call.
328 :     */
329 :     virtual bool isVideo() const;
330 :    
331 :     /*!
332 :     * Get the local ip-address and port number for the rtp audio media.
333 :     */
334 :     virtual void getLocalRtpAudioInfo( IpInfo& rtp_audio ) const;
335 :    
336 :     /*!
337 :     * Get the local ip-address and port number for the rtp video media.
338 :     */
339 :     virtual void getLocalRtpVideoInfo( IpInfo& rtp_video ) const;
340 :    
341 :     /*!
342 :     * Save the ip-address and port of the remote party's rtp audio.
343 :     */
344 :     virtual void setRemoteRtpAudioInfo( const IpInfo& rtp_audio );
345 :    
346 :     /*!
347 :     * Get the remote ip-address and port number for the rtp audio media.
348 :     */
349 :     virtual void getRemoteRtpAudioInfo( IpInfo& rtp_audio ) const;
350 :    
351 :     /*!
352 :     * Save the ip-address and port of the remote party's rtp video.
353 :     */
354 :     virtual void setRemoteRtpVideoInfo( const IpInfo& rtp_video );
355 :    
356 :     /*!
357 :     * Get the remote ip-address and port number for the rtp video media.
358 :     */
359 :     virtual void getRemoteRtpVideoInfo( IpInfo& rtp_video ) const;
360 :    
361 : jtarlton 637 /*!
362 : jtarlton 820 * Get the player object.
363 :     */
364 :     const Player& getPlayer() const { return player_; }
365 :    
366 :     /*!
367 :     * Get the recoder object.
368 :     */
369 :     const Recorder& getRecorder() const { return recorder_; }
370 :    
371 :     /*!
372 : jtarlton 637 * Clear the digit collection buffer.
373 :     */
374 :     void clearDigits() { collected_digits_.clear(); }
375 :    
376 :     /*!
377 : jtarlton 640 * Write a digit to the end of the collection buffer.
378 : jtarlton 637 * \param dtmf - digit to save.
379 :     */
380 :     void collectDigit( char dtmf ) { collected_digits_.push_back(dtmf); }
381 :    
382 :     /*!
383 :     * Get the digit collection buffer.
384 :     */
385 :     const std::string& getDigits() const { return collected_digits_; }
386 :    
387 : jtarlton 820 /*!
388 :     * Pass an event to the media state machine.
389 :     */
390 :     void onMediaEvent( Event* event );
391 :    
392 :     /*!
393 : jtarlton 931 * Handle an incoming call event from the ipt/dti device.
394 : jtarlton 820 * \param local_number - called number.
395 :     * \param remote_number - calling number.
396 :     */
397 : jtarlton 931 void onIncoming( const std::string& local_number,
398 : jtarlton 820 const std::string& remote_number );
399 :    
400 :     /*!
401 : jtarlton 931 * Handle an inbound call accepted event from the dti/ipt device.
402 : jtarlton 820 */
403 : jtarlton 931 void onAccepted();
404 : jtarlton 820
405 :     /*!
406 : jtarlton 931 * Handle an inbound call accepted event from the dti/ipt device.
407 : jtarlton 820 */
408 : jtarlton 931 void onAnswered();
409 : jtarlton 820
410 :     /*!
411 : jtarlton 931 * Handle an outbound call proceeding event from the dti/ipt device.
412 :     * Also used by conf devices, for consistency.
413 : jtarlton 820 */
414 : jtarlton 931 void onProceeding();
415 : jtarlton 820
416 :     /*!
417 : jtarlton 931 * Handle an outbound call, remote party ringing event from a dti/ipt device.
418 : jtarlton 820 */
419 : jtarlton 931 void onRinging();
420 : jtarlton 820
421 :     /*!
422 : jtarlton 931 * Handle an outbound call connected event.
423 :     * \param conn_type - cpa result etc.
424 : jtarlton 820 */
425 : jtarlton 931 void onConnect( const std::string& conn_type );
426 : jtarlton 820
427 :     /*!
428 :     * Handle a hangup from a dti/ipt device.
429 :     * \param gc - source of the event.
430 :     * \param cause - Q.931 cause value
431 :     * \param cause_text - description
432 :     * \param conn_type - cpa result (if applicable)
433 :     */
434 :     void onHangup( GcDevice* gc,
435 :     int cause,
436 :     const std::string& cause_text,
437 :     const std::string& conn_type = std::string());
438 :    
439 :     /*!
440 :     * Handle a hangup from a conference device. Called for all parties when the
441 :     * controller hangs up.
442 :     * \param confParty - source of the event.
443 :     */
444 :     void onHangup( ConfPartyDevice* confParty );
445 :    
446 :     /*!
447 : jtarlton 920 * Handle a hangup from a m3g device. Called when the h245 session ends.
448 :     * \param m3g - source of the event.
449 :     */
450 :     void onHangup( M3gDevice* m3g);
451 :    
452 :     /*!
453 : jtarlton 820 * Handle a dtmf digit received event.
454 :     * \param dtmf - ascii coded dtmf digit.
455 :     */
456 : jtarlton 912 void onDtmf( char dtmf );
457 : jtarlton 820
458 :     /*!
459 :     * Handle a tone detection event.
460 :     * \param name - the tone that has been detected.
461 :     */
462 : jtarlton 912 void onTone( const std::string& name );
463 : jtarlton 820
464 :     /*!
465 :     * Handle a dtmf send completion event.
466 :     */
467 : jtarlton 921 void onSendDtmfCompleted();
468 : jtarlton 820
469 :     /*!
470 :     * Handle a media connect completion event from a device.
471 :     * \param device - source of the event.
472 :     */
473 :     void onConnectCompleted( IpmDevice* device );
474 :    
475 :     /*!
476 :     * Handle a media disconnect completion event from a device.
477 :     * \param device - source of the event.
478 :     */
479 :     void onDisconnectCompleted( IpmDevice* device );
480 :    
481 :     /*!
482 :     * Handle a media connect completion event from a device.
483 :     * \param device - source of the event.
484 :     */
485 :     void onConnectCompleted( MmDevice* device );
486 :    
487 :     /*!
488 :     * Handle a media disconnect completion event from a device.
489 :     * \param device - source of the event.
490 :     */
491 :     void onDisconnectCompleted( MmDevice* device );
492 :    
493 :     /*!
494 :     * Handle a media connect completion event from a device.
495 :     * \param device - source of the event.
496 :     */
497 : jtarlton 920 void onConnectCompleted( M3gDevice* device );
498 : jtarlton 912
499 :     /*!
500 :     * Handle a media disconnect completion event from a device.
501 :     * \param device - source of the event.
502 :     */
503 : jtarlton 920 void onDisconnectCompleted( M3gDevice* device );
504 : jtarlton 912
505 :     /*!
506 : jtarlton 920 * Handle a media started event from an m3g device.
507 :     * \param device - source of the event.
508 :     */
509 :     void onMediaStarted( M3gDevice* device );
510 :    
511 :     /*!
512 :     * Handle a media stopped event from an m3g device.
513 :     * \param device - source of the event.
514 :     */
515 :     void onMediaStopped( M3gDevice* device );
516 :    
517 :     /*!
518 : jtarlton 912 * Handle a media connect completion event from a device.
519 :     * \param device - source of the event.
520 :     */
521 : jtarlton 820 void onConnectCompleted( ConfPartyDevice* device );
522 :    
523 :     /*!
524 :     * Handle a media disconnect completion event from a device.
525 :     * \param device - source of the event.
526 :     */
527 :     void onDisconnectCompleted( ConfPartyDevice* device );
528 :    
529 :     /*!
530 : jtarlton 822 * Handle a gateway media connect completion event from the statemachine.
531 :     */
532 :     void onGatewayConnected();
533 :    
534 :     /*!
535 :     * Handle a conference media connect completion event from the statemachine.
536 :     */
537 :     void onConfConnected();
538 :    
539 :     /*!
540 : jtarlton 820 * Handle a play completion event from an mm device.
541 :     * \param mm - source of the event.
542 :     * \param reason - why the play stopped.
543 :     * \param duration - length of play in ms.
544 :     */
545 :     void onPlayCompleted( MmDevice* mm,
546 :     const std::string& reason,
547 :     unsigned int duration );
548 :    
549 :     /*!
550 :     * Handle a play completion event from the state machine.
551 :     */
552 :     void onPlayCompleted();
553 :    
554 :     /*!
555 :     * Handle a record completion event from an mm device.
556 :     * \param mm - source of the event.
557 :     * \param reason - why the recording stopped.
558 :     * \param duration - length of recording in ms.
559 :     */
560 :     void onRecordCompleted( MmDevice* mm,
561 :     const std::string& reason,
562 :     unsigned int duration );
563 :    
564 :     /*!
565 :     * Handle a record completion event from the state machine.
566 :     */
567 :     void onRecordCompleted();
568 :    
569 : jtarlton 625 private:
570 :    
571 :     DialogicChannel();
572 :     DialogicChannel( const DialogicChannel& );
573 :     DialogicChannel& operator = ( const DialogicChannel& );
574 :    
575 :     private:
576 :    
577 : jtarlton 657 DialogicChannelManager& channelMgr_;
578 :    
579 : jtarlton 847 Context* context_; /* media state machine (SIP | CONF) */
580 : jtarlton 820
581 : jtarlton 640 GcDevice* gcDevice_; /* dti(dk) or ipt */
582 : jtarlton 903 M3gDevice* m3gDevice_;
583 : jtarlton 625 IpmDevice* ipmDevice_;
584 :     MmDevice* mmDevice_;
585 :     ConfDevice* confDevice_;
586 :     ConfPartyDevice* confParty_;
587 :    
588 :     Protocol protocol_;
589 : jtarlton 822 Direction direction_; /* inbound | outbound */
590 :     std::string conn_type_; /* CPA result (outbound) */
591 : jtarlton 625
592 : jtarlton 942 bool h324_connected_;
593 :    
594 : jtarlton 640 std::string stop_digits_; /* play/record remination digits */
595 :     std::string collected_digits_; /* digits received during a play */
596 : jtarlton 820
597 :     Player player_;
598 :     Recorder recorder_;
599 : jtarlton 826
600 :     Channel* other_channel_; /* optimised bridge */
601 : jtarlton 625 };
602 :    
603 :    
604 :     #endif // _DIALOGICCHANNEL_H
605 :    
606 :     /* vim:ts=4:set nu:
607 :     * EOF
608 :     */

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.8