📄 rtspclient.hh
字号:
/**********This library is free software; you can redistribute it and/or modify it underthe terms of the GNU Lesser General Public License as published by theFree Software Foundation; either version 2.1 of the License, or (at youroption) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)This library is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSFOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License formore details.You should have received a copy of the GNU Lesser General Public Licensealong with this library; if not, write to the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA**********/// "liveMedia"// Copyright (c) 1996-2010 Live Networks, Inc. All rights reserved.// A generic RTSP client - for a single "rtsp://" URL// C++ header#ifndef _RTSP_CLIENT_HH#define _RTSP_CLIENT_HH#ifndef _MEDIA_SESSION_HH#include "MediaSession.hh"#endif#ifndef _NET_ADDRESS_HH#include "NetAddress.hh"#endif#ifndef _DIGEST_AUTHENTICATION_HH#include "DigestAuthentication.hh"#endif#define RTSPCLIENT_SYNCHRONOUS_INTERFACE 1 // For now, continue to support the old synchronous interface as wellclass RTSPClient: public Medium {public: static RTSPClient* createNew(UsageEnvironment& env, char const* rtspURL, int verbosityLevel = 0, char const* applicationName = NULL, portNumBits tunnelOverHTTPPortNum = 0); // If "tunnelOverHTTPPortNum" is non-zero, we tunnel RTSP (and RTP) // over a HTTP connection with the given port number, using the technique // described in Apple's document <http://developer.apple.com/documentation/QuickTime/QTSS/Concepts/chapter_2_section_14.html> typedef void (responseHandler)(RTSPClient* rtspClient, int resultCode, char* resultString); // A function that is called in response to a RTSP command. The parameters are as follows: // "rtspClient": The "RTSPClient" object on which the original command was issued. // "resultCode": If zero, then the command completed successfully. If non-zero, then the command did not complete // successfully, and "resultCode" indicates the error, as follows: // A positive "resultCode" is a RTSP error code (for example, 404 means "not found") // A negative "resultCode" indicates a socket/network error; 0-"resultCode" is the standard "errno" code. // "resultString": A ('\0'-terminated) string returned along with the response, or else NULL. // In particular: // "resultString" for a successful "DESCRIBE" command will be the media session's SDP description. // "resultString" for a successful "OPTIONS" command will be a list of allowed commands. // Note that this string can be present (i.e., not NULL) even if "resultCode" is non-zero - i.e., an error message. // Note also that this string is dynamically allocated, and must be freed by the handler (or the caller) // - using "delete[]". unsigned sendDescribeCommand(responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "DESCRIBE" command, then returns the "CSeq" sequence number that was used in the command. // The (programmer-supplied) "responseHandler" function is called later to handle the response // (or is called immediately - with an error code - if the command cannot be sent). // "authenticator" (optional) is used for access control. If you have username and password strings, you can use this by // passing an actual parameter that you created by creating an "Authenticator(username, password) object". // (Note that if you supply a non-NULL "authenticator" parameter, you need do this only for the first command you send.) unsigned sendOptionsCommand(responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "OPTIONS" command, then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendAnnounceCommand(char const* sdpDescription, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "ANNOUNCE" command (with "sdpDescription" as parameter), // then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendSetupCommand(MediaSubsession& subsession, responseHandler* responseHandler, Boolean streamOutgoing = False, Boolean streamUsingTCP = False, Boolean forceMulticastOnUnspecified = False, Authenticator* authenticator = NULL); // Issues a RTSP "SETUP" command, then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendPlayCommand(MediaSession& session, responseHandler* responseHandler, double start = 0.0f, double end = -1.0f, float scale = 1.0f, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "PLAY" command on "session", then returns the "CSeq" sequence number that was used in the command. // (Note: start=-1 means 'resume'; end=-1 means 'play to end') // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendPlayCommand(MediaSubsession& subsession, responseHandler* responseHandler, double start = 0.0f, double end = -1.0f, float scale = 1.0f, Authenticator* authenticator = NULL); // Issues a RTSP "PLAY" command on "subsession", then returns the "CSeq" sequence number that was used in the command. // (Note: start=-1 means 'resume'; end=-1 means 'play to end') // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendPauseCommand(MediaSession& session, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "PAUSE" command on "session", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendPauseCommand(MediaSubsession& subsession, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "PAUSE" command on "subsession", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendRecordCommand(MediaSession& session, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "RECORD" command on "session", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendRecordCommand(MediaSubsession& subsession, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "RECORD" command on "subsession", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendTeardownCommand(MediaSession& session, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "TEARDOWN" command on "session", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendTeardownCommand(MediaSubsession& subsession, responseHandler* responseHandler, Authenticator* authenticator = NULL); // Issues a RTSP "TEARDOWN" command on "subsession", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendSetParameterCommand(MediaSession& session, responseHandler* responseHandler, char const* parameterName, char const* parameterValue, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "SET_PARAMETER" command on "session", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) unsigned sendGetParameterCommand(MediaSession& session, responseHandler* responseHandler, char const* parameterName, Authenticator* authenticator = NULL); // Issues an aggregate RTSP "GET_PARAMETER" command on "session", then returns the "CSeq" sequence number that was used in the command. // (The "responseHandler" and "authenticator" parameters are as described for "sendDescribeCommand".) Boolean changeResponseHandler(unsigned cseq, responseHandler* newResponseHandler); // Changes the response handler for the previously-performed command (whose operation returned "cseq"). // (To turn off any response handling for the command, use a "newResponseHandler" value of NULL. This might be done as part // of an implementation of a 'timeout handler' on the command, for example.) // This function returns True iff "cseq" was for a valid previously-performed command (whose response is still unhandled). int socketNum() const { return fInputSocketNum; } static Boolean lookupByName(UsageEnvironment& env, char const* sourceName, RTSPClient*& resultClient); static Boolean parseRTSPURL(UsageEnvironment& env, char const* url, NetAddress& address, portNumBits& portNum, char const** urlSuffix = NULL); // (ignores any "<username>[:<password>]@" in "url"); to get those, use: static Boolean parseRTSPURLUsernamePassword(char const* url, char*& username, char*& password); void setUserAgentString(char const* userAgentName); // sets an alternative string to be used in RTSP "User-Agent:" headers unsigned sessionTimeoutParameter() const { return fSessionTimeoutParameter; } static unsigned responseBufferSize;protected: RTSPClient(UsageEnvironment& env, char const* rtspURL, int verbosityLevel, char const* applicationName, portNumBits tunnelOverHTTPPortNum); // called only by createNew(); virtual ~RTSPClient();private: // redefined virtual functions virtual Boolean isRTSPClient() const;public: // Some compilers complain if this is "private:" // The state of a request-in-progress: class RequestRecord { public: 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); virtual ~RequestRecord();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -