<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" class="" style="word-wrap:break-word">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div id="yiv2230296969yui_3_16_0_1_1426141957505_33525">Hello Ross,</div>
<div id="yui_3_16_0_1_1426141957505_41732"><br clear="none">
</div>
<div id="yui_3_16_0_1_1426141957505_42310" dir="ltr">Hope that you're doing fine.</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33223"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33222">I digged a bit deeper into the problem and ran gprof to do profiling on the application.</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33527">Below are the results.<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33526"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33247"> 59.62      0.62     0.62  9593542    64.63   106.32  BasicTaskScheduler::SingleStep(unsigned int)<br class="yiv2230296969" style="" clear="none">
 15.39      0.78     0.16 19190028     8.34    10.42  DelayQueue::synchronize()<br class="yiv2230296969" style="" clear="none">
  5.77      0.84     0.06 57557157     1.04     1.04  HandlerIterator::next()<br class="yiv2230296969" style="" clear="none">
  4.81      0.89     0.05  9593542     5.21     5.21  HandlerIterator::HandlerIterator(HandlerSet&)<br class="yiv2230296969" style="" clear="none">
  3.85      0.93     0.04 19190029     2.08     2.08  TimeNow()<br class="yiv2230296969" style="" clear="none">
  2.88      0.96     0.03  9593542     3.13    13.55  DelayQueue::handleAlarm()<br class="yiv2230296969" style="" clear="none">
  2.88      0.99     0.03  9592398     3.13     3.13  BasicUDPSource::incomingPacketHandler1()<br class="yiv2230296969" style="" clear="none">
  1.92      1.01     0.02  9593542     2.08    12.51  DelayQueue::timeToNextAlarm()<br class="yiv2230296969" style="" clear="none">
  0.96      1.02     0.01  9592402     1.04     1.04  HandlerIterator::reset()<br class="yiv2230296969" style="" clear="none">
  0.96      1.03     0.01                             DelayQueue::findEntryByToken(long)<br class="yiv2230296969" style="" clear="none">
  0.96      1.04     0.01                             HandlerSet::lookupHandler(int)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00  9593541     0.00     0.00  HandlerIterator::~HandlerIterator()<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00  9592398     0.00     0.00  BasicUDPSource::incomingPacketHandler(BasicUDPSource*, int)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3094     0.00     0.00  DelayQueue::removeEntry(DelayQueueEntry*)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3093     0.00    10.42  DelayQueue::addEntry(DelayQueueEntry*)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3093     0.00     0.00  DelayQueueEntry::DelayQueueEntry(DelayInterval)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3092     0.00    10.43  BasicTaskScheduler0::scheduleDelayedTask(long, void (*)(void*), void*)<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3088     0.00     0.00  AlarmHandler::~AlarmHandler()<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3088     0.00     0.00  DelayQueueEntry::~DelayQueueEntry()<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3082     0.00    10.28  AlarmHandler::handleTimeout()<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     3081     0.00     0.00  DelayQueueEntry::handleTimeout()<br class="yiv2230296969" style="" clear="none">
  0.00      1.04     0.00     2988     0.00     0.00  BasicTaskScheduler::schedulerTickTask(void*)</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33248"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33530"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33528">What's happening is that the BasicUDPSource::incomingPacketHandler1() function is being called too many times.</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_33809">I added a counter in the function and it seems that this line of code is being called many many times (line 65 in BasicUDPSource.cpp):<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_34657">if (!isCurrentlyAwaitingData()) return;<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_34658"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_31943">I modified the line to:</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_35234">if (!isCurrentlyAwaitingData()) {usleep(500);return;}<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_34947"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_34946">And since then the CPU usage does not go up to 100% but stays around 1%! :)<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_34945"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_35814">I don't know if it's a correct thing to do and what its implications could be.</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_36685">When I'm running the stream, the audio is a bit choppy but I'm not sure that's related to this modification or my bandwidth. (I'll do some further tests to confirm this)<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_36686"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_36687">Do you have any idea why this line would be called so many times and maybe a better solution?<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_37280">I double checked the ffmpeg command and everything seems normal.<br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_36688"><br clear="none">
</div>
<div dir="ltr" id="yiv2230296969yui_3_16_0_1_1426141957505_36689">Thanks!</div>
Shaan
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF180457"><font face="Tahoma" color="#000000" size="2"><b>From:</b> live-devel [live-devel-bounces@ns.live555.com] on behalf of Ross Finlayson [finlayson@live555.com]<br>
<b>Sent:</b> Wednesday, March 11, 2015 3:25 AM<br>
<b>To:</b> LIVE555 Streaming Media - development & use<br>
<b>Subject:</b> Re: [Live-devel] 100% cpu usage when 1 or more client connects to RTSP server<br>
</font><br>
</div>
<div></div>
<div>
<div>
<blockquote type="cite" class="">
<div class="">
<div class="">
<p dir="ltr" class="">1. Actually it seems that reuseFirstSource variable is not used in the original testOnDemandRTSP for the UDP mpegts example(and in my code too).</p>
</div>
</div>
</blockquote>
<div>Yes, you’re correct.  The “MPEG2TransportUDPServerMediaSubsession” implementation sets the “reuseFirstSource” parameter to True when it calls the parent ("OnDemandServerMediSubsession”) constructor, so - in this particular case - the “reuseFirstSource”
 variable in the “testOnDemandRTSPServer” code isn’t used (and therefore isn’t relevant to you, if all you are doing is streaming from UDP input sources).  My mistake.</div>
</div>
<br class="">
<br class="">
<div class=""><span class="Apple-style-span" style="border-collapse:separate; color:rgb(0,0,0); font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px"><span class="Apple-style-span" style="border-collapse:separate; color:rgb(0,0,0); font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">Ross
 Finlayson<br class="">
Live Networks, Inc.<br class="">
<a href="http://www.live555.com/" class="" target="_blank">http://www.live555.com/</a></span></span>
</div>
<br class="">
</div>
</div>
</div>
<p style="FONT-FAMILY: Arial" id="c1-id-6"><font style="FONT-SIZE: 10pt" color="#444444" id="c1-id-7"><font style="FONT-SIZE: 10pt" id="c1-id-8"><strong id="c1-id-9"><font face="Arial" id="c1-id-10"><font style="FONT-SIZE: 10pt" id="c1-id-11"><font color="#000000" id="c1-id-12"><font color="#f69646" id="c1-id-13"> </font></font></font></font></strong></font></font></p>
<p style="FONT-FAMILY: Arial" id="c1-id-14"><font style="FONT-SIZE: 10pt" color="#444444" id="c1-id-15"><font style="FONT-SIZE: 10pt" id="c1-id-16"><strong id="c1-id-17"><font face="Arial" id="c1-id-18"><font style="FONT-SIZE: 10pt" id="c1-id-19"><font color="#000000" id="c1-id-20"><font color="#f69646" id="c1-id-21">Shaan
 Nobee</font> <br id="c1-id-22">
</font></font></font></strong><font face="Arial" id="c1-id-23"><font style="FONT-SIZE: 10pt" id="c1-id-24"><font color="#000000" id="c1-id-25"><font style="FONT-SIZE: 10pt" id="c1-id-26"></font><br id="c1-id-27">
</font><font color="black" id="c1-id-28"><font style="FONT-SIZE: 10pt" id="c1-id-29"></font></font></font></font>- Corporate Office<br id="c1-id-31">
<font face="Arial" id="c1-id-32"><font style="FONT-SIZE: 10pt" id="c1-id-33"><font color="#000000" id="c1-id-34"><strong id="c1-id-35">Tel:</strong> +2302037117  <strong id="c1-id-36">|</strong> 
<strong id="c1-id-37">Mob:</strong> +23052518816  <strong id="c1-id-38">|</strong>  <strong id="c1-id-39">Fax:</strong> +2302116996<br id="c1-id-40">
</font><font color="#004dbb" id="c1-id-41"><a href="mailto:shaan.nobee@mauritiustelecom.com">shaan.nobee@mauritiustelecom.com</a>
</font></font></font><br id="c1-id-42">
<a href="http://www.mauritiustelecom.com/" id="c1-id-43"><font style="FONT-SIZE: 10pt" color="#004dbb" face="Arial" id="c1-id-44">www.mauritiustelecom.com</font></a>     |<font color="#000000" face="Arial" id="c1-id-45">    
</font><a href="http://www.orange.mu/" id="c1-id-46"><font style="FONT-SIZE: 10pt" color="#004dbb" face="Arial" id="c1-id-47">www.orange.mu</font></a>     |    
<a title="Orange on Facebook" href="http://www.facebook.com/orangemauritius?ref=hl" id="c1-id-48">
<img border="0" hspace="0" alt="Orange on Facebook" src="cid:logo-fb.jpg" id="c1-id-49"></a>     |    
<a title="Orange on Twitter" href="http://https//twitter.com/OrangeMauritius" id="c1-id-50">
<img border="0" hspace="0" alt="Orange on Twitter" src="cid:logo-twitter.jpg" id="c1-id-51"></a>
<br id="c1-id-52">
<br id="c1-id-53">
<font style="FONT-SIZE: 10pt" id="c1-id-54"><a title="Mauritius Telecom" href="http://www.mauritiustelecom.com/" id="c1-id-55"><font style="FONT-SIZE: 10pt" color="#000000" face="Arial" id="c1-id-56"><img border="0" hspace="0" alt="Mauritius Telecom" src="cid:logo-mt.png" id="c1-id-57"></font></a><font style="FONT-SIZE: 10pt" color="#000000" face="Arial" id="c1-id-58">        
  </font><a title="Orange Mauritius" href="http://www.orange.mu/" id="c1-id-59"><font style="FONT-SIZE: 10pt" color="#000000" face="Arial" id="c1-id-60"><img border="0" hspace="0" alt="Orange Mauritius" src="cid:logo.gif" id="c1-id-61"></font></a></font><br id="c1-id-62">
</font></font><font style="FONT-SIZE: 10pt" color="#444444" id="c1-id-63"><font style="FONT-SIZE: 10pt" id="c1-id-64"><font color="#000000" face="Arial" id="c1-id-65">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.</font></font></font></p>
</body>
</html>