<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">Hi All:</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 24pt"><font face="Times New Roman"><span lang="EN-US">I would like to stream live video (encoded from my webcam) to the </span><span lang="EN-US">Darwin</span>
<span lang="EN-US"> streaming server, and I started from testMPEG4VideoToDarwin project in testprog. But there is one problem when trying to stop the project.</span></font></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 24pt"><span lang="EN-US"><font face="Times New Roman">Here is the code I modified in testMPEG4VideoToDarwin.cpp</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">char ThreadFlag = 0; </font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">int live_streamer_main(const char *program_name, const char *server_ip)</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">{</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>TaskScheduler* scheduler = BasicTaskScheduler::createNew();</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>env = BasicUsageEnvironment::createNew(*scheduler);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>DarwinInjector* injector = DarwinInjector::createNew(*env, programName);</font></span>
</p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>/* Create 'groupsocks' for RTP and RTCP here.*/</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videoSink = MPEG4ESVideoRTPSink::createNew(*env, &amp;rtpGroupsockVideo, 96);</font>
</span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>play();</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>awaitConfigInfo(videoSink);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>/* Create (and start) a 'RTCP instance' for this RTP sink here: */</font></span></p>

<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>injector-&gt;addStream(videoSink, videoRTCP);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>injector-&gt;setDestination(dssNameOrAddress, remoteStreamName,</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>programName, &quot;LIVE555 Streaming Media&quot;);</font>
</span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>env-&gt;taskScheduler().doEventLoop(&amp;ThreadFlag);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>afterPlaying(NULL);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>return 0; // only to prevent compiler warning</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">}</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">void afterPlaying(void* clientData) {</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videoSink-&gt;stopPlaying();</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>Medium::close(videoSource);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">}</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">void play() {</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videofileSource</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span>= DeviceSource::createNew(*env, *DeviceParameters::createNew(inputvideoFileName,10));
</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videoES = videofileSource;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videoSource = MPEG4VideoStreamFramer::createNew(*env, videoES);</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-spacerun: yes">&nbsp; </span>videoSink-&gt;startPlaying(*videoSource, afterPlaying, videoSink);</font></span></p>

<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">}</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 24pt"><span lang="EN-US"><font face="Times New Roman">When I set the ThreadFlag as -1, the program run to the afterplaying(), and crashed in the Medium::close(videoSource). I have traced the code and found it crashed in destructor of StreamParser. Is there something I forgot to stop? Please help me~ 
</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">&nbsp;</font></span></p>
<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman">Thank you.</font></span></p>