compat_h323.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef COMPAT_H323_H
  2. #define COMPAT_H323_H
  3. #include "ast_ptlib.h"
  4. #if VERSION(OPENH323_MAJOR,OPENH323_MINOR,OPENH323_BUILD) < VERSION(1,17,3)
  5. /**
  6. * Workaround for broken (less than 1.17.3) OpenH323 stack to be able to
  7. * make TCP connections from specific address
  8. */
  9. class MyH323TransportTCP : public H323TransportTCP
  10. {
  11. PCLASSINFO(MyH323TransportTCP, H323TransportTCP);
  12. public:
  13. MyH323TransportTCP(
  14. H323EndPoint & endpoint, ///< H323 End Point object
  15. PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(), ///< Local interface to use
  16. PBoolean listen = FALSE ///< Flag for need to wait for remote to connect
  17. );
  18. /**Connect to the remote party.
  19. */
  20. virtual PBoolean Connect();
  21. };
  22. #else
  23. #define MyH323TransportTCP H323TransportTCP
  24. #endif /* <VERSION(1,17,3) */
  25. class MyH323TransportUDP: public H323TransportUDP
  26. {
  27. PCLASSINFO(MyH323TransportUDP, H323TransportUDP);
  28. public:
  29. MyH323TransportUDP(H323EndPoint &endpoint,
  30. PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
  31. WORD localPort = 0,
  32. WORD remotePort = 0): H323TransportUDP(endpoint, binding, localPort, remotePort)
  33. {
  34. }
  35. virtual PBoolean DiscoverGatekeeper(H323Gatekeeper &,
  36. H323RasPDU &,
  37. const H323TransportAddress &);
  38. protected:
  39. PDECLARE_NOTIFIER(PThread, MyH323TransportUDP, DiscoverMain);
  40. H323Gatekeeper *discoverGatekeeper;
  41. H323RasPDU *discoverPDU;
  42. const H323TransportAddress *discoverAddress;
  43. PBoolean discoverResult;
  44. PBoolean discoverReady;
  45. PMutex discoverMutex;
  46. };
  47. template <class _Abstract_T, typename _Key_T = PString>
  48. class MyPFactory: public PFactory<_Abstract_T, _Key_T>
  49. {
  50. public:
  51. template <class _Concrete_T> class Worker: public PFactory<_Abstract_T, _Key_T>::WorkerBase
  52. {
  53. public:
  54. Worker(const _Key_T &_key, bool singleton = false)
  55. :PFactory<_Abstract_T, _Key_T>::WorkerBase(singleton), key(_key)
  56. {
  57. PFactory<_Abstract_T, _Key_T>::Register(key, this);
  58. }
  59. ~Worker()
  60. {
  61. PFactory<_Abstract_T, _Key_T>::Unregister(key);
  62. }
  63. protected:
  64. virtual _Abstract_T *Create(const _Key_T &) const { return new _Concrete_T; }
  65. private:
  66. PString key;
  67. };
  68. };
  69. #ifdef H323_REGISTER_CAPABILITY
  70. #undef H323_REGISTER_CAPABILITY
  71. #endif
  72. #define H323_REGISTER_CAPABILITY(cls, capName) static MyPFactory<H323Capability>::Worker<cls> cls##Factory(capName, true)
  73. #ifdef OPAL_MEDIA_FORMAT_DECLARE
  74. #undef OPAL_MEDIA_FORMAT_DECLARE
  75. #endif
  76. #define OPAL_MEDIA_FORMAT_DECLARE(classname, _fullName, _defaultSessionID, _rtpPayloadType, _needsJitter,_bandwidth, _frameSize, _frameTime, _timeUnits, _timeStamp) \
  77. class classname : public OpalMediaFormat \
  78. { \
  79. public: \
  80. classname() \
  81. : OpalMediaFormat(_fullName, _defaultSessionID, _rtpPayloadType, _needsJitter, _bandwidth, \
  82. _frameSize, _frameTime, _timeUnits, _timeStamp){} \
  83. }; \
  84. static MyPFactory<OpalMediaFormat>::Worker<classname> classname##Factory(_fullName, true)
  85. #endif /* !defined AST_H323_H */