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