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 <>.)
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.
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
21 #ifndef _RTSP_CLIENT_HH
22 #define _RTSP_CLIENT_HH
24 #ifndef _MEDIA_SESSION_HH
25 #include "MediaSession.hh"
26 #endif
27 #ifndef _NET_ADDRESS_HH
28 #include "NetAddress.hh"
29 #endif
31 #include "DigestAuthentication.hh"
32 #endif
33 #ifndef _TLS_STATE_HH
34 #include "TLSState.hh"
35 #endif
37 #ifndef _RTSP_SERVER_HH
38 #include "RTSPServer.hh" // For the optional "HandlerForREGISTERCommand" mini-server
39 #endif
40 #endif
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 <>
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.)
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[]".
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.)
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".)
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".)
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".)
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".)
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
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);
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".)
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".)
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".)
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".)
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".)
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).
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.
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.
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).
176  int socketNum() const { return fInputSocketNum; }
179  char const* sourceName,
180  RTSPClient*& resultClient);
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[].)
187  void setUserAgentString(char const* userAgentName);
188  // sets an alternative string to be used in RTSP "User-Agent:" headers
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).
196  char const* url() const { return fBaseURL; }
198  static unsigned responseBufferSize;
200 public: // Some compilers complain if this is "private:"
201  // The state of a request-in-progress:
203  public:
206  double start = 0.0f, double end = -1.0f, float scale = 1.0f, char const* contentStr = NULL);
208  char const* absStartTime, char const* absEndTime = NULL, float scale = 1.0f,
210  // alternative constructor for creating "PLAY" requests that include 'absolute' time values
211  virtual ~RequestRecord();
213  RequestRecord*& next() { return fNext; }
214  unsigned& cseq() { return fCSeq; }
215  char const* commandName() const { return fCommandName; }
216  MediaSession* session() const { return fSession; }
218  u_int32_t booleanFlags() const { return fBooleanFlags; }
219  double start() const { return fStart; }
220  double end() const { return fEnd; }
221  char const* absStartTime() const { return fAbsStartTime; }
222  char const* absEndTime() const { return fAbsEndTime; }
223  float scale() const { return fScale; }
224  char* contentStr() const { return fContentStr; }
227  private:
229  unsigned fCSeq;
230  char const* fCommandName;
233  u_int32_t fBooleanFlags;
234  double fStart, fEnd;
235  char *fAbsStartTime, *fAbsEndTime; // used for optional 'absolute' (i.e., "time=") range specifications
236  float fScale;
237  char* fContentStr;
239  };
241 protected:
242  RTSPClient(UsageEnvironment& env, char const* rtspURL,
243  int verbosityLevel, char const* applicationName, portNumBits tunnelOverHTTPPortNum, int socketNumToServer);
244  // called only by createNew();
245  virtual ~RTSPClient();
247  void reset();
248  void setBaseURL(char const* url);
249  int grabSocket(); // allows a subclass to reuse our input socket, so that it won't get closed when we're deleted
250  virtual unsigned sendRequest(RequestRecord* request);
252  char*& cmdURL, Boolean& cmdURLWasAllocated,
253  char const*& protocolStr,
254  char*& extraHeaders, Boolean& extraHeadersWereAllocated);
255  // used to implement "sendRequest()"; subclasses may reimplement this (e.g., when implementing a new command name)
256  virtual int connectToServer(int socketNum, portNumBits remotePortNum); // used to implement "openConnection()"; result values: -1: failure; 0: pending; 1: success
258 private: // redefined virtual functions
259  virtual Boolean isRTSPClient() const;
261 private:
262  class RequestQueue {
263  public:
265  RequestQueue(RequestQueue& origQueue); // moves the queue contents to the new queue
266  virtual ~RequestQueue();
268  void enqueue(RequestRecord* request); // "request" must not be NULL
270  void putAtHead(RequestRecord* request); // "request" must not be NULL
271  RequestRecord* findByCSeq(unsigned cseq);
272  Boolean isEmpty() const { return fHead == NULL; }
273  void reset();
275  private:
278  };
282  int openConnection(); // result values: -1: failure; 0: pending; 1: success
283  char* createAuthenticatorString(char const* cmd, char const* url);
284  char* createBlocksizeString(Boolean streamUsingTCP);
285  char* createKeyMgmtString(char const* url, MediaSubsession const& subsession);
287  Boolean parseResponseCode(char const* line, unsigned& responseCode, char const*& responseString);
289  static Boolean checkForHeader(char const* line, char const* headerName, unsigned headerNameLength, char const*& headerParams);
290  Boolean parseTransportParams(char const* paramsStr,
291  char*& serverAddressStr, portNumBits& serverPortNum,
292  unsigned char& rtpChannelId, unsigned char& rtcpChannelId);
293  Boolean parseScaleParam(char const* paramStr, float& scale);
294  Boolean parseSpeedParam(char const* paramStr, float& speed);
295  Boolean parseRTPInfoParams(char const*& paramStr, u_int16_t& seqNum, u_int32_t& timestamp);
296  Boolean handleSETUPResponse(MediaSubsession& subsession, char const* sessionParamsStr, char const* transportParamsStr,
297  Boolean streamUsingTCP);
299  char const* scaleParamsStr, const char* speedParamsStr,
300  char const* rangeParamsStr, char const* rtpInfoParamsStr);
302  Boolean handleGET_PARAMETERResponse(char const* parameterName, char*& resultValueString, char* resultValueStringEnd);
303  Boolean handleAuthenticationFailure(char const* wwwAuthenticateParamsStr);
305  char const* sessionURL(MediaSession const& session) const;
306  static void handleAlternativeRequestByte(void*, u_int8_t requestByte);
307  void handleAlternativeRequestByte1(u_int8_t requestByte);
308  void constructSubsessionURL(MediaSubsession const& subsession,
309  char const*& prefix,
310  char const*& separator,
311  char const*& suffix);
313  // Support for tunneling RTSP-over-HTTP:
314  Boolean setupHTTPTunneling1(); // send the HTTP "GET"
315  static void responseHandlerForHTTP_GET(RTSPClient* rtspClient, int responseCode, char* responseString);
316  void responseHandlerForHTTP_GET1(int responseCode, char* responseString);
317  Boolean setupHTTPTunneling2(); // send the HTTP "POST"
319  // Support for asynchronous connections to the server:
320  static void connectionHandler(void*, int /*mask*/);
323  // Support for handling data sent back by a server:
324  static void incomingDataHandler(void*, int /*mask*/);
326  void handleResponseBytes(int newBytesRead);
328  // Writing/reading data over a (already set-up) connection:
329  int write(const char* data, unsigned count);
330  int read(u_int8_t* buffer, unsigned bufferSize);
332 public:
334  // If set to a value >0, then a "Blocksize:" header with this value (minus an allowance for
335  // IP, UDP, and RTP headers) will be sent with each "SETUP" request.
337 protected:
339  unsigned fCSeq; // sequence number, used in consecutive requests
342  struct sockaddr_storage fServerAddress;
344 private:
349  char* fBaseURL;
350  unsigned char fTCPStreamIdCount; // used for (optional) RTP/TCP
352  unsigned fSessionTimeoutParameter; // optionally set in response "Session:" headers
356  char* fRequireStr;
358  // Support for tunneling RTSP-over-HTTP:
359  char fSessionCookie[33];
363  // Optional support for TLS:
365  ClientTLSState fPOSTSocketTLS; // used only for RTSP-over-HTTPS
368  friend class ClientTLSState;
369 };
375 // A simple server that creates a new "RTSPClient" object whenever a "REGISTER" request arrives (specifying the "rtsp://" URL
376 // of a stream). The new "RTSPClient" object will be created with the specified URL, and passed to the provided handler function.
378 typedef void onRTSPClientCreationFunc(RTSPClient* newRTSPClient, Boolean requestStreamingOverTCP);
381 public:
383  Port ourPort = 0, UserAuthenticationDatabase* authDatabase = NULL,
384  int verbosityLevel = 0, char const* applicationName = NULL);
385  // If ourPort.num() == 0, we'll choose the port number ourself. (Use the following function to get it.)
386  portNumBits serverPortNum() const { return ntohs(fServerPort.num()); }
388 protected:
389  HandlerServerForREGISTERCommand(UsageEnvironment& env, onRTSPClientCreationFunc* creationFunc, int ourSocketIPv4, int ourSocketIPv6, Port ourPort,
390  UserAuthenticationDatabase* authDatabase, int verbosityLevel, char const* applicationName);
391  // called only by createNew();
394  virtual RTSPClient* createNewRTSPClient(char const* rtspURL, int verbosityLevel, char const* applicationName,
395  int socketNumToServer);
396  // This function - by default - creates a (base) "RTSPClient" object. If you want to create a subclass
397  // of "RTSPClient" instead, then subclass this class, and redefine this virtual function.
399 protected: // redefined virtual functions
400  virtual char const* allowedCommandNames(); // "OPTIONS", "REGISTER", and (perhaps) "DEREGISTER" only
401  virtual Boolean weImplementREGISTER(char const* cmd/*"REGISTER" or "DEREGISTER"*/,
402  char const* proxyURLSuffix, char*& responseStr);
403  // redefined to return True (for cmd=="REGISTER")
404  virtual void implementCmd_REGISTER(char const* cmd/*"REGISTER" or "DEREGISTER"*/,
405  char const* url, char const* urlSuffix, int socketToRemoteServer,
406  Boolean deliverViaTCP, char const* proxyURLSuffix);
408 private:
412 };
413 #endif
415 #endif
const Boolean False
Definition: Boolean.hh:28
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:378
#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:409
portNumBits serverPortNum() const
Definition: RTSPClient.hh:386
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:272
RequestRecord * fTail
Definition: RTSPClient.hh:277
RequestRecord * fHead
Definition: RTSPClient.hh:276
MediaSubsession * fSubsession
Definition: RTSPClient.hh:232
u_int32_t booleanFlags() const
Definition: RTSPClient.hh:218
char const * absStartTime() const
Definition: RTSPClient.hh:221
char * contentStr() const
Definition: RTSPClient.hh:224
char const * absEndTime() const
Definition: RTSPClient.hh:222
char const * commandName() const
Definition: RTSPClient.hh:215
MediaSession * fSession
Definition: RTSPClient.hh:231
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:238
responseHandler *& handler()
Definition: RTSPClient.hh:225
RequestRecord * fNext
Definition: RTSPClient.hh:228
MediaSubsession * subsession() const
Definition: RTSPClient.hh:217
RequestRecord *& next()
Definition: RTSPClient.hh:213
MediaSession * session() const
Definition: RTSPClient.hh:216
void handleAlternativeRequestByte1(u_int8_t requestByte)
ClientTLSState * fInputTLS
Definition: RTSPClient.hh:366
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:333
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)
static void responseHandlerForHTTP_GET(RTSPClient *rtspClient, int responseCode, char *responseString)
RequestQueue fRequestsAwaitingHTTPTunneling
Definition: RTSPClient.hh:355
virtual Boolean setRequestFields(RequestRecord *request, char *&cmdURL, Boolean &cmdURLWasAllocated, char const *&protocolStr, char *&extraHeaders, Boolean &extraHeadersWereAllocated)
void connectionHandler1()
int fOutputSocketNum
Definition: RTSPClient.hh:348
unsigned sendPauseCommand(MediaSession &session, responseHandler *responseHandler, Authenticator *authenticator=NULL)
virtual ~RTSPClient()
Authenticator fCurrentAuthenticator
Definition: RTSPClient.hh:340
Boolean resendCommand(RequestRecord *request)
char * createBlocksizeString(Boolean streamUsingTCP)
void reset()
char * fBaseURL
Definition: RTSPClient.hh:349
void setSpeed(MediaSession &session, float speed=1.0f)
static unsigned responseBufferSize
Definition: RTSPClient.hh:198
int socketNum() const
Definition: RTSPClient.hh:176
void sendDummyUDPPackets(MediaSession &session, unsigned numDummyPackets=2)
unsigned sendRecordCommand(MediaSubsession &subsession, responseHandler *responseHandler, Authenticator *authenticator=NULL)
ClientTLSState * fOutputTLS
Definition: RTSPClient.hh:367
unsigned sendDescribeCommand(responseHandler *responseHandler, Authenticator *authenticator=NULL)
char * fUserAgentHeaderStr
Definition: RTSPClient.hh:346
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:350
unsigned fResponseBytesAlreadySeen
Definition: RTSPClient.hh:354
Boolean fHTTPTunnelingConnectionIsPending
Definition: RTSPClient.hh:361
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:341
char * fRequireStr
Definition: RTSPClient.hh:356
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:355
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:359
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
ClientTLSState fPOSTSocketTLS
Definition: RTSPClient.hh:365
portNumBits fTunnelOverHTTPPortNum
Definition: RTSPClient.hh:345
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:351
unsigned fResponseBufferBytesLeft
Definition: RTSPClient.hh:354
unsigned fCSeq
Definition: RTSPClient.hh:339
unsigned fUserAgentHeaderStrLen
Definition: RTSPClient.hh:347
int fVerbosityLevel
Definition: RTSPClient.hh:338
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:342
int fInputSocketNum
Definition: RTSPClient.hh:348
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:355
unsigned fSessionTimeoutParameter
Definition: RTSPClient.hh:352
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:360
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:353
ClientTLSState fTLS
Definition: RTSPClient.hh:364
Boolean setupHTTPTunneling1()
char * rtspURL(ServerMediaSession const *serverMediaSession, int clientSocket=-1, Boolean useIPv6=False) const