RTSP连接服务器
来源:互联网 发布:淘宝新店的扶持期 编辑:程序博客网 时间:2024/05/29 07:50
RTSP连接服务器是否成功,以及是否从服务器接收到实际播放的数据,主要是判断两个linux select函数的执行结果。
1.连接服务器的处理过程
调用----------> 调用---------->
2.是否接收到服务器发送的播放数据的处理
调用----------> 2.2 void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) {
case kWhatReceiveResponse:
onReceiveResponse();
break;
继续调用---------->
2.3
2.3.1.1 bool ARTSPConnection::receiveLine(AString *line) {
--->
2.3.1.1.1 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读一个字符
--->
2.3.1.1.1.1 ssize_t n = recv(mSocket, (uint8_t *)data + offset, size - offset, 0); // 从TCP连接的另一端接收数据
--->
2.3.1.2 sp<ABuffer> ARTSPConnection::receiveBinaryData()
--->
2.3.1.2.1 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读3个字符
--->
recv()
2.3.1.2.2 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读buffer->size()个字符
--->
recv()
--->
2.3.1.3 new ARTSPResponse
--->
2.3.1.4 receiveLine()
--->
2.3.1.5 recv() // while (numBytesRead < contentLength)
--->
2.3.1.6 函数返回
return isRequest
? handleServerRequest(response)
: notifyResponseListener(response);
1.连接服务器的处理过程
[cpp] view plaincopy
- ARTSPConnection::onConnect(const sp<AMessage> &msg)
- int err = ::connect(
- mSocket, (const struct sockaddr *)&remote, sizeof(remote));
- LOGE("%s L%d err = %d", __FUNCTION__, __LINE__, err);
- if (err < 0) {
- if (errno == EINPROGRESS) { // 正在连接中
- sp<AMessage> msg = new AMessage(kWhatCompleteConnection, id());
- msg->setMessage("reply", reply);
- msg->setInt32("connection-id", mConnectionID);
- msg->post();
[cpp] view plaincopy
- void ARTSPConnection::onMessageReceived(const sp<AMessage> &msg) {
- case kWhatCompleteConnection:
- onCompleteConnection(msg);
[cpp] view plaincopy
- ARTSPConnection::onCompleteConnection
- int res = select(mSocket + 1, NULL, &ws, NULL, &tv);
- CHECK_GE(res, 0);
- if (res == 0) {
- // Timed out. Not yet connected.
- LOGE("%s L%d -ECONNABORTED", __FUNCTION__, __LINE__);
- msg->post(); // 循环执行此函数检查是否connected
- return;
- }
2.是否接收到服务器发送的播放数据的处理
2.1 在ARTSPConnection::onCompleteConnection成功连接后,发送检查接收数据的event
[cpp] view plaincopy
- void ARTSPConnection::postReceiveReponseEvent() {
- if (mReceiveResponseEventPending) {
- return;
- }
- sp<AMessage> msg = new AMessage(kWhatReceiveResponse, id());
- msg->post();
- mReceiveResponseEventPending = true;
- }
case kWhatReceiveResponse:
onReceiveResponse();
break;
继续调用---------->
2.3
[cpp] view plaincopy
- void ARTSPConnection::onReceiveResponse() {
- int res = select(mSocket + 1, &rs, NULL, NULL, &tv);
- // LOGE("%s L%d select res = %d", __FUNCTION__, __LINE__, res);
- CHECK_GE(res, 0);
- if (res == 1) {
- MakeSocketBlocking(mSocket, true);
- bool success = receiveRTSPReponse(); // 2.3.1
- MakeSocketBlocking(mSocket, false);
- LOGE("%s L%d select ==== success = %d", __FUNCTION__, __LINE__, success);
- if (!success) {
- // Something horrible, irreparable has happened.
- flushPendingRequests();
- LOGE("%s L%d return ", __FUNCTION__, __LINE__);
- return;
- }
- }
- postReceiveReponseEvent(); // 循环执行此函数
继续调用……
2.3.1 bool ARTSPConnection::receiveRTSPReponse() {
--->2.3.1.1 bool ARTSPConnection::receiveLine(AString *line) {
--->
2.3.1.1.1 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读一个字符
--->
2.3.1.1.1.1 ssize_t n = recv(mSocket, (uint8_t *)data + offset, size - offset, 0); // 从TCP连接的另一端接收数据
--->
2.3.1.2 sp<ABuffer> ARTSPConnection::receiveBinaryData()
--->
2.3.1.2.1 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读3个字符
--->
recv()
2.3.1.2.2 status_t ARTSPConnection::receive(void *data, size_t size) { // 每次读buffer->size()个字符
--->
recv()
--->
2.3.1.3 new ARTSPResponse
--->
2.3.1.4 receiveLine()
--->
2.3.1.5 recv() // while (numBytesRead < contentLength)
--->
2.3.1.6 函数返回
return isRequest
? handleServerRequest(response)
: notifyResponseListener(response);
阅读全文
0 0
- RTSP连接服务器
- RTSP 服务器
- rtsp 服务器
- RTSP连接服务器和从服务器接收数据的处理流程
- android RTSP连接服务器和从服务器接收数据的处理流程
- 架设rtsp流媒体服务器
- 开源RTSP 流媒体服务器
- RTSP服务器(一)
- ffserver RTSP服务器配置
- RTSP服务器(一)
- RTSP服务器(二)
- RTSP服务器搭建
- RTSP服务器(二)
- linux rtsp 服务器
- DarwinStreamingServer搭建RTSP服务器
- ffserver 作为 rtsp 服务器
- live555MediaServer搭建RTSP服务器
- live555架设rtsp服务器
- http streaming 处理流程
- Android OpenCore error code定义
- 服务器系统的分类和介绍
- Redis: OOM command not allowed when used memory > ‘maxmemory’
- 多线程实现生产者消费者
- RTSP连接服务器
- Faster R-CNN 深入理解 && 改进方法汇总
- 【转载】StageFright框架流程解读
- Android 4.2 Wifi Display 之 Settings 源码分析
- Java 常用排序算法
- Android 4.2 Wifi Display之Settings源码分析(二)
- Android 4.2 Wifi Display核心分析 (一)
- Android 4.2 Wifi Display核心分析 (一.1)
- OMXCodec与OMX事件处理流程