houxiao
2017-07-20 5f5e870de69efe56d571a2c93362942af5bb49a5
RtspFace/PL_RTSPClient.cpp
@@ -33,11 +33,13 @@
   RtspClientParam lastParam;
   
   volatile bool killed;
   RTSPClient_Internal() : 
      rtspConfig(), live_daemon_thid(0), 
      eventLoopWatchVariable(0), live_daemon_running(false), 
      frame_mutex(new pthread_mutex_t), continue_mutex(new pthread_mutex_t), 
      lastFrame(), lastParam()
      lastFrame(), lastParam(), killed(false)
   {
      pthread_mutex_init(frame_mutex, NULL);
      pthread_mutex_init(continue_mutex, NULL);
@@ -167,7 +169,13 @@
   RTSPClient_Internal* in = (RTSPClient_Internal*)internal;
   
   in->eventLoopWatchVariable = 1;
   pthread_mutex_unlock(in->continue_mutex);
   pthread_mutex_unlock(in->frame_mutex);
   pthread_join(in->live_daemon_thid, NULL);
   in->reset();
}
bool PL_RTSPClient::pay(const PipeMaterial& pm)
@@ -187,10 +195,22 @@
      return false;
   }
   if (in->killed)
   {
      LOGP(WARN, "killed 1");
      return false;
   }
   ret = pthread_mutex_lock(in->frame_mutex);
   if(ret != 0)
   {
      LOGP(ERROR, "pthread_mutex_lock: %s/n", strerror(ret));
      return false;
   }
   if (in->killed)
   {
      LOGP(WARN, "killed 2");
      return false;
   }
   
@@ -200,6 +220,13 @@
   pm.former = this;
   return true;
}
void PL_RTSPClient::kill()
{
   RTSPClient_Internal* in = (RTSPClient_Internal*)internal;
   in->killed = true;
   pthread_mutex_unlock(in->frame_mutex);
}
void rtsp_client_set_param_callback(void* arg, RtspClientParam& param)
@@ -281,6 +308,6 @@
   int ret = pthread_mutex_lock(in->continue_mutex);
   if(ret != 0)
   {
      LOG_ERROR << "pthread_mutex_unlock continue_mutex: " << strerror(ret) << std::endl;
      LOG_ERROR << "pthread_mutex_lock continue_mutex: " << strerror(ret) << std::endl;
   }
}