live
RTSPClient.hh
Go to the documentation of this file.
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 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
18 // A generic RTSP client - for a single "rtsp://" URL
19 // C++ header
20 
21 #ifndef _RTSP_CLIENT_HH
22 #define _RTSP_CLIENT_HH
23 
24 #ifndef _MEDIA_SESSION_HH
25 #include "MediaSession.hh"
26 #endif
27 #ifndef _NET_ADDRESS_HH
28 #include "NetAddress.hh"
29 #endif
30 #ifndef _DIGEST_AUTHENTICATION_HH
31 #include "DigestAuthentication.hh"
32 #endif
33 #ifndef _TLS_STATE_HH
34 #include "TLSState.hh"
35 #endif
36 #ifndef OMIT_REGISTER_HANDLING
37 #ifndef _RTSP_SERVER_HH
38 #include "RTSPServer.hh" // For the optional "HandlerForREGISTERCommand" mini-server
39 #endif
40 #endif
41 
42 class RTSPClient: public Medium {
43 public:
44  static RTSPClient* createNew(UsageEnvironment& env, char const* rtspURL,
45  int verbosityLevel = 0,
46  char const* applicationName = NULL,
47  portNumBits tunnelOverHTTPPortNum = 0,
48  int socketNumToServer = -1);
49  // If "tunnelOverHTTPPortNum" is non-zero, we tunnel RTSP (and RTP)
50  // over a HTTP connection with the given port number, using the technique
51  // described in Apple's document <http://developer.apple.com/documentation/QuickTime/QTSS/Concepts/chapter_2_section_14.html>
52  // If "socketNumToServer" is >= 0, then it is the socket number of an already-existing TCP connection to the server.
53  // (In this case, "rtspURL" must point to the socket's endpoint, so that it can be accessed via the socket.)
54 
55  typedef void (responseHandler)(RTSPClient* rtspClient,
56  int resultCode, char* resultString);
57  // A function that is called in response to a RTSP command. The parameters are as follows:
58  // "rtspClient": The "RTSPClient" object on which the original command was issued.
59  // "resultCode": If zero, then the command completed successfully. If non-zero, then the command did not complete
60  // successfully, and "resultCode" indicates the error, as follows:
61  // A positive "resultCode" is a RTSP error code (for example, 404 means "not found")
62  // A negative "resultCode" indicates a socket/network error; 0-"resultCode" is the standard "errno" code.
63  // "resultString": A ('\0'-terminated) string returned along with the response, or else NULL.
64  // In particular:
65  // "resultString" for a successful "DESCRIBE" command will be the media session's SDP description.
66  // "resultString" for a successful "OPTIONS" command will be a list of allowed commands.
67  // Note that this string can be present (i.e., not NULL) even if "resultCode" is non-zero - i.e., an error message.
68  // Also, "resultString" can be NULL, even if "resultCode" is zero (e.g., if the RTSP command succeeded, but without
69  // including an appropriate result header).
70  // Note also that this string is dynamically allocated, and must be freed by the handler (or the caller)
71  // - using "delete[]".
72 
74  // Issues a RTSP "DESCRIBE" command, then returns the "CSeq" sequence number that was used in the command.
75  // The (programmer-supplied) "responseHandler" function is called later to handle the response
76  // (or is called immediately - with an error code - if the command cannot be sent).
77  // "authenticator" (optional) is used for access control. If you have username and password strings, you can use this by
78  // passing an actual parameter that you created by creating an "Authenticator(username, password) object".
79  // (Note that if you supply a non-NULL "authenticator" parameter, you need do this only for the first command you send.)
80 
82  // Issues a RTSP "OPTIONS" command, then returns the "CSeq" sequence number that was used in the command.
83  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
84 
85  unsigned sendAnnounceCommand(char const* sdpDescription, responseHandler* responseHandler, Authenticator* authenticator = NULL);
86  // Issues a RTSP "ANNOUNCE" command (with "sdpDescription" as parameter),
87  // then returns the "CSeq" sequence number that was used in the command.
88  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
89 
91  Boolean streamOutgoing = False,
92  Boolean streamUsingTCP = False,
93  Boolean forceMulticastOnUnspecified = False,
94  Authenticator* authenticator = NULL);
95  // Issues a RTSP "SETUP" command, then returns the "CSeq" sequence number that was used in the command.
96  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
97 
99  double start = 0.0f, double end = -1.0f, float scale = 1.0f,
100  Authenticator* authenticator = NULL);
101  // Issues an aggregate RTSP "PLAY" command on "session", then returns the "CSeq" sequence number that was used in the command.
102  // (Note: start=-1 means 'resume'; end=-1 means 'play to end')
103  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
105  double start = 0.0f, double end = -1.0f, float scale = 1.0f,
106  Authenticator* authenticator = NULL);
107  // Issues a RTSP "PLAY" command on "subsession", then returns the "CSeq" sequence number that was used in the command.
108  // (Note: start=-1 means 'resume'; end=-1 means 'play to end')
109  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
110 
111  // Alternative forms of "sendPlayCommand()", used to send "PLAY" commands that include an 'absolute' time range:
112  // (The "absStartTime" string (and "absEndTime" string, if present) *must* be of the form
113  // "YYYYMMDDTHHMMSSZ" or "YYYYMMDDTHHMMSS.<frac>Z")
115  char const* absStartTime, char const* absEndTime = NULL, float scale = 1.0f,
116  Authenticator* authenticator = NULL);
118  char const* absStartTime, char const* absEndTime = NULL, float scale = 1.0f,
119  Authenticator* authenticator = NULL);
120 
122  // Issues an aggregate RTSP "PAUSE" command on "session", then returns the "CSeq" sequence number that was used in the command.
123  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
125  // Issues a RTSP "PAUSE" command on "subsession", then returns the "CSeq" sequence number that was used in the command.
126  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
127 
129  // Issues an aggregate RTSP "RECORD" command on "session", then returns the "CSeq" sequence number that was used in the command.
130  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
132  // Issues a RTSP "RECORD" command on "subsession", then returns the "CSeq" sequence number that was used in the command.
133  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
134 
136  // Issues an aggregate RTSP "TEARDOWN" command on "session", then returns the "CSeq" sequence number that was used in the command.
137  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
139  // Issues a RTSP "TEARDOWN" command on "subsession", then returns the "CSeq" sequence number that was used in the command.
140  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
141 
143  char const* parameterName, char const* parameterValue,
144  Authenticator* authenticator = NULL);
145  // Issues an aggregate RTSP "SET_PARAMETER" command on "session", then returns the "CSeq" sequence number that was used in the command.
146  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
147 
148  unsigned sendGetParameterCommand(MediaSession& session, responseHandler* responseHandler, char const* parameterName,
149  Authenticator* authenticator = NULL);
150  // Issues an aggregate RTSP "GET_PARAMETER" command on "session", then returns the "CSeq" sequence number that was used in the command.
151  // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".)
152 
153  void setRequireValue(char const* requireValue = NULL);
154  // Sets a string to be used as the value of a "Require:" header to be included in
155  // subsequent RTSP commands. Call "setRequireValue()" again (i.e., with no parameter)
156  // to clear this (and so stop "Require:" headers from being included in subsequent cmds).
157 
158  void sendDummyUDPPackets(MediaSession& session, unsigned numDummyPackets = 2);
159  void sendDummyUDPPackets(MediaSubsession& subsession, unsigned numDummyPackets = 2);
160  // Sends short 'dummy' (i.e., non-RTP or RTCP) UDP packets towards the server, to increase
161  // the likelihood of RTP/RTCP packets from the server reaching us if we're behind a NAT.
162  // (If we requested RTP-over-TCP streaming, then these functions have no effect.)
163  // Our implementation automatically does this just prior to sending each "PLAY" command;
164  // You should not call these functions yourself unless you know what you're doing.
165 
166  void setSpeed(MediaSession& session, float speed = 1.0f);
167  // Set (recorded) media download speed to given value to support faster download using 'Speed:'
168  // option on 'PLAY' command.
169 
170  Boolean changeResponseHandler(unsigned cseq, responseHandler* newResponseHandler);
171  // Changes the response handler for the previously-performed command (whose operation returned "cseq").
172  // (To turn off any response handling for the command, use a "newResponseHandler" value of NULL. This might be done as part
173  // of an implementation of a 'timeout handler' on the command, for example.)
174  // This function returns True iff "cseq" was for a valid previously-performed command (whose response is still unhandled).
175 
176  int socketNum() const { return fInputSocketNum; }
177 
179  char const* sourceName,
180  RTSPClient*& resultClient);
181 
182  Boolean parseRTSPURL(char const* url,
183  char*& username, char*& password, NetAddress& address, portNumBits& portNum, char const** urlSuffix = NULL);
184  // Parses "url" as "rtsp://[<username>[:<password>]@]<server-address-or-name>[:<port>][/<stream-name>]"
185  // (Note that the returned "username" and "password" are either NULL, or heap-allocated strings that the caller must later delete[].)
186 
187  void setUserAgentString(char const* userAgentName);
188  // sets an alternative string to be used in RTSP "User-Agent:" headers
189 
191  // call this if you don't want the server to request 'Basic' authentication
192  // (which would cause the client to send usernames and passwords over the net).
193 
195 
196  char const* url() const { return fBaseURL; }
197 
198  void useTLS() { fTLS.isNeeded = True; }
199 
200  static unsigned responseBufferSize;
201 
202 public: // Some compilers complain if this is "private:"
203  // The state of a request-in-progress:
205  public:
208  double start = 0.0f, double end = -1.0f, float scale = 1.0f, char const* contentStr = NULL);
210  char const* absStartTime, char const* absEndTime = NULL, float scale = 1.0f,
212  // alternative constructor for creating "PLAY" requests that include 'absolute' time values
213  virtual ~RequestRecord();
214 
215  RequestRecord*& next() { return fNext; }
216  unsigned& cseq() { return fCSeq; }
217  char const* commandName() const { return fCommandName; }
218  MediaSession* session() const { return fSession; }
220  u_int32_t booleanFlags() const { return fBooleanFlags; }
221  double start() const { return fStart; }
222  double end() const { return fEnd; }
223  char const* absStartTime() const { return fAbsStartTime; }
224  char const* absEndTime() const { return fAbsEndTime; }
225  float scale() const { return fScale; }
226  char* contentStr() const { return fContentStr; }
228 
229  private:
231  unsigned fCSeq;
232  char const* fCommandName;
235  u_int32_t fBooleanFlags;
236  double fStart, fEnd;
237  char *fAbsStartTime, *fAbsEndTime; // used for optional 'absolute' (i.e., "time=") range specifications
238  float fScale;
239  char* fContentStr;
241  };
242 
243 protected:
244  RTSPClient(UsageEnvironment& env, char const* rtspURL,
245  int verbosityLevel, char const* applicationName, portNumBits tunnelOverHTTPPortNum, int socketNumToServer);
246  // called only by createNew();
247  virtual ~RTSPClient();
248 
249  void reset();
250  void setBaseURL(char const* url);
251  int grabSocket(); // allows a subclass to reuse our input socket, so that it won't get closed when we're deleted
252  virtual unsigned sendRequest(RequestRecord* request);
254  char*& cmdURL, Boolean& cmdURLWasAllocated,
255  char const*& protocolStr,
256  char*& extraHeaders, Boolean& extraHeadersWereAllocated);
257  // used to implement "sendRequest()"; subclasses may reimplement this (e.g., when implementing a new command name)
258  virtual int connectToServer(int socketNum, portNumBits remotePortNum); // used to implement "openConnection()"; result values: -1: failure; 0: pending; 1: success
259 
260 private: // redefined virtual functions
261  virtual Boolean isRTSPClient() const;
262 
263 private:
264  class RequestQueue {
265  public:
267  RequestQueue(RequestQueue& origQueue); // moves the queue contents to the new queue
268  virtual ~RequestQueue();
269 
270  void enqueue(RequestRecord* request); // "request" must not be NULL
272  void putAtHead(RequestRecord* request); // "request" must not be NULL
273  RequestRecord* findByCSeq(unsigned cseq);
274  Boolean isEmpty() const { return fHead == NULL; }
275  void reset();
276 
277  private:
280  };
281 
284  int openConnection(); // result values: -1: failure; 0: pending; 1: success
285  char* createAuthenticatorString(char const* cmd, char const* url);
286  char* createBlocksizeString(Boolean streamUsingTCP);
287  char* createKeyMgmtString(char const* url, MediaSubsession const& subsession);
289  Boolean parseResponseCode(char const* line, unsigned& responseCode, char const*& responseString);
291  static Boolean checkForHeader(char const* line, char const* headerName, unsigned headerNameLength, char const*& headerParams);
292  Boolean parseTransportParams(char const* paramsStr,
293  char*& serverAddressStr, portNumBits& serverPortNum,
294  unsigned char& rtpChannelId, unsigned char& rtcpChannelId);
295  Boolean parseScaleParam(char const* paramStr, float& scale);
296  Boolean parseSpeedParam(char const* paramStr, float& speed);
297  Boolean parseRTPInfoParams(char const*& paramStr, u_int16_t& seqNum, u_int32_t& timestamp);
298  Boolean handleSETUPResponse(MediaSubsession& subsession, char const* sessionParamsStr, char const* transportParamsStr,
299  Boolean streamUsingTCP);
301  char const* scaleParamsStr, const char* speedParamsStr,
302  char const* rangeParamsStr, char const* rtpInfoParamsStr);
304  Boolean handleGET_PARAMETERResponse(char const* parameterName, char*& resultValueString, char* resultValueStringEnd);
305  Boolean handleAuthenticationFailure(char const* wwwAuthenticateParamsStr);
307  char const* sessionURL(MediaSession const& session) const;
308  static void handleAlternativeRequestByte(void*, u_int8_t requestByte);
309  void handleAlternativeRequestByte1(u_int8_t requestByte);
310  void constructSubsessionURL(MediaSubsession const& subsession,
311  char const*& prefix,
312  char const*& separator,
313  char const*& suffix);
314 
315  // Support for tunneling RTSP-over-HTTP:
316  Boolean setupHTTPTunneling1(); // send the HTTP "GET"
317  static void responseHandlerForHTTP_GET(RTSPClient* rtspClient, int responseCode, char* responseString);
318  void responseHandlerForHTTP_GET1(int responseCode, char* responseString);
319  Boolean setupHTTPTunneling2(); // send the HTTP "POST"
320 
321  // Support for asynchronous connections to the server:
322  static void connectionHandler(void*, int /*mask*/);
324 
325  // Support for handling data sent back by a server:
326  static void incomingDataHandler(void*, int /*mask*/);
328  void handleResponseBytes(int newBytesRead);
329 
330  // Writing/reading data over a (already set-up) connection:
331  int write(const char* data, unsigned count);
332  int read(u_int8_t* buffer, unsigned bufferSize);
333 
334 public:
336  // If set to a value >0, then a "Blocksize:" header with this value (minus an allowance for
337  // IP, UDP, and RTP headers) will be sent with each "SETUP" request.
338 
339 protected:
341  unsigned fCSeq; // sequence number, used in consecutive requests
344  struct sockaddr_storage fServerAddress;
345 
346 private:
351  char* fBaseURL;
352  unsigned char fTCPStreamIdCount; // used for (optional) RTP/TCP
354  unsigned fSessionTimeoutParameter; // optionally set in response "Session:" headers
358  char* fRequireStr;
359 
360  // Support for tunneling RTSP-over-HTTP:
361  char fSessionCookie[33];
364 
365  // Optional support for TLS:
367  friend class ClientTLSState;
368 };
369 
370 
371 #ifndef OMIT_REGISTER_HANDLING
373 
374 // A simple server that creates a new "RTSPClient" object whenever a "REGISTER" request arrives (specifying the "rtsp://" URL
375 // of a stream). The new "RTSPClient" object will be created with the specified URL, and passed to the provided handler function.
376 
377 typedef void onRTSPClientCreationFunc(RTSPClient* newRTSPClient, Boolean requestStreamingOverTCP);
378 
380 public:
382  Port ourPort = 0, UserAuthenticationDatabase* authDatabase = NULL,
383  int verbosityLevel = 0, char const* applicationName = NULL);
384  // If ourPort.num() == 0, we'll choose the port number ourself. (Use the following function to get it.)
385  portNumBits serverPortNum() const { return ntohs(fServerPort.num()); }
386 
387 protected:
388  HandlerServerForREGISTERCommand(UsageEnvironment& env, onRTSPClientCreationFunc* creationFunc, int ourSocketIPv4, int ourSocketIPv6, Port ourPort,
389  UserAuthenticationDatabase* authDatabase, int verbosityLevel, char const* applicationName);
390  // called only by createNew();
392 
393  virtual RTSPClient* createNewRTSPClient(char const* rtspURL, int verbosityLevel, char const* applicationName,
394  int socketNumToServer);
395  // This function - by default - creates a (base) "RTSPClient" object. If you want to create a subclass
396  // of "RTSPClient" instead, then subclass this class, and redefine this virtual function.
397 
398 protected: // redefined virtual functions
399  virtual char const* allowedCommandNames(); // "OPTIONS", "REGISTER", and (perhaps) "DEREGISTER" only
400  virtual Boolean weImplementREGISTER(char const* cmd/*"REGISTER" or "DEREGISTER"*/,
401  char const* proxyURLSuffix, char*& responseStr);
402  // redefined to return True (for cmd=="REGISTER")
403  virtual void implementCmd_REGISTER(char const* cmd/*"REGISTER" or "DEREGISTER"*/,
404  char const* url, char const* urlSuffix, int socketToRemoteServer,
405  Boolean deliverViaTCP, char const* proxyURLSuffix);
406 
407 private:
411 };
412 #endif
413 
414 #endif
const Boolean False
Definition: Boolean.hh:28
const Boolean True
Definition: Boolean.hh:31
unsigned char Boolean
Definition: Boolean.hh:25
portNumBits portNum(struct sockaddr_storage const &address)
u_int16_t portNumBits
Definition: NetAddress.hh:102
void onRTSPClientCreationFunc(RTSPClient *newRTSPClient, Boolean requestStreamingOverTCP)
Definition: RTSPClient.hh:377
#define NULL
virtual char const * allowedCommandNames()
virtual void implementCmd_REGISTER(char const *cmd, char const *url, char const *urlSuffix, int socketToRemoteServer, Boolean deliverViaTCP, char const *proxyURLSuffix)
HandlerServerForREGISTERCommand(UsageEnvironment &env, onRTSPClientCreationFunc *creationFunc, int ourSocketIPv4, int ourSocketIPv6, Port ourPort, UserAuthenticationDatabase *authDatabase, int verbosityLevel, char const *applicationName)
onRTSPClientCreationFunc * fCreationFunc
Definition: RTSPClient.hh:408
portNumBits serverPortNum() const
Definition: RTSPClient.hh:385
static HandlerServerForREGISTERCommand * createNew(UsageEnvironment &env, onRTSPClientCreationFunc *creationFunc, Port ourPort=0, UserAuthenticationDatabase *authDatabase=NULL, int verbosityLevel=0, char const *applicationName=NULL)
virtual RTSPClient * createNewRTSPClient(char const *rtspURL, int verbosityLevel, char const *applicationName, int socketNumToServer)
virtual Boolean weImplementREGISTER(char const *cmd, char const *proxyURLSuffix, char *&responseStr)
Definition: Media.hh:50
portNumBits num() const
Definition: NetAddress.hh:108
void enqueue(RequestRecord *request)
RequestRecord * dequeue()
void putAtHead(RequestRecord *request)
RequestRecord * findByCSeq(unsigned cseq)
RequestQueue(RequestQueue &origQueue)
Boolean isEmpty() const
Definition: RTSPClient.hh:274
RequestRecord * fTail
Definition: RTSPClient.hh:279
RequestRecord * fHead
Definition: RTSPClient.hh:278
MediaSubsession * fSubsession
Definition: RTSPClient.hh:234
u_int32_t booleanFlags() const
Definition: RTSPClient.hh:220
char const * absStartTime() const
Definition: RTSPClient.hh:223
char * contentStr() const
Definition: RTSPClient.hh:226
char const * absEndTime() const
Definition: RTSPClient.hh:224
char const * commandName() const
Definition: RTSPClient.hh:217
MediaSession * fSession
Definition: RTSPClient.hh:233
RequestRecord(unsigned cseq, responseHandler *handler, char const *absStartTime, char const *absEndTime=NULL, float scale=1.0f, MediaSession *session=NULL, MediaSubsession *subsession=NULL)
RequestRecord(unsigned cseq, char const *commandName, responseHandler *handler, MediaSession *session=NULL, MediaSubsession *subsession=NULL, u_int32_t booleanFlags=0, double start=0.0f, double end=-1.0f, float scale=1.0f, char const *contentStr=NULL)
responseHandler * fHandler
Definition: RTSPClient.hh:240
responseHandler *& handler()
Definition: RTSPClient.hh:227
RequestRecord * fNext
Definition: RTSPClient.hh:230
MediaSubsession * subsession() const
Definition: RTSPClient.hh:219
RequestRecord *& next()
Definition: RTSPClient.hh:215
MediaSession * session() const
Definition: RTSPClient.hh:218
void handleAlternativeRequestByte1(u_int8_t requestByte)
Boolean parseRTSPURL(char const *url, char *&username, char *&password, NetAddress &address, portNumBits &portNum, char const **urlSuffix=NULL)
void resetTCPSockets()
Boolean parseSpeedParam(char const *paramStr, float &speed)
u_int16_t desiredMaxIncomingPacketSize
Definition: RTSPClient.hh:335
int grabSocket()
static RTSPClient * createNew(UsageEnvironment &env, char const *rtspURL, int verbosityLevel=0, char const *applicationName=NULL, portNumBits tunnelOverHTTPPortNum=0, int socketNumToServer=-1)
unsigned sendAnnounceCommand(char const *sdpDescription, responseHandler *responseHandler, Authenticator *authenticator=NULL)
Boolean changeResponseHandler(unsigned cseq, responseHandler *newResponseHandler)
void useTLS()
Definition: RTSPClient.hh:198
static void responseHandlerForHTTP_GET(RTSPClient *rtspClient, int responseCode, char *responseString)
RequestQueue fRequestsAwaitingHTTPTunneling
Definition: RTSPClient.hh:357
virtual Boolean setRequestFields(RequestRecord *request, char *&cmdURL, Boolean &cmdURLWasAllocated, char const *&protocolStr, char *&extraHeaders, Boolean &extraHeadersWereAllocated)
void connectionHandler1()
int fOutputSocketNum
Definition: RTSPClient.hh:350
unsigned sendPauseCommand(MediaSession &session, responseHandler *responseHandler, Authenticator *authenticator=NULL)
virtual ~RTSPClient()
Authenticator fCurrentAuthenticator
Definition: RTSPClient.hh:342
Boolean resendCommand(RequestRecord *request)
char * createBlocksizeString(Boolean streamUsingTCP)
void reset()
char * fBaseURL
Definition: RTSPClient.hh:351
void setSpeed(MediaSession &session, float speed=1.0f)
static unsigned responseBufferSize
Definition: RTSPClient.hh:200
int socketNum() const
Definition: RTSPClient.hh:176
void sendDummyUDPPackets(MediaSession &session, unsigned numDummyPackets=2)
unsigned sendRecordCommand(MediaSubsession &subsession, responseHandler *responseHandler, Authenticator *authenticator=NULL)
unsigned sendDescribeCommand(responseHandler *responseHandler, Authenticator *authenticator=NULL)
char * fUserAgentHeaderStr
Definition: RTSPClient.hh:348
Boolean parseResponseCode(char const *line, unsigned &responseCode, char const *&responseString)
unsigned sendPlayCommand(MediaSubsession &subsession, responseHandler *responseHandler, double start=0.0f, double end=-1.0f, float scale=1.0f, Authenticator *authenticator=NULL)
virtual Boolean isRTSPClient() const
static void incomingDataHandler(void *, int)
unsigned sendPlayCommand(MediaSession &session, responseHandler *responseHandler, char const *absStartTime, char const *absEndTime=NULL, float scale=1.0f, Authenticator *authenticator=NULL)
unsigned char fTCPStreamIdCount
Definition: RTSPClient.hh:352
unsigned fResponseBytesAlreadySeen
Definition: RTSPClient.hh:356
Boolean fHTTPTunnelingConnectionIsPending
Definition: RTSPClient.hh:363
unsigned sendTeardownCommand(MediaSession &session, responseHandler *responseHandler, Authenticator *authenticator=NULL)
unsigned sendPlayCommand(MediaSession &session, responseHandler *responseHandler, double start=0.0f, double end=-1.0f, float scale=1.0f, Authenticator *authenticator=NULL)
char * createKeyMgmtString(char const *url, MediaSubsession const &subsession)
Boolean fAllowBasicAuthentication
Definition: RTSPClient.hh:343
char * fRequireStr
Definition: RTSPClient.hh:358
Boolean handleTEARDOWNResponse(MediaSession &session, MediaSubsession &subsession)
unsigned sendGetParameterCommand(MediaSession &session, responseHandler *responseHandler, char const *parameterName, Authenticator *authenticator=NULL)
int read(u_int8_t *buffer, unsigned bufferSize)
int write(const char *data, unsigned count)
void sendDummyUDPPackets(MediaSubsession &subsession, unsigned numDummyPackets=2)
Boolean setupHTTPTunneling2()
unsigned sessionTimeoutParameter() const
Definition: RTSPClient.hh:194
void handleRequestError(RequestRecord *request)
void setBaseURL(char const *url)
void responseHandlerForHTTP_GET1(int responseCode, char *responseString)
Boolean parseTransportParams(char const *paramsStr, char *&serverAddressStr, portNumBits &serverPortNum, unsigned char &rtpChannelId, unsigned char &rtcpChannelId)
unsigned sendTeardownCommand(MediaSubsession &subsession, responseHandler *responseHandler, Authenticator *authenticator=NULL)
RequestQueue fRequestsAwaitingConnection
Definition: RTSPClient.hh:357
Boolean handleGET_PARAMETERResponse(char const *parameterName, char *&resultValueString, char *resultValueStringEnd)
static void handleAlternativeRequestByte(void *, u_int8_t requestByte)
static Boolean lookupByName(UsageEnvironment &env, char const *sourceName, RTSPClient *&resultClient)
virtual unsigned sendRequest(RequestRecord *request)
char fSessionCookie[33]
Definition: RTSPClient.hh:361
Boolean handleAuthenticationFailure(char const *wwwAuthenticateParamsStr)
void disallowBasicAuthentication()
Definition: RTSPClient.hh:190
void handleResponseBytes(int newBytesRead)
void() responseHandler(RTSPClient *rtspClient, int resultCode, char *resultString)
Definition: RTSPClient.hh:55
portNumBits fTunnelOverHTTPPortNum
Definition: RTSPClient.hh:347
void setRequireValue(char const *requireValue=NULL)
unsigned sendRecordCommand(MediaSession &session, responseHandler *responseHandler, Authenticator *authenticator=NULL)
unsigned sendOptionsCommand(responseHandler *responseHandler, Authenticator *authenticator=NULL)
char * fLastSessionId
Definition: RTSPClient.hh:353
unsigned fResponseBufferBytesLeft
Definition: RTSPClient.hh:356
unsigned fCSeq
Definition: RTSPClient.hh:341
unsigned fUserAgentHeaderStrLen
Definition: RTSPClient.hh:349
int fVerbosityLevel
Definition: RTSPClient.hh:340
RTSPClient(UsageEnvironment &env, char const *rtspURL, int verbosityLevel, char const *applicationName, portNumBits tunnelOverHTTPPortNum, int socketNumToServer)
Boolean parseScaleParam(char const *paramStr, float &scale)
int openConnection()
struct sockaddr_storage fServerAddress
Definition: RTSPClient.hh:344
int fInputSocketNum
Definition: RTSPClient.hh:350
unsigned sendSetParameterCommand(MediaSession &session, responseHandler *responseHandler, char const *parameterName, char const *parameterValue, Authenticator *authenticator=NULL)
char * createAuthenticatorString(char const *cmd, char const *url)
unsigned sendPauseCommand(MediaSubsession &subsession, responseHandler *responseHandler, Authenticator *authenticator=NULL)
static void connectionHandler(void *, int)
void resetResponseBuffer()
void handleIncomingRequest()
void setUserAgentString(char const *userAgentName)
virtual int connectToServer(int socketNum, portNumBits remotePortNum)
unsigned sendPlayCommand(MediaSubsession &subsession, responseHandler *responseHandler, char const *absStartTime, char const *absEndTime=NULL, float scale=1.0f, Authenticator *authenticator=NULL)
RequestQueue fRequestsAwaitingResponse
Definition: RTSPClient.hh:357
unsigned fSessionTimeoutParameter
Definition: RTSPClient.hh:354
unsigned sendSetupCommand(MediaSubsession &subsession, responseHandler *responseHandler, Boolean streamOutgoing=False, Boolean streamUsingTCP=False, Boolean forceMulticastOnUnspecified=False, Authenticator *authenticator=NULL)
static Boolean checkForHeader(char const *line, char const *headerName, unsigned headerNameLength, char const *&headerParams)
void incomingDataHandler1()
Boolean handleSETUPResponse(MediaSubsession &subsession, char const *sessionParamsStr, char const *transportParamsStr, Boolean streamUsingTCP)
char const * url() const
Definition: RTSPClient.hh:196
Boolean handlePLAYResponse(MediaSession *session, MediaSubsession *subsession, char const *scaleParamsStr, const char *speedParamsStr, char const *rangeParamsStr, char const *rtpInfoParamsStr)
unsigned fSessionCookieCounter
Definition: RTSPClient.hh:362
Boolean parseRTPInfoParams(char const *&paramStr, u_int16_t &seqNum, u_int32_t &timestamp)
void constructSubsessionURL(MediaSubsession const &subsession, char const *&prefix, char const *&separator, char const *&suffix)
char const * sessionURL(MediaSession const &session) const
char * fResponseBuffer
Definition: RTSPClient.hh:355
ClientTLSState fTLS
Definition: RTSPClient.hh:366
Boolean setupHTTPTunneling1()
char * rtspURL(ServerMediaSession const *serverMediaSession, int clientSocket=-1, Boolean useIPv6=False) const
Boolean isNeeded
Definition: TLSState.hh:39