Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5137c69c authored by Zhiming Jiang's avatar Zhiming Jiang Committed by Denis Hsu
Browse files

Handle RTSP make port error case

Bind interface don't allow bind muti-port in same socket.
in MakePortPair function, RTP socket bind would always fail
after RTP socket bind success and RTCP failed at one loop.

We should recreate RTP socket after RTCP bind fail.

Bug: 174103626
Change-Id: I909c3e7b6328bcafafed57e4070c38a7b3776114
parent e3d0ba33
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ void ARTPConnection::MakePortPair(
    unsigned start = (unsigned)((rand()* 1000LL)/RAND_MAX) + 15550;
    start &= ~1;

    for (unsigned port = start; port < 65536; port += 2) {
    for (unsigned port = start; port < 65535; port += 2) {
        struct sockaddr_in addr;
        memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
        addr.sin_family = AF_INET;
@@ -139,6 +139,13 @@ void ARTPConnection::MakePortPair(
                 (const struct sockaddr *)&addr, sizeof(addr)) == 0) {
            *rtpPort = port;
            return;
        } else {
            // we should recreate a RTP socket to avoid bind other port in same RTP socket
            close(*rtpSocket);

            *rtpSocket = socket(AF_INET, SOCK_DGRAM, 0);
            CHECK_GE(*rtpSocket, 0);
            bumpSocketBufferSize(*rtpSocket);
        }
    }