RTSPRegisterSender.hh 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**********
  2. This library is free software; you can redistribute it and/or modify it under
  3. the terms of the GNU Lesser General Public License as published by the
  4. Free Software Foundation; either version 3 of the License, or (at your
  5. option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
  6. This library is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  9. more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with this library; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  13. **********/
  14. // "liveMedia"
  15. // Copyright (c) 1996-2019 Live Networks, Inc. All rights reserved.
  16. // Special objects which, when created, sends a custom RTSP "REGISTER" (or "DEREGISTER") command
  17. // to a specified client.
  18. // C++ header
  19. #ifndef _RTSP_REGISTER_SENDER_HH
  20. #define _RTSP_REGISTER_SENDER_HH
  21. #ifndef _RTSP_CLIENT_HH
  22. #include "RTSPClient.hh"
  23. #endif
  24. class RTSPRegisterOrDeregisterSender: public RTSPClient {
  25. public:
  26. virtual ~RTSPRegisterOrDeregisterSender();
  27. protected: // we're a virtual base class
  28. RTSPRegisterOrDeregisterSender(UsageEnvironment& env,
  29. char const* remoteClientNameOrAddress, portNumBits remoteClientPortNum,
  30. Authenticator* authenticator,
  31. int verbosityLevel, char const* applicationName);
  32. public: // Some compilers complain if this is "protected:"
  33. // A subclass of "RTSPClient::RequestRecord", specific to our "REGISTER" and "DEREGISTER" commands:
  34. class RequestRecord_REGISTER_or_DEREGISTER: public RTSPClient::RequestRecord {
  35. public:
  36. RequestRecord_REGISTER_or_DEREGISTER(unsigned cseq, char const* cmdName, RTSPClient::responseHandler* rtspResponseHandler, char const* rtspURLToRegisterOrDeregister, char const* proxyURLSuffix);
  37. virtual ~RequestRecord_REGISTER_or_DEREGISTER();
  38. char const* proxyURLSuffix() const { return fProxyURLSuffix; }
  39. protected:
  40. char* fRTSPURLToRegisterOrDeregister;
  41. char* fProxyURLSuffix;
  42. };
  43. protected:
  44. portNumBits fRemoteClientPortNum;
  45. };
  46. //////////
  47. class RTSPRegisterSender: public RTSPRegisterOrDeregisterSender {
  48. public:
  49. static RTSPRegisterSender*
  50. createNew(UsageEnvironment& env,
  51. char const* remoteClientNameOrAddress, portNumBits remoteClientPortNum, char const* rtspURLToRegister,
  52. RTSPClient::responseHandler* rtspResponseHandler, Authenticator* authenticator = NULL,
  53. Boolean requestStreamingViaTCP = False, char const* proxyURLSuffix = NULL, Boolean reuseConnection = False,
  54. int verbosityLevel = 0, char const* applicationName = NULL);
  55. void grabConnection(int& sock, struct sockaddr_in& remoteAddress); // so that the socket doesn't get closed when we're deleted
  56. protected:
  57. RTSPRegisterSender(UsageEnvironment& env,
  58. char const* remoteClientNameOrAddress, portNumBits remoteClientPortNum, char const* rtspURLToRegister,
  59. RTSPClient::responseHandler* rtspResponseHandler, Authenticator* authenticator,
  60. Boolean requestStreamingViaTCP, char const* proxyURLSuffix, Boolean reuseConnection,
  61. int verbosityLevel, char const* applicationName);
  62. // called only by "createNew()"
  63. virtual ~RTSPRegisterSender();
  64. // Redefined virtual functions:
  65. virtual Boolean setRequestFields(RequestRecord* request,
  66. char*& cmdURL, Boolean& cmdURLWasAllocated,
  67. char const*& protocolStr,
  68. char*& extraHeaders, Boolean& extraHeadersWereAllocated);
  69. public: // Some compilers complain if this is "protected:"
  70. // A subclass of "RequestRecord_REGISTER_or_DEREGISTER", specific to our "REGISTER" command:
  71. class RequestRecord_REGISTER: public RTSPRegisterOrDeregisterSender::RequestRecord_REGISTER_or_DEREGISTER {
  72. public:
  73. RequestRecord_REGISTER(unsigned cseq, RTSPClient::responseHandler* rtspResponseHandler, char const* rtspURLToRegister,
  74. Boolean reuseConnection, Boolean requestStreamingViaTCP, char const* proxyURLSuffix);
  75. virtual ~RequestRecord_REGISTER();
  76. char const* rtspURLToRegister() const { return fRTSPURLToRegisterOrDeregister; }
  77. Boolean reuseConnection() const { return fReuseConnection; }
  78. Boolean requestStreamingViaTCP() const { return fRequestStreamingViaTCP; }
  79. private:
  80. Boolean fReuseConnection, fRequestStreamingViaTCP;
  81. };
  82. };
  83. //////////
  84. class RTSPDeregisterSender: public RTSPRegisterOrDeregisterSender {
  85. public:
  86. static RTSPDeregisterSender*
  87. createNew(UsageEnvironment& env,
  88. char const* remoteClientNameOrAddress, portNumBits remoteClientPortNum, char const* rtspURLToDeregister,
  89. RTSPClient::responseHandler* rtspResponseHandler, Authenticator* authenticator = NULL,
  90. char const* proxyURLSuffix = NULL,
  91. int verbosityLevel = 0, char const* applicationName = NULL);
  92. protected:
  93. RTSPDeregisterSender(UsageEnvironment& env,
  94. char const* remoteClientNameOrAddress, portNumBits remoteClientPortNum, char const* rtspURLToDeregister,
  95. RTSPClient::responseHandler* rtspResponseHandler, Authenticator* authenticator,
  96. char const* proxyURLSuffix,
  97. int verbosityLevel, char const* applicationName);
  98. // called only by "createNew()"
  99. virtual ~RTSPDeregisterSender();
  100. // Redefined virtual functions:
  101. virtual Boolean setRequestFields(RequestRecord* request,
  102. char*& cmdURL, Boolean& cmdURLWasAllocated,
  103. char const*& protocolStr,
  104. char*& extraHeaders, Boolean& extraHeadersWereAllocated);
  105. public: // Some compilers complain if this is "protected:"
  106. // A subclass of "RequestRecord_REGISTER_or_DEREGISTER", specific to our "DEREGISTER" command:
  107. class RequestRecord_DEREGISTER: public RTSPRegisterOrDeregisterSender::RequestRecord_REGISTER_or_DEREGISTER {
  108. public:
  109. RequestRecord_DEREGISTER(unsigned cseq, RTSPClient::responseHandler* rtspResponseHandler, char const* rtspURLToDeregister, char const* proxyURLSuffix);
  110. virtual ~RequestRecord_DEREGISTER();
  111. char const* rtspURLToDeregister() const { return fRTSPURLToRegisterOrDeregister; }
  112. };
  113. };
  114. #endif