The main difference between synchronous and asynchronous in the live555 API is that you must now specify a handler in an RTSP request. Your handler will be called from the live555 eventloop once the DESCRIBE request has completed.
In RTSPClient.hh responseHandler is defined as:
typedef void (responseHandler)(RTSPClient* rtspClient,
int resultCode, char* resultString);
When your handler is called, live555 will give you the following information:
The RTSP client on which the command was issued -> this allows you to subsequently call the next RTSP method.
The result code which is 0 on success, positive if an RTSP error code was returned by the server, and negative if some network/socket error occurred.
Use this info to decide how to proceed in your handler. Have a look at RTSPClient.hh where all of this is explained.
E.g. This means that when you want to call the sendDescribeCommand method:
You must specify which handler (of signature responseHandler) will be called once the DESCRIBE has been completed. In your handler you must then decide based on the result code, whether you want to do a SETUP (again specifying a handler) or terminate (if some error occurred).
As jenseb suggested the openRTSP client provides a very good starting point.
发布评论
评论(1)
live555 API 中同步和异步之间的主要区别在于您现在必须在 RTSP 请求中指定处理程序。一旦 DESCRIBE 请求完成,您的处理程序将从 live555 事件循环中调用。
在 RTSPClient.hh 中,responseHandler 定义为:
当调用您的处理程序时,live555 将为您提供以下信息:
发出命令的 RTSP 客户端 ->这允许您随后调用下一个 RTSP 方法。
结果代码,成功时为 0,如果服务器返回 RTSP 错误代码,则为正;如果发生某些网络/套接字错误,则结果代码为负。
使用此信息来决定如何在处理程序中继续进行。查看 RTSPClient.hh,其中解释了所有这些内容。
例如,这意味着当您想要调用 sendDescribeCommand 方法时:
您必须指定一旦 DESCRIBE 完成,将调用哪个处理程序(签名responseHandler)。然后,在处理程序中,您必须根据结果代码决定是否要执行 SETUP(再次指定处理程序)或终止(如果发生某些错误)。
正如 jenseb 所建议的,openRTSP 客户端提供了一个非常好的起点。
The main difference between synchronous and asynchronous in the live555 API is that you must now specify a handler in an RTSP request. Your handler will be called from the live555 eventloop once the DESCRIBE request has completed.
In RTSPClient.hh responseHandler is defined as:
When your handler is called, live555 will give you the following information:
The RTSP client on which the command was issued -> this allows you to subsequently call the next RTSP method.
The result code which is 0 on success, positive if an RTSP error code was returned by the server, and negative if some network/socket error occurred.
Use this info to decide how to proceed in your handler. Have a look at RTSPClient.hh where all of this is explained.
E.g. This means that when you want to call the sendDescribeCommand method:
You must specify which handler (of signature responseHandler) will be called once the DESCRIBE has been completed. In your handler you must then decide based on the result code, whether you want to do a SETUP (again specifying a handler) or terminate (if some error occurred).
As jenseb suggested the openRTSP client provides a very good starting point.