无法从Wowza Server接收RTP数据包

时间:2018-04-01 14:12:55

标签: c++ rtsp rtp

我尝试使用RTSP向rtsp://wowzaec2demo.streamlock.net发送请求,并通过UDP接收数据包。我已经使用wireshark来监听数据包,但没有这样的数据包回复给我。我的路由器可能没有将它们指向我吗?如果是这样,我应该向哪个端口转发以获取数据包给我?

SOCKADDR_IN addr;
int addrlen = sizeof(addr);
addr.sin_addr.s_addr = inet_addr("184.72.239.149");
addr.sin_port = htons(RTSP_PORT);
addr.sin_family = AF_INET;

Connection = socket(AF_INET, SOCK_STREAM, NULL);
if (connect(Connection, (SOCKADDR*)&addr, addrlen) != 0)
{
    MessageBoxA(NULL, "Failed to Connect", "Error", MB_OK | MB_ICONERROR);
    return 0;
}


void RTSPRequest(std::string requestType) {

CSeq++;
std::string request = requestType + " ";
request += RTSP_SERVER_ADDRESS;
request += RTSP_FILE_NAME;
request += " ";
request += "RTSP/1.0\r\nCSeq: " + std::to_string(CSeq);

if (requestType.compare("SETUP") == 0)
{
    request += "\r\nTransport: RTP/UDP;unicast;client_port= 8000\r\n\r\n";
}
else
{
    request += "\r\n";
    request += session.c_str();
    request += "\r\n\r\n";
}

const char* requestChar = request.c_str();

std::fill_n(buffer, sizeof(buffer), 0);
int sendReturnedValue = send(Connection, requestChar, strlen(requestChar), 0);
int recvReturnedValue = recv(Connection, buffer, sizeof(buffer), 0);

if (requestType.compare("SETUP") == 0)
{
    std::string bufferString(buffer, sizeof(buffer));
    int sessionStart = bufferString.find("Session");
    for (int i = 0;; i++)
    {
        if (buffer[sessionStart + i] == ';' || buffer[sessionStart + i] == '\r')
        {
            break;
        }
        else
        {
            session += buffer[sessionStart + i];
        }

    }
}

}

这会向我发送一个RTSP响应,我收到所有requestTypes,但是当我发送播放请求时,我不会通过RTP / UDP或任何我能找到的内容从服务器收到任何数据包。我已尝试搜索所有其他帖子,但似乎找不到任何人遇到与我相同的问题。

提前致谢:)

0 个答案:

没有答案