使用live555构建rtsp Server时,在给客户端地址之前,需要将地址对应的ServerMediaSession事先创建好;否则客户端会连接失败。
当服务端接收到客户端的第一个OPTION command,如果没有事先创建好ServerMediaSession,会导致错误。
源代码如下,其中的handleCmd_sessionNotFound就指明的要求:
void RTSPServer::RTSPClientConnection::handleRequestBytes(int newBytesRead) {
int numBytesRemaining = 0;
++fRecursionCount;
do {
RTSPServer::RTSPClientSession* clientSession = NULL;
...
Boolean parseSucceeded = parseRTSPRequestString((char*)fRequestBuffer, fLastCRLF+2 - fRequestBuffer,
cmdName, sizeof cmdName,
urlPreSuffix, sizeof urlPreSuffix,
urlSuffix, sizeof urlSuffix,
cseq, sizeof cseq,
sessionIdStr, sizeof sessionIdStr,
contentLength);
...
// We now have a complete RTSP request.
// Handle the specified command (beginning with commands that are session-independent):
fCurrentCSeq = cseq;
if (strcmp(cmdName, "OPTIONS") == 0) {
// If the "OPTIONS" command included a "Session:" id for a session that doesn't exist,
// then treat this as an error:
if (requestIncludedSessionId && clientSession == NULL) {
handleCmd_sessionNotFound();
} else {
// Normal case:
handleCmd_OPTIONS();
}
} else if
在使用live555构建RTSP Server时,必须预先为客户端地址创建ServerMediaSession。如果在接收客户端OPTION命令时未创建,会导致连接错误。源代码中,handleCmd_sessionNotFound函数处理了这一情况,表明在处理命令前需确保Session存在。这确保了正常处理OPTIONS命令和其他依赖Session的RTSP请求。
3600

被折叠的 条评论
为什么被折叠?



