Parent Directory
|
Revision Log
Pass/store rtp information in RtpIpInfo objects. These include the media direction in addition to the ip address and port number.
1 /* 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 * Copyright (C) 2009,2010 Dialogic Corp. 8 * 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 * \brief Manages the resources for a single call channel. 31 * \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 #include "gciptdevice.h" 53 #include "confdevice.h" 54 #include "confpartydevice.h" 55 #include "mediastatemachine.h" 56 57 /*----------------------------------------------------------------------------*/ 58 59 /*! 60 * \struct Player 61 * \brief data for playing media. 62 */ 63 struct Player 64 { 65 /* request 66 */ 67 std::string audioFile; 68 std::string audioEncoding; 69 std::string videoFile; 70 std::string videoEncoding; 71 unsigned int videoSize; /* width */ 72 unsigned int videoFps; /* eVIDEO_FRAMESPERSEC */ 73 int repeatCount; 74 std::string overlay; 75 76 int rtspSessionId; 77 78 /* response 79 */ 80 std::string reason; 81 unsigned int duration; 82 }; 83 84 /*! 85 * \struct Recorder 86 * \brief data for recording media. 87 */ 88 struct Recorder 89 { 90 /* request 91 */ 92 std::string audioFile; 93 std::string audioEncoding; 94 std::string videoFile; 95 std::string videoEncoding; 96 unsigned int videoSize; /* width */ 97 unsigned int videoFps; /* eVIDEO_FRAMESPERSEC */ 98 bool beep; 99 unsigned int maxTime; 100 101 /* response 102 */ 103 std::string reason; 104 unsigned int duration; 105 }; 106 107 /*! 108 * \class DialogicChannel 109 * A channel manages the resources for a single call leg. 110 */ 111 class DialogicChannel : public Channel 112 { 113 public: 114 115 /*! 116 * ctor. ISDN 117 */ 118 DialogicChannel( DialogicChannelManager& channelMgr, 119 GcIsdnDevice* gc, 120 IpmDevice* ipm ); 121 122 /*! 123 * ctor. H324 (ISDN) 124 */ 125 DialogicChannel( DialogicChannelManager& channelMgr, 126 StateMachine& sm, 127 GcIsdnDevice* gc, 128 M3gDevice* m3g, 129 IpmDevice* ipm ); 130 131 /*! 132 * ctor. SIP 133 */ 134 DialogicChannel( DialogicChannelManager& channelMgr, 135 StateMachine& sm, 136 GcIptDevice* gc, 137 IpmDevice* ipm ); 138 139 /*! 140 * ctor. CONF 141 */ 142 DialogicChannel( DialogicChannelManager& channelMgr, 143 StateMachine& sm, 144 ConfDevice* confDevice, 145 ConfPartyDevice* confParty, 146 IpmDevice* ipm ); 147 148 /*! 149 * dtor 150 */ 151 virtual ~DialogicChannel(); 152 153 /*! 154 * Get the channel manager object. 155 */ 156 DialogicChannelManager& getChannelMgr() const { return channelMgr_; } 157 158 /*! 159 * Get the signalling protocol. 160 */ 161 virtual Protocol getProtocol() const { return protocol_; } 162 163 /*! 164 * Test if this is an inbound call. 165 */ 166 bool isInBound() const { return direction_ == DIRECTION_INBOUND; } 167 168 /*! 169 * Test if this is an outbound call. 170 */ 171 bool isOutBound() const { return direction_ == DIRECTION_OUTBOUND; } 172 173 /*! 174 * Get the ipm device associated with this channel. 175 */ 176 IpmDevice* getIpmDevice() const { return ipmDevice_; } 177 178 /*! 179 * Get the GC device associated with this channel. 180 */ 181 GcDevice* getGcDevice() const { return gcDevice_; } 182 183 /*! 184 * Get the M3g device associated with this channel. 185 */ 186 M3gDevice* getM3gDevice() const { return m3gDevice_; } 187 188 /*! 189 * Get the MM device associated with this channel. 190 */ 191 MmDevice* getMmDevice() const { return mmDevice_; } 192 193 /*! 194 * Set the MM device associated with this channel. 195 */ 196 void setMmDevice( MmDevice* mm ) { mmDevice_ = mm; } 197 198 /*! 199 * Get the RTSP IPM device associated with this channel. 200 */ 201 IpmDevice* getRtspIpmDevice() const { return rtspIpmDevice_; } 202 203 /*! 204 * Set the RTSP IPM device associated with this channel. 205 */ 206 void setRtspIpmDevice( IpmDevice* ipm ) { rtspIpmDevice_ = ipm; } 207 208 /*! 209 * Get the conference party device associated with this channel. 210 */ 211 ConfPartyDevice* getConfPartyDevice() const { return confParty_; } 212 213 /*! 214 * Get the conference device associated with this channel. 215 */ 216 ConfDevice* getConfDevice() const { return confDevice_; } 217 218 /*! 219 * Get the channel the this one is bridge to. 220 */ 221 Channel* getOtherChannel() const { return other_channel_; } 222 223 /*! 224 * Make an outbound call. 225 * \param local_number - caller's number 226 * \param local_name - caller's name 227 * \param remote_number - callee's number 228 * \param cpa - set true to enable call progress analysis. 229 */ 230 virtual bool makeCall( const std::string& local_number, 231 const std::string& local_name, 232 const std::string& remote_number, 233 bool cpa ); 234 235 /*! 236 * Hangup the current call. 237 * \param cause - reason the call is being cleared 238 */ 239 virtual bool hangup( int cause ); 240 241 /*! 242 * Accept the current call. 243 */ 244 virtual bool accept(); 245 246 /*! 247 * Answer the current call. 248 */ 249 virtual bool answer(); 250 251 /*! 252 * Send dtmf digits inband using the vox device. 253 */ 254 virtual bool sendDtmf( const std::string& dtmf ); 255 256 /*! 257 * Enable tone event notifications. 258 */ 259 virtual bool enableToneEvents(); 260 261 /*! 262 * Disable tone event notifications. 263 */ 264 virtual bool disableToneEvents(); 265 266 /*! 267 * Enable info event notifications. 268 */ 269 virtual bool enableInfoEvents(); 270 271 /*! 272 * Disable info event notifications. 273 */ 274 virtual bool disableInfoEvents(); 275 276 /*! 277 * Play media to an established call using the mm device. 278 * \param audio_uri - audio file. 279 * \param video_uri - video file. 280 * \param overlay - overlay content. 281 * \param stop_digits - termination digits. 282 * \param lang - language 283 * \param repeat_count - repetitions, use INT_MAX for infinite. 284 */ 285 virtual bool play( const std::string& audio_uri, 286 const std::string& video_uri, 287 const std::string& overlay, 288 const std::string& stop_digits, 289 const std::string& lang, 290 int repeat_count ); 291 292 /*! 293 * Record media from an established call using the mm device. 294 * \param audio_uri - audio file. 295 * \param video_uri - video file. 296 * \param stop_digits - termination digits. 297 * \param lang - language 298 * \param beep - if true, play a tone when recording starts. 299 * \param maxTime - max length of recording in ms, use 0 for unlimited. 300 */ 301 virtual bool record( const std::string& audio_uri, 302 const std::string& video_uri, 303 const std::string& stop_digits, 304 const std::string& lang, 305 bool beep, 306 unsigned int maxTime ); 307 308 /*! 309 * Stop the current play or record operation. 310 */ 311 virtual bool stop(); 312 313 /*! 314 * Generate a video overlay. 315 * \param overlay - overlay content. 316 */ 317 bool requestOverlay( const std::string& overlay ); 318 319 /*! 320 * Create a half-duplex media bridge from the external device of this channel 321 * to the external device of another channel. 322 * \param other_channel - channel to bridge to. 323 */ 324 virtual bool bridge( Channel* other_channel ); 325 326 /*! 327 * Unbridge the external media device of this channel from the external media 328 * device of another channel and restore the connection to the internal device. 329 */ 330 virtual bool unbridge(); 331 332 /*! 333 * Test if this channel is bridged to another. 334 */ 335 virtual bool isBridged() { return other_channel_ != 0; } 336 337 /*! 338 * Test if a dtmf digit is a stop digit for the current play/record operation. 339 * \param dtmf - digit to test. 340 */ 341 virtual bool isStopDigit( char dtmf ) const; 342 343 /*! 344 * Start streaming media to the client. 345 */ 346 virtual bool startMedia(); 347 348 /*! 349 * Stop streaming media to the client. 350 */ 351 virtual bool stopMedia(); 352 353 /*! 354 * Test if this is a video call. 355 */ 356 virtual bool isVideo() const; 357 358 /*! 359 * Get the local ip-address and port number for the rtp audio media. 360 */ 361 virtual void getLocalRtpAudioInfo( RtpIpInfo& rtp_audio ) const; 362 363 /*! 364 * Get the local ip-address and port number for the rtp video media. 365 */ 366 virtual void getLocalRtpVideoInfo( RtpIpInfo& rtp_video ) const; 367 368 /*! 369 * Save the ip-address and port of the remote party's rtp audio. 370 */ 371 virtual void setRemoteRtpAudioInfo( const RtpIpInfo& rtp_audio ); 372 373 /*! 374 * Get the remote ip-address and port number for the rtp audio media. 375 */ 376 virtual void getRemoteRtpAudioInfo( RtpIpInfo& rtp_audio ) const; 377 378 /*! 379 * Save the ip-address and port of the remote party's rtp video. 380 */ 381 virtual void setRemoteRtpVideoInfo( const RtpIpInfo& rtp_video ); 382 383 /*! 384 * Get the remote ip-address and port number for the rtp video media. 385 */ 386 virtual void getRemoteRtpVideoInfo( RtpIpInfo& rtp_video ) const; 387 388 /*! 389 * Get the RtspConnector object. 390 */ 391 RtspConnector& getRtspConnector(); 392 393 /*! 394 * Get the player object. 395 */ 396 const Player& getPlayer() const { return player_; } 397 398 /*! 399 * Get the recoder object. 400 */ 401 const Recorder& getRecorder() const { return recorder_; } 402 403 /*! 404 * Clear the digit collection buffer. 405 */ 406 void clearDigits() { collected_digits_.clear(); } 407 408 /*! 409 * Write a digit to the end of the collection buffer. 410 * \param dtmf - digit to save. 411 */ 412 void collectDigit( char dtmf ) { collected_digits_.push_back(dtmf); } 413 414 /*! 415 * Get the digit collection buffer. 416 */ 417 const std::string& getDigits() const { return collected_digits_; } 418 419 /*! 420 * Pass an event to the media state machine. 421 */ 422 void onMediaEvent( Event* event ); 423 424 /*! 425 * Handle an incoming call event from the ipt/dti device. 426 * \param local_number - called number. 427 * \param local_uri - called uri (sip). 428 * \param remote_number - calling number. 429 * \param remote_number - calling name. 430 */ 431 void onIncoming( const std::string& local_number, 432 const std::string& local_uri, 433 const std::string& remote_number, 434 const std::string& remote_name = std::string() ); 435 436 /*! 437 * Handle an inbound call accepted event from the dti/ipt device. 438 */ 439 void onAccepted(); 440 441 /*! 442 * Handle an inbound call accepted event from the dti/ipt device. 443 */ 444 void onAnswered(); 445 446 /*! 447 * Handle an outbound call proceeding event from the dti/ipt device. 448 * Also used by conf devices, for consistency. 449 */ 450 void onProceeding(); 451 452 /*! 453 * Handle an outbound call, remote party ringing event from a dti/ipt device. 454 */ 455 void onRinging(); 456 457 /*! 458 * Handle an outbound call connected event. 459 * \param conn_type - cpa result etc. 460 */ 461 void onConnect( const std::string& conn_type ); 462 463 /*! 464 * Handle a hangup from a dti/ipt device. 465 * \param gc - source of the event. 466 * \param cause - Q.931 cause value 467 * \param cause_text - description 468 * \param conn_type - cpa result (if applicable) 469 */ 470 void onHangup( GcDevice* gc, 471 int cause, 472 const std::string& cause_text, 473 const std::string& conn_type = std::string()); 474 475 /*! 476 * Handle a hangup from a conference device. Called for all parties when the 477 * controller hangs up. 478 * \param confParty - source of the event. 479 */ 480 void onHangup( ConfPartyDevice* confParty ); 481 482 /*! 483 * Handle a hangup from a m3g device. Called when the h245 session ends. 484 * \param m3g - source of the event. 485 */ 486 void onHangup( M3gDevice* m3g); 487 488 /*! 489 * Handle a dtmf digit received event. 490 * \param dtmf - ascii coded dtmf digit. 491 */ 492 void onDtmf( char dtmf ); 493 494 /*! 495 * Handle a tone detection event. 496 * \param name - the tone that has been detected. 497 */ 498 void onTone( const std::string& name ); 499 500 /*! 501 * Handle a user info event. 502 * \param mimetype - content type. 503 * \param content - data. 504 */ 505 void onInfo( const std::string& mimetype, 506 const std::string& content ); 507 508 /*! 509 * Handle a dtmf send completion event. 510 */ 511 void onSendDtmfCompleted(); 512 513 /*! 514 * Handle a media connect completion event from a device. 515 * \param device - source of the event. 516 */ 517 void onConnectCompleted( IpmDevice* device ); 518 519 /*! 520 * Handle a media disconnect completion event from a device. 521 * \param device - source of the event. 522 */ 523 void onDisconnectCompleted( IpmDevice* device ); 524 525 /*! 526 * Handle a media connect completion event from a device. 527 * \param device - source of the event. 528 */ 529 void onConnectCompleted( MmDevice* device ); 530 531 /*! 532 * Handle a media disconnect completion event from a device. 533 * \param device - source of the event. 534 */ 535 void onDisconnectCompleted( MmDevice* device ); 536 537 /*! 538 * Handle a media connect completion event from a device. 539 * \param device - source of the event. 540 */ 541 void onConnectCompleted( M3gDevice* device ); 542 543 /*! 544 * Handle a media disconnect completion event from a device. 545 * \param device - source of the event. 546 */ 547 void onDisconnectCompleted( M3gDevice* device ); 548 549 /*! 550 * Handle a media started event from an m3g device. 551 * \param device - source of the event. 552 */ 553 void onMediaStarted( M3gDevice* device ); 554 555 /*! 556 * Handle a media stopped event from an m3g device. 557 * \param device - source of the event. 558 */ 559 void onMediaStopped( M3gDevice* device ); 560 561 /*! 562 * Handle a media connect completion event from a device. 563 * \param device - source of the event. 564 */ 565 void onConnectCompleted( ConfPartyDevice* device ); 566 567 /*! 568 * Handle a media disconnect completion event from a device. 569 * \param device - source of the event. 570 */ 571 void onDisconnectCompleted( ConfPartyDevice* device ); 572 573 /*! 574 * Handle a gateway media connect completion event from the statemachine. 575 */ 576 void onGatewayConnected(); 577 578 /*! 579 * Handle a conference media connect completion event from the statemachine. 580 */ 581 void onConfConnected(); 582 583 /*! 584 * Handle a play started event from a media device. 585 */ 586 void onPlayStarted( DialogicDevice* device ); 587 588 /*! 589 * Handle a play failed event from a media device. 590 */ 591 void onPlayFailed( DialogicDevice* media_device ); 592 593 /*! 594 * Handle a play completion event from a device. 595 * \param reason - why the play stopped. 596 * \param duration - length of play in ms. 597 */ 598 void onPlayCompleted( const std::string& reason, 599 unsigned int duration ); 600 601 /*! 602 * Handle a play completion event from the state machine. 603 */ 604 void onPlayCompleted(); 605 606 /*! 607 * Handle a record started event from a media device. 608 */ 609 void onRecordStarted( DialogicDevice* device ); 610 611 /*! 612 * Handle a record failed event from a media device. 613 */ 614 void onRecordFailed( DialogicDevice* media_device ); 615 616 /*! 617 * Handle a record completion event from an mm device. 618 * \param reason - why the recording stopped. 619 * \param duration - length of recording in ms. 620 */ 621 void onRecordCompleted( const std::string& reason, 622 unsigned int duration ); 623 624 /*! 625 * Handle a record completion event from the state machine. 626 */ 627 void onRecordCompleted(); 628 629 /*! 630 * Handle a bridge completion event from the state machine. 631 */ 632 void onBridgeCompleted(); 633 634 /*! 635 * Handle a rstp session opened (from an ipm device). 636 * \param session_id - unique identifier for the rtsp session. 637 * \param audio_encoding - codec name 638 * \param video_encoding - codec name 639 * \param width - picture width 640 * \param height - picture height 641 * \param fps - framerate 642 */ 643 void onRtspSession( int session_id, 644 std::string audio_encoding, 645 std::string video_encoding, 646 unsigned int width, 647 unsigned int height, 648 unsigned int fps ); 649 650 /*! 651 * Handle a overlay added event. 652 */ 653 void onOverlayAdded(); 654 655 /*! 656 * Handle a overlay removed event. 657 */ 658 void onOverlayRemoved(); 659 660 private: 661 662 DialogicChannel(); 663 DialogicChannel( const DialogicChannel& ); 664 DialogicChannel& operator = ( const DialogicChannel& ); 665 666 private: 667 668 DialogicChannelManager& channelMgr_; 669 670 Context* context_; /* media state machine (SIP | CONF) */ 671 672 GcDevice* gcDevice_; /* dti(dk) or ipt */ 673 M3gDevice* m3gDevice_; 674 IpmDevice* ipmDevice_; 675 MmDevice* mmDevice_; 676 ConfDevice* confDevice_; 677 ConfPartyDevice* confParty_; 678 679 IpmDevice* rtspIpmDevice_; 680 681 Protocol protocol_; 682 Direction direction_; /* inbound | outbound */ 683 std::string conn_type_; /* CPA result (outbound) */ 684 685 bool h324_connected_; 686 687 std::string stop_digits_; /* play/record remination digits */ 688 std::string collected_digits_; /* digits received during a play */ 689 690 Player player_; 691 Recorder recorder_; 692 693 DialogicChannel* other_channel_; /* optimised bridge */ 694 }; 695 696 697 #endif // _DIALOGICCHANNEL_H 698 699 /* vim:ts=4:set nu: 700 * EOF 701 */
| No admin address has been configured | ViewVC Help |
| Powered by ViewVC 1.0.8 |