<DIV><PRE>Hi,Ross
Thanks for your help.
I use live555 Server to stream H.264 live data which receive from the IP camera.
If there is no data from the IP camera, I want to close this ServerMediaSession. 
But this situation just occured in the function ByteStreamFileSource::doReadFromFile() as the follow code.

I have read some answer from the pipermail, you have said when fFrameSize ==0 invoke the
handleClosure(this) function can not free anything.
&gt;"FramedSource::handleClosure" doesn't delete anything.  Instead, its 
&gt;purpose is to tell the downstream object that the flow of data has ended.
&gt;To actually reclaim a 'media' object (i.e., a subclass of "Medium"), call 
&gt;"Medium::close()" on it.
Question:
   You said reclaim a 'media' object and call "Medium::close()" on it,
Does you mean use the following code
if(fFrameSize==0)
{
        Medium::close(this);
}
instead of
if(fFrame)
{
        handleClosure(this);
}



So I want to know what should I do when I want to close this ServerMediaSession.
especially, how to free the memory whick allocated before.

When the fFrameSize=0,I trace the code, I found that it will enter the following function
void StreamState::reclaim()
{
  // Delete allocated media objects
  Medium::close(fRTCPInstance) /* will send a RTCP BYE */; fRTCPInstance = NULL;
  Medium::close(fRTPSink); fRTPSink = NULL;
  Medium::close(fUDPSink); fUDPSink = NULL;
  fMaster.closeStreamSource(fMediaSource); fMediaSource = NULL;
  delete fRTPgs; fRTPgs = NULL;
  delete fRTCPgs; fRTCPgs = NULL;
}
It seems that It could free some memory which allocated before.But I can not sure all the memory allocated before are free .


Beacause my bad english, So I want to explain by code.
Thanks in advance.

void ByteStreamFileSource::doReadFromFile() 
{
  // Try to read as many bytes as will fit in the buffer provided
  // (or "fPreferredFrameSize" if less)
  DATAPACKETHEADER DataPacket;
  int port_i,ret;
  if (fPreferredFrameSize &gt; 0 &amp;&amp; fPreferredFrameSize &lt; fMaxSize) 
  {
    fMaxSize = fPreferredFrameSize;
  }
  
  if (m_live_s==1234)
  {
          port_i=m_h264_port_num;
  }

  if(port_i&gt;=0&amp;&amp;port_i&lt;MP4Sys_MAX_SUPPORTS&amp;&amp;m_live_s==1234)
  {
        if (g_Mp4PlayStream[port_i]-&gt;m_nPacketNum&gt;0)
        {
                Get_Frame_Data[port_i]=0;
                GetPacket(port_i,&amp;DataPacket,0,NULL);
        }
        else
        {
                while(g_Mp4PlayStream[port_i]-&gt;m_nPacketNum&lt;=0)
                {
                        Get_Frame_Data[port_i]++;
                        if (Get_Frame_Data[port_i]&gt;30)
                        {
                                fFrameSize=0;
                                Get_Frame_Data[port_i]=0;
                                printf("port=%d will goto clost the stream\n",port_i);
                                goto Frame_End;
                        }
                    usleep(33000);
                }
                GetPacket(port_i,&amp;DataPacket,0,NULL);
                if((DataPacket.DataPacketStartCode)==0xc7010000)
                {
                        memcpy(fTo,g_Mp4PlayStream[port_i]-&gt;m_DecodeSrc,DataPacket.nOverloadLen);
                        fFrameSize=DataPacket.nOverloadLen;
                }
        }
  }

Frame_End:
  if (fFrameSize == 0) 
  {
////////////////////////////////////////////////////////////////////////////////
/////////////////here what should I do to free the memory whick allocated before
////////////////////////////////////////////////////////////////////////////////
    handleClosure(this);
    return;
  }
  // Set the 'presentation time':
  if (fPlayTimePerFrame &gt; 0 &amp;&amp; fPreferredFrameSize &gt; 0) 
.............
}</PRE><BR><BR></DIV>
<DIV><BR>--<BR><A href="http://mail.163.com/" target="_blank"><IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; FLOAT: left; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" src="http://mimg.126.net/hd/all/stamp/091027_bsd/091027/img/qm.jpg"></A></DIV><br><br><span title="neteasefooter"/><hr/>
<a href="http://allyes.nie.163.com/main/adfclick?db=afanie&bid=1254,611,23&cid=145,4,1&sid=1351&show=ignore&url=http://tx2.163.com/fab.html">09年新晋3D主流网游《天下贰》,网易六年亿资打造</a>
</span>