[Live-devel] 100% cpu usage when 1 or more client connects to RTSP server

Shaan Nobee shaan.nobee at mauritiustelecom.com
Sun Mar 8 01:59:28 PST 2015


Hello everyone!

I would be very grateful if someone could help me out with the issue below, I'm new to live555.

I've got nine audio streams that I'm pulling in via ffmpeg and then re-encoding them to AAC-LC and pushing to udp://127.0.0.1:port_num?pkt_size=1316 (where port_num is replaced by respective port number) The first stream is being pushed to port 10000, the second one to 10001, third one to 10002, etc.

Example for first stream:
ffmpeg -i remotestream [...codec options...] -f mpegts udp://127.0.0.1:10000?pkt_size=1316

I've modified testOnDemandRTSPServer.cpp as shown below. (taken from live555-latest.tar.gz downloaded today - 8 March 2015)
I launch my ffmpeg instances & the rtsp server and connect to it via VLC/another rtsp client.

It works, I do hear the audio stream, however the issue is that as soon as one client connects, the RTSP server uses 100% of the CPU.
As soon as the client disconnects, the CPU usage falls back to normal. Any idea of what could be wrong?

#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"

UsageEnvironment* env;
Boolean reuseFirstSource = False;
Boolean iFramesOnly = False;

int main(int argc, char** argv) {
  TaskScheduler* scheduler = BasicTaskScheduler::createNew();
  env = BasicUsageEnvironment::createNew(*scheduler);

  RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554, NULL);
  if (rtspServer == NULL) {
    *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
    exit(1);
  }

  char const* descriptionString
    = "Session streamed by \"MyRTSPServer\"";

   int NUM_STREAMS = 9;
   char const* streams[] = {"stream1","stream2","stream3","stream4","stream5","stream6","stream7","stream8","stream9"};
   int port = 10000;

  for(int i=0;i<NUM_STREAMS;i++)
  {
    const char* streamName = streams[i];
    const char* inputAddressStr = "127.0.0.1";
    portNumBits inputPortNum = port; port++;
    Boolean const inputStreamIsRawUDP = True;
    ServerMediaSession* sms = ServerMediaSession::createNew(*env, streamName, streamName,descriptionString);
    sms->addSubsession(MPEG2TransportUDPServerMediaSubsession::createNew(*env, inputAddressStr, inputPortNum, inputStreamIsRawUDP));
    rtspServer->addServerMediaSession(sms);

    char* url = rtspServer->rtspURL(sms);
    *env << "\n\"" << streamName << "\" stream, from a UDP Transport Stream input source \n\t(";
    if (inputAddressStr != NULL) {
      *env << "IP multicast address " << inputAddressStr << ",";
    } else {
      *env << "unicast;";
    }
    *env << " port " << inputPortNum << ")\n";
    *env << "Play this stream using the URL \"" << url << "\"\n";
    delete[] url;
  }

  env->taskScheduler().doEventLoop(); // does not return

  return 0; // only to prevent compiler warning
}


Thanks!
Shaan



Shaan Nobee

- Corporate Office
Tel: +2302037117  |  Mob: +23052518816  |  Fax: +2302116996
shaan.nobee at mauritiustelecom.com<mailto:shaan.nobee at mauritiustelecom.com>
www.mauritiustelecom.com<http://www.mauritiustelecom.com/>     |     www.orange.mu<http://www.orange.mu/>     |     [Orange on Facebook] <http://www.facebook.com/orangemauritius?ref=hl>      |     [Orange on Twitter] <http://https//twitter.com/OrangeMauritius>

[Mauritius Telecom]<http://www.mauritiustelecom.com/>          [Orange Mauritius] <http://www.orange.mu/>
This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Mauritius Telecom - Orange is not liable for messages that have been modified, changed or falsified.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150308/147614bd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-fb.jpg
Type: image/jpeg
Size: 899 bytes
Desc: logo-fb.jpg
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150308/147614bd/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-twitter.jpg
Type: image/jpeg
Size: 1046 bytes
Desc: logo-twitter.jpg
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150308/147614bd/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-mt.png
Type: image/png
Size: 5883 bytes
Desc: logo-mt.png
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150308/147614bd/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo.gif
Type: image/gif
Size: 504 bytes
Desc: logo.gif
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20150308/147614bd/attachment.gif>


More information about the live-devel mailing list