live555 RTSPClient修改:RTSP over udp

在live555的RTSPClient中,只给出RTSP over TCP的实现,而没有给出RTSP over UDP的实现。

如果想实现rtsp over udp,只要将下面代码修改一下即可。

int RTSPClient::openConnection() {
	do {
		// Set up a connection to the server.  Begin by parsing the URL:

		char* username;
		char* password;
		NetAddress destAddress;
		portNumBits urlPortNum;
		char const* urlSuffix;
		if (!parseRTSPURL(envir(), fBaseURL, username, password, destAddress, urlPortNum, &urlSuffix)) break;
		portNumBits destPortNum = fTunnelOverHTTPPortNum == 0 ? urlPortNum : fTunnelOverHTTPPortNum;
		if (username != NULL || password != NULL) {
			fCurrentAuthenticator.setUsernameAndPassword(username, password);
			delete[] username;
			delete[] password;
		}

		// We don't yet have a TCP socket (or we used to have one, but it got closed).  Set it up now.
		fInputSocketNum = fOutputSocketNum = setupStreamSocket(envir(), 0);//可以看到,这里是setupStreamSocket,建立的是TCP连接,我们改成setupDatagramSocket即可建立UDP连接。
将最后一行改成如下,即可:
fInputSocketNum = fOutputSocketNum = setupDatagramSocket(envir(), UDP端口号);


直接这样改,我感觉没有问题。

因为udp socket编程中也可以使用属于tcp的函数,比如send() 或者recv()

你可能感兴趣的:(多媒体)