private void Destroy()
 {
     if (m_Pipeline != null)
     {
         // Send EOS down the pipeline
         m_Pipeline.StopEncoding();
         // Wait for EOS to reach the end
         while (!m_EOS)
         {
             System.Threading.Thread.Sleep(1000);
         }
         m_Pipeline.Destroy();
         m_Pipeline = null;
         GStreamer.Unref();
         m_instanceHandle.Free();
     }
 }