live555 调优总结

       发送优化方面,主要就是调整live555的缓冲区大小和每次发送的数据大小,众所周知,流媒体发送的是各种大小的音视频数据,而这些数据大的几百k,小的就几个字节,如果每一个零散的数据都要走一遍发送循环,对于live555这种单线程的架构来说,性能吃紧,所以做了几点调整:

MediaSink.cpp
114行:
unsigned OutPacketBuffer::maxSize = 30000;

StreamParser.cp
宏定义:
#define BANK_SIZE 150000,改为2400000;

MultiFramedRTPSink.cpp
47行:
setPacketSizes(1000, 8192);


RTPInterface.cpp
129行:
increaseSendBufferTo(envir(), fGS->socketNum(), 512*1024);
//数据累积发送,不再单独发送
//注释掉332行,修改为以下:
//if (!sendDataOverTCP(socketNum, framingHeader, 4, False)) break;
//if (!sendDataOverTCP(socketNum, packet, packetSize, True)) break;
    struct iovec iov[2];
    iov[0].iov_base = framingHeader;
    iov[0].iov_len = 4;
    iov[1].iov_base = packet;
    iov[1].iov_len = packetSize;
    writev(socketNum, iov, 2);


调度方面优化

MultiFramedRTPSink.cpp
402 行
//当前的数据缓冲区如果没有发送完成,就继续发送,不再走一遍live555的eventloop流程,提高效率!

#if 0
    // We have more frames left to send.  Figure out when the next frame
    // is due to start playing, then make sure that we wait this long before
    // sending the next packet.
    struct timeval timeNow;
    gettimeofday(&timeNow, NULL);
    int secsDiff = fNextSendTime.tv_sec - timeNow.tv_sec;
    int64_t uSecondsToGo = secsDiff*1000000 + (fNextSendTime.tv_usec - timeNow.tv_usec);
    if (uSecondsToGo < 0 || secsDiff < 0) { // sanity check: Make sure that the time-to-delay is non-negative:
      uSecondsToGo = 0;
    }

    if (uSecondsToGo > 0)
        printf("uSecondsToGo: %d\n", uSecondsToGo);

    // Delay this amount of time:
    nextTask() = envir().taskScheduler().scheduleDelayedTask(uSecondsToGo, (TaskFunc*)sendNext, this);
#else
    sendNext(this);
#endif

这样几点修改,大大提升了 live555 在网络数据发送方面的性能






评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值