[Live-devel] How to response custom rtsp header and limit the client number?

Ross Finlayson finlayson at live555.com
Wed Apr 26 00:58:37 PDT 2017


> we would like to
> 1) limit the number of client, do you have any suggestion about this?
> 2) if system cpu usage is very high, we want to response special custom rtsp header.

Here’s how you can do both of these things:

1/ Download the latest version (2017.04.26) of the code; it contains a new member function that you’ll need.

2/ Subclass “RTSPServer” and “RTSPServer::RTSPClientSession”

3/ In your subclass of “RTSPServer”, redefine the virtual function “createNewClientSession()”, and reimplement it as follows:
	ClientSession* MyRTSPServerSubclass::createNewClientSession(u_int32_t sessionId) {
		if (numClientSessions() == myLimitOnTheNumberOfClients) {
			return NULL;
		} else {
			return new MyRTSPClientSessionSubclass(*this, sessionId);
		}
	}

4/ In your subclass of "RTSPServer::RTSPClientSession”, redefine the virtual function “handleCmd_SETUP()”, and reimplement it as follows:
	void MyRTSPServerSubclass::MyRTSPClientSessionSubclass handleCmd_SETUP(RTSPClientConnection* ourClientConnection, char const* urlPreSuffix, char const* urlSuffix, char const* fullRequestStr) {
		if (MyCPUUsageIsTooHigh) {
			setRTSPResponse(ourClientConnection, "453 No Resources”);
			return;
		}

		// Otherwise, handle the request as usual:
		RTSPServer::RTSPClientSession(ourClientConnection, urlPreSuffix, urlSuffix, fullRequestStr);
	}



Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list