call.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
  4. *
  5. * Version: MPL 1.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Anthony Minessale II <anthm@freeswitch.org>
  21. * Portions created by the Initial Developer are Copyright (C)
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. *
  26. * Joao Mesquita <jmesquita@freeswitch.org>
  27. *
  28. */
  29. #ifndef CALL_H
  30. #define CALL_H
  31. #include <QtCore>
  32. #include <QString>
  33. #include <switch.h>
  34. #include "channel.h"
  35. typedef enum {
  36. FSCOMM_CALL_STATE_RINGING = 0,
  37. FSCOMM_CALL_STATE_TRYING = 1,
  38. FSCOMM_CALL_STATE_ANSWERED = 2,
  39. FSCOMM_CALL_STATE_FAILED = 3,
  40. FSCOMM_CALL_STATE_TRANSFER = 4
  41. } fscomm_call_state_t;
  42. typedef enum {
  43. FSCOMM_CALL_DIRECTION_INBOUND = 0,
  44. FSCOMM_CALL_DIRECTION_OUTBOUND = 1
  45. } fscomm_call_direction_t;
  46. class Call {
  47. public:
  48. Call();
  49. /* Needs rework */
  50. QString getCidName(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidName() : _channel.data()->getCidName(); }
  51. QString getCidNumber(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidNumber() : _channel.data()->getCidNumber(); }
  52. QString getDestinationNumber(void) { return _otherLegChannel.data()->getDestinationNumber(); }
  53. void setChannel(QSharedPointer<Channel> channel) { _channel = channel; }
  54. QSharedPointer<Channel> getChannel() { return _channel; }
  55. void setOtherLegChannel(QSharedPointer<Channel> channel) { _otherLegChannel = channel; }
  56. QSharedPointer<Channel> getOtherLegChannel() { return _otherLegChannel; }
  57. QString getUuid(void) { return _channel.data()->getUuid(); }
  58. QString getOtherLegUuid(void) { return _otherLegChannel.data()->getUuid(); }
  59. void setCallDirection(fscomm_call_direction_t dir) { _direction = dir; }
  60. int getCallID(void) { return _channel.data()->getPaCallId(); }
  61. fscomm_call_direction_t getDirection() { return _direction; }
  62. fscomm_call_state_t getState() { return _state; }
  63. void setState(fscomm_call_state_t state) { _state = state; }
  64. void setCause(QString cause) { _cause = cause; qDebug()<<cause; }
  65. QString getCause() { return _cause; qDebug() << _cause; }
  66. void setActive(bool isActive) { _isActive = isActive; }
  67. bool isActive() { return _isActive == true; }
  68. switch_status_t toggleRecord(bool);
  69. switch_status_t toggleHold(bool);
  70. void sendDTMF(QString digit);
  71. void setAnsweredEpoch(qulonglong time) { _answeredEpoch = time/1000000; }
  72. QTime getCurrentStateTime();
  73. /*bool transfer();*/
  74. private:
  75. QSharedPointer<Channel> _channel; /* This should be our portaudio channel */
  76. QSharedPointer<Channel> _otherLegChannel;
  77. QString _cause;
  78. fscomm_call_direction_t _direction;
  79. bool _isActive;
  80. QString _recording_filename;
  81. fscomm_call_state_t _state;
  82. qulonglong _answeredEpoch;
  83. };
  84. Q_DECLARE_METATYPE(Call)
  85. #endif // CALL_H